@intlify/unplugin-vue-i18n 0.7.2 → 0.7.3

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/lib/index.cjs CHANGED
@@ -103,6 +103,7 @@ const VIRTUAL_PREFIX = "\0";
103
103
  const debug = createDebug__default("unplugin-vue-i18n");
104
104
  const installedPkg = bundleUtils.checkInstallPackage("@intlify/unplugin-vue-i18n", debug);
105
105
  const installedVueI18nBridge = bundleUtils.checkVueI18nBridgeInstallPackage(debug);
106
+ const vueI18nVersion = bundleUtils.getVueI18nVersion(debug);
106
107
  const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
107
108
  debug("plugin options:", options, meta.framework);
108
109
  if (!["vite", "webpack"].includes(meta.framework)) {
@@ -137,11 +138,14 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
137
138
  warn(`'useVueI18nImportName' option is experimental`);
138
139
  }
139
140
  debug("useVueI18nImportName", useVueI18nImportName);
140
- const getAliasName = () => installedVueI18nBridge && installedPkg === "vue-i18n" ? "vue-i18n-bridge" : installedPkg === "petite-vue-i18n" && shared.isBoolean(useVueI18nImportName) && useVueI18nImportName ? "vue-i18n" : `${installedPkg}`;
141
+ const getVueI18nAliasName = () => vueI18nVersion === "9" || vueI18nVersion === "8" ? "vue-i18n" : vueI18nVersion === "unknown" && installedPkg === "petite-vue-i18n" && shared.isBoolean(useVueI18nImportName) && useVueI18nImportName ? "vue-i18n" : installedPkg;
142
+ const getVueI18nBridgeAliasPath = () => `vue-i18n-bridge/dist/vue-i18n-bridge.runtime.esm-bundler.js`;
143
+ const getVueI18nAliasPath = (aliasName) => vueI18nVersion === "8" ? `${aliasName}/dist/${aliasName}.esm.js` : `${aliasName}/dist/${installedPkg}.runtime.esm-bundler.js`;
141
144
  const esm = shared.isBoolean(options.esm) ? options.esm : true;
142
145
  debug("esm", esm);
143
146
  let isProduction = false;
144
147
  let sourceMap = false;
148
+ const vueI18nAliasName = getVueI18nAliasName();
145
149
  return {
146
150
  name: "unplugin-vue-i18n",
147
151
  enforce: meta.framework === "vite" ? "pre" : "post",
@@ -152,19 +156,34 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
152
156
  meta.framework
153
157
  );
154
158
  if (command === "build" && runtimeOnly) {
155
- const aliasName = getAliasName();
156
- debug(`alias name: ${aliasName}`);
159
+ debug(`vue-i18n alias name: ${vueI18nAliasName}`);
157
160
  if (shared.isArray(config.resolve.alias)) {
158
161
  config.resolve.alias.push({
159
- find: aliasName,
160
- replacement: `${aliasName}/dist/${aliasName}.runtime.esm-bundler.js`
162
+ find: vueI18nAliasName,
163
+ replacement: getVueI18nAliasPath(vueI18nAliasName)
161
164
  });
165
+ if (installedVueI18nBridge) {
166
+ config.resolve.alias.push({
167
+ find: "vue-i18n-bridge",
168
+ replacement: getVueI18nBridgeAliasPath()
169
+ });
170
+ }
162
171
  } else if (shared.isObject(config.resolve.alias)) {
163
- config.resolve.alias[aliasName] = `${aliasName}/dist/${aliasName}.runtime.esm-bundler.js`;
172
+ config.resolve.alias[vueI18nAliasName] = getVueI18nAliasPath(vueI18nAliasName);
173
+ if (installedVueI18nBridge) {
174
+ config.resolve.alias["vue-i18n-bridge"] = getVueI18nBridgeAliasPath();
175
+ }
164
176
  }
165
177
  debug(
166
- `set ${aliasName} runtime only: ${aliasName}/dist/${aliasName}.runtime.esm-bundler.js`
178
+ `set ${vueI18nAliasName} runtime only: ${getVueI18nAliasPath(
179
+ vueI18nAliasName
180
+ )}`
167
181
  );
182
+ if (installedVueI18nBridge) {
183
+ debug(
184
+ `set vue-i18n-bridge runtime only: ${getVueI18nBridgeAliasPath()}`
185
+ );
186
+ }
168
187
  } else if (command === "serve" && installedPkg === "petite-vue-i18n" && useVueI18nImportName) {
169
188
  config.resolve = normalizeConfigResolveAlias(
170
189
  config.resolve,
@@ -172,13 +191,13 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
172
191
  );
173
192
  if (shared.isArray(config.resolve.alias)) {
174
193
  config.resolve.alias.push({
175
- find: "vue-i18n",
194
+ find: vueI18nAliasName,
176
195
  replacement: `petite-vue-i18n/dist/petite-vue-i18n.esm-bundler.js`
177
196
  });
178
197
  } else {
179
- config.resolve.alias["vue-i18n"] = `petite-vue-i18n/dist/petite-vue-i18n.esm-bundler.js`;
198
+ config.resolve.alias[vueI18nAliasName] = `petite-vue-i18n/dist/petite-vue-i18n.esm-bundler.js`;
180
199
  }
181
- debug(`alias name: ${getAliasName()}`);
200
+ debug(`petite-vue-i18n alias name: ${vueI18nAliasName}`);
182
201
  }
183
202
  config.define = config.define || {};
184
203
  config.define["__VUE_I18N_LEGACY_API__"] = !compositionOnly;
@@ -229,12 +248,28 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
229
248
  isProduction = compiler.options.mode !== "development";
230
249
  sourceMap = !!compiler.options.devtool;
231
250
  debug(`webpack: isProduction = ${isProduction}, sourceMap = ${sourceMap}`);
251
+ compiler.options.resolve = normalizeConfigResolveAlias(
252
+ compiler.options.resolve,
253
+ meta.framework
254
+ );
232
255
  if (isProduction && runtimeOnly) {
233
- compiler.options.resolve = normalizeConfigResolveAlias(
234
- compiler.options.resolve,
235
- meta.framework
256
+ compiler.options.resolve.alias[vueI18nAliasName] = getVueI18nAliasPath(vueI18nAliasName);
257
+ if (installedVueI18nBridge) {
258
+ compiler.options.resolve.alias["vue-i18n-bridge"] = getVueI18nBridgeAliasPath();
259
+ }
260
+ debug(
261
+ `set ${vueI18nAliasName} runtime only: ${getVueI18nAliasPath(
262
+ vueI18nAliasName
263
+ )}`
236
264
  );
237
- compiler.options.resolve.alias["vue-i18n"] = `vue-i18n/dist/vue-i18n.runtime.esm-bundler.js`;
265
+ if (installedVueI18nBridge) {
266
+ debug(
267
+ `set vue-i18n-bridge runtime only: ${getVueI18nBridgeAliasPath()}`
268
+ );
269
+ }
270
+ } else if (!isProduction && installedPkg === "petite-vue-i18n" && useVueI18nImportName) {
271
+ compiler.options.resolve.alias[vueI18nAliasName] = `petite-vue-i18n/dist/petite-vue-i18n.esm-bundler.js`;
272
+ debug(`petite-vue-i18n alias name: ${vueI18nAliasName}`);
238
273
  }
239
274
  loadWebpack().then((webpack) => {
240
275
  if (webpack) {
@@ -255,7 +290,9 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
255
290
  compiler.options.module.rules.push({
256
291
  test: /\.(json5?|ya?ml)$/,
257
292
  type: "javascript/auto",
258
- exclude: include
293
+ include(resource) {
294
+ return filter(resource);
295
+ }
259
296
  });
260
297
  }
261
298
  },
package/lib/index.mjs CHANGED
@@ -4,7 +4,7 @@ import createDebug from 'debug';
4
4
  import fg from 'fast-glob';
5
5
  import { isString, isArray, isBoolean, isObject, isNumber, isEmptyObject, assign, generateCodeFrame } from '@intlify/shared';
6
6
  import { createFilter } from '@rollup/pluginutils';
7
- import { checkInstallPackage, checkVueI18nBridgeInstallPackage, generateJSON, generateYAML } from '@intlify/bundle-utils';
7
+ import { checkInstallPackage, checkVueI18nBridgeInstallPackage, getVueI18nVersion, generateJSON, generateYAML } from '@intlify/bundle-utils';
8
8
  import { parse as parse$1 } from '@vue/compiler-sfc';
9
9
  import JSON5 from 'json5';
10
10
  import yaml from 'js-yaml';
@@ -91,6 +91,7 @@ const VIRTUAL_PREFIX = "\0";
91
91
  const debug = createDebug("unplugin-vue-i18n");
92
92
  const installedPkg = checkInstallPackage("@intlify/unplugin-vue-i18n", debug);
93
93
  const installedVueI18nBridge = checkVueI18nBridgeInstallPackage(debug);
94
+ const vueI18nVersion = getVueI18nVersion(debug);
94
95
  const unplugin = createUnplugin((options = {}, meta) => {
95
96
  debug("plugin options:", options, meta.framework);
96
97
  if (!["vite", "webpack"].includes(meta.framework)) {
@@ -125,11 +126,14 @@ const unplugin = createUnplugin((options = {}, meta) => {
125
126
  warn(`'useVueI18nImportName' option is experimental`);
126
127
  }
127
128
  debug("useVueI18nImportName", useVueI18nImportName);
128
- const getAliasName = () => installedVueI18nBridge && installedPkg === "vue-i18n" ? "vue-i18n-bridge" : installedPkg === "petite-vue-i18n" && isBoolean(useVueI18nImportName) && useVueI18nImportName ? "vue-i18n" : `${installedPkg}`;
129
+ const getVueI18nAliasName = () => vueI18nVersion === "9" || vueI18nVersion === "8" ? "vue-i18n" : vueI18nVersion === "unknown" && installedPkg === "petite-vue-i18n" && isBoolean(useVueI18nImportName) && useVueI18nImportName ? "vue-i18n" : installedPkg;
130
+ const getVueI18nBridgeAliasPath = () => `vue-i18n-bridge/dist/vue-i18n-bridge.runtime.esm-bundler.js`;
131
+ const getVueI18nAliasPath = (aliasName) => vueI18nVersion === "8" ? `${aliasName}/dist/${aliasName}.esm.js` : `${aliasName}/dist/${installedPkg}.runtime.esm-bundler.js`;
129
132
  const esm = isBoolean(options.esm) ? options.esm : true;
130
133
  debug("esm", esm);
131
134
  let isProduction = false;
132
135
  let sourceMap = false;
136
+ const vueI18nAliasName = getVueI18nAliasName();
133
137
  return {
134
138
  name: "unplugin-vue-i18n",
135
139
  enforce: meta.framework === "vite" ? "pre" : "post",
@@ -140,19 +144,34 @@ const unplugin = createUnplugin((options = {}, meta) => {
140
144
  meta.framework
141
145
  );
142
146
  if (command === "build" && runtimeOnly) {
143
- const aliasName = getAliasName();
144
- debug(`alias name: ${aliasName}`);
147
+ debug(`vue-i18n alias name: ${vueI18nAliasName}`);
145
148
  if (isArray(config.resolve.alias)) {
146
149
  config.resolve.alias.push({
147
- find: aliasName,
148
- replacement: `${aliasName}/dist/${aliasName}.runtime.esm-bundler.js`
150
+ find: vueI18nAliasName,
151
+ replacement: getVueI18nAliasPath(vueI18nAliasName)
149
152
  });
153
+ if (installedVueI18nBridge) {
154
+ config.resolve.alias.push({
155
+ find: "vue-i18n-bridge",
156
+ replacement: getVueI18nBridgeAliasPath()
157
+ });
158
+ }
150
159
  } else if (isObject(config.resolve.alias)) {
151
- config.resolve.alias[aliasName] = `${aliasName}/dist/${aliasName}.runtime.esm-bundler.js`;
160
+ config.resolve.alias[vueI18nAliasName] = getVueI18nAliasPath(vueI18nAliasName);
161
+ if (installedVueI18nBridge) {
162
+ config.resolve.alias["vue-i18n-bridge"] = getVueI18nBridgeAliasPath();
163
+ }
152
164
  }
153
165
  debug(
154
- `set ${aliasName} runtime only: ${aliasName}/dist/${aliasName}.runtime.esm-bundler.js`
166
+ `set ${vueI18nAliasName} runtime only: ${getVueI18nAliasPath(
167
+ vueI18nAliasName
168
+ )}`
155
169
  );
170
+ if (installedVueI18nBridge) {
171
+ debug(
172
+ `set vue-i18n-bridge runtime only: ${getVueI18nBridgeAliasPath()}`
173
+ );
174
+ }
156
175
  } else if (command === "serve" && installedPkg === "petite-vue-i18n" && useVueI18nImportName) {
157
176
  config.resolve = normalizeConfigResolveAlias(
158
177
  config.resolve,
@@ -160,13 +179,13 @@ const unplugin = createUnplugin((options = {}, meta) => {
160
179
  );
161
180
  if (isArray(config.resolve.alias)) {
162
181
  config.resolve.alias.push({
163
- find: "vue-i18n",
182
+ find: vueI18nAliasName,
164
183
  replacement: `petite-vue-i18n/dist/petite-vue-i18n.esm-bundler.js`
165
184
  });
166
185
  } else {
167
- config.resolve.alias["vue-i18n"] = `petite-vue-i18n/dist/petite-vue-i18n.esm-bundler.js`;
186
+ config.resolve.alias[vueI18nAliasName] = `petite-vue-i18n/dist/petite-vue-i18n.esm-bundler.js`;
168
187
  }
169
- debug(`alias name: ${getAliasName()}`);
188
+ debug(`petite-vue-i18n alias name: ${vueI18nAliasName}`);
170
189
  }
171
190
  config.define = config.define || {};
172
191
  config.define["__VUE_I18N_LEGACY_API__"] = !compositionOnly;
@@ -217,12 +236,28 @@ const unplugin = createUnplugin((options = {}, meta) => {
217
236
  isProduction = compiler.options.mode !== "development";
218
237
  sourceMap = !!compiler.options.devtool;
219
238
  debug(`webpack: isProduction = ${isProduction}, sourceMap = ${sourceMap}`);
239
+ compiler.options.resolve = normalizeConfigResolveAlias(
240
+ compiler.options.resolve,
241
+ meta.framework
242
+ );
220
243
  if (isProduction && runtimeOnly) {
221
- compiler.options.resolve = normalizeConfigResolveAlias(
222
- compiler.options.resolve,
223
- meta.framework
244
+ compiler.options.resolve.alias[vueI18nAliasName] = getVueI18nAliasPath(vueI18nAliasName);
245
+ if (installedVueI18nBridge) {
246
+ compiler.options.resolve.alias["vue-i18n-bridge"] = getVueI18nBridgeAliasPath();
247
+ }
248
+ debug(
249
+ `set ${vueI18nAliasName} runtime only: ${getVueI18nAliasPath(
250
+ vueI18nAliasName
251
+ )}`
224
252
  );
225
- compiler.options.resolve.alias["vue-i18n"] = `vue-i18n/dist/vue-i18n.runtime.esm-bundler.js`;
253
+ if (installedVueI18nBridge) {
254
+ debug(
255
+ `set vue-i18n-bridge runtime only: ${getVueI18nBridgeAliasPath()}`
256
+ );
257
+ }
258
+ } else if (!isProduction && installedPkg === "petite-vue-i18n" && useVueI18nImportName) {
259
+ compiler.options.resolve.alias[vueI18nAliasName] = `petite-vue-i18n/dist/petite-vue-i18n.esm-bundler.js`;
260
+ debug(`petite-vue-i18n alias name: ${vueI18nAliasName}`);
226
261
  }
227
262
  loadWebpack().then((webpack) => {
228
263
  if (webpack) {
@@ -243,7 +278,9 @@ const unplugin = createUnplugin((options = {}, meta) => {
243
278
  compiler.options.module.rules.push({
244
279
  test: /\.(json5?|ya?ml)$/,
245
280
  type: "javascript/auto",
246
- exclude: include
281
+ include(resource) {
282
+ return filter(resource);
283
+ }
247
284
  });
248
285
  }
249
286
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intlify/unplugin-vue-i18n",
3
- "version": "0.7.2",
3
+ "version": "0.7.3",
4
4
  "description": "unplugin for Vue I18n",
5
5
  "author": {
6
6
  "name": "kazuya kawaguchi",
@@ -26,15 +26,15 @@
26
26
  }
27
27
  },
28
28
  "dependencies": {
29
- "@intlify/bundle-utils": "^3.2.1",
29
+ "@intlify/bundle-utils": "^3.4.0",
30
30
  "@intlify/shared": "next",
31
31
  "@rollup/pluginutils": "^4.2.0",
32
- "@vue/compiler-sfc": "^3.2.23",
32
+ "@vue/compiler-sfc": "^3.2.45",
33
33
  "debug": "^4.3.1",
34
34
  "fast-glob": "^3.2.5",
35
35
  "js-yaml": "^4.1.0",
36
36
  "json5": "^2.2.0",
37
- "pathe": "^0.2.0",
37
+ "pathe": "^0.3.9",
38
38
  "picocolors": "^1.0.0",
39
39
  "source-map": "0.6.1",
40
40
  "unplugin": "^0.8.0"