@intlify/bundle-utils 0.3.0 → 2.2.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/CHANGELOG.md +36 -0
- package/lib/codegen.d.ts +1 -0
- package/lib/json.d.ts +1 -1
- package/lib/json.js +14 -9
- package/lib/yaml.d.ts +1 -1
- package/lib/yaml.js +14 -9
- package/package.json +12 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,40 @@
|
|
|
1
1
|
|
|
2
|
+
## @intlify/bundle-utils@2.2.0 (2021-12-16)
|
|
3
|
+
|
|
4
|
+
#### :zap: Improvement Features
|
|
5
|
+
* [#75](https://github.com/intlify/bundle-tools/pull/75) Add vue-class-components support via loader option ([@SniperJoe](https://github.com/SniperJoe))
|
|
6
|
+
|
|
7
|
+
#### Committers: 1
|
|
8
|
+
- [@SniperJoe](https://github.com/SniperJoe)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
## @intlify/bundle-utils@2.1.0 (2021-11-10)
|
|
12
|
+
|
|
13
|
+
#### :zap: Improvement Features
|
|
14
|
+
* [#67](https://github.com/intlify/bundle-tools/pull/67) fix: add vite and vue-i18n as peerDependencies ([@AlexandreBonaventure](https://github.com/AlexandreBonaventure))
|
|
15
|
+
|
|
16
|
+
#### Committers: 1
|
|
17
|
+
- Alexandre Bonaventure Geissmann ([@AlexandreBonaventure](https://github.com/AlexandreBonaventure))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
## @intlify/bundle-utils@2.0.0 (2021-10-24)
|
|
21
|
+
|
|
22
|
+
#### :star: Features
|
|
23
|
+
* [#60](https://github.com/intlify/bundle-tools/pull/60) feat: change to intlify beta related deps ([@kazupon](https://github.com/kazupon))
|
|
24
|
+
|
|
25
|
+
#### Committers: 1
|
|
26
|
+
- kazuya kawaguchi ([@kazupon](https://github.com/kazupon))
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
## @intlify/bundle-utils@1.0.0 (2021-10-24)
|
|
30
|
+
|
|
31
|
+
#### :star: Features
|
|
32
|
+
* [#56](https://github.com/intlify/bundle-tools/pull/56) feat: bump to major version ([@kazupon](https://github.com/kazupon))
|
|
33
|
+
|
|
34
|
+
#### Committers: 1
|
|
35
|
+
- kazuya kawaguchi ([@kazupon](https://github.com/kazupon))
|
|
36
|
+
|
|
37
|
+
|
|
2
38
|
## @intlify/bundle-utils@0.3.0 (2021-09-29)
|
|
3
39
|
|
|
4
40
|
#### :star: Features
|
package/lib/codegen.d.ts
CHANGED
package/lib/json.d.ts
CHANGED
|
@@ -7,4 +7,4 @@ import type { CodeGenOptions, CodeGenResult } from './codegen';
|
|
|
7
7
|
/**
|
|
8
8
|
* @internal
|
|
9
9
|
*/
|
|
10
|
-
export declare function generate(targetSource: string | Buffer, { type, bridge, filename, inSourceMap, locale, isGlobal, sourceMap, env, forceStringify }: CodeGenOptions, injector?: () => string): CodeGenResult<JSONProgram>;
|
|
10
|
+
export declare function generate(targetSource: string | Buffer, { type, bridge, filename, inSourceMap, locale, isGlobal, sourceMap, env, forceStringify, useClassComponent }: CodeGenOptions, injector?: () => string): CodeGenResult<JSONProgram>;
|
package/lib/json.js
CHANGED
|
@@ -10,7 +10,7 @@ const codegen_1 = require("./codegen");
|
|
|
10
10
|
/**
|
|
11
11
|
* @internal
|
|
12
12
|
*/
|
|
13
|
-
function generate(targetSource, { type = 'plain', bridge = false, filename = 'vue-i18n-loader.json', inSourceMap = undefined, locale = '', isGlobal = false, sourceMap = false, env = 'development', forceStringify = false }, injector) {
|
|
13
|
+
function generate(targetSource, { type = 'plain', bridge = false, filename = 'vue-i18n-loader.json', inSourceMap = undefined, locale = '', isGlobal = false, sourceMap = false, env = 'development', forceStringify = false, useClassComponent = false }, injector) {
|
|
14
14
|
const target = Buffer.isBuffer(targetSource)
|
|
15
15
|
? targetSource.toString()
|
|
16
16
|
: targetSource;
|
|
@@ -28,7 +28,8 @@ function generate(targetSource, { type = 'plain', bridge = false, filename = 'vu
|
|
|
28
28
|
inSourceMap,
|
|
29
29
|
env,
|
|
30
30
|
filename,
|
|
31
|
-
forceStringify
|
|
31
|
+
forceStringify,
|
|
32
|
+
useClassComponent
|
|
32
33
|
};
|
|
33
34
|
const generator = codegen_1.createCodeGenerator(options);
|
|
34
35
|
const ast = jsonc_eslint_parser_1.parseJSON(value, { filePath: filename });
|
|
@@ -56,8 +57,12 @@ function generateNode(generator, node, options, injector) {
|
|
|
56
57
|
const itemsCountStack = [];
|
|
57
58
|
const { forceStringify } = generator.context();
|
|
58
59
|
const codeMaps = new Map();
|
|
59
|
-
const { type, bridge, sourceMap, isGlobal, locale } = options;
|
|
60
|
-
const componentNamespace = bridge
|
|
60
|
+
const { type, bridge, sourceMap, isGlobal, locale, useClassComponent } = options;
|
|
61
|
+
const componentNamespace = bridge
|
|
62
|
+
? `Component.options`
|
|
63
|
+
: useClassComponent
|
|
64
|
+
? `Component.__o`
|
|
65
|
+
: `Component`;
|
|
61
66
|
jsonc_eslint_parser_1.traverseNodes(node, {
|
|
62
67
|
enterNode(node, parent) {
|
|
63
68
|
switch (node.type) {
|
|
@@ -72,8 +77,8 @@ function generateNode(generator, node, options, injector) {
|
|
|
72
77
|
const exportSyntax = bridge ? `module.exports =` : `export default`;
|
|
73
78
|
generator.push(`${exportSyntax} function (Component) {`);
|
|
74
79
|
generator.indent();
|
|
75
|
-
generator.pushline(`${componentNamespace}
|
|
76
|
-
generator.push(`${componentNamespace}
|
|
80
|
+
generator.pushline(`${componentNamespace}.${variableName} = ${componentNamespace}.${variableName} || []`);
|
|
81
|
+
generator.push(`${componentNamespace}.${variableName}.push({`);
|
|
77
82
|
generator.indent();
|
|
78
83
|
generator.pushline(`"locale": ${JSON.stringify(localeName)},`);
|
|
79
84
|
generator.push(`"resource": `);
|
|
@@ -165,9 +170,9 @@ function generateNode(generator, node, options, injector) {
|
|
|
165
170
|
generator.push(`})`);
|
|
166
171
|
if (bridge && injector) {
|
|
167
172
|
generator.newline();
|
|
168
|
-
generator.pushline(`${componentNamespace}__i18nBridge = ${componentNamespace}__i18nBridge || []`);
|
|
169
|
-
generator.pushline(`${componentNamespace}__i18nBridge.push('${injector()}')`);
|
|
170
|
-
generator.pushline(`delete ${componentNamespace}_Ctor`);
|
|
173
|
+
generator.pushline(`${componentNamespace}.__i18nBridge = ${componentNamespace}.__i18nBridge || []`);
|
|
174
|
+
generator.pushline(`${componentNamespace}.__i18nBridge.push('${injector()}')`);
|
|
175
|
+
generator.pushline(`delete ${componentNamespace}._Ctor`);
|
|
171
176
|
}
|
|
172
177
|
generator.deindent();
|
|
173
178
|
generator.pushline(`}`);
|
package/lib/yaml.d.ts
CHANGED
|
@@ -7,4 +7,4 @@ import type { CodeGenOptions, CodeGenResult } from './codegen';
|
|
|
7
7
|
/**
|
|
8
8
|
* @internal
|
|
9
9
|
*/
|
|
10
|
-
export declare function generate(targetSource: string | Buffer, { type, bridge, filename, inSourceMap, locale, isGlobal, sourceMap, env, forceStringify }: CodeGenOptions, injector?: () => string): CodeGenResult<YAMLProgram>;
|
|
10
|
+
export declare function generate(targetSource: string | Buffer, { type, bridge, useClassComponent, filename, inSourceMap, locale, isGlobal, sourceMap, env, forceStringify }: CodeGenOptions, injector?: () => string): CodeGenResult<YAMLProgram>;
|
package/lib/yaml.js
CHANGED
|
@@ -10,7 +10,7 @@ const yaml_eslint_parser_1 = require("yaml-eslint-parser");
|
|
|
10
10
|
/**
|
|
11
11
|
* @internal
|
|
12
12
|
*/
|
|
13
|
-
function generate(targetSource, { type = 'plain', bridge = false, filename = 'vue-i18n-loader.yaml', inSourceMap = undefined, locale = '', isGlobal = false, sourceMap = false, env = 'development', forceStringify = false }, injector) {
|
|
13
|
+
function generate(targetSource, { type = 'plain', bridge = false, useClassComponent = false, filename = 'vue-i18n-loader.yaml', inSourceMap = undefined, locale = '', isGlobal = false, sourceMap = false, env = 'development', forceStringify = false }, injector) {
|
|
14
14
|
const value = Buffer.isBuffer(targetSource)
|
|
15
15
|
? targetSource.toString()
|
|
16
16
|
: targetSource;
|
|
@@ -24,7 +24,8 @@ function generate(targetSource, { type = 'plain', bridge = false, filename = 'vu
|
|
|
24
24
|
inSourceMap,
|
|
25
25
|
env,
|
|
26
26
|
filename,
|
|
27
|
-
forceStringify
|
|
27
|
+
forceStringify,
|
|
28
|
+
useClassComponent
|
|
28
29
|
};
|
|
29
30
|
const generator = codegen_1.createCodeGenerator(options);
|
|
30
31
|
const ast = yaml_eslint_parser_1.parseYAML(value, { filePath: filename });
|
|
@@ -46,8 +47,12 @@ function generateNode(generator, node, options, injector) {
|
|
|
46
47
|
const itemsCountStack = [];
|
|
47
48
|
const { forceStringify } = generator.context();
|
|
48
49
|
const codeMaps = new Map();
|
|
49
|
-
const { type, bridge, sourceMap, isGlobal, locale } = options;
|
|
50
|
-
const componentNamespace = bridge
|
|
50
|
+
const { type, bridge, sourceMap, isGlobal, locale, useClassComponent } = options;
|
|
51
|
+
const componentNamespace = bridge
|
|
52
|
+
? `Component.options`
|
|
53
|
+
: useClassComponent
|
|
54
|
+
? `Component.__o`
|
|
55
|
+
: `Component`;
|
|
51
56
|
yaml_eslint_parser_1.traverseNodes(node, {
|
|
52
57
|
enterNode(node, parent) {
|
|
53
58
|
switch (node.type) {
|
|
@@ -61,8 +66,8 @@ function generateNode(generator, node, options, injector) {
|
|
|
61
66
|
const exportSyntax = bridge ? `module.exports =` : `export default`;
|
|
62
67
|
generator.push(`${exportSyntax} function (Component) {`);
|
|
63
68
|
generator.indent();
|
|
64
|
-
generator.pushline(`${componentNamespace}
|
|
65
|
-
generator.push(`${componentNamespace}
|
|
69
|
+
generator.pushline(`${componentNamespace}.${variableName} = ${componentNamespace}.${variableName} || []`);
|
|
70
|
+
generator.push(`${componentNamespace}.${variableName}.push({`);
|
|
66
71
|
generator.indent();
|
|
67
72
|
generator.pushline(`"locale": ${JSON.stringify(localeName)},`);
|
|
68
73
|
generator.push(`"resource": `);
|
|
@@ -156,9 +161,9 @@ function generateNode(generator, node, options, injector) {
|
|
|
156
161
|
generator.push(`})`);
|
|
157
162
|
if (bridge && injector) {
|
|
158
163
|
generator.newline();
|
|
159
|
-
generator.pushline(`${componentNamespace}__i18nBridge = ${componentNamespace}__i18nBridge || []`);
|
|
160
|
-
generator.pushline(`${componentNamespace}__i18nBridge.push('${injector()}')`);
|
|
161
|
-
generator.pushline(`delete ${componentNamespace}_Ctor`);
|
|
164
|
+
generator.pushline(`${componentNamespace}.__i18nBridge = ${componentNamespace}.__i18nBridge || []`);
|
|
165
|
+
generator.pushline(`${componentNamespace}.__i18nBridge.push('${injector()}')`);
|
|
166
|
+
generator.pushline(`delete ${componentNamespace}._Ctor`);
|
|
162
167
|
}
|
|
163
168
|
generator.deindent();
|
|
164
169
|
generator.push(`}`);
|
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": "
|
|
4
|
+
"version": "2.2.0",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "kazuya kawaguchi",
|
|
7
7
|
"email": "kawakazu80@gmail.com"
|
|
@@ -9,10 +9,18 @@
|
|
|
9
9
|
"bugs": {
|
|
10
10
|
"url": "https://github.com/intlify/bundle-tools/issues"
|
|
11
11
|
},
|
|
12
|
+
"peerDependencies": {},
|
|
13
|
+
"peerDependenciesMeta": {
|
|
14
|
+
"vue-i18n": {
|
|
15
|
+
"optional": true
|
|
16
|
+
},
|
|
17
|
+
"petite-vue-i18n": {
|
|
18
|
+
"optional": true
|
|
19
|
+
}
|
|
20
|
+
},
|
|
12
21
|
"dependencies": {
|
|
13
|
-
"@intlify/
|
|
14
|
-
"@intlify/
|
|
15
|
-
"@intlify/shared": "^9.1.6",
|
|
22
|
+
"@intlify/message-compiler": "beta",
|
|
23
|
+
"@intlify/shared": "beta",
|
|
16
24
|
"jsonc-eslint-parser": "^1.0.1",
|
|
17
25
|
"source-map": "^0.6.1",
|
|
18
26
|
"yaml-eslint-parser": "^0.3.2"
|
|
@@ -27,7 +35,6 @@
|
|
|
27
35
|
"homepage": "https://github.com/intlify/bundle-tools/blob/main/packages/bundle-utils/README.md",
|
|
28
36
|
"license": "MIT",
|
|
29
37
|
"main": "lib/index.js",
|
|
30
|
-
"peerDependencies": {},
|
|
31
38
|
"repository": {
|
|
32
39
|
"type": "git",
|
|
33
40
|
"url": "git+https://github.com/intlify/bundle-tools.git",
|