feat: 使用esbuild
This commit is contained in:
parent
272845fe87
commit
f11810220e
1
.npmrc
1
.npmrc
@ -1,2 +1,3 @@
|
|||||||
@abearxiong:registry=https://npm.pkg.github.com
|
@abearxiong:registry=https://npm.pkg.github.com
|
||||||
//registry.npmjs.org/:_authToken=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
|
//registry.npmjs.org/:_authToken=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
|
||||||
|
@kevisual:registry=https://npm.xiongxiao.me
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
import { runParser } from '../dist/index.js';
|
import { runParser } from '../dist/app.mjs';
|
||||||
|
|
||||||
runParser(process.argv);
|
runParser(process.argv);
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
"@rollup/plugin-json": "^6.1.0",
|
"@rollup/plugin-json": "^6.1.0",
|
||||||
"@rollup/plugin-node-resolve": "^15.3.0",
|
"@rollup/plugin-node-resolve": "^15.3.0",
|
||||||
"@rollup/plugin-typescript": "^12.1.1",
|
"@rollup/plugin-typescript": "^12.1.1",
|
||||||
|
"@rollup/plugin-alias": "^5.1.1",
|
||||||
|
"rollup-plugin-esbuild": "^6.1.1",
|
||||||
"@types/node": "^22.8.6",
|
"@types/node": "^22.8.6",
|
||||||
"chalk": "^5.3.0",
|
"chalk": "^5.3.0",
|
||||||
"commander": "^12.1.0",
|
"commander": "^12.1.0",
|
||||||
|
54
pnpm-lock.yaml
generated
54
pnpm-lock.yaml
generated
@ -14,9 +14,15 @@ importers:
|
|||||||
'@kevisual/router':
|
'@kevisual/router':
|
||||||
specifier: ^0.0.3
|
specifier: ^0.0.3
|
||||||
version: 0.0.3
|
version: 0.0.3
|
||||||
|
'@rollup/plugin-alias':
|
||||||
|
specifier: ^5.1.1
|
||||||
|
version: 5.1.1(rollup@4.24.3)
|
||||||
pg-hstore:
|
pg-hstore:
|
||||||
specifier: ^2.3.4
|
specifier: ^2.3.4
|
||||||
version: 2.3.4
|
version: 2.3.4
|
||||||
|
rollup-plugin-esbuild:
|
||||||
|
specifier: ^6.1.1
|
||||||
|
version: 6.1.1(esbuild@0.21.5)(rollup@4.24.3)
|
||||||
sequelize:
|
sequelize:
|
||||||
specifier: ^6.37.5
|
specifier: ^6.37.5
|
||||||
version: 6.37.5(pg-hstore@2.3.4)(sqlite3@5.1.7)
|
version: 6.37.5(pg-hstore@2.3.4)(sqlite3@5.1.7)
|
||||||
@ -328,6 +334,15 @@ packages:
|
|||||||
engines: {node: '>=10'}
|
engines: {node: '>=10'}
|
||||||
deprecated: This functionality has been moved to @npmcli/fs
|
deprecated: This functionality has been moved to @npmcli/fs
|
||||||
|
|
||||||
|
'@rollup/plugin-alias@5.1.1':
|
||||||
|
resolution: {integrity: sha512-PR9zDb+rOzkRb2VD+EuKB7UC41vU5DIwZ5qqCpk0KJudcWAyi8rvYOhS7+L5aZCspw1stTViLgN5v6FF1p5cgQ==}
|
||||||
|
engines: {node: '>=14.0.0'}
|
||||||
|
peerDependencies:
|
||||||
|
rollup: ^1.20.0||^2.0.0||^3.0.0||^4.0.0
|
||||||
|
peerDependenciesMeta:
|
||||||
|
rollup:
|
||||||
|
optional: true
|
||||||
|
|
||||||
'@rollup/plugin-commonjs@28.0.1':
|
'@rollup/plugin-commonjs@28.0.1':
|
||||||
resolution: {integrity: sha512-+tNWdlWKbpB3WgBN7ijjYkq9X5uhjmcvyjEght4NmH5fAU++zfQzAJ6wumLS+dNcvwEZhKx2Z+skY8m7v0wGSA==}
|
resolution: {integrity: sha512-+tNWdlWKbpB3WgBN7ijjYkq9X5uhjmcvyjEght4NmH5fAU++zfQzAJ6wumLS+dNcvwEZhKx2Z+skY8m7v0wGSA==}
|
||||||
engines: {node: '>=16.0.0 || 14 >= 14.17'}
|
engines: {node: '>=16.0.0 || 14 >= 14.17'}
|
||||||
@ -680,6 +695,9 @@ packages:
|
|||||||
err-code@2.0.3:
|
err-code@2.0.3:
|
||||||
resolution: {integrity: sha512-2bmlRpNKBxT/CRmPOlyISQpNj+qSeYvcym/uT0Jx2bMOlKLtSy1ZmLuVxSEKKyor/N5yhvp/ZiG1oE3DEYMSFA==}
|
resolution: {integrity: sha512-2bmlRpNKBxT/CRmPOlyISQpNj+qSeYvcym/uT0Jx2bMOlKLtSy1ZmLuVxSEKKyor/N5yhvp/ZiG1oE3DEYMSFA==}
|
||||||
|
|
||||||
|
es-module-lexer@1.5.4:
|
||||||
|
resolution: {integrity: sha512-MVNK56NiMrOwitFB7cqDwq0CQutbw+0BvLshJSse0MUNU+y1FC3bUS/AQg7oUng+/wKrrki7JfmwtVHkVfPLlw==}
|
||||||
|
|
||||||
esbuild@0.21.5:
|
esbuild@0.21.5:
|
||||||
resolution: {integrity: sha512-mg3OPMV4hXywwpoDxu3Qda5xCKQi+vCTZq8S9J/EpkhB2HzKXq4SNFZE3+NK93JYxc8VMSep+lOUSC/RVKaBqw==}
|
resolution: {integrity: sha512-mg3OPMV4hXywwpoDxu3Qda5xCKQi+vCTZq8S9J/EpkhB2HzKXq4SNFZE3+NK93JYxc8VMSep+lOUSC/RVKaBqw==}
|
||||||
engines: {node: '>=12'}
|
engines: {node: '>=12'}
|
||||||
@ -738,6 +756,9 @@ packages:
|
|||||||
engines: {node: ^12.13.0 || ^14.15.0 || >=16.0.0}
|
engines: {node: ^12.13.0 || ^14.15.0 || >=16.0.0}
|
||||||
deprecated: This package is no longer supported.
|
deprecated: This package is no longer supported.
|
||||||
|
|
||||||
|
get-tsconfig@4.8.1:
|
||||||
|
resolution: {integrity: sha512-k9PN+cFBmaLWtVz29SkUoqU5O0slLuHJXt/2P+tMVFT+phsSGXGkp9t3rQIqdz0e+06EHNGs3oM6ZX1s2zHxRg==}
|
||||||
|
|
||||||
github-from-package@0.0.0:
|
github-from-package@0.0.0:
|
||||||
resolution: {integrity: sha512-SyHy3T1v2NUXn29OsWdxmK6RwHD+vkj3v8en8AOBZ1wBQ/hCAQ5bAQTD02kW4W9tUp/3Qh6J8r9EvntiyCmOOw==}
|
resolution: {integrity: sha512-SyHy3T1v2NUXn29OsWdxmK6RwHD+vkj3v8en8AOBZ1wBQ/hCAQ5bAQTD02kW4W9tUp/3Qh6J8r9EvntiyCmOOw==}
|
||||||
|
|
||||||
@ -1056,6 +1077,9 @@ packages:
|
|||||||
resolution: {integrity: sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==}
|
resolution: {integrity: sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==}
|
||||||
engines: {node: '>= 6'}
|
engines: {node: '>= 6'}
|
||||||
|
|
||||||
|
resolve-pkg-maps@1.0.0:
|
||||||
|
resolution: {integrity: sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==}
|
||||||
|
|
||||||
resolve@1.22.8:
|
resolve@1.22.8:
|
||||||
resolution: {integrity: sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw==}
|
resolution: {integrity: sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw==}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
@ -1084,6 +1108,13 @@ packages:
|
|||||||
rollup: ^3.29.4 || ^4
|
rollup: ^3.29.4 || ^4
|
||||||
typescript: ^4.5 || ^5.0
|
typescript: ^4.5 || ^5.0
|
||||||
|
|
||||||
|
rollup-plugin-esbuild@6.1.1:
|
||||||
|
resolution: {integrity: sha512-CehMY9FAqJD5OUaE/Mi1r5z0kNeYxItmRO2zG4Qnv2qWKF09J2lTy5GUzjJR354ZPrLkCj4fiBN41lo8PzBUhw==}
|
||||||
|
engines: {node: '>=14.18.0'}
|
||||||
|
peerDependencies:
|
||||||
|
esbuild: '>=0.18.0'
|
||||||
|
rollup: ^1.20.0 || ^2.0.0 || ^3.0.0 || ^4.0.0
|
||||||
|
|
||||||
rollup@4.24.3:
|
rollup@4.24.3:
|
||||||
resolution: {integrity: sha512-HBW896xR5HGmoksbi3JBDtmVzWiPAYqp7wip50hjQ67JbDz61nyoMPdqu1DvVW9asYb2M65Z20ZHsyJCMqMyDg==}
|
resolution: {integrity: sha512-HBW896xR5HGmoksbi3JBDtmVzWiPAYqp7wip50hjQ67JbDz61nyoMPdqu1DvVW9asYb2M65Z20ZHsyJCMqMyDg==}
|
||||||
engines: {node: '>=18.0.0', npm: '>=8.0.0'}
|
engines: {node: '>=18.0.0', npm: '>=8.0.0'}
|
||||||
@ -1575,6 +1606,10 @@ snapshots:
|
|||||||
rimraf: 3.0.2
|
rimraf: 3.0.2
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
|
'@rollup/plugin-alias@5.1.1(rollup@4.24.3)':
|
||||||
|
optionalDependencies:
|
||||||
|
rollup: 4.24.3
|
||||||
|
|
||||||
'@rollup/plugin-commonjs@28.0.1(rollup@4.24.3)':
|
'@rollup/plugin-commonjs@28.0.1(rollup@4.24.3)':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@rollup/pluginutils': 5.1.2(rollup@4.24.3)
|
'@rollup/pluginutils': 5.1.2(rollup@4.24.3)
|
||||||
@ -1876,6 +1911,8 @@ snapshots:
|
|||||||
err-code@2.0.3:
|
err-code@2.0.3:
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
|
es-module-lexer@1.5.4: {}
|
||||||
|
|
||||||
esbuild@0.21.5:
|
esbuild@0.21.5:
|
||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
'@esbuild/aix-ppc64': 0.21.5
|
'@esbuild/aix-ppc64': 0.21.5
|
||||||
@ -1955,6 +1992,10 @@ snapshots:
|
|||||||
wide-align: 1.1.5
|
wide-align: 1.1.5
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
|
get-tsconfig@4.8.1:
|
||||||
|
dependencies:
|
||||||
|
resolve-pkg-maps: 1.0.0
|
||||||
|
|
||||||
github-from-package@0.0.0: {}
|
github-from-package@0.0.0: {}
|
||||||
|
|
||||||
glob@11.0.0:
|
glob@11.0.0:
|
||||||
@ -2324,6 +2365,8 @@ snapshots:
|
|||||||
string_decoder: 1.3.0
|
string_decoder: 1.3.0
|
||||||
util-deprecate: 1.0.2
|
util-deprecate: 1.0.2
|
||||||
|
|
||||||
|
resolve-pkg-maps@1.0.0: {}
|
||||||
|
|
||||||
resolve@1.22.8:
|
resolve@1.22.8:
|
||||||
dependencies:
|
dependencies:
|
||||||
is-core-module: 2.15.1
|
is-core-module: 2.15.1
|
||||||
@ -2353,6 +2396,17 @@ snapshots:
|
|||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
'@babel/code-frame': 7.26.2
|
'@babel/code-frame': 7.26.2
|
||||||
|
|
||||||
|
rollup-plugin-esbuild@6.1.1(esbuild@0.21.5)(rollup@4.24.3):
|
||||||
|
dependencies:
|
||||||
|
'@rollup/pluginutils': 5.1.2(rollup@4.24.3)
|
||||||
|
debug: 4.3.7
|
||||||
|
es-module-lexer: 1.5.4
|
||||||
|
esbuild: 0.21.5
|
||||||
|
get-tsconfig: 4.8.1
|
||||||
|
rollup: 4.24.3
|
||||||
|
transitivePeerDependencies:
|
||||||
|
- supports-color
|
||||||
|
|
||||||
rollup@4.24.3:
|
rollup@4.24.3:
|
||||||
dependencies:
|
dependencies:
|
||||||
'@types/estree': 1.0.6
|
'@types/estree': 1.0.6
|
||||||
|
@ -4,6 +4,10 @@ import typescript from '@rollup/plugin-typescript';
|
|||||||
import resolve from '@rollup/plugin-node-resolve';
|
import resolve from '@rollup/plugin-node-resolve';
|
||||||
import commonjs from '@rollup/plugin-commonjs';
|
import commonjs from '@rollup/plugin-commonjs';
|
||||||
import json from '@rollup/plugin-json';
|
import json from '@rollup/plugin-json';
|
||||||
|
import path from 'path'
|
||||||
|
import esbuild from 'rollup-plugin-esbuild'
|
||||||
|
import alias from '@rollup/plugin-alias'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {import('rollup').RollupOptions}
|
* @type {import('rollup').RollupOptions}
|
||||||
*/
|
*/
|
||||||
@ -12,20 +16,57 @@ export default {
|
|||||||
output: {
|
output: {
|
||||||
// file: 'dist/app.js', // 输出文件
|
// file: 'dist/app.js', // 输出文件
|
||||||
dir: 'dist',
|
dir: 'dist',
|
||||||
format: 'es', // 输出格式设置为 ES 模块
|
entryFileNames: 'app.mjs',
|
||||||
|
chunkFileNames: '[name]-[hash].mjs',
|
||||||
|
// format: 'cjs'
|
||||||
|
format: 'esm', // 输出格式设置为 ES 模块
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
resolve(), // 使用 @rollup/plugin-node-resolve 解析 node_modules 中的模块
|
alias({
|
||||||
|
// only esbuild needs to be configured
|
||||||
|
entries: [
|
||||||
|
{ find: '@', replacement: path.resolve('src') }, // 配置 @ 为 src 目录
|
||||||
|
{ find: 'http', replacement: 'node:http' },
|
||||||
|
{ find: 'https', replacement: 'node:https' },
|
||||||
|
{ find: 'fs', replacement: 'node:fs' },
|
||||||
|
{ find: 'path', replacement: 'node:path' },
|
||||||
|
{ find: 'crypto', replacement: 'node:crypto' },
|
||||||
|
{ find: 'zlib', replacement: 'node:zlib' },
|
||||||
|
{ find: 'stream', replacement: 'node:stream' },
|
||||||
|
{ find: 'net', replacement: 'node:net' },
|
||||||
|
{ find: 'tty', replacement: 'node:tty' },
|
||||||
|
{ find: 'tls', replacement: 'node:tls' },
|
||||||
|
{ find: 'buffer', replacement: 'node:buffer' },
|
||||||
|
{ find: 'timers', replacement: 'node:timers' },
|
||||||
|
// { find: 'string_decoder', replacement: 'node:string_decoder' },
|
||||||
|
{ find: 'dns', replacement: 'node:dns' },
|
||||||
|
{ find: 'domain', replacement: 'node:domain' },
|
||||||
|
{ find: 'os', replacement: 'node:os' },
|
||||||
|
{ find: 'events', replacement: 'node:events' },
|
||||||
|
{ find: 'url', replacement: 'node:url' },
|
||||||
|
{ find: 'assert', replacement: 'node:assert' },
|
||||||
|
{ find: 'util', replacement: 'node:util' }
|
||||||
|
]
|
||||||
|
}),
|
||||||
|
resolve({
|
||||||
|
preferBuiltins: true, // 强制优先使用内置模块
|
||||||
|
}), // 使用 @rollup/plugin-node-resolve 解析 node_modules 中的模块
|
||||||
commonjs({
|
commonjs({
|
||||||
// dynamicRequireTargets: ['node_modules/sqlite3/lib/*.js'],
|
// dynamicRequireTargets: ['node_modules/sqlite3/lib/*.js'],
|
||||||
}),
|
}),
|
||||||
|
esbuild({
|
||||||
|
target: 'node22', // 目标为 Node.js 14
|
||||||
|
minify: false, // 启用代码压缩
|
||||||
|
tsconfig: 'tsconfig.json'
|
||||||
|
}),
|
||||||
json(),
|
json(),
|
||||||
typescript({
|
// typescript({
|
||||||
allowImportingTsExtensions: true,
|
// allowImportingTsExtensions: true,
|
||||||
noEmit: true,
|
// noEmit: true,
|
||||||
// 不生成声明文件
|
// // 不生成声明文件
|
||||||
declaration: false,
|
// declaration: false,
|
||||||
}), // 使用 @rollup/plugin-typescript 处理 TypeScript 文件
|
// }), // 使用 @rollup/plugin-typescript 处理 TypeScript 文件
|
||||||
],
|
],
|
||||||
external: ['sqlite3', 'sequelize', 'vite'], // 将 sqlite3 作为外部依赖
|
// 将 sqlite3 作为外部依赖
|
||||||
|
external: ['sqlite3', 'sequelize', 'vite', 'sequelize', '@kevisual/router', 'ioredis', 'socket.io', 'minio'],
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user