Skip to content

Commit

Permalink
Merge pull request #374 from vector-im/bwindels/fix-sideeffects-stripped
Browse files Browse the repository at this point in the history
allow side-effects while bundling at module level in src/ dir
  • Loading branch information
bwindels authored Jun 2, 2021
2 parents d9de28b + d5e8481 commit 928d3b5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions scripts/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const projectDir = path.join(__dirname, "../");
const cssSrcDir = path.join(projectDir, "src/platform/web/ui/css/");
const srcDir = path.join(projectDir, "src/");
const isPathInSrcDir = path => path.startsWith(srcDir);

const parameters = new commander.Command();
parameters
Expand Down Expand Up @@ -192,7 +194,7 @@ async function buildJs(mainFile, extraFiles, importOverrides) {
}
const bundle = await rollup({
// for fake-indexeddb, so usage for tests only doesn't put it in bundle
treeshake: {moduleSideEffects: false},
treeshake: {moduleSideEffects: isPathInSrcDir},
input: extraFiles.concat(mainFile),
plugins
});
Expand Down Expand Up @@ -233,7 +235,7 @@ async function buildJsLegacy(mainFile, extraFiles, importOverrides) {
// create js bundle
const rollupConfig = {
// for fake-indexeddb, so usage for tests only doesn't put it in bundle
treeshake: {moduleSideEffects: false},
treeshake: {moduleSideEffects: isPathInSrcDir},
// important the extraFiles come first,
// so polyfills are available in the global scope
// if needed for the mainfile
Expand Down

0 comments on commit 928d3b5

Please sign in to comment.