From 0739a7eefcf48b2369c7d7f153d85abf767b2385 Mon Sep 17 00:00:00 2001 From: windychen0 <49142109+windychen0@users.noreply.github.com> Date: Sat, 6 Jun 2026 20:11:41 +0800 Subject: [PATCH] =?UTF-8?q?fix-ai:=20=E4=BF=AE=E5=A4=8D=E5=BC=95=E5=85=A5n?= =?UTF-8?q?ode=E6=A8=A1=E5=9D=97=E5=AF=BC=E8=87=B4=E7=9A=84=E6=89=93?= =?UTF-8?q?=E5=8C=85=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webpack.config.js | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/webpack.config.js b/webpack.config.js index cf1c28a..b3254e3 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -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] }; };