Skip to content

Commit aef68a8

Browse files
authored
fix(unplugin-vue-i18n): support unplugin v0.8 (#154)
* fix(unplugin-vue-i18n): support unplugin v0.8 * drop node v12
1 parent 867e30d commit aef68a8

File tree

5 files changed

+46
-34
lines changed

5 files changed

+46
-34
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ env:
1717

1818
jobs:
1919
test:
20-
name: "Test on Node.js ${{ matrix.node }} OS: ${{matrix.os}}"
20+
name: 'Test on Node.js ${{ matrix.node }} OS: ${{matrix.os}}'
2121
runs-on: ${{ matrix.os }}
2222
strategy:
2323
matrix:
2424
os: [ubuntu-latest]
25-
node: [12, 14, 16]
25+
node: [14.16, 16]
2626
steps:
2727
- name: Checkout
2828
uses: actions/checkout@v2

packages/unplugin-vue-i18n/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,16 @@
3131
"js-yaml": "^4.1.0",
3232
"json5": "^2.2.0",
3333
"pathe": "^0.2.0",
34+
"picocolors": "^1.0.0",
3435
"source-map": "0.6.1",
35-
"unplugin": "^0.6.2"
36+
"unplugin": "^0.8.0"
3637
},
3738
"devDependencies": {
3839
"mlly": "^0.5.2",
3940
"unbuild": "^0.7.4"
4041
},
4142
"engines": {
42-
"node": ">= 12"
43+
"node": ">= 14.16"
4344
},
4445
"files": [
4546
"lib",

packages/unplugin-vue-i18n/src/index.ts

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -91,20 +91,6 @@ export const unplugin = createUnplugin<PluginOptions>((options = {}, meta) => {
9191
*/
9292
enforce: meta.framework === 'vite' ? 'pre' : 'post',
9393

94-
transformInclude(id) {
95-
debug('transformInclude', id)
96-
if (meta.framework === 'vite') {
97-
return true
98-
} else {
99-
const { filename } = parseVueRequest(id)
100-
return filename.endsWith('vue') ||
101-
filename.endsWith(INTLIFY_BUNDLE_IMPORT_ID) ||
102-
filename.endsWith(INTLIFY_BUNDLE_IMPORT_DEPRECTED_ID)
103-
? true
104-
: /\.(json5?|ya?ml)$/.test(id) && filter(id)
105-
}
106-
},
107-
10894
vite: {
10995
config(config, { command }) {
11096
normalizeConfigResolveAlias(config.resolve, meta.framework)
@@ -266,6 +252,21 @@ export const unplugin = createUnplugin<PluginOptions>((options = {}, meta) => {
266252
}
267253
},
268254

255+
transformInclude(id) {
256+
debug('transformInclude', id)
257+
if (meta.framework === 'vite') {
258+
return true
259+
} else {
260+
const { filename } = parseVueRequest(id)
261+
return (
262+
filename.endsWith('vue') ||
263+
filename.endsWith(INTLIFY_BUNDLE_IMPORT_ID) ||
264+
filename.endsWith(INTLIFY_BUNDLE_IMPORT_DEPRECTED_ID) ||
265+
(/\.(json5?|ya?ml)$/.test(filename) && filter(filename))
266+
)
267+
}
268+
},
269+
269270
async transform(code, id) {
270271
const { filename, query } = parseVueRequest(id)
271272
debug('transform', id, JSON.stringify(query), filename)
@@ -411,9 +412,7 @@ async function loadWebpack() {
411412
try {
412413
webpack = await import('webpack').then(m => m.default || m)
413414
} catch (e) {
414-
console.warn(
415-
`[@intlify/unplugin-vue-i18n] webpack not found, please install webpack.`
416-
)
415+
warn(`webpack not found, please install webpack.`)
417416
}
418417
return webpack
419418
}

packages/unplugin-vue-i18n/src/utils.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import { promises as fs } from 'fs'
2+
import pc from 'picocolors'
23

34
export function warn(...args: unknown[]) {
4-
console.warn(`[unplugin-vue-i18n] `, ...args)
5+
console.warn(pc.yellow(pc.bold(`[unplugin-vue-i18n] `)), ...args)
56
}
67

78
export function error(...args: unknown[]) {
8-
console.error(`[unplugin-vue-i18n] `, ...args)
9+
console.error(pc.red(pc.bold(`[unplugin-vue-i18n] `)), ...args)
910
}
1011

1112
export async function getRaw(path: string): Promise<string> {

yarn.lock

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -657,9 +657,10 @@ __metadata:
657657
json5: ^2.2.0
658658
mlly: ^0.5.2
659659
pathe: ^0.2.0
660+
picocolors: ^1.0.0
660661
source-map: 0.6.1
661662
unbuild: ^0.7.4
662-
unplugin: ^0.6.2
663+
unplugin: ^0.8.0
663664
peerDependencies:
664665
petite-vue-i18n: "*"
665666
vue-i18n: "*"
@@ -2780,6 +2781,15 @@ __metadata:
27802781
languageName: node
27812782
linkType: hard
27822783

2784+
"acorn@npm:^8.8.0":
2785+
version: 8.8.0
2786+
resolution: "acorn@npm:8.8.0"
2787+
bin:
2788+
acorn: bin/acorn
2789+
checksum: 7270ca82b242eafe5687a11fea6e088c960af712683756abf0791b68855ea9cace3057bd5e998ffcef50c944810c1e0ca1da526d02b32110e13c722aa959afdc
2790+
languageName: node
2791+
linkType: hard
2792+
27832793
"agent-base@npm:5":
27842794
version: 5.1.1
27852795
resolution: "agent-base@npm:5.1.1"
@@ -13457,17 +13467,18 @@ __metadata:
1345713467
languageName: node
1345813468
linkType: hard
1345913469

13460-
"unplugin@npm:^0.6.2":
13461-
version: 0.6.2
13462-
resolution: "unplugin@npm:0.6.2"
13470+
"unplugin@npm:^0.8.0":
13471+
version: 0.8.0
13472+
resolution: "unplugin@npm:0.8.0"
1346313473
dependencies:
13474+
acorn: ^8.8.0
1346413475
chokidar: ^3.5.3
1346513476
webpack-sources: ^3.2.3
13466-
webpack-virtual-modules: ^0.4.3
13477+
webpack-virtual-modules: ^0.4.4
1346713478
peerDependencies:
1346813479
esbuild: ">=0.13"
1346913480
rollup: ^2.50.0
13470-
vite: ^2.3.0
13481+
vite: ^2.3.0 || ^3.0.0-0
1347113482
webpack: 4 || 5
1347213483
peerDependenciesMeta:
1347313484
esbuild:
@@ -13478,7 +13489,7 @@ __metadata:
1347813489
optional: true
1347913490
webpack:
1348013491
optional: true
13481-
checksum: 0ad0b290c00a528196f9af95cb31872d92221f1cd4a3b3ee7c72d6b1cf2130c1c342aca97ccee44e5c911b59cdf996c095c8188802d7ff7a002a98b84eafc4eb
13492+
checksum: 116052627de4b015ce6b856bfb589647390591cd4bd49120475ea591e14706d8ce3992f522192b222c6956a08afe361abd76d8139d028323fecc9821a5d8e5e5
1348213493
languageName: node
1348313494
linkType: hard
1348413495

@@ -14070,10 +14081,10 @@ __metadata:
1407014081
languageName: node
1407114082
linkType: hard
1407214083

14073-
"webpack-virtual-modules@npm:^0.4.3":
14074-
version: 0.4.3
14075-
resolution: "webpack-virtual-modules@npm:0.4.3"
14076-
checksum: 158d30633e0d9be3cfcde10fe959b28df5d5adb1068e0f057fcfb10b0b16ede6c892eba438f6ced089c7c442087748c2fcd1e3f035e4e2dc6760517a8c227714
14084+
"webpack-virtual-modules@npm:^0.4.4":
14085+
version: 0.4.4
14086+
resolution: "webpack-virtual-modules@npm:0.4.4"
14087+
checksum: 6720b4c47d76dc9cbaff557562506c192da7560a90395e9918a418e257a0c0cda9f5e3ac92107ec0789f8f23ad942313bd8cdebc95031d0adef1032bf6142bc7
1407714088
languageName: node
1407814089
linkType: hard
1407914090

0 commit comments

Comments
 (0)