Skip to content

Commit

Permalink
support suppress esm-bundler feature flags warning (#384)
Browse files Browse the repository at this point in the history
  • Loading branch information
kazupon committed Mar 5, 2021
1 parent 6ae074e commit 5bde6ca
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 2 deletions.
3 changes: 2 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ module.exports = {
__ESM_BROWSER__: false,
__NODE_JS__: true,
__FEATURE_FULL_INSTALL__: true,
__FEATURE_LEGACY_API__: true
__FEATURE_LEGACY_API__: true,
__FEATURE_ESM_BUNDLER_WARN__: true
},

// The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.
Expand Down
1 change: 1 addition & 0 deletions packages/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ declare let __COMMIT__: string
declare let __FEATURE_PROD_DEVTOOLS__: boolean
declare let __FEATURE_LEGACY_API__: boolean
declare let __FEATURE_FULL_INSTALL__: boolean
declare let __FEATURE_ESM_BUNDLER_WARN__: boolean

// for tests
declare namespace jest {
Expand Down
8 changes: 7 additions & 1 deletion packages/vue-i18n/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ Internationalization plugin for Vue.js
- If you bundle your app with webpack with `target: 'node'` and properly externalize `vue-i18n`, this is the build that will be loaded
- The dev/prod files are pre-built, but the appropriate file is automatically required based on `process.env.NODE_ENV`

## Bundler Build Feature Flags
## For Bundler feature flags

### Build Feature Flags

The `esm-bundler` builds now exposes global feature flags that can be overwritten at compile time:

Expand All @@ -59,6 +61,10 @@ The build will work without configuring these flags, however it is **strongly re

Note: the replacement value **must be boolean literals** and cannot be strings, otherwise the bundler/minifier will not be able to properly evaluate the conditions.

## Other Feature Flags

- `__FEATURE_ESM_BUNDLER_WARN__` (Suppress / Not suppress feature flags recommended warnings in build for `esm-bulder`)

## :copyright: License

[MIT](http://opensource.org/licenses/MIT)
4 changes: 4 additions & 0 deletions packages/vue-i18n/src/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ export function initFeatureFlags(): void {
getGlobalThis().__INTLIFY_PROD_DEVTOOLS__ = false
}

if (__DEV__ && typeof __FEATURE_ESM_BUNDLER_WARN__ === 'boolean') {
needWarn = __FEATURE_ESM_BUNDLER_WARN__
}

if (__DEV__ && needWarn) {
console.warn(
`You are running the esm-bundler build of vue-i18n. It is recommended to ` +
Expand Down
1 change: 1 addition & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ function createReplacePlugin(
__FEATURE_PROD_DEVTOOLS__: isBundlerESMBuild
? `__INTLIFY_PROD_DEVTOOLS__`
: false,
__FEATURE_ESM_BUNDLER_WARN__: true,
preventAssignment: false,
...(isProduction && isBrowserBuild
? {
Expand Down

0 comments on commit 5bde6ca

Please sign in to comment.