Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Commit 5f40471

Browse files
committed
update build and fix lodash issue in esbuild on firefox
1 parent c346a01 commit 5f40471

File tree

4 files changed

+177
-158
lines changed

4 files changed

+177
-158
lines changed

client/browser/config/esbuild.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,15 @@ export function esbuildBuildOptions(mode: 'dev' | 'prod', extraPlugins: esbuild.
3333
// Worker
3434
path.resolve(browserSourcePath, 'shared/extensionHostWorker.ts'),
3535
],
36-
format: 'cjs',
36+
format: 'esm',
3737
platform: 'browser',
3838
plugins: [stylePlugin, ...extraPlugins],
3939
define: {
4040
'process.env.NODE_ENV': JSON.stringify(mode === 'dev' ? 'development' : 'production'),
4141
'process.env.BUNDLE_UID': JSON.stringify(generateBundleUID()),
4242
},
4343
bundle: true,
44+
treeShaking: true,
4445
minify: false,
4546
logLevel: 'error',
4647
jsx: 'automatic',
@@ -49,7 +50,12 @@ export function esbuildBuildOptions(mode: 'dev' | 'prod', extraPlugins: esbuild.
4950
entryNames: '[ext]/[name].bundle',
5051
target: 'esnext',
5152
sourcemap: true,
52-
alias: { path: 'path-browserify' },
53+
alias: { path: 'path-browserify', lodash: 'lodash-es' },
54+
banner: {
55+
// HACK: lodash has a `Function("return this")`, which Firefox's CSP protection
56+
// complains about. This ensures we do not encounter it.
57+
js: 'globalThis.global = globalThis;',
58+
},
5359
loader: {
5460
'.svg': 'text',
5561
},

client/build-config/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
"dependencies": {
1717
"buffer": "^6.0.3",
1818
"enhanced-resolve": "^5.9.3",
19-
"esbuild": "^0.17.7",
2019
"monaco-editor-webpack-plugin": "^3.1.0",
2120
"postcss": "^8.4.19",
2221
"postcss-cli": "^10.1.0",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@
194194
"dedent": "^0.7.0",
195195
"dompurify": "^3.0.6",
196196
"envalid": "^7.3.1",
197-
"esbuild": "^0.17.14",
197+
"esbuild": "^0.23.0",
198198
"eslint": "^8.52.0",
199199
"eslint-plugin-monorepo": "^0.3.2",
200200
"eslint-plugin-react": "^7.33.2",

0 commit comments

Comments
 (0)