Skip to content

Commit ffcc6ad

Browse files
authored
fix: build feature flags (#595)
1 parent c79284a commit ffcc6ad

File tree

8 files changed

+371
-41
lines changed

8 files changed

+371
-41
lines changed

examples/petite/formatting/linked.html

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,24 @@
3333
'message.dio': 'DIO:',
3434
'message.linked': '@:message.dio @:message.the_world !!!!',
3535
'message.homeAddress': 'Home address',
36-
'message.missingHomeAddress': 'Please provide @.lower:message.homeAddress',
36+
'message.missingHomeAddress':
37+
'Please provide @.lower:message.homeAddress',
3738
'message.snake': 'snake case',
38-
'message.custom_modifier': "custom modifiers example: @.snakeCase:{'message.snake'}"
39+
'message.custom_modifier':
40+
"custom modifiers example: @.snakeCase:{'message.snake'}"
3941
},
4042
ja: {
4143
'message.language': '言語',
4244
'message.the_world': 'ザ・ワールド',
4345
'message.dio': 'ディオ:',
4446
'message.linked': '@:message.dio @:message.the_world !!!!',
4547
'message.homeAddress': 'ホームアドレス',
46-
'message.missingHomeAddress': 'どうか、@.lower:message.homeAddress を提供してください。',
48+
'message.missingHomeAddress':
49+
'どうか、@.lower:message.homeAddress を提供してください。',
4750
'message.snake': 'スネーク ケース',
4851
'message.foo': 'message.snake',
49-
'message.custom_modifier': "カスタム修飾子の例: @.snakeCase:{'message.snake'}"
52+
'message.custom_modifier':
53+
"カスタム修飾子の例: @.snakeCase:{'message.snake'}"
5054
}
5155
},
5256
modifiers: {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"build:size-petite-vue-i18n": "cd packages/size-check-petite-vue-i18n && yarn build --minify false",
2222
"build:size-vue-i18n": "cd packages/size-check-vue-i18n && yarn build --minify false",
2323
"build:sourcemap": "yarn build --sourcemap",
24-
"build:type": "yarn build --types && cat ./packages/vue-i18n/src/vue.d.ts >> ./packages/vue-i18n/dist/vue-i18n.d.ts && cat ./packages/petite-vue-i18n/src/vue.d.ts.template >> ./packages/petite-vue-i18n/dist/petite-vue-i18n.d.ts",
24+
"build:type": "yarn build --types && tail -n +32 ./packages/vue-i18n/src/vue.d.ts >> ./packages/vue-i18n/dist/vue-i18n.d.ts && tail -n +32 ./packages/petite-vue-i18n/src/vue.d.ts >> ./packages/petite-vue-i18n/dist/petite-vue-i18n.d.ts",
2525
"clean": "npm-run-all --parallel clean:*",
2626
"clean:cache": "yarn clean:cache:jest",
2727
"clean:cache:jest": "jest --clearCache",

packages/petite-vue-i18n/src/index.ts

Lines changed: 49 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
import { registerMessageCompiler, compileToFunction } from '@intlify/core-base'
1+
import { getGlobalThis } from '@intlify/shared'
2+
import {
3+
setDevToolsHook,
4+
registerMessageCompiler,
5+
compileToFunction
6+
} from '@intlify/core-base'
7+
import { initDev, initFeatureFlags } from '../../vue-i18n-core/src/misc'
28

39
// register message compiler at petite-vue-i18n
410
registerMessageCompiler(compileToFunction)
@@ -13,20 +19,22 @@ export {
1319
LocaleMessageDictionary,
1420
LocaleMessageType,
1521
LocaleMessages,
16-
IntlNumberFormat,
17-
IntlDateTimeFormat,
18-
IntlDateTimeFormats,
19-
IntlNumberFormats,
20-
IntlLocaleMatcher,
21-
IntlFormatMatcher,
22+
NumberFormat as IntlNumberFormat,
23+
DateTimeFormat as IntlDateTimeFormat,
24+
DateTimeFormats as IntlDateTimeFormats,
25+
NumberFormats as IntlNumberFormats,
26+
LocaleMatcher as IntlLocaleMatcher,
27+
FormatMatcher as IntlFormatMatcher,
2228
MessageFunction,
2329
MessageFunctions,
2430
PluralizationRule,
2531
LinkedModifiers,
2632
TranslateOptions,
2733
DateTimeOptions,
2834
NumberOptions,
29-
PostTranslationHandler,
35+
PostTranslationHandler
36+
} from '@intlify/core-base'
37+
export {
3038
VueMessageType,
3139
DefineLocaleMessage,
3240
DefaultLocaleMessageSchema,
@@ -43,7 +51,9 @@ export {
4351
ComposerDateTimeFormatting,
4452
ComposerNumberFormatting,
4553
ComposerResolveLocaleMessageTranslation,
46-
RemovedIndexResources,
54+
RemovedIndexResources
55+
} from '../../vue-i18n-core/src/composer'
56+
export {
4757
TranslateResult,
4858
Choice,
4959
LocaleMessageObject,
@@ -59,7 +69,9 @@ export {
5969
VueI18nDateTimeFormatting,
6070
VueI18nNumberFormatting,
6171
VueI18nResolveLocaleMessageTranslation,
62-
ComponentInstanceCreatedListener,
72+
ComponentInstanceCreatedListener
73+
} from '../../vue-i18n-core/src/legacy'
74+
export {
6375
createI18n,
6476
useI18n,
6577
I18nOptions,
@@ -69,7 +81,30 @@ export {
6981
I18nScope,
7082
ComposerAdditionalOptions,
7183
UseI18nOptions,
72-
ExportedGlobalComposer,
73-
I18nPluginOptions,
74-
VERSION
75-
} from '@intlify/vue-i18n-core'
84+
ExportedGlobalComposer
85+
} from '../../vue-i18n-core/src/i18n'
86+
export { I18nPluginOptions } from '../../vue-i18n-core/src/plugin'
87+
export { VERSION } from './../../vue-i18n-core/src/misc'
88+
89+
export type {
90+
IsNever,
91+
IsEmptyObject,
92+
PickupPaths,
93+
PickupKeys,
94+
PickupFormatPathKeys
95+
} from '@intlify/core-base'
96+
97+
if (__ESM_BUNDLER__ && !__TEST__) {
98+
initFeatureFlags()
99+
}
100+
101+
// NOTE: experimental !!
102+
if (__DEV__ || __FEATURE_PROD_INTLIFY_DEVTOOLS__) {
103+
const target = getGlobalThis()
104+
target.__INTLIFY__ = true
105+
setDevToolsHook(target.__INTLIFY_DEVTOOLS_GLOBAL_HOOK__)
106+
}
107+
108+
if (__DEV__) {
109+
initDev()
110+
}

packages/petite-vue-i18n/src/runtime.ts

Lines changed: 46 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
import { getGlobalThis } from '@intlify/shared'
2+
import { setDevToolsHook } from '@intlify/core-base'
3+
import { initDev, initFeatureFlags } from '../../vue-i18n-core/src/misc'
4+
15
export {
26
Path,
37
PathValue,
@@ -8,20 +12,22 @@ export {
812
LocaleMessageDictionary,
913
LocaleMessageType,
1014
LocaleMessages,
11-
IntlNumberFormat,
12-
IntlDateTimeFormat,
13-
IntlDateTimeFormats,
14-
IntlNumberFormats,
15-
IntlLocaleMatcher,
16-
IntlFormatMatcher,
15+
NumberFormat as IntlNumberFormat,
16+
DateTimeFormat as IntlDateTimeFormat,
17+
DateTimeFormats as IntlDateTimeFormats,
18+
NumberFormats as IntlNumberFormats,
19+
LocaleMatcher as IntlLocaleMatcher,
20+
FormatMatcher as IntlFormatMatcher,
1721
MessageFunction,
1822
MessageFunctions,
1923
PluralizationRule,
2024
LinkedModifiers,
2125
TranslateOptions,
2226
DateTimeOptions,
2327
NumberOptions,
24-
PostTranslationHandler,
28+
PostTranslationHandler
29+
} from '@intlify/core-base'
30+
export {
2531
VueMessageType,
2632
DefineLocaleMessage,
2733
DefaultLocaleMessageSchema,
@@ -38,7 +44,9 @@ export {
3844
ComposerDateTimeFormatting,
3945
ComposerNumberFormatting,
4046
ComposerResolveLocaleMessageTranslation,
41-
RemovedIndexResources,
47+
RemovedIndexResources
48+
} from '../../vue-i18n-core/src/composer'
49+
export {
4250
TranslateResult,
4351
Choice,
4452
LocaleMessageObject,
@@ -54,7 +62,9 @@ export {
5462
VueI18nDateTimeFormatting,
5563
VueI18nNumberFormatting,
5664
VueI18nResolveLocaleMessageTranslation,
57-
ComponentInstanceCreatedListener,
65+
ComponentInstanceCreatedListener
66+
} from '../../vue-i18n-core/src/legacy'
67+
export {
5868
createI18n,
5969
useI18n,
6070
I18nOptions,
@@ -64,7 +74,30 @@ export {
6474
I18nScope,
6575
ComposerAdditionalOptions,
6676
UseI18nOptions,
67-
ExportedGlobalComposer,
68-
I18nPluginOptions,
69-
VERSION
70-
} from '@intlify/vue-i18n-core'
77+
ExportedGlobalComposer
78+
} from '../../vue-i18n-core/src/i18n'
79+
export { I18nPluginOptions } from '../../vue-i18n-core/src/plugin'
80+
export { VERSION } from './../../vue-i18n-core/src/misc'
81+
82+
export type {
83+
IsNever,
84+
IsEmptyObject,
85+
PickupPaths,
86+
PickupKeys,
87+
PickupFormatPathKeys
88+
} from '@intlify/core-base'
89+
90+
if (__ESM_BUNDLER__ && !__TEST__) {
91+
initFeatureFlags()
92+
}
93+
94+
// NOTE: experimental !!
95+
if (__DEV__ || __FEATURE_PROD_INTLIFY_DEVTOOLS__) {
96+
const target = getGlobalThis()
97+
target.__INTLIFY__ = true
98+
setDevToolsHook(target.__INTLIFY_DEVTOOLS_GLOBAL_HOOK__)
99+
}
100+
101+
if (__DEV__) {
102+
initDev()
103+
}

packages/petite-vue-i18n/src/vue.d.ts.template renamed to packages/petite-vue-i18n/src/vue.d.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,34 @@
1+
import type { Path, NamedValue } from '@intlify/core-base'
12
import type {
3+
Locale,
4+
LocaleMessageValue,
5+
MessageFunction,
6+
TranslateOptions,
7+
DateTimeOptions,
8+
NumberOptions,
29
IsNever,
310
IsEmptyObject,
411
PickupPaths,
512
PickupKeys,
613
PickupFormatPathKeys
7-
} from '@intlify/vue-i18n-core'
14+
} from '@intlify/core-base'
15+
import type {
16+
CustomBlocks,
17+
VueMessageType
18+
} from '../../vue-i18n-core/src/composer'
19+
import type {
20+
DefineLocaleMessage,
21+
DefineDateTimeFormat,
22+
RemovedIndexResources
23+
} from '../../vue-i18n-core/src/composer'
24+
import type {
25+
VueI18n,
26+
VueI18nOptions,
27+
TranslateResult,
28+
DateTimeFormatResult,
29+
NumberFormatResult
30+
} from '../../vue-i18n-core/src/legacy'
31+
import type { ExportedGlobalComposer } from '../../vue-i18n-core/src/i18n'
832

933
declare module '@vue/runtime-core' {
1034
/**

0 commit comments

Comments
 (0)