Skip to content

Commit

Permalink
fix: integrate vue-i18n jit compilation (#2199)
Browse files Browse the repository at this point in the history
* fix: integrate vue-i18n jit compilation

* fix: basic implementation

* fix: sourcemap warnings

* upgrade vue-i18n

* updates formating and linting

* upgrade playwright

* fix: wrong tests

* upgrade unplugin-vue-i18n
  • Loading branch information
kazupon authored Jul 7, 2023
1 parent 2040351 commit d20c654
Show file tree
Hide file tree
Showing 35 changed files with 1,890 additions and 2,179 deletions.
7 changes: 1 addition & 6 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@ module.exports = {
env: {
node: true
},
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:prettier/recommended',
'prettier'
],
extends: ['plugin:@typescript-eslint/recommended', 'plugin:@typescript-eslint/eslint-recommended', 'prettier'],
plugins: ['@typescript-eslint'],
parserOptions: {
parser: '@typescript-eslint/parser',
Expand Down
2 changes: 1 addition & 1 deletion .prettierrc.cjs → .prettierrc.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
export default {
semi: false,
singleQuote: true,
printWidth: 120,
Expand Down
6 changes: 3 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"files.associations": {
"*.json": "jsonc"
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"editor.formatOnPaste": true,
"editor.formatOnType": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
Expand Down
15 changes: 0 additions & 15 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ This changelog is generated by [GitHub Releases](https://github.com/nuxt-modules

#####     [View changes on GitHub](https://github.com/nuxt-modules/i18n/compare/v8.0.0-beta.11...v8.0.0-beta.12)


# v8.0.0-beta.11 (2023-04-13T11:10:28Z)

This changelog is generated by [GitHub Releases](https://github.com/nuxt-modules/i18n/releases/tag/v8.0.0-beta.11)
Expand Down Expand Up @@ -48,7 +47,6 @@ This changelog is generated by [GitHub Releases](https://github.com/nuxt-modules

#####     [View changes on GitHub](https://github.com/nuxt-modules/i18n/compare/v8.0.0-beta.10...v8.0.0-beta.11)


# v8.0.0-beta.10 (2023-02-22T15:09:36Z)

This changelog is generated by [GitHub Releases](https://github.com/nuxt-modules/i18n/releases/tag/v8.0.0-beta.10)
Expand All @@ -68,7 +66,6 @@ This changelog is generated by [GitHub Releases](https://github.com/nuxt-modules

#####     [View changes on GitHub](https://github.com/nuxt-modules/i18n/compare/v8.0.0-beta.9...v8.0.0-beta.10)


# v8.0.0-beta.9 (2023-01-27T03:32:07Z)

This changelog is generated by [GitHub Releases](https://github.com/nuxt-modules/i18n/releases/tag/v8.0.0-beta.9)
Expand All @@ -83,12 +80,10 @@ This changelog is generated by [GitHub Releases](https://github.com/nuxt-modules

#####     [View changes on GitHub](https://github.com/nuxt-modules/i18n/compare/v8.0.0-beta.8...v8.0.0-beta.9)


# v8.0.0-beta.8 (2023-01-21T13:46:45Z)

This changelog is generated by [GitHub Releases](https://github.com/nuxt-modules/i18n/releases/tag/v8.0.0-beta.8)


### 🚨 Breaking Changes

- Injection fields completion for nuxt app instance and page meta - by **kazuya kawaguchi** in https://github.com/nuxt-modules/i18n/issues/1711 [<samp>(8e682)</samp>](https://github.com/nuxt-modules/i18n/commit/8e682a6)
Expand All @@ -113,7 +108,6 @@ This changelog is generated by [GitHub Releases](https://github.com/nuxt-modules

##### [View changes on GitHub](https://github.com/nuxt-modules/i18n/compare/v8.0.0-beta.7...v8.0.0-beta.8)


# v8.0.0-beta.7 (2022-12-08T01:11:15Z)

This changelog is generated by [GitHub Releases](https://github.com/nuxt-modules/i18n/releases/tag/v8.0.0-beta.7)
Expand All @@ -130,7 +124,6 @@ This changelog is generated by [GitHub Releases](https://github.com/nuxt-modules

##### &nbsp;&nbsp;&nbsp;&nbsp;[View changes on GitHub](https://github.com/nuxt-modules/i18n/compare/v8.0.0-beta.6...v8.0.0-beta.7)


# v8.0.0-beta.6 (2022-11-29T05:24:25Z)

This changelog is generated by [GitHub Releases](https://github.com/nuxt-community/i18n-module/releases/tag/v8.0.0-beta.6)
Expand All @@ -141,7 +134,6 @@ This changelog is generated by [GitHub Releases](https://github.com/nuxt-communi

##### &nbsp;&nbsp;&nbsp;&nbsp;[View changes on GitHub](https://github.com/nuxt-community/i18n-module/compare/v8.0.0-beta.5...v8.0.0-beta.6)


# v8.0.0-beta.5 (2022-11-28T08:40:36Z)

This changelog is generated by [GitHub Releases](https://github.com/nuxt-community/i18n-module/releases/tag/v8.0.0-beta.5)
Expand All @@ -164,7 +156,6 @@ This changelog is generated by [GitHub Releases](https://github.com/nuxt-communi

##### &nbsp;&nbsp;&nbsp;&nbsp;[View changes on GitHub](https://github.com/nuxt-community/i18n-module/compare/v8.0.0-beta.4...v8.0.0-beta.5)


# v8.0.0-beta.4 (2022-11-12T09:00:57Z)

This changelog is generated by [GitHub Releases](https://github.com/nuxt-community/i18n-module/releases/tag/v8.0.0-beta.4)
Expand All @@ -186,7 +177,6 @@ This changelog is generated by [GitHub Releases](https://github.com/nuxt-communi

##### &nbsp;&nbsp;&nbsp;&nbsp;[View changes on GitHub](https://github.com/nuxt-community/i18n-module/compare/v8.0.0-beta.3...v8.0.0-beta.4)


# v8.0.0-beta.3 (2022-10-31T17:00:44Z)

This changelog is generated by [GitHub Releases](https://github.com/nuxt-community/i18n-module/releases/tag/v8.0.0-beta.3)
Expand All @@ -205,7 +195,6 @@ This changelog is generated by [GitHub Releases](https://github.com/nuxt-communi

##### &nbsp;&nbsp;&nbsp;&nbsp;[View changes on GitHub](https://github.com/nuxt-community/i18n-module/compare/v8.0.0-beta.2...v8.0.0-beta.3)


# v8.0.0-beta.2 (2022-10-26T14:50:23Z)

This changelog is generated by [GitHub Releases](https://github.com/nuxt-community/i18n-module/releases/tag/v8.0.0-beta.2)
Expand All @@ -218,7 +207,6 @@ This changelog is generated by [GitHub Releases](https://github.com/nuxt-communi

##### &nbsp;&nbsp;&nbsp;&nbsp;[View changes on GitHub](https://github.com/nuxt-community/i18n-module/compare/v8.0.0-beta.1...v8.0.0-beta.2)


# v8.0.0-beta.1 (2022-10-20T11:05:51Z)

This changelog is generated by [GitHub Releases](https://github.com/nuxt-community/i18n-module/releases/tag/v8.0.0-beta.1)
Expand All @@ -243,7 +231,6 @@ This changelog is generated by [GitHub Releases](https://github.com/nuxt-communi

##### &nbsp;&nbsp;&nbsp;&nbsp;[View changes on GitHub](https://github.com/nuxt-community/i18n-module/compare/v8.0.0-alpha.3...v8.0.0-beta.1)


# v8.0.0-alpha.3 (2022-10-10T01:47:49Z)

This changelog is generated by [GitHub Releases](https://github.com/nuxt-community/i18n-module/releases/tag/v8.0.0-alpha.3)
Expand All @@ -258,7 +245,6 @@ This changelog is generated by [GitHub Releases](https://github.com/nuxt-communi

##### &nbsp;&nbsp;&nbsp;&nbsp;[View changes on GitHub](https://github.com/nuxt-community/i18n-module/compare/v8.0.0-alpha.2...v8.0.0-alpha.3)


# v8.0.0-alpha.2 (2022-09-28T08:47:05Z)

This changelog is generated by [GitHub Releases](https://github.com/nuxt-community/i18n-module/releases/tag/v8.0.0-alpha.2)
Expand All @@ -281,7 +267,6 @@ This changelog is generated by [GitHub Releases](https://github.com/nuxt-communi

##### &nbsp;&nbsp;&nbsp;&nbsp;[View changes on GitHub](https://github.com/nuxt-community/i18n-module/compare/v8.0.0-alpha.1...v8.0.0-alpha.2)


## 8.0.0-alpha.1 (2022-09-03)

This release is for Nuxt3.
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ pnpm docs:dev
> Please make sure all languages are in sync. If you don't speak a particular language, insert english text in place.
- Commit and push your changes
- Once you're done, submit that shiny PR!
- Once you're done, submit that shiny PR!
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ npm install @nuxtjs/i18n@next --save-dev
# Using yarn
yarn add --dev @nuxtjs/i18n@next

# Using pnpm
# Using pnpm
pnpm install --shamefully-hoist -D @nuxtjs/i18n@next
```

Expand Down Expand Up @@ -72,6 +72,7 @@ pnpm install --shamefully-hoist -D @nuxtjs/i18n@next
Keep in mind that not all features are currently supported yet and some things might be broken.

## 🔗 Links

- 📘 [Documentation for v8](https://v8.i18n.nuxtjs.org/)
- 📘 [Documentation for v7](https://i18n.nuxtjs.org/)
- 🔖 [Release notes](./CHANGELOG.md)
Expand Down
9 changes: 5 additions & 4 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# TODO

- For Official release
- [ ] remove `i18n:extends-messages` hook logic
- [ ] remove `parsePage` option logic
- [ ] update `@intlify/**` and vue-i18-* pkgs for latest version
- [ ] update `@intlify/**` and vue-i18-\* pkgs for latest version
- Refactoring
- [ ] module alias, langs option, etc should be resolved with `createResolver`
- [ ] resolve i18n options of nuxt.config with `useRuntimeConfig`, not `i18n.options.mjs`
- [ ] module alias, langs option, etc should be resolved with `createResolver`
- [ ] resolve i18n options of nuxt.config with `useRuntimeConfig`, not `i18n.options.mjs`
- [ ] pass `vueI18n` option as config and pass it to vue-i18n in runtime context.
- [ ] request nuxt sergment parser from `@nuxt/kit` API and use it.
- [ ] request nuxt sergment parser from `@nuxt/kit` API and use it.
10 changes: 0 additions & 10 deletions docs/content/1.getting-started/1.setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,6 @@ pnpm add @nuxtjs/i18n@next --save-dev
```
::

## `package.json`

Then, you need to add `"type": "module"` to `package.json` of your nuxt project.

::alert{type="info"}
This is necessary because nitro prerender is used for the dynamic import of nuxt i18n config and i18n resources on the Node runtime, on nuxt build.
::

## `nuxt.config.ts`

Then, add `@nuxtjs/i18n` to the `modules` section in your `nuxt.config`. You can use either of the following ways to specify the module options:

```ts {}[nuxt.config.ts]
Expand Down
4 changes: 2 additions & 2 deletions docs/content/3.options/6.misc.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ Supported properties:
- `jsTsFormatResource` (default: `false`) - Allow the format `js` and `ts` for locale messages in lazy load translation.


## `precompile`
## `compilation`

- type: `object`
- default: `{ strictMessage: true, escapeHtml: false }`

Configure flags that sets the behavior precompilation of locale messages.
Configure flags that sets the behavior compilation of locale messages.

Supported properties:

Expand Down
65 changes: 32 additions & 33 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"docs:generate": "nuxi generate docs",
"docs:preview": "nuxi preview docs",
"fix": "run-p lint:fix format:fix",
"format": "prettier --config .prettierrc.cjs --ignore-path .prettierignore --list-different '**/*.{js,json,html}'",
"format": "prettier --config .prettierrc.mjs --ignore-path .prettierignore --list-different '**/*.{js,json,html,md}'",
"format:fix": "pnpm format --write",
"lint": "eslint --cache --ext .js,.ts,.vue,.json .",
"lint:fix": "pnpm lint --fix",
Expand All @@ -74,62 +74,61 @@
}
},
"dependencies": {
"@intlify/bundle-utils": "^5.5.0",
"@intlify/shared": "9.3.0-beta.17",
"@intlify/unplugin-vue-i18n": "^0.10.0",
"@intlify/bundle-utils": "^7.0.1",
"@intlify/shared": "9.3.0-beta.22",
"@intlify/unplugin-vue-i18n": "^0.12.1",
"@mizchi/sucrase": "^4.1.0",
"@nuxt/kit": "^3.4.1",
"@vue/compiler-sfc": "^3.2.47",
"@vue/compiler-sfc": "^3.3.4",
"cookie-es": "^0.5.0",
"debug": "^4.3.4",
"defu": "^6.1.2",
"estree-walker": "^3.0.3",
"is-https": "^4.0.0",
"js-cookie": "^3.0.1",
"js-cookie": "^3.0.5",
"knitwork": "^1.0.0",
"magic-string": "^0.27.0",
"mlly": "^1.2.0",
"pathe": "^1.1.0",
"pkg-types": "^1.0.2",
"ufo": "^1.1.0",
"unplugin": "^1.3.1",
"mlly": "^1.4.0",
"pathe": "^1.1.1",
"pkg-types": "^1.0.3",
"ufo": "^1.1.2",
"unplugin": "^1.3.2",
"unstorage": "^1.5.0",
"vue-i18n": "9.3.0-beta.19",
"vue-i18n": "9.3.0-beta.22",
"vue-i18n-routing": "^0.13.0"
},
"devDependencies": {
"@babel/parser": "^7.21.4",
"@babel/plugin-syntax-import-assertions": "^7.20.0",
"@babel/types": "^7.21.4",
"@babel/parser": "^7.22.7",
"@babel/plugin-syntax-import-assertions": "^7.22.5",
"@babel/types": "^7.22.5",
"@nuxt/module-builder": "latest",
"@nuxt/schema": "^3.4.1",
"@types/debug": "^4.1.7",
"@types/debug": "^4.1.8",
"@types/js-cookie": "^3.0.3",
"@types/rimraf": "^3",
"@typescript-eslint/eslint-plugin": "^5.58.0",
"@typescript-eslint/parser": "^5.58.0",
"bumpp": "^9.1.0",
"changelogithub": "^0.12.7",
"@types/rimraf": "^3.0.2",
"@typescript-eslint/eslint-plugin": "^5.61.0",
"@typescript-eslint/parser": "^5.61.0",
"bumpp": "^9.1.1",
"changelogithub": "^0.12.12",
"debug": "^4.3.4",
"eslint": "^8.38.0",
"eslint": "^8.44.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-prettier": "^4.2.1",
"execa": "^7.1.1",
"get-port-please": "^3.0.1",
"gh-changelogen": "^0.2.8",
"jiti": "^1.18.2",
"jsdom": "^21.1.1",
"lint-staged": "^13.2.1",
"jiti": "^1.19.1",
"jsdom": "^21.1.2",
"lint-staged": "^13.2.3",
"npm-run-all": "^4.1.5",
"nuxt": "^3.4.1",
"ofetch": "^1.0.1",
"playwright": "^1.32.3",
"prettier": "^2.8.7",
"ofetch": "^1.1.1",
"playwright": "^1.35.1",
"prettier": "^3.0.0",
"rimraf": "^4.4.1",
"ts-essentials": "^9.3.1",
"typescript": "^5.1.3",
"vitest": "^0.30.1",
"vue": "^3.2.47",
"ts-essentials": "^9.3.2",
"typescript": "^5.1.6",
"vitest": "^0.32.4",
"vue": "^3.3.4",
"yorkie": "^2.0.0"
},
"gitHooks": {
Expand Down
4 changes: 2 additions & 2 deletions playground/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default defineNuxtConfig({
experimental: {
jsTsFormatResource: true
},
precompile: {
compilation: {
strictMessage: false,
escapeHtml: true
},
Expand Down Expand Up @@ -110,7 +110,7 @@ export default defineNuxtConfig({
experimental: {
jsTsFormatResource: true
},
precompile: {
compilation: {
strictMessage: false,
escapeHtml: true
},
Expand Down
Loading

0 comments on commit d20c654

Please sign in to comment.