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'),
format: 'cjs',
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([

View file

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