Skip to content

Commit

Permalink
fix(build): no import.meta for "module" condition (#1393)
Browse files Browse the repository at this point in the history
* fix(build): no import.meta for "module" condition

* be consistent with others
  • Loading branch information
dai-shi committed Oct 31, 2022
1 parent 296bb4b commit 20ee6e9
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions rollup.config.js
Expand Up @@ -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({
Expand All @@ -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',
Expand All @@ -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 })),
Expand Down Expand Up @@ -140,7 +139,6 @@ function createSystemConfig(input, output, env) {
output: {
file: `${output}.${env}.js`,
format: 'system',
exports: 'named',
},
external,
plugins: [
Expand Down Expand Up @@ -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'),
Expand Down

0 comments on commit 20ee6e9

Please sign in to comment.