@intlify/bundle-utils 3.1.0 → 3.1.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/lib/codegen.d.ts +7 -2
- package/lib/codegen.js +14 -4
- package/lib/errors.d.ts +2 -0
- package/lib/errors.js +6 -0
- package/lib/json.d.ts +1 -1
- package/lib/json.js +2 -1
- package/lib/yaml.d.ts +1 -1
- package/lib/yaml.js +2 -1
- package/package.json +1 -1
- package/CHANGELOG.md +0 -111
package/lib/codegen.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ResourceNode } from '@intlify/message-compiler';
|
|
1
|
+
import { CompileError, ResourceNode } from '@intlify/message-compiler';
|
|
2
2
|
import { SourceMapGenerator } from 'source-map';
|
|
3
3
|
import type { RawSourceMap } from 'source-map';
|
|
4
4
|
/**
|
|
@@ -35,7 +35,12 @@ export interface CodeGenOptions {
|
|
|
35
35
|
forceStringify?: boolean;
|
|
36
36
|
useClassComponent?: boolean;
|
|
37
37
|
onWarn?: (msg: string) => void;
|
|
38
|
-
onError?: (msg: string
|
|
38
|
+
onError?: (msg: string, extra?: {
|
|
39
|
+
source: string;
|
|
40
|
+
code?: CompileError['code'];
|
|
41
|
+
domain?: CompileError['domain'];
|
|
42
|
+
location?: CompileError['location'];
|
|
43
|
+
}) => void;
|
|
39
44
|
}
|
|
40
45
|
export interface CodeGenContext {
|
|
41
46
|
source?: string;
|
package/lib/codegen.js
CHANGED
|
@@ -96,13 +96,23 @@ function advancePositionWithSource(pos, source, numberOfCharacters = source.leng
|
|
|
96
96
|
}
|
|
97
97
|
function generateMessageFunction(msg, options) {
|
|
98
98
|
const env = options.env != null ? options.env : 'development';
|
|
99
|
-
|
|
100
|
-
const
|
|
99
|
+
const onError = options.onError;
|
|
100
|
+
const errors = [];
|
|
101
|
+
const newOptions = Object.assign({ mode: 'arrow' }, options);
|
|
101
102
|
newOptions.onError = (err) => {
|
|
102
|
-
|
|
103
|
-
|
|
103
|
+
if (onError) {
|
|
104
|
+
const extra = {
|
|
105
|
+
source: msg,
|
|
106
|
+
code: err.code,
|
|
107
|
+
domain: err.domain,
|
|
108
|
+
location: err.location
|
|
109
|
+
};
|
|
110
|
+
onError(err.message, extra);
|
|
111
|
+
errors.push(err);
|
|
112
|
+
}
|
|
104
113
|
};
|
|
105
114
|
const { code, ast, map } = (0, message_compiler_1.baseCompile)(msg, newOptions);
|
|
115
|
+
const occured = errors.length > 0;
|
|
106
116
|
const genCode = !occured
|
|
107
117
|
? env === 'development'
|
|
108
118
|
? `(()=>{const fn=${code};fn.source=${JSON.stringify(msg)};return fn;})()`
|
package/lib/errors.d.ts
ADDED
package/lib/errors.js
ADDED
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, exportESM, filename, inSourceMap, locale, isGlobal, sourceMap, env, forceStringify, useClassComponent }: CodeGenOptions, injector?: () => string): CodeGenResult<JSONProgram>;
|
|
10
|
+
export declare function generate(targetSource: string | Buffer, { type, bridge, exportESM, filename, inSourceMap, locale, isGlobal, sourceMap, env, forceStringify, onError, 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, exportESM = false, filename = 'vue-i18n-loader.json', inSourceMap = undefined, locale = '', isGlobal = false, sourceMap = false, env = 'development', forceStringify = false, useClassComponent = false }, injector) {
|
|
13
|
+
function generate(targetSource, { type = 'plain', bridge = false, exportESM = false, filename = 'vue-i18n-loader.json', inSourceMap = undefined, locale = '', isGlobal = false, sourceMap = false, env = 'development', forceStringify = false, onError = undefined, useClassComponent = false }, injector) {
|
|
14
14
|
const target = Buffer.isBuffer(targetSource)
|
|
15
15
|
? targetSource.toString()
|
|
16
16
|
: targetSource;
|
|
@@ -30,6 +30,7 @@ function generate(targetSource, { type = 'plain', bridge = false, exportESM = fa
|
|
|
30
30
|
env,
|
|
31
31
|
filename,
|
|
32
32
|
forceStringify,
|
|
33
|
+
onError,
|
|
33
34
|
useClassComponent
|
|
34
35
|
};
|
|
35
36
|
const generator = (0, codegen_1.createCodeGenerator)(options);
|
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, exportESM, useClassComponent, filename, inSourceMap, locale, isGlobal, sourceMap, env, forceStringify }: CodeGenOptions, injector?: () => string): CodeGenResult<YAMLProgram>;
|
|
10
|
+
export declare function generate(targetSource: string | Buffer, { type, bridge, exportESM, useClassComponent, filename, inSourceMap, locale, isGlobal, sourceMap, env, forceStringify, onError }: 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, exportESM = false, useClassComponent = 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, exportESM = false, useClassComponent = false, filename = 'vue-i18n-loader.yaml', inSourceMap = undefined, locale = '', isGlobal = false, sourceMap = false, env = 'development', forceStringify = false, onError = undefined }, injector) {
|
|
14
14
|
const value = Buffer.isBuffer(targetSource)
|
|
15
15
|
? targetSource.toString()
|
|
16
16
|
: targetSource;
|
|
@@ -26,6 +26,7 @@ function generate(targetSource, { type = 'plain', bridge = false, exportESM = fa
|
|
|
26
26
|
env,
|
|
27
27
|
filename,
|
|
28
28
|
forceStringify,
|
|
29
|
+
onError,
|
|
29
30
|
useClassComponent
|
|
30
31
|
};
|
|
31
32
|
const generator = (0, codegen_1.createCodeGenerator)(options);
|
package/package.json
CHANGED
package/CHANGELOG.md
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
## @intlify/bundle-utils@3.1.0 (2022-05-06)
|
|
3
|
-
|
|
4
|
-
#### :zap: Improvement Features
|
|
5
|
-
* [#116](https://github.com/intlify/bundle-tools/pull/116) improvement(bundle-utils): support ESM exporting on bridge ([@kazupon](https://github.com/kazupon))
|
|
6
|
-
|
|
7
|
-
#### Committers: 1
|
|
8
|
-
- kazuya kawaguchi ([@kazupon](https://github.com/kazupon))
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
## @intlify/bundle-utils@3.0.0 (2022-04-05)
|
|
12
|
-
|
|
13
|
-
#### :star: Features
|
|
14
|
-
* [#101](https://github.com/intlify/bundle-tools/pull/101) feat(bundle-utils): pinned intlify related module next version ([@kazupon](https://github.com/kazupon))
|
|
15
|
-
|
|
16
|
-
#### Committers: 1
|
|
17
|
-
- kazuya kawaguchi ([@kazupon](https://github.com/kazupon))
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
## @intlify/bundle-utils@2.2.2 (2022-04-05)
|
|
21
|
-
|
|
22
|
-
#### :zap: Improvement Features
|
|
23
|
-
* [#100](https://github.com/intlify/bundle-tools/pull/100) fix(bundle-utils): pinned latest stable version ([@kazupon](https://github.com/kazupon))
|
|
24
|
-
|
|
25
|
-
#### Committers: 1
|
|
26
|
-
- kazuya kawaguchi ([@kazupon](https://github.com/kazupon))
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
## @intlify/bundle-utils@2.2.1 (2022-03-22)
|
|
30
|
-
|
|
31
|
-
#### :bug: Bug Fixes
|
|
32
|
-
* [#98](https://github.com/intlify/bundle-tools/pull/98) fix(bundle-utils): fix nested array code generation ([@kazupon](https://github.com/kazupon))
|
|
33
|
-
|
|
34
|
-
#### Committers: 1
|
|
35
|
-
- kazuya kawaguchi ([@kazupon](https://github.com/kazupon))
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
## @intlify/bundle-utils@2.2.1 (2022-03-22)
|
|
39
|
-
|
|
40
|
-
#### :bug: Bug Fixes
|
|
41
|
-
* [#98](https://github.com/intlify/bundle-tools/pull/98) fix(bundle-utils): fix nested array code generation ([@kazupon](https://github.com/kazupon))
|
|
42
|
-
|
|
43
|
-
#### Committers: 1
|
|
44
|
-
- kazuya kawaguchi ([@kazupon](https://github.com/kazupon))
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
## @intlify/bundle-utils@2.2.0 (2021-12-16)
|
|
48
|
-
|
|
49
|
-
#### :zap: Improvement Features
|
|
50
|
-
* [#75](https://github.com/intlify/bundle-tools/pull/75) Add vue-class-components support via loader option ([@SniperJoe](https://github.com/SniperJoe))
|
|
51
|
-
|
|
52
|
-
#### Committers: 1
|
|
53
|
-
- [@SniperJoe](https://github.com/SniperJoe)
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
## @intlify/bundle-utils@2.1.0 (2021-11-10)
|
|
57
|
-
|
|
58
|
-
#### :zap: Improvement Features
|
|
59
|
-
* [#67](https://github.com/intlify/bundle-tools/pull/67) fix: add vite and vue-i18n as peerDependencies ([@AlexandreBonaventure](https://github.com/AlexandreBonaventure))
|
|
60
|
-
|
|
61
|
-
#### Committers: 1
|
|
62
|
-
- Alexandre Bonaventure Geissmann ([@AlexandreBonaventure](https://github.com/AlexandreBonaventure))
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
## @intlify/bundle-utils@2.0.0 (2021-10-24)
|
|
66
|
-
|
|
67
|
-
#### :star: Features
|
|
68
|
-
* [#60](https://github.com/intlify/bundle-tools/pull/60) feat: change to intlify beta related deps ([@kazupon](https://github.com/kazupon))
|
|
69
|
-
|
|
70
|
-
#### Committers: 1
|
|
71
|
-
- kazuya kawaguchi ([@kazupon](https://github.com/kazupon))
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
## @intlify/bundle-utils@1.0.0 (2021-10-24)
|
|
75
|
-
|
|
76
|
-
#### :star: Features
|
|
77
|
-
* [#56](https://github.com/intlify/bundle-tools/pull/56) feat: bump to major version ([@kazupon](https://github.com/kazupon))
|
|
78
|
-
|
|
79
|
-
#### Committers: 1
|
|
80
|
-
- kazuya kawaguchi ([@kazupon](https://github.com/kazupon))
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
## @intlify/bundle-utils@0.3.0 (2021-09-29)
|
|
84
|
-
|
|
85
|
-
#### :star: Features
|
|
86
|
-
* [#47](https://github.com/intlify/bundle-tools/pull/47) feat: support vue i18n bridge ([@kazupon](https://github.com/kazupon))
|
|
87
|
-
|
|
88
|
-
#### Committers: 1
|
|
89
|
-
- kazuya kawaguchi ([@kazupon](https://github.com/kazupon))
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
## @intlify/bundle-utils@0.2.0 (2021-07-26)
|
|
93
|
-
|
|
94
|
-
#### :star: Features
|
|
95
|
-
* [#36](https://github.com/intlify/bundle-tools/pull/36) add install package checking ([@kazupon](https://github.com/kazupon))
|
|
96
|
-
|
|
97
|
-
#### Committers: 1
|
|
98
|
-
- kazuya kawaguchi ([@kazupon](https://github.com/kazupon))
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
## @intlify/bundle-utils@0.1.0 (2021-07-12)
|
|
102
|
-
|
|
103
|
-
#### :star: Features
|
|
104
|
-
* [#26](https://github.com/intlify/bundle-tools/pull/26) feat: bundle-utils basic implementation ([@kazupon](https://github.com/kazupon))
|
|
105
|
-
|
|
106
|
-
#### Committers: 1
|
|
107
|
-
- kazuya kawaguchi ([@kazupon](https://github.com/kazupon))
|
|
108
|
-
|
|
109
|
-
## v0.0.0 (2021-07-13)
|
|
110
|
-
|
|
111
|
-
:tada: Initial release.
|