@intlify/bundle-utils 5.0.1 → 5.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 +4 -1
- package/lib/codegen.js +2 -2
- package/lib/index.cjs +1036 -0
- package/lib/index.mjs +1038 -0
- package/lib/js.d.ts +2 -3
- package/lib/js.js +162 -102
- package/package.json +6 -4
package/lib/codegen.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export interface Position {
|
|
|
13
13
|
offset?: number;
|
|
14
14
|
}
|
|
15
15
|
export interface SourceLocationable {
|
|
16
|
+
start?: number;
|
|
16
17
|
loc?: {
|
|
17
18
|
start: Position;
|
|
18
19
|
end: Position;
|
|
@@ -34,6 +35,7 @@ export interface CodeGenOptions {
|
|
|
34
35
|
env?: DevEnv;
|
|
35
36
|
forceStringify?: boolean;
|
|
36
37
|
useClassComponent?: boolean;
|
|
38
|
+
allowDynamic?: boolean;
|
|
37
39
|
onWarn?: (msg: string) => void;
|
|
38
40
|
onError?: (msg: string, extra?: {
|
|
39
41
|
source: string;
|
|
@@ -66,9 +68,10 @@ export interface CodeGenerator {
|
|
|
66
68
|
/**
|
|
67
69
|
* @internal
|
|
68
70
|
*/
|
|
69
|
-
export interface CodeGenResult<ASTNode> {
|
|
71
|
+
export interface CodeGenResult<ASTNode, CodeGenError extends Error = Error> {
|
|
70
72
|
code: string;
|
|
71
73
|
ast: ASTNode;
|
|
74
|
+
errors?: CodeGenError[];
|
|
72
75
|
map?: RawSourceMap;
|
|
73
76
|
}
|
|
74
77
|
export declare function createCodeGenerator(options?: CodeGenOptions): CodeGenerator;
|
package/lib/codegen.js
CHANGED
|
@@ -21,8 +21,8 @@ function createCodeGenerator(options = {
|
|
|
21
21
|
const context = () => _context;
|
|
22
22
|
function push(code, node, name) {
|
|
23
23
|
_context.code += code;
|
|
24
|
-
if (_context.map) {
|
|
25
|
-
if (node
|
|
24
|
+
if (_context.map && node) {
|
|
25
|
+
if (node.loc && node.loc !== message_compiler_1.LocationStub) {
|
|
26
26
|
addMapping(node.loc.start, name);
|
|
27
27
|
}
|
|
28
28
|
advancePositionWithSource(_context, code);
|