@intlify/bundle-utils 3.3.0 → 4.0.0

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/index.mjs ADDED
@@ -0,0 +1 @@
1
+ export * from './lib/index.js'
package/lib/codegen.d.ts CHANGED
@@ -6,7 +6,7 @@ import type { RawSourceMap } from 'source-map';
6
6
  *
7
7
  * @public
8
8
  */
9
- export declare type DevEnv = 'development' | 'production';
9
+ export type DevEnv = 'development' | 'production';
10
10
  export interface Position {
11
11
  line: number;
12
12
  column: number;
package/lib/deps.d.ts CHANGED
@@ -1,6 +1,7 @@
1
- export declare type InstalledPackage = 'vue-i18n' | 'petite-vue-i18n';
1
+ export type InstalledPackage = 'vue-i18n' | 'petite-vue-i18n';
2
2
  export declare function checkInstallPackage(pkg: string, debug: Function): InstalledPackage;
3
3
  export declare function checkVueI18nBridgeInstallPackage(debug: Function): boolean;
4
- export declare function isInstalledVue2(debug: Function): boolean;
5
- export declare function isInstalledVue3(debug: Function): boolean;
4
+ type VueI18nVersion = '8' | '9' | 'unknown' | '';
5
+ export declare function getVueI18nVersion(debug: Function): VueI18nVersion;
6
6
  export declare function loadModule(moduleName: string, debug: Function): any;
7
+ export {};
package/lib/deps.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.loadModule = exports.isInstalledVue3 = exports.isInstalledVue2 = exports.checkVueI18nBridgeInstallPackage = exports.checkInstallPackage = void 0;
3
+ exports.loadModule = exports.getVueI18nVersion = exports.checkVueI18nBridgeInstallPackage = exports.checkInstallPackage = void 0;
4
4
  // eslint-disable-next-line @typescript-eslint/ban-types
5
5
  function checkInstallPackage(pkg, debug) {
6
6
  let installedVueI18n = false;
@@ -41,16 +41,20 @@ function checkVueI18nBridgeInstallPackage(debug) {
41
41
  return ret;
42
42
  }
43
43
  exports.checkVueI18nBridgeInstallPackage = checkVueI18nBridgeInstallPackage;
44
- function isInstalledVue2(debug) {
45
- const vue = loadModule('vue', debug);
46
- return vue != null && vue.version != null && vue.version.startsWith('2.');
47
- }
48
- exports.isInstalledVue2 = isInstalledVue2;
49
- function isInstalledVue3(debug) {
50
- const vue = loadModule('vue', debug);
51
- return vue != null && vue.version != null && vue.version.startsWith('3.');
44
+ function getVueI18nVersion(debug) {
45
+ const VueI18n = loadModule('vue-i18n', debug);
46
+ if (VueI18n == null) {
47
+ return '';
48
+ }
49
+ if (VueI18n.version && VueI18n.version.startsWith('8.')) {
50
+ return '8';
51
+ }
52
+ if (VueI18n.VERSION && VueI18n.VERSION.startsWith('9.')) {
53
+ return '9';
54
+ }
55
+ return 'unknown';
52
56
  }
53
- exports.isInstalledVue3 = isInstalledVue3;
57
+ exports.getVueI18nVersion = getVueI18nVersion;
54
58
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
55
59
  function loadModule(moduleName, debug) {
56
60
  try {
package/lib/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export { CodeGenOptions, CodeGenResult, DevEnv } from './codegen';
2
2
  export { generate as generateJSON } from './json';
3
3
  export { generate as generateYAML } from './yaml';
4
- export { isInstalledVue2, isInstalledVue3, checkInstallPackage, checkVueI18nBridgeInstallPackage, InstalledPackage } from './deps';
4
+ export { getVueI18nVersion, checkInstallPackage, checkVueI18nBridgeInstallPackage, InstalledPackage } from './deps';
package/lib/index.js CHANGED
@@ -1,12 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.checkVueI18nBridgeInstallPackage = exports.checkInstallPackage = exports.isInstalledVue3 = exports.isInstalledVue2 = exports.generateYAML = exports.generateJSON = void 0;
3
+ exports.checkVueI18nBridgeInstallPackage = exports.checkInstallPackage = exports.getVueI18nVersion = exports.generateYAML = exports.generateJSON = void 0;
4
4
  var json_1 = require("./json");
5
5
  Object.defineProperty(exports, "generateJSON", { enumerable: true, get: function () { return json_1.generate; } });
6
6
  var yaml_1 = require("./yaml");
7
7
  Object.defineProperty(exports, "generateYAML", { enumerable: true, get: function () { return yaml_1.generate; } });
8
8
  var deps_1 = require("./deps");
9
- Object.defineProperty(exports, "isInstalledVue2", { enumerable: true, get: function () { return deps_1.isInstalledVue2; } });
10
- Object.defineProperty(exports, "isInstalledVue3", { enumerable: true, get: function () { return deps_1.isInstalledVue3; } });
9
+ Object.defineProperty(exports, "getVueI18nVersion", { enumerable: true, get: function () { return deps_1.getVueI18nVersion; } });
11
10
  Object.defineProperty(exports, "checkInstallPackage", { enumerable: true, get: function () { return deps_1.checkInstallPackage; } });
12
11
  Object.defineProperty(exports, "checkVueI18nBridgeInstallPackage", { enumerable: true, get: function () { return deps_1.checkVueI18nBridgeInstallPackage; } });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@intlify/bundle-utils",
3
3
  "description": "Bundle utilities for Intlify project",
4
- "version": "3.3.0",
4
+ "version": "4.0.0",
5
5
  "author": {
6
6
  "name": "kazuya kawaguchi",
7
7
  "email": "kawakazu80@gmail.com"
@@ -28,11 +28,23 @@
28
28
  "node": ">= 12"
29
29
  },
30
30
  "files": [
31
- "lib"
31
+ "lib",
32
+ "index.mjs"
32
33
  ],
33
34
  "homepage": "https://github.com/intlify/bundle-tools/blob/main/packages/bundle-utils/README.md",
34
35
  "license": "MIT",
35
36
  "main": "lib/index.js",
37
+ "module": "./index.mjs",
38
+ "types": "lib/index.d.ts",
39
+ "exports": {
40
+ ".": {
41
+ "import": "./index.mjs",
42
+ "require": "./lib/index.js",
43
+ "types": "./lib/index.d.ts"
44
+ },
45
+ "./lib/*": "./lib/*",
46
+ "./package.json": "./package.json"
47
+ },
36
48
  "repository": {
37
49
  "type": "git",
38
50
  "url": "git+https://github.com/intlify/bundle-tools.git",
@@ -45,6 +57,5 @@
45
57
  "watch": "tsc -p . --watch",
46
58
  "changelog": "jiti ../../scripts/changelog.ts",
47
59
  "release": "jiti ../../scripts/release.ts"
48
- },
49
- "types": "lib/index.d.ts"
60
+ }
50
61
  }
package/lib/check.d.ts DELETED
@@ -1,3 +0,0 @@
1
- export declare type InstalledPackage = 'vue-i18n' | 'petite-vue-i18n';
2
- export declare function checkInstallPackage(pkg: string, debug: Function): InstalledPackage;
3
- export declare function checkVueI18nBridgeInstallPackage(debug: Function): boolean;
package/lib/check.js DELETED
@@ -1,43 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.checkVueI18nBridgeInstallPackage = exports.checkInstallPackage = void 0;
4
- // eslint-disable-next-line @typescript-eslint/ban-types
5
- function checkInstallPackage(pkg, debug) {
6
- let installedVueI18n = false;
7
- try {
8
- debug(`vue-i18n load path: ${require.resolve('vue-i18n')}`);
9
- installedVueI18n = true;
10
- }
11
- catch (e) {
12
- debug(`cannot find 'vue-i18n'`, e);
13
- }
14
- let installedPetiteVueI18n = false;
15
- try {
16
- debug(`petite-vue-i18n load path: ${require.resolve('petite-vue-i18n')}`);
17
- installedPetiteVueI18n = true;
18
- }
19
- catch (e) {
20
- debug(`cannot find 'petite-vue-i18n'`, e);
21
- }
22
- if (installedVueI18n) {
23
- return 'vue-i18n';
24
- }
25
- if (installedPetiteVueI18n) {
26
- return 'petite-vue-i18n';
27
- }
28
- throw new Error(`${pkg} requires 'vue-i18n' or 'petite-vue-i18n' to be present in the dependency tree.`);
29
- }
30
- exports.checkInstallPackage = checkInstallPackage;
31
- // eslint-disable-next-line @typescript-eslint/ban-types
32
- function checkVueI18nBridgeInstallPackage(debug) {
33
- let ret = false;
34
- try {
35
- debug(`vue-i18n-bridge load path: ${require.resolve('vue-i18n-bridge')}`);
36
- ret = true;
37
- }
38
- catch (e) {
39
- debug(`cannot find 'vue-i18n-bridge'`, e);
40
- }
41
- return ret;
42
- }
43
- exports.checkVueI18nBridgeInstallPackage = checkVueI18nBridgeInstallPackage;
package/lib/errors.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export declare class CompileError extends SyntaxError {
2
- }
package/lib/errors.js DELETED
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CompileError = void 0;
4
- class CompileError extends SyntaxError {
5
- }
6
- exports.CompileError = CompileError;