Closed jeetiss closed 1 year ago
what if we make chain
etc side effects free? Would this work as well?
i'm not sure that it will gain some improvements here but it is safe so we can
I've meant different thing: can we remove PURE annotation from variables if we have __NO_SIDE_EFFECTS__
annotation in chain
?
__NO_SIDE_EFFECTS__
annotation is supported only by rollup and esbuild. terser and uglifyjs don't support it.
google closure compiler work with @nosideeffects
but not __NO_SIDE_EFFECTS__
I think it is too early to migrate to this annotation, it should be adopted well before
I like __NO_SIDE_EFFECTS__
approach more. it's less noisy, hope it would be implemented by other minifiers in some days
Got it.
Why does support by minifiers matter though? The build is usually done by bundlers first, because minifiers lack some features. After that, minifier does a second pass, on a bundled code.
I found this thread by Ivan Akulov https://twitter.com/iamakulov/status/1353650608750825472
tldr;
webpack still relay that dead code elimination (and tree-shaking) would be done by terser (or other minifier) so it is important
I've just tested esbuild and the PURE annotations don't work.
import { base64url } from '@scure/base';
base64url.encode('a')
{
"name": "build",
"private": true,
"version": "1.0.0",
"main": "input.js",
"type": "module",
"devDependencies": {
"@scure/base": "..",
"esbuild": "0.17.19"
},
"scripts": {
"build": "npx esbuild --bundle input.js --outfile=scure-base.js --global-name=scureBase"
}
}
Exported properties are still kept. Any ideas why?