Skip to content

Commit a1db8ad

Browse files
authored
Merge pull request #55 from CodinGame/fix-clean-PURE-comments
[FIX] Remove PURE comments from output bundle
2 parents a0ba764 + d423c20 commit a1db8ad

File tree

3 files changed

+68
-0
lines changed

3 files changed

+68
-0
lines changed

package-lock.json

Lines changed: 56 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
"eslint-plugin-unused-imports": "^2.0.0",
6565
"jest": "^28.1.2",
6666
"jest-environment-jsdom": "^28.1.2",
67+
"js-cleanup": "^1.2.0",
6768
"monaco-languageclient": "^2.0.2",
6869
"proxy-polyfill": "^0.3.2",
6970
"rollup": "2.76.0",

rollup.config.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import alias from '@rollup/plugin-alias'
44
import { nodeResolve } from '@rollup/plugin-node-resolve'
55
import eslint from '@rollup/plugin-eslint'
66
import { babel } from '@rollup/plugin-babel'
7+
import cleanup from 'js-cleanup'
78
import * as rollup from 'rollup'
89
import * as recast from 'recast'
910
import nodePolyfills from 'rollup-plugin-polyfill-node'
@@ -174,6 +175,16 @@ export default rollup.defineConfig({
174175
}
175176
return undefined
176177
}
178+
}, {
179+
name: 'cleanup',
180+
renderChunk (code) {
181+
// Remove comments, and #__PURE__ comments in enum IIFE in particular because webpack will treeshake them out
182+
// While rollup doesn't if the parameter is used
183+
return cleanup(code, null, {
184+
comments: 'none',
185+
sourcemap: false
186+
}).code
187+
}
177188
}
178189
]
179190
})

0 commit comments

Comments
 (0)