Skip to content

imporovement: custom block fully pre-compilation #146

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 0 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -324,35 +324,6 @@ module.exports = {
}
```

## :rocket: i18n resource optimization

You can optimize your localization performance with pre-compiling the i18n resources.

You need to specify the `preCompile: true` option in your webpack config as below:

```javascript
module.exports = {
module: {
rules: [
// ...
{
resourceQuery: /blockType=i18n/,
type: 'javascript/auto',
use: [
{
loader: '@intlify/vue-i18n-loader',
options: {
preCompile: true // you need to specify at here!
}
}
]
},
// ...
]
}
}
```

## :scroll: Changelog
Details changes for each release are documented in the [CHANGELOG.md](https://github.com/intlify/vue-i18n-loader/blob/master/CHANGELOG.md).

Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions example/composition/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { createApp } from 'vue'
import { createI18n } from 'vue-i18n'
import App from './App.vue'

import ja from './ja.json'
import en from './en.yaml'
import ja from './locales/ja.json'
import en from './locales/en.yaml'

const i18n = createI18n({
legacy: false,
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions example/legacy/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { createApp } from 'vue'
import { createI18n } from 'vue-i18n'
import App from './App.vue'

import ja from './ja.json'
import en from './en.yaml'
import ja from './locales/ja.json'
import en from './locales/en.yaml'

const i18n = createI18n({
legacy: true,
Expand Down
21 changes: 8 additions & 13 deletions example/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ module.exports = {
// is a simple `export * from '@vue/runtime-dom`. However having this
// extra re-export somehow causes webpack to always invalidate the module
// on the first HMR update and causes the page to reload.
vue: '@vue/runtime-dom',
'vue-i18n': 'vue-i18n/dist/vue-i18n.runtime.esm-bundler.js'
vue: '@vue/runtime-dom'
}
},
devServer: {
Expand All @@ -42,28 +41,24 @@ module.exports = {
test: /\.(json5?|ya?ml)$/, // target json, json5, yaml and yml files
type: 'javascript/auto',
// Use `Rule.include` to specify the files of locale messages to be pre-compiled
include: [path.resolve(__dirname, './')],
include: [
path.resolve(__dirname, './composition/locales'),
path.resolve(__dirname, './legacy/locales')
],
use: [
{
loader: path.resolve(__dirname, '../lib/index.js'),
options: {
// Whether pre-compile number and boolean literal as message functions that return the string value, default `false`
forceStringify: true
// forceStringify: true
}
}
]
},
{
resourceQuery: /blockType=i18n/,
type: 'javascript/auto',
use: [
{
loader: path.resolve(__dirname, '../lib/index.js'),
options: {
preCompile: true
}
}
]
resourceQuery: /blockType=i18n/,
loader: path.resolve(__dirname, '../lib/index.js')
}
]
},
Expand Down
22 changes: 7 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,30 +24,22 @@
}
},
"dependencies": {
"@intlify/core-base": "^9.0.0-beta.14",
"@intlify/message-compiler": "^9.0.0-beta.14",
"@intlify/shared": "^9.0.0-beta.14",
"flat": "^5.0.2",
"js-yaml": "^3.14.0",
"json5": "^2.1.3",
"@intlify/core-base": "^9.0.0-beta.15",
"@intlify/message-compiler": "^9.0.0-beta.15",
"@intlify/shared": "^9.0.0-beta.15",
"jsonc-eslint-parser": "^0.6.0",
"loader-utils": "^2.0.0",
"prettier": "^2.2.1",
"yaml-eslint-parser": "^0.2.0"
},
"devDependencies": {
"@intlify/runtime": "^9.0.0-beta.14",
"@intlify/runtime": "^9.0.0-beta.15",
"@types/eslint": "^7.2.6",
"@types/eslint-visitor-keys": "^1.0.0",
"@types/flat": "^5.0.1",
"@types/jest": "^26.0.16",
"@types/js-yaml": "^3.12.5",
"@types/jsdom": "^16.2.5",
"@types/json5": "^0.0.30",
"@types/loader-utils": "^2.0.0",
"@types/memory-fs": "^0.3.2",
"@types/node": "^14.14.10",
"@types/prettier": "^2.1.5",
"@types/webpack": "^4.41.1",
"@types/webpack-merge": "^4.1.5",
"@typescript-eslint/eslint-plugin": "^4.9.0",
Expand All @@ -73,8 +65,8 @@
"typescript": "^4.1.2",
"typescript-eslint-language-service": "^4.1.2",
"vue": "^3.0.4",
"vue-i18n": "^9.0.0-beta.14",
"vue-loader": "^16.1.0",
"vue-i18n": "^9.0.0-beta.15",
"vue-loader": "^16.1.2",
"webpack": "^4.44.2",
"webpack-cli": "^3.3.12",
"webpack-dev-server": "^3.11.0",
Expand Down Expand Up @@ -122,6 +114,6 @@
"test:cover": "yarn test:unit --coverage",
"test:e2e": "yarn build && jest --runInBand --config ./jest.e2e.config.js",
"test:unit": "yarn clean:cache:jest && jest --env node",
"test:watch": "clean:cache:jest && jest --env node --watch"
"test:watch": "yarn clean:cache:jest && jest --env node --watch"
}
}
116 changes: 0 additions & 116 deletions src/gen.ts

This file was deleted.

Loading