Skip to content

Commit bec9dda

Browse files
authored
fix: support runtime module for node.js (#1573)
* fix: support runtime module for node.js * fix * fix
1 parent cdfff41 commit bec9dda

File tree

4 files changed

+35
-16
lines changed

4 files changed

+35
-16
lines changed

docs/guide/installation.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,14 @@ If you use `vue-i18n.runtime.esm-bundler.js`, you will need to precompile all lo
139139
:new: 9.3+
140140
:::
141141
142-
- **`vue-i18n.node.mjs`**:
142+
- **`vue-i18n(.runtime).node.mjs`**:
143143
- For ES Moudles usage in Node.js
144144
- For use in Node.js via `import`
145145
- The dev/prod files are pre-built, but the appropriate file is automatically required based on `process.env`<wbr/>`.NODE_ENV`
146+
- This module is proxy module of `vue-i18n(.runtime).mjs`
147+
- **`vue-i18n.runtime.node.mjs`**: is runtime only. proxy `vue-i18n.runtime.mjs`.
148+
- **`vue-i18n.node.mjs`**: includes the runtime compiler. proxy `vue-i18n.mjs`.
146149
147150
:::tip NOTE
148-
ES Modules will be the future of the Node.js module system. The `vue-i18n.cjs(.prod).js` will be deprecated in the future. We recommend you would use `vue-i18n.node.mjs`.
151+
ES Modules will be the future of the Node.js module system. The `vue-i18n.cjs(.prod).js` will be deprecated in the future. We recommend you would use `vue-i18n(.runtime).node.mjs`.
149152
:::

packages/core/README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,15 @@ The intlify core module for i18n
4242
- If you bundle your app with webpack with `target: 'node'` and properly externalize `@intlify/core`, this is the build that will be loaded
4343
- The dev/prod files are pre-built, but the appropriate file is automatically required based on `process.env.NODE_ENV`
4444

45-
- **`core.node.mjs`**:
45+
- **`core(.runtime).node.mjs`**:
4646
- For ES Moudles usage in Node.js
4747
- For use in Node.js via `import`
48-
- The dev/prod files are pre-built, but the appropriate file is automatically required based on `process.env`<wbr/>`.NODE_ENV`
48+
- The dev/prod files are pre-built, but the appropriate file is automatically required based on `process.env.NODE_ENV`
49+
- This module is proxy module of `core(.runtime).mjs`
50+
- **`core.runtime.node.mjs`**: is runtime only. proxy `core.runtime.mjs`
51+
- **`core.node.mjs`**: includes the runtime compiler. proxy `core.mjs`
4952

50-
> NOTE: ES Modules will be the future of the Node.js module system. The `core.cjs(.prod).js` will be deprecated in the future. We recommend you would use `core.node.mjs`. 9.3+
53+
> NOTE: ES Modules will be the future of the Node.js module system. The `core.cjs(.prod).js` will be deprecated in the future. We recommend you would use `core(.runtime).node.mjs`. 9.3+
5154
5255

5356
## :copyright: License

packages/vue-i18n/README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,15 @@ Internationalization plugin for Vue.js
4444
- If you bundle your app with webpack with `target: 'node'` and properly externalize `vue-i18n`, this is the build that will be loaded
4545
- The dev/prod files are pre-built, but the appropriate file is automatically required based on `process.env.NODE_ENV`
4646

47-
- **`vue-i18n.node.mjs`**:
47+
- **`vue-i18n(.runtime).node.mjs`**:
4848
- For ES Moudles usage in Node.js
4949
- For use in Node.js via `import`
50-
- The dev/prod files are pre-built, but the appropriate file is automatically required based on `process.env`<wbr/>`.NODE_ENV`
51-
50+
- The dev/prod files are pre-built, but the appropriate file is automatically required based on `process.env.NODE_ENV`
51+
- This module is proxy module of `vue-i18n(.runtime).mjs`
52+
- **`vue-i18n.runtime.node.mjs`**: is runtime only. proxy `vue-i18n.runtime.mjs`
53+
- **`vue-i18n.node.mjs`**: includes the runtime compiler. proxy `vue-i18n.mjs`
5254

53-
> NOTE: ES Modules will be the future of the Node.js module system. The `vue-i18n.cjs(.prod).js` will be deprecated in the future. We recommend you would use `vue-i18n.node.mjs`. 9.3+
55+
> NOTE: ES Modules will be the future of the Node.js module system. The `vue-i18n.cjs(.prod).js` will be deprecated in the future. We recommend you would use `vue-i18n(.runtime).node.mjs`. 9.3+
5456
5557

5658
## For Bundler feature flags

rollup.config.mjs

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -274,26 +274,37 @@ function createConfig(format, _output, plugins = []) {
274274
console.log(`created stub ${pc.bold(`dist/${stub}`)}`)
275275

276276
// add the node specific version
277-
if (format === 'mjs') {
277+
if (format === 'mjs' || format === 'mjs-runtime') {
278278
// NOTE:
279279
// https://github.com/vuejs/router/issues/1516
280280
// https://github.com/vuejs/router/commit/53f720622aa273e33c05517fa917cdcfbfba52bc
281-
if (name === 'vue-i18n' || name === 'vue-i18n-bridge' || name === 'petite-vue-i18n') {
282-
const outfile = `dist/${stub}`.replace('esm-bundler.js', 'node.mjs')
281+
if (
282+
name === 'vue-i18n' ||
283+
name === 'vue-i18n-bridge' ||
284+
name === 'petite-vue-i18n'
285+
) {
286+
const outfile = `dist/${stub}`.replace(
287+
'esm-bundler.js',
288+
'node.mjs'
289+
)
283290
await fs.writeFile(
284291
resolve(outfile),
285292
`global.__VUE_PROD_DEVTOOLS__ = false;\n` + contents
286293
)
287294
console.log(`created stub ${pc.bold(outfile)}`)
288-
} else if(name === 'core') {
289-
const outfile = `dist/${stub}`.replace('esm-bundler.js', 'node.mjs')
295+
} else if (name === 'core') {
296+
const outfile = `dist/${stub}`.replace(
297+
'esm-bundler.js',
298+
'node.mjs'
299+
)
290300
await fs.writeFile(
291301
resolve(outfile),
292-
`global.__VUE_PROD_DEVTOOLS__ = false;\nglobal.__INTLIFY_JIT_COMPILATION__ = true;\n` + contents
302+
`global.__VUE_PROD_DEVTOOLS__ = false;\nglobal.__INTLIFY_JIT_COMPILATION__ = true;\n` +
303+
contents
293304
)
294305
console.log(`created stub ${pc.bold(outfile)}`)
295306
}
296-
}
307+
}
297308
}
298309
}
299310
],

0 commit comments

Comments
 (0)