Skip to content

Commit

Permalink
fix(build): no import.meta for "module" condition (#582)
Browse files Browse the repository at this point in the history
  • Loading branch information
dai-shi committed Oct 29, 2022
1 parent a0ec4fb commit 09fffb5
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions rollup.config.js
Original file line number Diff line number Diff line change
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 @@ -66,7 +63,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 #410
'use-sync-external-store/shim': 'use-sync-external-store/shim/index.js',
delimiters: ['\\b', '\\b(?!(\\.|/))'],
Expand All @@ -80,7 +79,7 @@ function createESMConfig(input, output) {
function createCommonJSConfig(input, output) {
return {
input,
output: { file: `${output}.js`, format: 'cjs', exports: 'named' },
output: { file: `${output}.js`, format: 'cjs' },
external,
plugins: [
alias({
Expand All @@ -91,7 +90,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 All @@ -106,7 +105,6 @@ function createUMDConfig(input, output, env) {
output: {
file: `${output}.${env}.js`,
format: 'umd',
exports: 'named',
name:
c === 'index'
? 'valtio'
Expand Down Expand Up @@ -141,7 +139,6 @@ function createSystemConfig(input, output, env) {
output: {
file: `${output}.${env}.js`,
format: 'system',
exports: 'named',
},
external,
plugins: [
Expand Down Expand Up @@ -171,7 +168,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

1 comment on commit 09fffb5

@vercel
Copy link

@vercel vercel bot commented on 09fffb5 Oct 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

valtio – ./

valtio.vercel.app
valtio-pmndrs.vercel.app
valtio.pmnd.rs
valtio-git-main-pmndrs.vercel.app

Please sign in to comment.