From 20ee6e9633ffc6890e121e6204f927c4074c7e35 Mon Sep 17 00:00:00 2001 From: Daishi Kato Date: Mon, 31 Oct 2022 21:39:57 +0900 Subject: [PATCH] fix(build): no import.meta for "module" condition (#1393) * fix(build): no import.meta for "module" condition * be consistent with others --- rollup.config.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/rollup.config.js b/rollup.config.js index b66cdf210..cd69816ef 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -52,10 +52,7 @@ function createDeclarationConfig(input, output) { function createESMConfig(input, output) { return { input, - output: [ - { file: `${output}.js`, format: 'esm' }, - { file: `${output}.mjs`, format: 'esm' }, - ], + output: { file: output, format: 'esm' }, external, plugins: [ alias({ @@ -65,7 +62,9 @@ function createESMConfig(input, output) { }), resolve({ extensions }), replace({ - __DEV__: '(import.meta.env&&import.meta.env.MODE)!=="production"', + __DEV__: output.endsWith('.mjs') + ? '((import.meta.env&&import.meta.env.MODE)!=="production")' + : '(process.env.NODE_ENV!=="production")', // a workround for #829 'use-sync-external-store/shim/with-selector': 'use-sync-external-store/shim/with-selector.js', @@ -89,7 +88,7 @@ function createCommonJSConfig(input, output) { }), resolve({ extensions }), replace({ - __DEV__: 'process.env.NODE_ENV!=="production"', + __DEV__: '(process.env.NODE_ENV!=="production")', preventAssignment: true, }), babelPlugin(getBabelOptions({ ie: 11 })), @@ -140,7 +139,6 @@ function createSystemConfig(input, output, env) { output: { file: `${output}.${env}.js`, format: 'system', - exports: 'named', }, external, plugins: [ @@ -169,7 +167,8 @@ module.exports = function (args) { return [ ...(c === 'index' ? [createDeclarationConfig(`src/${c}.ts`, 'dist')] : []), createCommonJSConfig(`src/${c}.ts`, `dist/${c}`), - createESMConfig(`src/${c}.ts`, `dist/esm/${c}`), + createESMConfig(`src/${c}.ts`, `dist/esm/${c}.js`), + createESMConfig(`src/${c}.ts`, `dist/esm/${c}.mjs`), createUMDConfig(`src/${c}.ts`, `dist/umd/${c}`, 'development'), createUMDConfig(`src/${c}.ts`, `dist/umd/${c}`, 'production'), createSystemConfig(`src/${c}.ts`, `dist/system/${c}`, 'development'),