From 12ef5e86508e5d739de91891aa3d270f3759243c Mon Sep 17 00:00:00 2001 From: josc146 Date: Sun, 4 Aug 2024 22:21:33 +0800 Subject: [PATCH] fix Buffer is not defined when using tiny package (#691, https://github.com/josStorer/chatGPTBox/issues/752#issuecomment-2240977750) --- build.mjs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/build.mjs b/build.mjs index c02fdbb..e2c678c 100644 --- a/build.mjs +++ b/build.mjs @@ -71,7 +71,9 @@ async function runWebpack(isWithoutKatex, isWithoutTiktoken, minimal, callback) }, plugins: [ minimal - ? undefined + ? new webpack.ProvidePlugin({ + Buffer: ['buffer', 'Buffer'], + }) : new webpack.ProvidePlugin({ process: 'process/browser.js', Buffer: ['buffer', 'Buffer'], @@ -104,7 +106,7 @@ async function runWebpack(isWithoutKatex, isWithoutTiktoken, minimal, callback) alias: { parse5: path.resolve(__dirname, 'node_modules/parse5'), ...(minimal - ? {} + ? { buffer: path.resolve(__dirname, 'node_modules/buffer') } : { util: path.resolve(__dirname, 'node_modules/util'), buffer: path.resolve(__dirname, 'node_modules/buffer'),