Skip to content

Commit 1c28a8f

Browse files
authored
tweak bundling (#150)
1 parent 1845d72 commit 1c28a8f

File tree

5 files changed

+20
-10
lines changed

5 files changed

+20
-10
lines changed

rollup.config.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,11 @@ function createReplacePlugin(
197197
...(isProduction && isBrowserBuild
198198
? {
199199
'emitError(': `/*#__PURE__*/ emitError(`,
200-
'createCompileError(': `/*#__PURE__*/ createCompileError(`
200+
'createCompileError(': `/*#__PURE__*/ createCompileError(`,
201+
'function createCoreError(': `/*#__PURE__*/ function createCoreError(`,
202+
'throw createCoreError(': `throw Error(`,
203+
'function createI18nError(': `/*#__PURE__*/ function createI18nError(`,
204+
'throw createI18nError(': `throw Error(`
201205
}
202206
: {})
203207
}

src/global.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ declare let __DEV__: boolean
33
declare let __TEST__: boolean
44
declare let __ESM_BUNDLER__: boolean
55
declare let __BROWSER__: boolean
6+
declare let __NODE_JS__: boolean
67
declare let __VERSION__: string
78

89
// Feature flags

src/i18n.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ export function createI18n<
280280
},
281281
// install plugin
282282
async install(app: App, ...options: unknown[]): Promise<void> {
283-
if (__DEV__ || __FEATURE_PROD_DEVTOOLS__) {
283+
if ((__DEV__ || __FEATURE_PROD_DEVTOOLS__) && !__NODE_JS__) {
284284
app.__VUE_I18N__ = i18n as _I18n
285285
}
286286

@@ -313,7 +313,7 @@ export function createI18n<
313313
)
314314
}
315315

316-
if (__DEV__) {
316+
if ((__DEV__ || __FEATURE_PROD_DEVTOOLS__) && !__NODE_JS__) {
317317
const ret = await enableDevTools(app, i18n as _I18n)
318318
if (!ret) {
319319
throw createI18nError(I18nErrorCodes.CANNOT_SETUP_VUE_DEVTOOLS_PLUGIN)
@@ -366,7 +366,7 @@ export function createI18n<
366366
}
367367
}
368368

369-
if (__DEV__ || __FEATURE_PROD_DEVTOOLS__) {
369+
if ((__DEV__ || __FEATURE_PROD_DEVTOOLS__) && !__NODE_JS__) {
370370
devtoolsRegisterI18n(i18n, VERSION)
371371
}
372372

@@ -582,7 +582,11 @@ function setupLifeCycle<Messages, DateTimeFormats, NumberFormats>(
582582

583583
onMounted(() => {
584584
// inject composer instance to DOM for intlify-devtools
585-
if ((__DEV__ || __FEATURE_PROD_DEVTOOLS__) && target.vnode.el) {
585+
if (
586+
(__DEV__ || __FEATURE_PROD_DEVTOOLS__) &&
587+
!__NODE_JS__ &&
588+
target.vnode.el
589+
) {
586590
target.vnode.el.__INTLIFY__ = composer
587591
emitter = createEmitter<DevToolsEmitterEvents>()
588592
// eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -596,6 +600,7 @@ function setupLifeCycle<Messages, DateTimeFormats, NumberFormats>(
596600
// remove composer instance from DOM for intlify-devtools
597601
if (
598602
(__DEV__ || __FEATURE_PROD_DEVTOOLS__) &&
603+
!__NODE_JS__ &&
599604
target.vnode.el &&
600605
target.vnode.el.__INTLIFY__
601606
) {

src/mixin.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export function defineMixin<Messages, DateTimeFormats, NumberFormats>(
9191
},
9292

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

116-
if (__DEV__ || __FEATURE_PROD_DEVTOOLS__) {
116+
if ((__DEV__ || __FEATURE_PROD_DEVTOOLS__) && !__NODE_JS__) {
117117
if (this.__emitter) {
118118
this.__emitter.off('*', addTimelineEvent)
119119
delete this.__emitter

yarn.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7998,9 +7998,9 @@ typescript@~3.9.7:
79987998
integrity sha512-BLbiRkiBzAwsjut4x/dsibSTB6yWpwT5qWmC2OfuCg3GgVQCSgMs4vEctYPhsaGtd0AeuuHMkjZ2h2WG8MSzRw==
79997999

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

80058005
union-value@^1.0.0:
80068006
version "1.0.1"

0 commit comments

Comments
 (0)