Skip to content

Commit 9ec2bff

Browse files
authored
build: Disable side-effects for any ./debug-build.ts file (#16929)
- Closes #16846
1 parent 0fc803a commit 9ec2bff

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

dev-packages/rollup-utils/npmHelpers.mjs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
2626

2727
const packageDotJSON = JSON.parse(fs.readFileSync(path.resolve(process.cwd(), './package.json'), { encoding: 'utf8' }));
2828

29+
const ignoreSideEffects = /[\\\/]debug-build\.ts$/;
30+
2931
export function makeBaseNPMConfig(options = {}) {
3032
const {
3133
entrypoints = ['src/index.ts'],
@@ -83,6 +85,17 @@ export function makeBaseNPMConfig(options = {}) {
8385
interop: 'esModule',
8486
},
8587

88+
treeshake: {
89+
moduleSideEffects: (id, external) => {
90+
if (external === false && ignoreSideEffects.test(id)) {
91+
// Tell Rollup this module has no side effects, so it can be tree-shaken
92+
return false;
93+
}
94+
95+
return true;
96+
}
97+
},
98+
8699
plugins: [nodeResolvePlugin, sucrasePlugin, debugBuildStatementReplacePlugin, rrwebBuildPlugin, cleanupPlugin],
87100

88101
// don't include imported modules from outside the package in the final output

0 commit comments

Comments
 (0)