Merge pull request #374 from vector-im/bwindels/fix-sideeffects-stripped
allow side-effects while bundling at module level in src/ dir
This commit is contained in:
commit
928d3b5eda
1 changed files with 4 additions and 2 deletions
|
@ -46,6 +46,8 @@ const __filename = fileURLToPath(import.meta.url);
|
||||||
const __dirname = dirname(__filename);
|
const __dirname = dirname(__filename);
|
||||||
const projectDir = path.join(__dirname, "../");
|
const projectDir = path.join(__dirname, "../");
|
||||||
const cssSrcDir = path.join(projectDir, "src/platform/web/ui/css/");
|
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();
|
const parameters = new commander.Command();
|
||||||
parameters
|
parameters
|
||||||
|
@ -192,7 +194,7 @@ async function buildJs(mainFile, extraFiles, importOverrides) {
|
||||||
}
|
}
|
||||||
const bundle = await rollup({
|
const bundle = await rollup({
|
||||||
// for fake-indexeddb, so usage for tests only doesn't put it in bundle
|
// for fake-indexeddb, so usage for tests only doesn't put it in bundle
|
||||||
treeshake: {moduleSideEffects: false},
|
treeshake: {moduleSideEffects: isPathInSrcDir},
|
||||||
input: extraFiles.concat(mainFile),
|
input: extraFiles.concat(mainFile),
|
||||||
plugins
|
plugins
|
||||||
});
|
});
|
||||||
|
@ -233,7 +235,7 @@ async function buildJsLegacy(mainFile, extraFiles, importOverrides) {
|
||||||
// create js bundle
|
// create js bundle
|
||||||
const rollupConfig = {
|
const rollupConfig = {
|
||||||
// for fake-indexeddb, so usage for tests only doesn't put it in bundle
|
// 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,
|
// important the extraFiles come first,
|
||||||
// so polyfills are available in the global scope
|
// so polyfills are available in the global scope
|
||||||
// if needed for the mainfile
|
// if needed for the mainfile
|
||||||
|
|
Reference in a new issue