Skip to content

Commit

Permalink
Merge branch 'master' into Claude.ai-v2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
josStorer authored Dec 3, 2023
2 parents 615a3e3 + d24958f commit 269c477
Show file tree
Hide file tree
Showing 9 changed files with 4,582 additions and 2,343 deletions.
46 changes: 44 additions & 2 deletions build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ async function deleteOldDir() {
await fs.rm(outdir, { recursive: true, force: true })
}

async function runWebpack(isWithoutKatex, isWithoutTiktoken, callback) {
async function runWebpack(isWithoutKatex, isWithoutTiktoken, minimal, callback) {
const shared = [
'preact',
'webextension-polyfill',
Expand Down Expand Up @@ -70,6 +70,12 @@ async function runWebpack(isWithoutKatex, isWithoutTiktoken, callback) {
concatenateModules: !isAnalyzing,
},
plugins: [
minimal
? undefined
: new webpack.ProvidePlugin({
process: 'process/browser.js',
Buffer: ['buffer', 'Buffer'],
}),
new ProgressBarPlugin({
format: ' build [:bar] :percent (:elapsed seconds)',
clear: false,
Expand Down Expand Up @@ -97,6 +103,14 @@ async function runWebpack(isWithoutKatex, isWithoutTiktoken, callback) {
extensions: ['.jsx', '.mjs', '.js'],
alias: {
parse5: path.resolve(__dirname, 'node_modules/parse5'),
...(minimal
? {}
: {
util: path.resolve(__dirname, 'node_modules/util'),
buffer: path.resolve(__dirname, 'node_modules/buffer'),
stream: 'stream-browserify',
crypto: 'crypto-browserify',
}),
},
},
module: {
Expand Down Expand Up @@ -206,7 +220,7 @@ async function runWebpack(isWithoutKatex, isWithoutTiktoken, callback) {
},
}
: {},
isWithoutKatex && isWithoutTiktoken
minimal
? {
test: /styles\.scss$/,
loader: 'string-replace-loader',
Expand All @@ -220,6 +234,32 @@ async function runWebpack(isWithoutKatex, isWithoutTiktoken, callback) {
},
}
: {},
minimal
? {
test: /index\.mjs$/,
loader: 'string-replace-loader',
options: {
multiple: [
{
search: 'import { generateAnswersWithChatGLMApi }',
replace: '//',
},
{
search: 'await generateAnswersWithChatGLMApi',
replace: '//',
},
{
search: 'chatglmTurbo',
replace: '//',
},
{
search: "'chatglmTurbo",
replace: '//',
},
],
},
}
: {},
],
},
})
Expand Down Expand Up @@ -305,13 +345,15 @@ async function build() {
// )
// await new Promise((r) => setTimeout(r, 5000))
await runWebpack(
true,
true,
true,
generateWebpackCallback(() => finishOutput('-without-katex-and-tiktoken')),
)
await new Promise((r) => setTimeout(r, 10000))
}
await runWebpack(
false,
false,
false,
generateWebpackCallback(() => finishOutput('')),
Expand Down
Loading

0 comments on commit 269c477

Please sign in to comment.