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: ESM dev entrypoint was causing unexpected behaviors #1059

Merged
merged 1 commit into from
May 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions packages/core/npm/esm/dev.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import {
i18n as i18nProd,
setupI18n as setupI18nProd,
formats as formatsProd,
I18n as I18nProd
} from './dev.production.min';

import {
i18n as i18nDev,
setupI18n as setupI18nDev,
formats as formatsDev,
I18n as I18nDev
} from './dev.development';

export const i18n = process.env.NODE_ENV === 'production' ? i18nProd : i18nDev;
export const setupI18n = process.env.NODE_ENV === 'production' ? setupI18nProd : setupI18nDev;
export const formats = process.env.NODE_ENV === 'production' ? formatsProd : formatsDev;
export const I18n = process.env.NODE_ENV === 'production' ? I18nProd : I18nDev;
4 changes: 2 additions & 2 deletions packages/core/npm/esm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import {
setupI18n as setupI18nProd,
formats as formatsProd,
I18n as I18nProd
} from './core.esm';
} from './core.production.min';

import {
i18n as i18nDev,
setupI18n as setupI18nDev,
formats as formatsDev,
I18n as I18nDev
} from './dev.esm';
} from './core.development';

export const i18n = process.env.NODE_ENV === 'production' ? i18nProd : i18nDev;
export const setupI18n = process.env.NODE_ENV === 'production' ? setupI18nProd : setupI18nDev;
Expand Down
11 changes: 7 additions & 4 deletions scripts/build/rollup.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ const codeFrame = require("babel-code-frame")
const babelConfig = require("./babel.config")

const Modules = require("./modules")
const Bundles = require("./bundles")
const Packaging = require("./packaging")

const UMD_DEV = "UMD_DEV"
const UMD_PROD = "UMD_PROD"
const NODE_DEV = "NODE_DEV"
const NODE_PROD = "NODE_PROD"
const ESM_PROD = "ESM_PROD"
const ESM_DEV = "ESM_DEV"

const extensions = [".js", ".ts", ".tsx"]

Expand Down Expand Up @@ -71,6 +71,7 @@ function getFormat(bundleType) {
case NODE_PROD:
return 'cjs'
case ESM_PROD:
case ESM_DEV:
return 'es'
}
}
Expand All @@ -79,20 +80,21 @@ function getFilename(bundle, bundleType) {
const filename = bundle.label || bundle.entry
switch (bundleType) {
case NODE_DEV:
case ESM_DEV:
case UMD_DEV:
return `${filename}.development.js`
case UMD_PROD:
case NODE_PROD:
return `${filename}.production.min.js`
case ESM_PROD:
return `${filename}.esm.js`
return `${filename}.production.min.js`
}
}

function isProductionBundleType(bundleType) {
switch (bundleType) {
case UMD_DEV:
case NODE_DEV:
case ESM_DEV:
return false
case UMD_PROD:
case NODE_PROD:
Expand Down Expand Up @@ -291,7 +293,7 @@ async function build(bundle, bundleType) {
),
}
const [mainOutputPath, ...otherOutputPaths] = Packaging.getBundleOutputPaths(
bundleType === ESM_PROD ? "ESM" : "UNIVERSAL",
bundleType === ESM_PROD || bundleType === ESM_DEV ? "ESM" : "UNIVERSAL",
filename,
packageName
)
Expand Down Expand Up @@ -320,6 +322,7 @@ async function build(bundle, bundleType) {
module.exports = async function (bundle) {
await build(bundle, NODE_DEV)
await build(bundle, NODE_PROD)
await build(bundle, ESM_DEV)
await build(bundle, ESM_PROD)
// await build(bundle, UMD_DEV)
// await build(bundle, UMD_PROD)
Expand Down