File tree Expand file tree Collapse file tree 7 files changed +41
-18
lines changed Expand file tree Collapse file tree 7 files changed +41
-18
lines changed Original file line number Diff line number Diff line change @@ -52,13 +52,13 @@ function baseCompile(
5252 return { ...baseCompileCore ( message , options ) , detectError }
5353}
5454
55- export function compileToFunction <
55+ export const compileToFunction = /* #__PURE__*/ <
5656 Message = string ,
5757 MessageSource = string | ResourceNode
5858> (
5959 message : MessageSource ,
6060 context : MessageCompilerContext
61- ) : MessageFunction < Message > {
61+ ) : MessageFunction < Message > => {
6262 if ( ! isString ( message ) ) {
6363 throw createCoreError ( CoreErrorCodes . NOT_SUPPORT_NON_STRING_MESSAGE )
6464 }
@@ -107,8 +107,10 @@ export function compile<
107107 context : MessageCompilerContext
108108) : MessageFunction < Message > {
109109 if (
110- __FEATURE_JIT_COMPILATION__ &&
111- ! __FEATURE_DROP_MESSAGE_COMPILER__ &&
110+ ( __ESM_BROWSER__ ||
111+ __NODE_JS__ ||
112+ __GLOBAL__ ||
113+ ( __FEATURE_JIT_COMPILATION__ && ! __FEATURE_DROP_MESSAGE_COMPILER__ ) ) &&
112114 isString ( message )
113115 ) {
114116 // check HTML message
Original file line number Diff line number Diff line change 6666 "default" : " ./index.js"
6767 }
6868 },
69- "import " : " ./dist/core.mjs " ,
70- "browser " : " ./dist/core.esm-browser.js "
69+ "browser " : " ./dist/core.esm-browser.js " ,
70+ "import " : " ./dist/core.mjs "
7171 },
7272 "./dist/*" : " ./dist/*" ,
7373 "./package.json" : " ./package.json"
Original file line number Diff line number Diff line change @@ -14,10 +14,15 @@ if (__ESM_BUNDLER__ && !__TEST__) {
1414}
1515
1616// register message compiler at @intlify /core
17- if ( ! __FEATURE_JIT_COMPILATION__ ) {
18- registerMessageCompiler ( compileToFunction )
19- } else {
17+ if (
18+ __ESM_BROWSER__ ||
19+ __NODE_JS__ ||
20+ __GLOBAL__ ||
21+ __FEATURE_JIT_COMPILATION__
22+ ) {
2023 registerMessageCompiler ( compile )
24+ } else {
25+ registerMessageCompiler ( compileToFunction )
2126}
2227
2328// register message resolver at @intlify /core
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ declare let __BROWSER__: boolean
55declare let __GLOBAL__ : boolean
66declare let __RUNTIME__ : boolean
77declare let __ESM_BUNDLER__ : boolean
8+ declare let __ESM_BROWSER__ : boolean
89declare let __NODE_JS__ : boolean
910declare let __LITE__ : boolean
1011declare let __BRIDGE__ : boolean
Original file line number Diff line number Diff line change @@ -12,10 +12,15 @@ if (__ESM_BUNDLER__ && !__TEST__) {
1212}
1313
1414// register message compiler at petite-vue-i18n
15- if ( ! __FEATURE_JIT_COMPILATION__ ) {
16- registerMessageCompiler ( compileToFunction )
17- } else {
15+ if (
16+ __ESM_BROWSER__ ||
17+ __NODE_JS__ ||
18+ __GLOBAL__ ||
19+ __FEATURE_JIT_COMPILATION__
20+ ) {
1821 registerMessageCompiler ( compile )
22+ } else {
23+ registerMessageCompiler ( compileToFunction )
1924}
2025
2126export {
Original file line number Diff line number Diff line change @@ -16,10 +16,15 @@ if (__ESM_BUNDLER__ && !__TEST__) {
1616}
1717
1818// register message compiler at vue-i18n
19- if ( ! __FEATURE_JIT_COMPILATION__ ) {
20- registerMessageCompiler ( compileToFunction )
21- } else {
19+ if (
20+ __ESM_BROWSER__ ||
21+ __NODE_JS__ ||
22+ __GLOBAL__ ||
23+ __FEATURE_JIT_COMPILATION__
24+ ) {
2225 registerMessageCompiler ( compile )
26+ } else {
27+ registerMessageCompiler ( compileToFunction )
2328}
2429
2530// register message resolver at vue-i18n
Original file line number Diff line number Diff line change @@ -16,10 +16,15 @@ if (__ESM_BUNDLER__ && !__TEST__) {
1616}
1717
1818// register message compiler at vue-i18n
19- if ( ! __FEATURE_JIT_COMPILATION__ ) {
20- registerMessageCompiler ( compileToFunction )
21- } else {
19+ if (
20+ __ESM_BROWSER__ ||
21+ __NODE_JS__ ||
22+ __GLOBAL__ ||
23+ __FEATURE_JIT_COMPILATION__
24+ ) {
2225 registerMessageCompiler ( compile )
26+ } else {
27+ registerMessageCompiler ( compileToFunction )
2328}
2429
2530// register message resolver at vue-i18n
You can’t perform that action at this time.
0 commit comments