Fix React's DCE error in r3f

This fixes the react error that says "React is running in production mode, but dead code elimination has not been applied."
This commit is contained in:
Aria Minaei 2023-07-28 20:25:57 +02:00 committed by Aria
parent bc7fcf8e0a
commit 1280de02d0
3 changed files with 245 additions and 4 deletions

View file

@ -96,6 +96,16 @@ async function createBundles() {
outfile: path.join(__dirname, '../dist/extension/index.js'), outfile: path.join(__dirname, '../dist/extension/index.js'),
format: 'cjs', format: 'cjs',
metafile: true, metafile: true,
/**
* Don't minify the extension bundle because it'll eventually get minified by the bundler of the user's project.
* However, we do want to tree shake the bundle and minify the syntax, so at least all the `if (false) {...}` blocks
* are removed. This also removes React's error that says "react is running in production mode but dead code elimination has not been applied...".
*/
minifyIdentifiers: false,
minifySyntax: true,
minifyWhitespace: false,
treeShaking: true,
} }
const result = await Promise.all([ const result = await Promise.all([

View file

@ -54,8 +54,8 @@
"@types/node": "^15.6.2", "@types/node": "^15.6.2",
"@types/react": "^17.0.9", "@types/react": "^17.0.9",
"@types/styled-components": "^5.1.9", "@types/styled-components": "^5.1.9",
"esbuild": "^0.12.15", "esbuild": "^0.18.17",
"esbuild-register": "^2.5.0", "esbuild-register": "^3.4.2",
"lodash-es": "^4.17.21", "lodash-es": "^4.17.21",
"npm-run-all": "^4.1.5", "npm-run-all": "^4.1.5",
"polished": "^4.1.3", "polished": "^4.1.3",

235
yarn.lock
View file

@ -6193,6 +6193,13 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@esbuild/android-arm64@npm:0.18.17":
version: 0.18.17
resolution: "@esbuild/android-arm64@npm:0.18.17"
conditions: os=android & cpu=arm64
languageName: node
linkType: hard
"@esbuild/android-arm@npm:0.15.15": "@esbuild/android-arm@npm:0.15.15":
version: 0.15.15 version: 0.15.15
resolution: "@esbuild/android-arm@npm:0.15.15" resolution: "@esbuild/android-arm@npm:0.15.15"
@ -6221,6 +6228,13 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@esbuild/android-arm@npm:0.18.17":
version: 0.18.17
resolution: "@esbuild/android-arm@npm:0.18.17"
conditions: os=android & cpu=arm
languageName: node
linkType: hard
"@esbuild/android-x64@npm:0.17.19": "@esbuild/android-x64@npm:0.17.19":
version: 0.17.19 version: 0.17.19
resolution: "@esbuild/android-x64@npm:0.17.19" resolution: "@esbuild/android-x64@npm:0.17.19"
@ -6242,6 +6256,13 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@esbuild/android-x64@npm:0.18.17":
version: 0.18.17
resolution: "@esbuild/android-x64@npm:0.18.17"
conditions: os=android & cpu=x64
languageName: node
linkType: hard
"@esbuild/darwin-arm64@npm:0.17.19": "@esbuild/darwin-arm64@npm:0.17.19":
version: 0.17.19 version: 0.17.19
resolution: "@esbuild/darwin-arm64@npm:0.17.19" resolution: "@esbuild/darwin-arm64@npm:0.17.19"
@ -6263,6 +6284,13 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@esbuild/darwin-arm64@npm:0.18.17":
version: 0.18.17
resolution: "@esbuild/darwin-arm64@npm:0.18.17"
conditions: os=darwin & cpu=arm64
languageName: node
linkType: hard
"@esbuild/darwin-x64@npm:0.17.19": "@esbuild/darwin-x64@npm:0.17.19":
version: 0.17.19 version: 0.17.19
resolution: "@esbuild/darwin-x64@npm:0.17.19" resolution: "@esbuild/darwin-x64@npm:0.17.19"
@ -6284,6 +6312,13 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@esbuild/darwin-x64@npm:0.18.17":
version: 0.18.17
resolution: "@esbuild/darwin-x64@npm:0.18.17"
conditions: os=darwin & cpu=x64
languageName: node
linkType: hard
"@esbuild/freebsd-arm64@npm:0.17.19": "@esbuild/freebsd-arm64@npm:0.17.19":
version: 0.17.19 version: 0.17.19
resolution: "@esbuild/freebsd-arm64@npm:0.17.19" resolution: "@esbuild/freebsd-arm64@npm:0.17.19"
@ -6305,6 +6340,13 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@esbuild/freebsd-arm64@npm:0.18.17":
version: 0.18.17
resolution: "@esbuild/freebsd-arm64@npm:0.18.17"
conditions: os=freebsd & cpu=arm64
languageName: node
linkType: hard
"@esbuild/freebsd-x64@npm:0.17.19": "@esbuild/freebsd-x64@npm:0.17.19":
version: 0.17.19 version: 0.17.19
resolution: "@esbuild/freebsd-x64@npm:0.17.19" resolution: "@esbuild/freebsd-x64@npm:0.17.19"
@ -6326,6 +6368,13 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@esbuild/freebsd-x64@npm:0.18.17":
version: 0.18.17
resolution: "@esbuild/freebsd-x64@npm:0.18.17"
conditions: os=freebsd & cpu=x64
languageName: node
linkType: hard
"@esbuild/linux-arm64@npm:0.17.19": "@esbuild/linux-arm64@npm:0.17.19":
version: 0.17.19 version: 0.17.19
resolution: "@esbuild/linux-arm64@npm:0.17.19" resolution: "@esbuild/linux-arm64@npm:0.17.19"
@ -6347,6 +6396,13 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@esbuild/linux-arm64@npm:0.18.17":
version: 0.18.17
resolution: "@esbuild/linux-arm64@npm:0.18.17"
conditions: os=linux & cpu=arm64
languageName: node
linkType: hard
"@esbuild/linux-arm@npm:0.17.19": "@esbuild/linux-arm@npm:0.17.19":
version: 0.17.19 version: 0.17.19
resolution: "@esbuild/linux-arm@npm:0.17.19" resolution: "@esbuild/linux-arm@npm:0.17.19"
@ -6368,6 +6424,13 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@esbuild/linux-arm@npm:0.18.17":
version: 0.18.17
resolution: "@esbuild/linux-arm@npm:0.18.17"
conditions: os=linux & cpu=arm
languageName: node
linkType: hard
"@esbuild/linux-ia32@npm:0.17.19": "@esbuild/linux-ia32@npm:0.17.19":
version: 0.17.19 version: 0.17.19
resolution: "@esbuild/linux-ia32@npm:0.17.19" resolution: "@esbuild/linux-ia32@npm:0.17.19"
@ -6389,6 +6452,13 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@esbuild/linux-ia32@npm:0.18.17":
version: 0.18.17
resolution: "@esbuild/linux-ia32@npm:0.18.17"
conditions: os=linux & cpu=ia32
languageName: node
linkType: hard
"@esbuild/linux-loong64@npm:0.14.54": "@esbuild/linux-loong64@npm:0.14.54":
version: 0.14.54 version: 0.14.54
resolution: "@esbuild/linux-loong64@npm:0.14.54" resolution: "@esbuild/linux-loong64@npm:0.14.54"
@ -6424,6 +6494,13 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@esbuild/linux-loong64@npm:0.18.17":
version: 0.18.17
resolution: "@esbuild/linux-loong64@npm:0.18.17"
conditions: os=linux & cpu=loong64
languageName: node
linkType: hard
"@esbuild/linux-mips64el@npm:0.17.19": "@esbuild/linux-mips64el@npm:0.17.19":
version: 0.17.19 version: 0.17.19
resolution: "@esbuild/linux-mips64el@npm:0.17.19" resolution: "@esbuild/linux-mips64el@npm:0.17.19"
@ -6445,6 +6522,13 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@esbuild/linux-mips64el@npm:0.18.17":
version: 0.18.17
resolution: "@esbuild/linux-mips64el@npm:0.18.17"
conditions: os=linux & cpu=mips64el
languageName: node
linkType: hard
"@esbuild/linux-ppc64@npm:0.17.19": "@esbuild/linux-ppc64@npm:0.17.19":
version: 0.17.19 version: 0.17.19
resolution: "@esbuild/linux-ppc64@npm:0.17.19" resolution: "@esbuild/linux-ppc64@npm:0.17.19"
@ -6466,6 +6550,13 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@esbuild/linux-ppc64@npm:0.18.17":
version: 0.18.17
resolution: "@esbuild/linux-ppc64@npm:0.18.17"
conditions: os=linux & cpu=ppc64
languageName: node
linkType: hard
"@esbuild/linux-riscv64@npm:0.17.19": "@esbuild/linux-riscv64@npm:0.17.19":
version: 0.17.19 version: 0.17.19
resolution: "@esbuild/linux-riscv64@npm:0.17.19" resolution: "@esbuild/linux-riscv64@npm:0.17.19"
@ -6487,6 +6578,13 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@esbuild/linux-riscv64@npm:0.18.17":
version: 0.18.17
resolution: "@esbuild/linux-riscv64@npm:0.18.17"
conditions: os=linux & cpu=riscv64
languageName: node
linkType: hard
"@esbuild/linux-s390x@npm:0.17.19": "@esbuild/linux-s390x@npm:0.17.19":
version: 0.17.19 version: 0.17.19
resolution: "@esbuild/linux-s390x@npm:0.17.19" resolution: "@esbuild/linux-s390x@npm:0.17.19"
@ -6508,6 +6606,13 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@esbuild/linux-s390x@npm:0.18.17":
version: 0.18.17
resolution: "@esbuild/linux-s390x@npm:0.18.17"
conditions: os=linux & cpu=s390x
languageName: node
linkType: hard
"@esbuild/linux-x64@npm:0.17.19": "@esbuild/linux-x64@npm:0.17.19":
version: 0.17.19 version: 0.17.19
resolution: "@esbuild/linux-x64@npm:0.17.19" resolution: "@esbuild/linux-x64@npm:0.17.19"
@ -6529,6 +6634,13 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@esbuild/linux-x64@npm:0.18.17":
version: 0.18.17
resolution: "@esbuild/linux-x64@npm:0.18.17"
conditions: os=linux & cpu=x64
languageName: node
linkType: hard
"@esbuild/netbsd-x64@npm:0.17.19": "@esbuild/netbsd-x64@npm:0.17.19":
version: 0.17.19 version: 0.17.19
resolution: "@esbuild/netbsd-x64@npm:0.17.19" resolution: "@esbuild/netbsd-x64@npm:0.17.19"
@ -6550,6 +6662,13 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@esbuild/netbsd-x64@npm:0.18.17":
version: 0.18.17
resolution: "@esbuild/netbsd-x64@npm:0.18.17"
conditions: os=netbsd & cpu=x64
languageName: node
linkType: hard
"@esbuild/openbsd-x64@npm:0.17.19": "@esbuild/openbsd-x64@npm:0.17.19":
version: 0.17.19 version: 0.17.19
resolution: "@esbuild/openbsd-x64@npm:0.17.19" resolution: "@esbuild/openbsd-x64@npm:0.17.19"
@ -6571,6 +6690,13 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@esbuild/openbsd-x64@npm:0.18.17":
version: 0.18.17
resolution: "@esbuild/openbsd-x64@npm:0.18.17"
conditions: os=openbsd & cpu=x64
languageName: node
linkType: hard
"@esbuild/sunos-x64@npm:0.17.19": "@esbuild/sunos-x64@npm:0.17.19":
version: 0.17.19 version: 0.17.19
resolution: "@esbuild/sunos-x64@npm:0.17.19" resolution: "@esbuild/sunos-x64@npm:0.17.19"
@ -6592,6 +6718,13 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@esbuild/sunos-x64@npm:0.18.17":
version: 0.18.17
resolution: "@esbuild/sunos-x64@npm:0.18.17"
conditions: os=sunos & cpu=x64
languageName: node
linkType: hard
"@esbuild/win32-arm64@npm:0.17.19": "@esbuild/win32-arm64@npm:0.17.19":
version: 0.17.19 version: 0.17.19
resolution: "@esbuild/win32-arm64@npm:0.17.19" resolution: "@esbuild/win32-arm64@npm:0.17.19"
@ -6613,6 +6746,13 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@esbuild/win32-arm64@npm:0.18.17":
version: 0.18.17
resolution: "@esbuild/win32-arm64@npm:0.18.17"
conditions: os=win32 & cpu=arm64
languageName: node
linkType: hard
"@esbuild/win32-ia32@npm:0.17.19": "@esbuild/win32-ia32@npm:0.17.19":
version: 0.17.19 version: 0.17.19
resolution: "@esbuild/win32-ia32@npm:0.17.19" resolution: "@esbuild/win32-ia32@npm:0.17.19"
@ -6634,6 +6774,13 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@esbuild/win32-ia32@npm:0.18.17":
version: 0.18.17
resolution: "@esbuild/win32-ia32@npm:0.18.17"
conditions: os=win32 & cpu=ia32
languageName: node
linkType: hard
"@esbuild/win32-x64@npm:0.17.19": "@esbuild/win32-x64@npm:0.17.19":
version: 0.17.19 version: 0.17.19
resolution: "@esbuild/win32-x64@npm:0.17.19" resolution: "@esbuild/win32-x64@npm:0.17.19"
@ -6655,6 +6802,13 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@esbuild/win32-x64@npm:0.18.17":
version: 0.18.17
resolution: "@esbuild/win32-x64@npm:0.18.17"
conditions: os=win32 & cpu=x64
languageName: node
linkType: hard
"@eslint/eslintrc@npm:^0.4.3": "@eslint/eslintrc@npm:^0.4.3":
version: 0.4.3 version: 0.4.3
resolution: "@eslint/eslintrc@npm:0.4.3" resolution: "@eslint/eslintrc@npm:0.4.3"
@ -9943,8 +10097,8 @@ __metadata:
"@types/node": ^15.6.2 "@types/node": ^15.6.2
"@types/react": ^17.0.9 "@types/react": ^17.0.9
"@types/styled-components": ^5.1.9 "@types/styled-components": ^5.1.9
esbuild: ^0.12.15 esbuild: ^0.18.17
esbuild-register: ^2.5.0 esbuild-register: ^3.4.2
lodash-es: ^4.17.21 lodash-es: ^4.17.21
npm-run-all: ^4.1.5 npm-run-all: ^4.1.5
polished: ^4.1.3 polished: ^4.1.3
@ -17951,6 +18105,83 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"esbuild@npm:^0.18.17":
version: 0.18.17
resolution: "esbuild@npm:0.18.17"
dependencies:
"@esbuild/android-arm": 0.18.17
"@esbuild/android-arm64": 0.18.17
"@esbuild/android-x64": 0.18.17
"@esbuild/darwin-arm64": 0.18.17
"@esbuild/darwin-x64": 0.18.17
"@esbuild/freebsd-arm64": 0.18.17
"@esbuild/freebsd-x64": 0.18.17
"@esbuild/linux-arm": 0.18.17
"@esbuild/linux-arm64": 0.18.17
"@esbuild/linux-ia32": 0.18.17
"@esbuild/linux-loong64": 0.18.17
"@esbuild/linux-mips64el": 0.18.17
"@esbuild/linux-ppc64": 0.18.17
"@esbuild/linux-riscv64": 0.18.17
"@esbuild/linux-s390x": 0.18.17
"@esbuild/linux-x64": 0.18.17
"@esbuild/netbsd-x64": 0.18.17
"@esbuild/openbsd-x64": 0.18.17
"@esbuild/sunos-x64": 0.18.17
"@esbuild/win32-arm64": 0.18.17
"@esbuild/win32-ia32": 0.18.17
"@esbuild/win32-x64": 0.18.17
dependenciesMeta:
"@esbuild/android-arm":
optional: true
"@esbuild/android-arm64":
optional: true
"@esbuild/android-x64":
optional: true
"@esbuild/darwin-arm64":
optional: true
"@esbuild/darwin-x64":
optional: true
"@esbuild/freebsd-arm64":
optional: true
"@esbuild/freebsd-x64":
optional: true
"@esbuild/linux-arm":
optional: true
"@esbuild/linux-arm64":
optional: true
"@esbuild/linux-ia32":
optional: true
"@esbuild/linux-loong64":
optional: true
"@esbuild/linux-mips64el":
optional: true
"@esbuild/linux-ppc64":
optional: true
"@esbuild/linux-riscv64":
optional: true
"@esbuild/linux-s390x":
optional: true
"@esbuild/linux-x64":
optional: true
"@esbuild/netbsd-x64":
optional: true
"@esbuild/openbsd-x64":
optional: true
"@esbuild/sunos-x64":
optional: true
"@esbuild/win32-arm64":
optional: true
"@esbuild/win32-ia32":
optional: true
"@esbuild/win32-x64":
optional: true
bin:
esbuild: bin/esbuild
checksum: c6e1ffa776978a45697763a07ec9b16411db3d3b3997b2c4a0165a211727fce8b63b87165a28d8ef60d3a28b98197bbbc2833e51b89888a4437e0a483dffc8ff
languageName: node
linkType: hard
"escalade@npm:^3.0.2, escalade@npm:^3.1.1": "escalade@npm:^3.0.2, escalade@npm:^3.1.1":
version: 3.1.1 version: 3.1.1
resolution: "escalade@npm:3.1.1" resolution: "escalade@npm:3.1.1"