From 4f622a0f33da518b6e970a71da7dc5982bc8cc2f Mon Sep 17 00:00:00 2001 From: Porfirio Date: Sat, 15 Mar 2025 21:41:34 +0000 Subject: [PATCH] Add production build for esm-browser Change the rollup config to also build pinia for esm browsers prod It will remove devtools and minify the code Closes #2205 --- rollup.config.mjs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/rollup.config.mjs b/rollup.config.mjs index 0d8f921da0..81d452d270 100644 --- a/rollup.config.mjs +++ b/rollup.config.mjs @@ -77,7 +77,7 @@ const packageConfigs = packageBuilds.map((format) => packageBuilds.forEach((buildName) => { if (buildName === 'cjs') { packageConfigs.push(createProductionConfig(buildName)) - } else if (buildName === 'global') { + } else if (buildName === 'global' || buildName === 'browser') { packageConfigs.push(createMinifiedConfig(buildName)) } }) @@ -99,7 +99,7 @@ function createConfig(buildName, output, plugins = []) { const isProductionBuild = /\.prod\.[cm]?js$/.test(output.file) const isGlobalBuild = buildName === 'global' - const isRawESMBuild = buildName === 'browser' + const isRawESMBuild = buildName.includes('browser') const isNodeBuild = buildName === 'cjs' const isBundlerESMBuild = buildName === 'browser' || buildName === 'mjs' @@ -125,7 +125,8 @@ function createConfig(buildName, output, plugins = []) { // during a single build. hasTSChecked = true - const external = ['vue', '@vue/devtools-api'] + const external = ['vue'] + if (buildName !== 'browser-prod') external.push('@vue/devtools-api') const nodePlugins = [nodeResolve(), commonjs()] @@ -219,9 +220,9 @@ function createProductionConfig(format) { function createMinifiedConfig(format) { return createConfig( - format, + format === 'browser' ? 'browser-prod' : format, { - file: `dist/${name}.${format === 'global' ? 'iife' : format}.prod.js`, + file: `dist/${name}.${format === 'browser' ? 'esm-browser' : format === 'global' ? 'iife' : format}.prod.js`, format: outputConfigs[format].format, }, [