From d5e8481e22ab3fad79f9aadf5fb9eedda851f4ac Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Wed, 2 Jun 2021 13:12:12 +0200 Subject: [PATCH] allow side-effects at module level in src/ dir otherwise things like src/observable/index.js break --- scripts/build.mjs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/build.mjs b/scripts/build.mjs index 997d974f..040d9c69 100644 --- a/scripts/build.mjs +++ b/scripts/build.mjs @@ -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 @@ -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 }); @@ -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