@intlify/unplugin-vue-i18n 5.0.0-beta.0 → 5.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -1
- package/lib/index.cjs +66 -79
- package/lib/index.mjs +64 -81
- package/lib/types.d.cts +0 -1
- package/lib/types.d.mts +0 -1
- package/lib/types.d.ts +0 -1
- package/lib/vite.cjs +3 -1
- package/lib/vite.mjs +3 -1
- package/lib/webpack.cjs +3 -1
- package/lib/webpack.mjs +3 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -548,7 +548,7 @@ If do you will use this option, you need to enable `jitCompilation` option.
|
|
|
548
548
|
This option that to use i18n custom blocks in `vue-class-component`.
|
|
549
549
|
|
|
550
550
|
> [!IMPORTANT]
|
|
551
|
-
|
|
551
|
+
`useClassComponent` option is deprecated in v5.
|
|
552
552
|
This option will be supported with vue-i18n until v9 latest version.
|
|
553
553
|
|
|
554
554
|
### `onlyLocales`
|
|
@@ -567,6 +567,9 @@ If do you will use this option, you need to enable `jitCompilation` option.
|
|
|
567
567
|
|
|
568
568
|
This option allows a smooth migration from `petite-vue-i18n` to `vue-i18n` and allows progressive enhacement.
|
|
569
569
|
|
|
570
|
+
> [!IMPORTANT]
|
|
571
|
+
`useVueI18nImportName` option is deprecated in v5.
|
|
572
|
+
This option will be supported with vue-i18n until v9 latest version.
|
|
570
573
|
|
|
571
574
|
## 📜 Changelog
|
|
572
575
|
|
package/lib/index.cjs
CHANGED
|
@@ -10,14 +10,20 @@ const shared = require('@intlify/shared');
|
|
|
10
10
|
const pluginutils = require('@rollup/pluginutils');
|
|
11
11
|
const bundleUtils = require('@intlify/bundle-utils');
|
|
12
12
|
const compilerSfc = require('@vue/compiler-sfc');
|
|
13
|
-
const fs = require('fs');
|
|
13
|
+
const fs = require('node:fs');
|
|
14
14
|
const pc = require('picocolors');
|
|
15
|
+
const module$1 = require('node:module');
|
|
16
|
+
const path = require('node:path');
|
|
15
17
|
|
|
18
|
+
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
16
19
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
17
20
|
|
|
18
21
|
const createDebug__default = /*#__PURE__*/_interopDefaultCompat(createDebug);
|
|
19
22
|
const fg__default = /*#__PURE__*/_interopDefaultCompat(fg);
|
|
23
|
+
const fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
|
|
20
24
|
const pc__default = /*#__PURE__*/_interopDefaultCompat(pc);
|
|
25
|
+
const module__default = /*#__PURE__*/_interopDefaultCompat(module$1);
|
|
26
|
+
const path__default = /*#__PURE__*/_interopDefaultCompat(path);
|
|
21
27
|
|
|
22
28
|
function parseVueRequest(id) {
|
|
23
29
|
const [filename, rawQuery] = id.split(`?`, 2);
|
|
@@ -57,14 +63,39 @@ function parseVueRequest(id) {
|
|
|
57
63
|
};
|
|
58
64
|
}
|
|
59
65
|
|
|
66
|
+
const _require = module__default.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
|
|
67
|
+
function checkInstallPackage(debug) {
|
|
68
|
+
const pkgInfo = resolvePkgPath("vue-i18n", debug) || resolvePkgPath("petite-vue-i18n", debug);
|
|
69
|
+
if (!pkgInfo) {
|
|
70
|
+
throw new Error(
|
|
71
|
+
`requires 'vue-i18n' or 'petite-vue-i18n' to be present in the dependency tree.`
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
debug("installed package info:", pkgInfo);
|
|
75
|
+
return pkgInfo;
|
|
76
|
+
}
|
|
77
|
+
function resolvePkgPath(id, debug) {
|
|
78
|
+
try {
|
|
79
|
+
const resolvedPath = _require.resolve(id);
|
|
80
|
+
const pkgPath = path__default.dirname(resolvedPath);
|
|
81
|
+
const pkgJson = JSON.parse(
|
|
82
|
+
fs__default.readFileSync(path__default.join(pkgPath, "package.json"), "utf-8")
|
|
83
|
+
);
|
|
84
|
+
const pkgName = pkgJson.name.startsWith("vue-i18n") ? "vue-i18n" : pkgJson.name.startsWith("petite-vue-i18n") ? "petite-vue-i18n" : "";
|
|
85
|
+
return pkgJson ? { alias: id, pkg: pkgName } : null;
|
|
86
|
+
} catch (e) {
|
|
87
|
+
debug(`cannot find '${id}'`, e);
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
60
91
|
function warn(...args) {
|
|
61
92
|
console.warn(pc__default.yellow(pc__default.bold(`[unplugin-vue-i18n] `)), ...args);
|
|
62
93
|
}
|
|
63
94
|
function error(...args) {
|
|
64
95
|
console.error(pc__default.red(pc__default.bold(`[unplugin-vue-i18n] `)), ...args);
|
|
65
96
|
}
|
|
66
|
-
async function getRaw(
|
|
67
|
-
return fs.promises.readFile(
|
|
97
|
+
async function getRaw(path2) {
|
|
98
|
+
return fs.promises.readFile(path2, { encoding: "utf-8" });
|
|
68
99
|
}
|
|
69
100
|
function raiseError(message) {
|
|
70
101
|
throw new Error(`[unplugin-vue-i18n] ${message}`);
|
|
@@ -73,7 +104,7 @@ function raiseError(message) {
|
|
|
73
104
|
const INTLIFY_BUNDLE_IMPORT_ID = "@intlify/unplugin-vue-i18n/messages";
|
|
74
105
|
const VIRTUAL_PREFIX = "\0";
|
|
75
106
|
const debug = createDebug__default("unplugin-vue-i18n");
|
|
76
|
-
const
|
|
107
|
+
const installedPkgInfo = checkInstallPackage(debug);
|
|
77
108
|
const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
|
|
78
109
|
debug("plugin options:", options, meta.framework);
|
|
79
110
|
if (!["vite", "webpack"].includes(meta.framework)) {
|
|
@@ -102,20 +133,14 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
|
|
|
102
133
|
debug("runtimeOnly", runtimeOnly);
|
|
103
134
|
const dropMessageCompiler = !!options.dropMessageCompiler;
|
|
104
135
|
debug("dropMessageCompiler", dropMessageCompiler);
|
|
105
|
-
const compositionOnly =
|
|
136
|
+
const compositionOnly = installedPkgInfo.pkg === "vue-i18n" ? shared.isBoolean(options.compositionOnly) ? options.compositionOnly : true : true;
|
|
106
137
|
debug("compositionOnly", compositionOnly);
|
|
107
|
-
const fullInstall =
|
|
138
|
+
const fullInstall = installedPkgInfo.pkg === "vue-i18n" ? shared.isBoolean(options.fullInstall) ? options.fullInstall : true : false;
|
|
108
139
|
debug("fullInstall", fullInstall);
|
|
109
140
|
const ssrBuild = !!options.ssr;
|
|
110
141
|
debug("ssr", ssrBuild);
|
|
111
|
-
const useVueI18nImportName = options.useVueI18nImportName;
|
|
112
|
-
if (useVueI18nImportName != null) {
|
|
113
|
-
warn(`'useVueI18nImportName' option is experimental`);
|
|
114
|
-
}
|
|
115
|
-
debug("useVueI18nImportName", useVueI18nImportName);
|
|
116
|
-
const getVueI18nAliasName = () => installedPkg === "petite-vue-i18n" && shared.isBoolean(useVueI18nImportName) && useVueI18nImportName ? "vue-i18n" : installedPkg;
|
|
117
142
|
const getVueI18nAliasPath = ({ ssr = false, runtimeOnly: runtimeOnly2 = false }) => {
|
|
118
|
-
return `${
|
|
143
|
+
return `${installedPkgInfo.alias}/dist/${installedPkgInfo.pkg}${runtimeOnly2 ? ".runtime" : ""}.${!ssr ? "esm-bundler.js" : "node.mjs"}`;
|
|
119
144
|
};
|
|
120
145
|
const allowDynamic = !!options.allowDynamic;
|
|
121
146
|
debug("allowDynamic", allowDynamic);
|
|
@@ -125,7 +150,8 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
|
|
|
125
150
|
debug("escapeHtml", escapeHtml);
|
|
126
151
|
let isProduction = false;
|
|
127
152
|
let sourceMap = false;
|
|
128
|
-
const vueI18nAliasName =
|
|
153
|
+
const vueI18nAliasName = installedPkgInfo.alias;
|
|
154
|
+
debug(`vue-i18n alias name: ${vueI18nAliasName}`);
|
|
129
155
|
return {
|
|
130
156
|
name: "unplugin-vue-i18n",
|
|
131
157
|
/**
|
|
@@ -138,62 +164,28 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
|
|
|
138
164
|
*/
|
|
139
165
|
enforce: meta.framework === "vite" ? "pre" : "post",
|
|
140
166
|
vite: {
|
|
141
|
-
config(
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
167
|
+
config() {
|
|
168
|
+
const defineConfig = {
|
|
169
|
+
define: {
|
|
170
|
+
__VUE_I18N_LEGACY_API__: !compositionOnly,
|
|
171
|
+
__VUE_I18N_FULL_INSTALL__: fullInstall,
|
|
172
|
+
__INTLIFY_DROP_MESSAGE_COMPILER__: dropMessageCompiler,
|
|
173
|
+
__VUE_I18N_PROD_DEVTOOLS__: false
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
debug("define Config:", defineConfig);
|
|
177
|
+
const aliasConfig = {
|
|
178
|
+
resolve: {
|
|
179
|
+
alias: {
|
|
180
|
+
[vueI18nAliasName]: getVueI18nAliasPath({
|
|
152
181
|
ssr: ssrBuild,
|
|
153
182
|
runtimeOnly
|
|
154
183
|
})
|
|
155
|
-
}
|
|
156
|
-
} else if (shared.isObject(config.resolve.alias)) {
|
|
157
|
-
config.resolve.alias[vueI18nAliasName] = getVueI18nAliasPath({
|
|
158
|
-
ssr: ssrBuild,
|
|
159
|
-
runtimeOnly
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
debug(
|
|
163
|
-
`set ${vueI18nAliasName} runtime only: ${getVueI18nAliasPath({
|
|
164
|
-
ssr: ssrBuild,
|
|
165
|
-
runtimeOnly
|
|
166
|
-
})}`
|
|
167
|
-
);
|
|
168
|
-
} else if (command === "serve" && installedPkg === "petite-vue-i18n" && useVueI18nImportName) {
|
|
169
|
-
config.resolve = normalizeConfigResolveAlias(
|
|
170
|
-
config.resolve,
|
|
171
|
-
meta.framework
|
|
172
|
-
);
|
|
173
|
-
if (shared.isArray(config.resolve.alias)) {
|
|
174
|
-
config.resolve.alias.push({
|
|
175
|
-
find: vueI18nAliasName,
|
|
176
|
-
replacement: `petite-vue-i18n/dist/petite-vue-i18n.esm-bundler.js`
|
|
177
|
-
});
|
|
178
|
-
} else {
|
|
179
|
-
config.resolve.alias[vueI18nAliasName] = `petite-vue-i18n/dist/petite-vue-i18n.esm-bundler.js`;
|
|
184
|
+
}
|
|
180
185
|
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
config.define["__VUE_I18N_LEGACY_API__"] = !compositionOnly;
|
|
185
|
-
debug(
|
|
186
|
-
`set __VUE_I18N_LEGACY_API__ is '${config.define["__VUE_I18N_LEGACY_API__"]}'`
|
|
187
|
-
);
|
|
188
|
-
config.define["__VUE_I18N_FULL_INSTALL__"] = fullInstall;
|
|
189
|
-
debug(
|
|
190
|
-
`set __VUE_I18N_FULL_INSTALL__ is '${config.define["__VUE_I18N_FULL_INSTALL__"]}'`
|
|
191
|
-
);
|
|
192
|
-
config.define["__INTLIFY_DROP_MESSAGE_COMPILER__"] = dropMessageCompiler;
|
|
193
|
-
debug(
|
|
194
|
-
`set __INTLIFY_DROP_MESSAGE_COMPILER__ is '${config.define["__INTLIFY_DROP_MESSAGE_COMPILER__"]}'`
|
|
195
|
-
);
|
|
196
|
-
config.define["__VUE_I18N_PROD_DEVTOOLS__"] = false;
|
|
186
|
+
};
|
|
187
|
+
debug("alias Config:", aliasConfig);
|
|
188
|
+
return shared.assign(defineConfig, aliasConfig);
|
|
197
189
|
},
|
|
198
190
|
configResolved(config) {
|
|
199
191
|
isProduction = config.isProduction;
|
|
@@ -287,21 +279,16 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
|
|
|
287
279
|
compiler.options.resolve,
|
|
288
280
|
meta.framework
|
|
289
281
|
);
|
|
290
|
-
|
|
291
|
-
|
|
282
|
+
compiler.options.resolve.alias[vueI18nAliasName] = getVueI18nAliasPath({
|
|
283
|
+
ssr: ssrBuild,
|
|
284
|
+
runtimeOnly
|
|
285
|
+
});
|
|
286
|
+
debug(
|
|
287
|
+
`set ${vueI18nAliasName}: ${getVueI18nAliasPath({
|
|
292
288
|
ssr: ssrBuild,
|
|
293
289
|
runtimeOnly
|
|
294
|
-
})
|
|
295
|
-
|
|
296
|
-
`set ${vueI18nAliasName}: ${getVueI18nAliasPath({
|
|
297
|
-
ssr: ssrBuild,
|
|
298
|
-
runtimeOnly
|
|
299
|
-
})}`
|
|
300
|
-
);
|
|
301
|
-
} else if (!isProduction && installedPkg === "petite-vue-i18n" && useVueI18nImportName) {
|
|
302
|
-
compiler.options.resolve.alias[vueI18nAliasName] = `petite-vue-i18n/dist/petite-vue-i18n.esm-bundler.js`;
|
|
303
|
-
debug(`petite-vue-i18n alias name: ${vueI18nAliasName}`);
|
|
304
|
-
}
|
|
290
|
+
})}`
|
|
291
|
+
);
|
|
305
292
|
loadWebpack().then((webpack) => {
|
|
306
293
|
if (webpack) {
|
|
307
294
|
compiler.options.plugins.push(
|
package/lib/index.mjs
CHANGED
|
@@ -2,12 +2,14 @@ import { createUnplugin } from 'unplugin';
|
|
|
2
2
|
import { normalize, parse } from 'pathe';
|
|
3
3
|
import createDebug from 'debug';
|
|
4
4
|
import fg from 'fast-glob';
|
|
5
|
-
import { isArray, isString, isBoolean,
|
|
5
|
+
import { isArray, isString, isBoolean, assign, isNumber, isEmptyObject, generateCodeFrame } from '@intlify/shared';
|
|
6
6
|
import { createFilter } from '@rollup/pluginutils';
|
|
7
|
-
import {
|
|
7
|
+
import { generateJSON, generateYAML, generateJavaScript } from '@intlify/bundle-utils';
|
|
8
8
|
import { parse as parse$1 } from '@vue/compiler-sfc';
|
|
9
|
-
import { promises } from 'fs';
|
|
9
|
+
import fs, { promises } from 'node:fs';
|
|
10
10
|
import pc from 'picocolors';
|
|
11
|
+
import module from 'node:module';
|
|
12
|
+
import path from 'node:path';
|
|
11
13
|
|
|
12
14
|
function parseVueRequest(id) {
|
|
13
15
|
const [filename, rawQuery] = id.split(`?`, 2);
|
|
@@ -47,14 +49,39 @@ function parseVueRequest(id) {
|
|
|
47
49
|
};
|
|
48
50
|
}
|
|
49
51
|
|
|
52
|
+
const _require = module.createRequire(import.meta.url);
|
|
53
|
+
function checkInstallPackage(debug) {
|
|
54
|
+
const pkgInfo = resolvePkgPath("vue-i18n", debug) || resolvePkgPath("petite-vue-i18n", debug);
|
|
55
|
+
if (!pkgInfo) {
|
|
56
|
+
throw new Error(
|
|
57
|
+
`requires 'vue-i18n' or 'petite-vue-i18n' to be present in the dependency tree.`
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
debug("installed package info:", pkgInfo);
|
|
61
|
+
return pkgInfo;
|
|
62
|
+
}
|
|
63
|
+
function resolvePkgPath(id, debug) {
|
|
64
|
+
try {
|
|
65
|
+
const resolvedPath = _require.resolve(id);
|
|
66
|
+
const pkgPath = path.dirname(resolvedPath);
|
|
67
|
+
const pkgJson = JSON.parse(
|
|
68
|
+
fs.readFileSync(path.join(pkgPath, "package.json"), "utf-8")
|
|
69
|
+
);
|
|
70
|
+
const pkgName = pkgJson.name.startsWith("vue-i18n") ? "vue-i18n" : pkgJson.name.startsWith("petite-vue-i18n") ? "petite-vue-i18n" : "";
|
|
71
|
+
return pkgJson ? { alias: id, pkg: pkgName } : null;
|
|
72
|
+
} catch (e) {
|
|
73
|
+
debug(`cannot find '${id}'`, e);
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
50
77
|
function warn(...args) {
|
|
51
78
|
console.warn(pc.yellow(pc.bold(`[unplugin-vue-i18n] `)), ...args);
|
|
52
79
|
}
|
|
53
80
|
function error(...args) {
|
|
54
81
|
console.error(pc.red(pc.bold(`[unplugin-vue-i18n] `)), ...args);
|
|
55
82
|
}
|
|
56
|
-
async function getRaw(
|
|
57
|
-
return promises.readFile(
|
|
83
|
+
async function getRaw(path2) {
|
|
84
|
+
return promises.readFile(path2, { encoding: "utf-8" });
|
|
58
85
|
}
|
|
59
86
|
function raiseError(message) {
|
|
60
87
|
throw new Error(`[unplugin-vue-i18n] ${message}`);
|
|
@@ -63,7 +90,7 @@ function raiseError(message) {
|
|
|
63
90
|
const INTLIFY_BUNDLE_IMPORT_ID = "@intlify/unplugin-vue-i18n/messages";
|
|
64
91
|
const VIRTUAL_PREFIX = "\0";
|
|
65
92
|
const debug = createDebug("unplugin-vue-i18n");
|
|
66
|
-
const
|
|
93
|
+
const installedPkgInfo = checkInstallPackage(debug);
|
|
67
94
|
const unplugin = createUnplugin((options = {}, meta) => {
|
|
68
95
|
debug("plugin options:", options, meta.framework);
|
|
69
96
|
if (!["vite", "webpack"].includes(meta.framework)) {
|
|
@@ -92,20 +119,14 @@ const unplugin = createUnplugin((options = {}, meta) => {
|
|
|
92
119
|
debug("runtimeOnly", runtimeOnly);
|
|
93
120
|
const dropMessageCompiler = !!options.dropMessageCompiler;
|
|
94
121
|
debug("dropMessageCompiler", dropMessageCompiler);
|
|
95
|
-
const compositionOnly =
|
|
122
|
+
const compositionOnly = installedPkgInfo.pkg === "vue-i18n" ? isBoolean(options.compositionOnly) ? options.compositionOnly : true : true;
|
|
96
123
|
debug("compositionOnly", compositionOnly);
|
|
97
|
-
const fullInstall =
|
|
124
|
+
const fullInstall = installedPkgInfo.pkg === "vue-i18n" ? isBoolean(options.fullInstall) ? options.fullInstall : true : false;
|
|
98
125
|
debug("fullInstall", fullInstall);
|
|
99
126
|
const ssrBuild = !!options.ssr;
|
|
100
127
|
debug("ssr", ssrBuild);
|
|
101
|
-
const useVueI18nImportName = options.useVueI18nImportName;
|
|
102
|
-
if (useVueI18nImportName != null) {
|
|
103
|
-
warn(`'useVueI18nImportName' option is experimental`);
|
|
104
|
-
}
|
|
105
|
-
debug("useVueI18nImportName", useVueI18nImportName);
|
|
106
|
-
const getVueI18nAliasName = () => installedPkg === "petite-vue-i18n" && isBoolean(useVueI18nImportName) && useVueI18nImportName ? "vue-i18n" : installedPkg;
|
|
107
128
|
const getVueI18nAliasPath = ({ ssr = false, runtimeOnly: runtimeOnly2 = false }) => {
|
|
108
|
-
return `${
|
|
129
|
+
return `${installedPkgInfo.alias}/dist/${installedPkgInfo.pkg}${runtimeOnly2 ? ".runtime" : ""}.${!ssr ? "esm-bundler.js" : "node.mjs"}`;
|
|
109
130
|
};
|
|
110
131
|
const allowDynamic = !!options.allowDynamic;
|
|
111
132
|
debug("allowDynamic", allowDynamic);
|
|
@@ -115,7 +136,8 @@ const unplugin = createUnplugin((options = {}, meta) => {
|
|
|
115
136
|
debug("escapeHtml", escapeHtml);
|
|
116
137
|
let isProduction = false;
|
|
117
138
|
let sourceMap = false;
|
|
118
|
-
const vueI18nAliasName =
|
|
139
|
+
const vueI18nAliasName = installedPkgInfo.alias;
|
|
140
|
+
debug(`vue-i18n alias name: ${vueI18nAliasName}`);
|
|
119
141
|
return {
|
|
120
142
|
name: "unplugin-vue-i18n",
|
|
121
143
|
/**
|
|
@@ -128,62 +150,28 @@ const unplugin = createUnplugin((options = {}, meta) => {
|
|
|
128
150
|
*/
|
|
129
151
|
enforce: meta.framework === "vite" ? "pre" : "post",
|
|
130
152
|
vite: {
|
|
131
|
-
config(
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
153
|
+
config() {
|
|
154
|
+
const defineConfig = {
|
|
155
|
+
define: {
|
|
156
|
+
__VUE_I18N_LEGACY_API__: !compositionOnly,
|
|
157
|
+
__VUE_I18N_FULL_INSTALL__: fullInstall,
|
|
158
|
+
__INTLIFY_DROP_MESSAGE_COMPILER__: dropMessageCompiler,
|
|
159
|
+
__VUE_I18N_PROD_DEVTOOLS__: false
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
debug("define Config:", defineConfig);
|
|
163
|
+
const aliasConfig = {
|
|
164
|
+
resolve: {
|
|
165
|
+
alias: {
|
|
166
|
+
[vueI18nAliasName]: getVueI18nAliasPath({
|
|
142
167
|
ssr: ssrBuild,
|
|
143
168
|
runtimeOnly
|
|
144
169
|
})
|
|
145
|
-
}
|
|
146
|
-
} else if (isObject(config.resolve.alias)) {
|
|
147
|
-
config.resolve.alias[vueI18nAliasName] = getVueI18nAliasPath({
|
|
148
|
-
ssr: ssrBuild,
|
|
149
|
-
runtimeOnly
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
debug(
|
|
153
|
-
`set ${vueI18nAliasName} runtime only: ${getVueI18nAliasPath({
|
|
154
|
-
ssr: ssrBuild,
|
|
155
|
-
runtimeOnly
|
|
156
|
-
})}`
|
|
157
|
-
);
|
|
158
|
-
} else if (command === "serve" && installedPkg === "petite-vue-i18n" && useVueI18nImportName) {
|
|
159
|
-
config.resolve = normalizeConfigResolveAlias(
|
|
160
|
-
config.resolve,
|
|
161
|
-
meta.framework
|
|
162
|
-
);
|
|
163
|
-
if (isArray(config.resolve.alias)) {
|
|
164
|
-
config.resolve.alias.push({
|
|
165
|
-
find: vueI18nAliasName,
|
|
166
|
-
replacement: `petite-vue-i18n/dist/petite-vue-i18n.esm-bundler.js`
|
|
167
|
-
});
|
|
168
|
-
} else {
|
|
169
|
-
config.resolve.alias[vueI18nAliasName] = `petite-vue-i18n/dist/petite-vue-i18n.esm-bundler.js`;
|
|
170
|
+
}
|
|
170
171
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
config.define["__VUE_I18N_LEGACY_API__"] = !compositionOnly;
|
|
175
|
-
debug(
|
|
176
|
-
`set __VUE_I18N_LEGACY_API__ is '${config.define["__VUE_I18N_LEGACY_API__"]}'`
|
|
177
|
-
);
|
|
178
|
-
config.define["__VUE_I18N_FULL_INSTALL__"] = fullInstall;
|
|
179
|
-
debug(
|
|
180
|
-
`set __VUE_I18N_FULL_INSTALL__ is '${config.define["__VUE_I18N_FULL_INSTALL__"]}'`
|
|
181
|
-
);
|
|
182
|
-
config.define["__INTLIFY_DROP_MESSAGE_COMPILER__"] = dropMessageCompiler;
|
|
183
|
-
debug(
|
|
184
|
-
`set __INTLIFY_DROP_MESSAGE_COMPILER__ is '${config.define["__INTLIFY_DROP_MESSAGE_COMPILER__"]}'`
|
|
185
|
-
);
|
|
186
|
-
config.define["__VUE_I18N_PROD_DEVTOOLS__"] = false;
|
|
172
|
+
};
|
|
173
|
+
debug("alias Config:", aliasConfig);
|
|
174
|
+
return assign(defineConfig, aliasConfig);
|
|
187
175
|
},
|
|
188
176
|
configResolved(config) {
|
|
189
177
|
isProduction = config.isProduction;
|
|
@@ -277,21 +265,16 @@ const unplugin = createUnplugin((options = {}, meta) => {
|
|
|
277
265
|
compiler.options.resolve,
|
|
278
266
|
meta.framework
|
|
279
267
|
);
|
|
280
|
-
|
|
281
|
-
|
|
268
|
+
compiler.options.resolve.alias[vueI18nAliasName] = getVueI18nAliasPath({
|
|
269
|
+
ssr: ssrBuild,
|
|
270
|
+
runtimeOnly
|
|
271
|
+
});
|
|
272
|
+
debug(
|
|
273
|
+
`set ${vueI18nAliasName}: ${getVueI18nAliasPath({
|
|
282
274
|
ssr: ssrBuild,
|
|
283
275
|
runtimeOnly
|
|
284
|
-
})
|
|
285
|
-
|
|
286
|
-
`set ${vueI18nAliasName}: ${getVueI18nAliasPath({
|
|
287
|
-
ssr: ssrBuild,
|
|
288
|
-
runtimeOnly
|
|
289
|
-
})}`
|
|
290
|
-
);
|
|
291
|
-
} else if (!isProduction && installedPkg === "petite-vue-i18n" && useVueI18nImportName) {
|
|
292
|
-
compiler.options.resolve.alias[vueI18nAliasName] = `petite-vue-i18n/dist/petite-vue-i18n.esm-bundler.js`;
|
|
293
|
-
debug(`petite-vue-i18n alias name: ${vueI18nAliasName}`);
|
|
294
|
-
}
|
|
276
|
+
})}`
|
|
277
|
+
);
|
|
295
278
|
loadWebpack().then((webpack) => {
|
|
296
279
|
if (webpack) {
|
|
297
280
|
compiler.options.plugins.push(
|
package/lib/types.d.cts
CHANGED
package/lib/types.d.mts
CHANGED
package/lib/types.d.ts
CHANGED
package/lib/vite.cjs
CHANGED
|
@@ -9,8 +9,10 @@ require('@intlify/shared');
|
|
|
9
9
|
require('@rollup/pluginutils');
|
|
10
10
|
require('@intlify/bundle-utils');
|
|
11
11
|
require('@vue/compiler-sfc');
|
|
12
|
-
require('fs');
|
|
12
|
+
require('node:fs');
|
|
13
13
|
require('picocolors');
|
|
14
|
+
require('node:module');
|
|
15
|
+
require('node:path');
|
|
14
16
|
|
|
15
17
|
const vite = index.unplugin.vite;
|
|
16
18
|
|
package/lib/vite.mjs
CHANGED
|
@@ -7,8 +7,10 @@ import '@intlify/shared';
|
|
|
7
7
|
import '@rollup/pluginutils';
|
|
8
8
|
import '@intlify/bundle-utils';
|
|
9
9
|
import '@vue/compiler-sfc';
|
|
10
|
-
import 'fs';
|
|
10
|
+
import 'node:fs';
|
|
11
11
|
import 'picocolors';
|
|
12
|
+
import 'node:module';
|
|
13
|
+
import 'node:path';
|
|
12
14
|
|
|
13
15
|
const vite = unplugin.vite;
|
|
14
16
|
|
package/lib/webpack.cjs
CHANGED
|
@@ -9,8 +9,10 @@ require('@intlify/shared');
|
|
|
9
9
|
require('@rollup/pluginutils');
|
|
10
10
|
require('@intlify/bundle-utils');
|
|
11
11
|
require('@vue/compiler-sfc');
|
|
12
|
-
require('fs');
|
|
12
|
+
require('node:fs');
|
|
13
13
|
require('picocolors');
|
|
14
|
+
require('node:module');
|
|
15
|
+
require('node:path');
|
|
14
16
|
|
|
15
17
|
const webpack = index.unplugin.webpack;
|
|
16
18
|
|
package/lib/webpack.mjs
CHANGED
|
@@ -7,8 +7,10 @@ import '@intlify/shared';
|
|
|
7
7
|
import '@rollup/pluginutils';
|
|
8
8
|
import '@intlify/bundle-utils';
|
|
9
9
|
import '@vue/compiler-sfc';
|
|
10
|
-
import 'fs';
|
|
10
|
+
import 'node:fs';
|
|
11
11
|
import 'picocolors';
|
|
12
|
+
import 'node:module';
|
|
13
|
+
import 'node:path';
|
|
12
14
|
|
|
13
15
|
const webpack = unplugin.webpack;
|
|
14
16
|
|