Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions dev-packages/rollup-utils/npmHelpers.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));

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

const ignoreSideEffects = /[\\\/]debug-build\.ts$/;

export function makeBaseNPMConfig(options = {}) {
const {
entrypoints = ['src/index.ts'],
Expand Down Expand Up @@ -83,6 +85,17 @@ export function makeBaseNPMConfig(options = {}) {
interop: 'esModule',
},

treeshake: {
moduleSideEffects: (id, external) => {
if (external === false && ignoreSideEffects.test(id)) {
// Tell Rollup this module has no side effects, so it can be tree-shaken
return false;
}

return true;
}
},

plugins: [nodeResolvePlugin, sucrasePlugin, debugBuildStatementReplacePlugin, rrwebBuildPlugin, cleanupPlugin],

// don't include imported modules from outside the package in the final output
Expand Down
Loading