From 9990ebaa9d30f7e218c106a2abfd7ddbcf0e0170 Mon Sep 17 00:00:00 2001 From: Sergio Moreno Date: Tue, 18 May 2021 18:10:11 +0200 Subject: [PATCH] fix: reduce size of ESM packages (#1066) --- package.json | 16 ++++++++++++ packages/core/npm/esm/dev.js | 19 +------------- packages/core/npm/esm/index.js | 19 +------------- packages/detect-locale/npm/esm/index.js | 34 +------------------------ packages/react/npm/esm/index.js | 13 +--------- 5 files changed, 20 insertions(+), 81 deletions(-) diff --git a/package.json b/package.json index 1c330bc7e..2c434eec1 100644 --- a/package.json +++ b/package.json @@ -122,6 +122,22 @@ { "path": "./packages/react/build/cjs/react.production.min.js", "limit": "5 kB" + }, + { + "path": "./packages/core/build/esm/index.js", + "limit": "3 kB" + }, + { + "path": "./packages/core/build/esm/dev.js", + "limit": "10 kB" + }, + { + "path": "./packages/detect-locale/build/esm/index.js", + "limit": "1 kB" + }, + { + "path": "./packages/react/build/esm/index.js", + "limit": "5 kB" } ] } diff --git a/packages/core/npm/esm/dev.js b/packages/core/npm/esm/dev.js index 988a5a2f4..ff4cefa5a 100644 --- a/packages/core/npm/esm/dev.js +++ b/packages/core/npm/esm/dev.js @@ -1,18 +1 @@ -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; \ No newline at end of file +export * from './dev.development'; \ No newline at end of file diff --git a/packages/core/npm/esm/index.js b/packages/core/npm/esm/index.js index 01cf71e7b..40150173b 100644 --- a/packages/core/npm/esm/index.js +++ b/packages/core/npm/esm/index.js @@ -1,18 +1 @@ -import { - i18n as i18nProd, - setupI18n as setupI18nProd, - formats as formatsProd, - I18n as I18nProd -} from './core.production.min'; - -import { - i18n as i18nDev, - setupI18n as setupI18nDev, - formats as formatsDev, - I18n as I18nDev -} from './core.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; \ No newline at end of file +export * from './core.production.min'; \ No newline at end of file diff --git a/packages/detect-locale/npm/esm/index.js b/packages/detect-locale/npm/esm/index.js index 178dd29c5..0be927a3a 100644 --- a/packages/detect-locale/npm/esm/index.js +++ b/packages/detect-locale/npm/esm/index.js @@ -1,33 +1 @@ -import { - detect as detectDev, - fromCookie as fromCookieDev, - fromHtmlTag as fromHtmlTagDev, - fromNavigator as fromNavigatorDev, - fromPath as fromPathDev, - fromStorage as fromStorageDev, - fromSubdomain as fromSubdomainDev, - fromUrl as fromUrlDev, - multipleDetect as multipleDetectDev, -} from "./detect-locale.development.js" - -import { - detect as detectProd, - fromCookie as fromCookieProd, - fromHtmlTag as fromHtmlTagProd, - fromNavigator as fromNavigatorProd, - fromPath as fromPathProd, - fromStorage as fromStorageProd, - fromSubdomain as fromSubdomainProd, - fromUrl as fromUrlProd, - multipleDetect as multipleDetectProd, -} from "./detect-locale.production.min.js" - -export const detect = process.env.NODE_ENV === "production" ? detectProd : detectDev; -export const fromCookie = process.env.NODE_ENV === "production" ? fromCookieProd : fromCookieDev; -export const fromHtmlTag = process.env.NODE_ENV === "production" ? fromHtmlTagProd : fromHtmlTagDev; -export const fromNavigator = process.env.NODE_ENV === "production" ? fromNavigatorProd : fromNavigatorDev; -export const fromPath = process.env.NODE_ENV === "production" ? fromPathProd : fromPathDev; -export const fromStorage = process.env.NODE_ENV === "production" ? fromStorageProd : fromStorageDev; -export const fromSubdomain = process.env.NODE_ENV === "production" ? fromSubdomainProd : fromSubdomainDev; -export const fromUrl = process.env.NODE_ENV === "production" ? fromUrlProd : fromUrlDev; -export const multipleDetect = process.env.NODE_ENV === "production" ? multipleDetectProd : multipleDetectDev; \ No newline at end of file +export * from "./detect-locale.production.min" \ No newline at end of file diff --git a/packages/react/npm/esm/index.js b/packages/react/npm/esm/index.js index 6c91ac7df..a1fd5ad06 100644 --- a/packages/react/npm/esm/index.js +++ b/packages/react/npm/esm/index.js @@ -1,12 +1 @@ -import { - I18nProvider as devI18nProvider, Trans as devTrans, useLingui as devuseLingui, withI18n as devwithI18n -} from "./react.development.js" - -import { - I18nProvider as I18nProviderProd, Trans as TransProd, useLingui as useLinguiProd, withI18n as withI18nProd -} from "./react.production.min.js" - -export const I18nProvider = process.env.NODE_ENV === "production" ? I18nProviderProd : devI18nProvider; -export const Trans = process.env.NODE_ENV === "production" ? TransProd : devTrans; -export const useLingui = process.env.NODE_ENV === "production" ? useLinguiProd : devuseLingui; -export const withI18n = process.env.NODE_ENV === "production" ? withI18nProd : devwithI18n; \ No newline at end of file +export * from "./react.production.min"; \ No newline at end of file