Skip to content

Commit 971498f

Browse files
authored
imporovement: custom block fully pre-compilation (#146)
* breacking: custom block fully pre-compilation * implement custom block source mapping * updates
1 parent fc9aa9e commit 971498f

26 files changed

+706
-602
lines changed

README.md

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -324,35 +324,6 @@ module.exports = {
324324
}
325325
```
326326

327-
## :rocket: i18n resource optimization
328-
329-
You can optimize your localization performance with pre-compiling the i18n resources.
330-
331-
You need to specify the `preCompile: true` option in your webpack config as below:
332-
333-
```javascript
334-
module.exports = {
335-
module: {
336-
rules: [
337-
// ...
338-
{
339-
resourceQuery: /blockType=i18n/,
340-
type: 'javascript/auto',
341-
use: [
342-
{
343-
loader: '@intlify/vue-i18n-loader',
344-
options: {
345-
preCompile: true // you need to specify at here!
346-
}
347-
}
348-
]
349-
},
350-
// ...
351-
]
352-
}
353-
}
354-
```
355-
356327
## :scroll: Changelog
357328
Details changes for each release are documented in the [CHANGELOG.md](https://github.com/intlify/vue-i18n-loader/blob/master/CHANGELOG.md).
358329

File renamed without changes.
File renamed without changes.

example/composition/main.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { createApp } from 'vue'
22
import { createI18n } from 'vue-i18n'
33
import App from './App.vue'
44

5-
import ja from './ja.json'
6-
import en from './en.yaml'
5+
import ja from './locales/ja.json'
6+
import en from './locales/en.yaml'
77

88
const i18n = createI18n({
99
legacy: false,
File renamed without changes.
File renamed without changes.

example/legacy/main.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { createApp } from 'vue'
22
import { createI18n } from 'vue-i18n'
33
import App from './App.vue'
44

5-
import ja from './ja.json'
6-
import en from './en.yaml'
5+
import ja from './locales/ja.json'
6+
import en from './locales/en.yaml'
77

88
const i18n = createI18n({
99
legacy: true,

example/webpack.config.js

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ module.exports = {
2020
// is a simple `export * from '@vue/runtime-dom`. However having this
2121
// extra re-export somehow causes webpack to always invalidate the module
2222
// on the first HMR update and causes the page to reload.
23-
vue: '@vue/runtime-dom',
24-
'vue-i18n': 'vue-i18n/dist/vue-i18n.runtime.esm-bundler.js'
23+
vue: '@vue/runtime-dom'
2524
}
2625
},
2726
devServer: {
@@ -42,28 +41,24 @@ module.exports = {
4241
test: /\.(json5?|ya?ml)$/, // target json, json5, yaml and yml files
4342
type: 'javascript/auto',
4443
// Use `Rule.include` to specify the files of locale messages to be pre-compiled
45-
include: [path.resolve(__dirname, './')],
44+
include: [
45+
path.resolve(__dirname, './composition/locales'),
46+
path.resolve(__dirname, './legacy/locales')
47+
],
4648
use: [
4749
{
4850
loader: path.resolve(__dirname, '../lib/index.js'),
4951
options: {
5052
// Whether pre-compile number and boolean literal as message functions that return the string value, default `false`
51-
forceStringify: true
53+
// forceStringify: true
5254
}
5355
}
5456
]
5557
},
5658
{
57-
resourceQuery: /blockType=i18n/,
5859
type: 'javascript/auto',
59-
use: [
60-
{
61-
loader: path.resolve(__dirname, '../lib/index.js'),
62-
options: {
63-
preCompile: true
64-
}
65-
}
66-
]
60+
resourceQuery: /blockType=i18n/,
61+
loader: path.resolve(__dirname, '../lib/index.js')
6762
}
6863
]
6964
},

package.json

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,30 +24,22 @@
2424
}
2525
},
2626
"dependencies": {
27-
"@intlify/core-base": "^9.0.0-beta.14",
28-
"@intlify/message-compiler": "^9.0.0-beta.14",
29-
"@intlify/shared": "^9.0.0-beta.14",
30-
"flat": "^5.0.2",
31-
"js-yaml": "^3.14.0",
32-
"json5": "^2.1.3",
27+
"@intlify/core-base": "^9.0.0-beta.15",
28+
"@intlify/message-compiler": "^9.0.0-beta.15",
29+
"@intlify/shared": "^9.0.0-beta.15",
3330
"jsonc-eslint-parser": "^0.6.0",
3431
"loader-utils": "^2.0.0",
35-
"prettier": "^2.2.1",
3632
"yaml-eslint-parser": "^0.2.0"
3733
},
3834
"devDependencies": {
39-
"@intlify/runtime": "^9.0.0-beta.14",
35+
"@intlify/runtime": "^9.0.0-beta.15",
4036
"@types/eslint": "^7.2.6",
4137
"@types/eslint-visitor-keys": "^1.0.0",
42-
"@types/flat": "^5.0.1",
4338
"@types/jest": "^26.0.16",
44-
"@types/js-yaml": "^3.12.5",
4539
"@types/jsdom": "^16.2.5",
46-
"@types/json5": "^0.0.30",
4740
"@types/loader-utils": "^2.0.0",
4841
"@types/memory-fs": "^0.3.2",
4942
"@types/node": "^14.14.10",
50-
"@types/prettier": "^2.1.5",
5143
"@types/webpack": "^4.41.1",
5244
"@types/webpack-merge": "^4.1.5",
5345
"@typescript-eslint/eslint-plugin": "^4.9.0",
@@ -73,8 +65,8 @@
7365
"typescript": "^4.1.2",
7466
"typescript-eslint-language-service": "^4.1.2",
7567
"vue": "^3.0.4",
76-
"vue-i18n": "^9.0.0-beta.14",
77-
"vue-loader": "^16.1.0",
68+
"vue-i18n": "^9.0.0-beta.15",
69+
"vue-loader": "^16.1.2",
7870
"webpack": "^4.44.2",
7971
"webpack-cli": "^3.3.12",
8072
"webpack-dev-server": "^3.11.0",
@@ -122,6 +114,6 @@
122114
"test:cover": "yarn test:unit --coverage",
123115
"test:e2e": "yarn build && jest --runInBand --config ./jest.e2e.config.js",
124116
"test:unit": "yarn clean:cache:jest && jest --env node",
125-
"test:watch": "clean:cache:jest && jest --env node --watch"
117+
"test:watch": "yarn clean:cache:jest && jest --env node --watch"
126118
}
127119
}

src/gen.ts

Lines changed: 0 additions & 116 deletions
This file was deleted.

0 commit comments

Comments
 (0)