From f14a926292863887f66636a4b57c4738bb2054c6 Mon Sep 17 00:00:00 2001 From: kianfang Date: Sat, 13 May 2023 23:28:10 +0800 Subject: [PATCH 1/2] build: add vue-router.esm-browser.prod.js build file --- packages/router/rollup.config.mjs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/router/rollup.config.mjs b/packages/router/rollup.config.mjs index a0dd7b387..9258ad591 100644 --- a/packages/router/rollup.config.mjs +++ b/packages/router/rollup.config.mjs @@ -59,7 +59,10 @@ const packageConfigs = packageBuilds.map(buildName => packageBuilds.forEach(buildName => { if (buildName === 'cjs') { packageConfigs.push(createProductionConfig(buildName)) - } else if (buildName === 'global') { + return; + } + + if (['global', 'browser'].includes(buildName)) { packageConfigs.push(createMinifiedConfig(buildName)) } }) @@ -221,10 +224,12 @@ function createProductionConfig(format) { } function createMinifiedConfig(format) { + const item = path.parse(outputConfigs[format].file); + return createConfig( format, { - file: `dist/${name}.${format}.prod.js`, + file: `${item.dir}/${item.name}.prod${item.ext}`, format: outputConfigs[format].format, }, [ From 79f83dcdf80829bb86a1fd916e7ca3a64345738b Mon Sep 17 00:00:00 2001 From: skirtle <65301168+skirtles-code@users.noreply.github.com> Date: Fri, 17 May 2024 04:49:22 +0100 Subject: [PATCH 2/2] build: update vue-router.esm-browser.prod.js --- packages/router/rollup.config.mjs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/packages/router/rollup.config.mjs b/packages/router/rollup.config.mjs index 14677e159..3b1a56c80 100644 --- a/packages/router/rollup.config.mjs +++ b/packages/router/rollup.config.mjs @@ -59,10 +59,7 @@ const packageConfigs = packageBuilds.map(buildName => packageBuilds.forEach(buildName => { if (buildName === 'cjs') { packageConfigs.push(createProductionConfig(buildName)) - return; - } - - if (['global', 'browser'].includes(buildName)) { + } else if (buildName === 'global' || buildName === 'browser') { packageConfigs.push(createMinifiedConfig(buildName)) } }) @@ -128,6 +125,10 @@ function createConfig(buildName, output, plugins = []) { // Global and Browser ESM builds inlines everything so that they can be // used alone. external, + treeshake: { + // Ensure @vue/devtools-api can be treeshaken in production builds + moduleSideEffects: false, + }, plugins: [ tsPlugin, createReplacePlugin( @@ -224,12 +225,10 @@ function createProductionConfig(format) { } function createMinifiedConfig(format) { - const item = path.parse(outputConfigs[format].file); - return createConfig( format, { - file: `${item.dir}/${item.name}.prod${item.ext}`, + file: outputConfigs[format].file.replace(/.js$/, '.prod.js'), format: outputConfigs[format].format, }, [