fix-ai: 修复引入node模块导致的打包问题
Node.js Build / build (push) Failing after 5s

This commit is contained in:
windychen0
2026-06-06 20:11:41 +08:00
parent 186a4bc48c
commit 0739a7eefc
+27 -13
View File
@@ -1,26 +1,39 @@
const path = require('path');
const path = require("path");
const nodeExternalModules = ["better-sqlite3"];
const commonConfig = {
externals: nodeExternalModules,
resolve: {
fallback: {
fs: false,
path: false,
util: false,
},
},
};
const configs = {
cjs: {
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'windychen-utils.cjs.js',
libraryTarget: 'commonjs2',
path: path.resolve(__dirname, "dist"),
filename: "windychen-utils.cjs.js",
libraryTarget: "commonjs2",
},
},
esm: {
experiments: { outputModule: true },
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'windychen-utils.esm.js',
libraryTarget: 'module',
path: path.resolve(__dirname, "dist"),
filename: "windychen-utils.esm.js",
libraryTarget: "module",
},
},
umd: {
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'windychen-utils.js',
library: { name: 'WindychenUtils', type: 'umd', export: 'default' },
path: path.resolve(__dirname, "dist"),
filename: "windychen-utils.js",
library: { name: "WindychenUtils", type: "umd", export: "default" },
},
},
};
@@ -28,10 +41,11 @@ const configs = {
module.exports = (env = {}) => {
const format = env.format;
if (!format || format === 'all') {
if (!format || format === "all") {
return Object.keys(configs).map((key) => ({
name: key,
entry: './index.js',
entry: "./index.js",
...commonConfig,
...configs[key],
}));
}
@@ -40,5 +54,5 @@ module.exports = (env = {}) => {
throw new Error(`不支持的格式: ${format},可选值: cjs, esm, umd`);
}
return { entry: './index.js', ...configs[format] };
return { entry: "./index.js", ...commonConfig, ...configs[format] };
};