Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(build): no import.meta for "module" condition #1393

Merged
merged 2 commits into from Oct 31, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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