Skip to content
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
6 changes: 5 additions & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,11 @@ function createReplacePlugin(
...(isProduction && isBrowserBuild
? {
'emitError(': `/*#__PURE__*/ emitError(`,
'createCompileError(': `/*#__PURE__*/ createCompileError(`
'createCompileError(': `/*#__PURE__*/ createCompileError(`,
'function createCoreError(': `/*#__PURE__*/ function createCoreError(`,
'throw createCoreError(': `throw Error(`,
'function createI18nError(': `/*#__PURE__*/ function createI18nError(`,
'throw createI18nError(': `throw Error(`
}
: {})
}
Expand Down
1 change: 1 addition & 0 deletions src/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ declare let __DEV__: boolean
declare let __TEST__: boolean
declare let __ESM_BUNDLER__: boolean
declare let __BROWSER__: boolean
declare let __NODE_JS__: boolean
declare let __VERSION__: string

// Feature flags
Expand Down
13 changes: 9 additions & 4 deletions src/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ export function createI18n<
},
// install plugin
async install(app: App, ...options: unknown[]): Promise<void> {
if (__DEV__ || __FEATURE_PROD_DEVTOOLS__) {
if ((__DEV__ || __FEATURE_PROD_DEVTOOLS__) && !__NODE_JS__) {
app.__VUE_I18N__ = i18n as _I18n
}

Expand Down Expand Up @@ -313,7 +313,7 @@ export function createI18n<
)
}

if (__DEV__) {
if ((__DEV__ || __FEATURE_PROD_DEVTOOLS__) && !__NODE_JS__) {
const ret = await enableDevTools(app, i18n as _I18n)
if (!ret) {
throw createI18nError(I18nErrorCodes.CANNOT_SETUP_VUE_DEVTOOLS_PLUGIN)
Expand Down Expand Up @@ -366,7 +366,7 @@ export function createI18n<
}
}

if (__DEV__ || __FEATURE_PROD_DEVTOOLS__) {
if ((__DEV__ || __FEATURE_PROD_DEVTOOLS__) && !__NODE_JS__) {
devtoolsRegisterI18n(i18n, VERSION)
}

Expand Down Expand Up @@ -582,7 +582,11 @@ function setupLifeCycle<Messages, DateTimeFormats, NumberFormats>(

onMounted(() => {
// inject composer instance to DOM for intlify-devtools
if ((__DEV__ || __FEATURE_PROD_DEVTOOLS__) && target.vnode.el) {
if (
(__DEV__ || __FEATURE_PROD_DEVTOOLS__) &&
!__NODE_JS__ &&
target.vnode.el
) {
target.vnode.el.__INTLIFY__ = composer
emitter = createEmitter<DevToolsEmitterEvents>()
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand All @@ -596,6 +600,7 @@ function setupLifeCycle<Messages, DateTimeFormats, NumberFormats>(
// remove composer instance from DOM for intlify-devtools
if (
(__DEV__ || __FEATURE_PROD_DEVTOOLS__) &&
!__NODE_JS__ &&
target.vnode.el &&
target.vnode.el.__INTLIFY__
) {
Expand Down
4 changes: 2 additions & 2 deletions src/mixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export function defineMixin<Messages, DateTimeFormats, NumberFormats>(
},

mounted(): void {
if (__DEV__ || __FEATURE_PROD_DEVTOOLS__) {
if ((__DEV__ || __FEATURE_PROD_DEVTOOLS__) && !__NODE_JS__) {
this.$el.__INTLIFY__ = this.$i18n.__composer
const emitter: DevToolsEmitter = (this.__emitter = createEmitter<
DevToolsEmitterEvents
Expand All @@ -113,7 +113,7 @@ export function defineMixin<Messages, DateTimeFormats, NumberFormats>(
throw createI18nError(I18nErrorCodes.UNEXPECTED_ERROR)
}

if (__DEV__ || __FEATURE_PROD_DEVTOOLS__) {
if ((__DEV__ || __FEATURE_PROD_DEVTOOLS__) && !__NODE_JS__) {
if (this.__emitter) {
this.__emitter.off('*', addTimelineEvent)
delete this.__emitter
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7998,9 +7998,9 @@ typescript@~3.9.7:
integrity sha512-BLbiRkiBzAwsjut4x/dsibSTB6yWpwT5qWmC2OfuCg3GgVQCSgMs4vEctYPhsaGtd0AeuuHMkjZ2h2WG8MSzRw==

uglify-js@^3.1.4:
version "3.11.2"
resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.11.2.tgz#9f50325544273c27b20e586def140e7726c525ea"
integrity sha512-G440NU6fewtnQftSgqRV1r2A5ChKbU1gqFCJ7I8S7MPpY/eZZfLGefaY6gUZYiWebMaO+txgiQ1ZyLDuNWJulg==
version "3.11.3"
resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.11.3.tgz#b2f8c87826344f091ba48c417c499d6cba5d5786"
integrity sha512-wDRziHG94mNj2n3R864CvYw/+pc9y/RNImiTyrrf8BzgWn75JgFSwYvXrtZQMnMnOp/4UTrf3iCSQxSStPiByA==

union-value@^1.0.0:
version "1.0.1"
Expand Down