@umijs/bundler-utils 3.5.20 → 4.0.0-beta.4
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/README.md +2 -0
- package/compiled/@babel/code-frame/LICENSE +22 -0
- package/compiled/@babel/code-frame/index.d.ts +54 -0
- package/compiled/@babel/code-frame/package.json +1 -0
- package/compiled/@babel/core/LICENSE +22 -0
- package/compiled/@babel/core/index.d.ts +771 -0
- package/compiled/@babel/core/package.json +1 -0
- package/compiled/@babel/generator/LICENSE +22 -0
- package/compiled/@babel/generator/index.d.ts +212 -0
- package/compiled/@babel/generator/package.json +1 -0
- package/compiled/@babel/parser/LICENSE +19 -0
- package/compiled/@babel/parser/package.json +1 -0
- package/compiled/@babel/parser/typings/babel-parser.d.ts +203 -0
- package/compiled/@babel/template/LICENSE +22 -0
- package/compiled/@babel/template/index.d.ts +100 -0
- package/compiled/@babel/template/package.json +1 -0
- package/compiled/@babel/traverse/LICENSE +22 -0
- package/compiled/@babel/traverse/index.d.ts +1172 -0
- package/compiled/@babel/traverse/package.json +1 -0
- package/compiled/@babel/types/LICENSE +22 -0
- package/compiled/@babel/types/lib/index-legacy.d.ts +2692 -0
- package/compiled/@babel/types/package.json +1 -0
- package/compiled/babel/code-frame.d.ts +3 -0
- package/compiled/babel/code-frame.js +1 -0
- package/compiled/babel/core.d.ts +3 -0
- package/compiled/babel/core.js +1 -0
- package/compiled/babel/generator.d.ts +3 -0
- package/compiled/babel/generator.js +1 -0
- package/compiled/babel/index.js +101726 -0
- package/compiled/babel/parser.d.ts +3 -0
- package/compiled/babel/parser.js +1 -0
- package/compiled/babel/plugin-proposal-decorators.js +1 -0
- package/compiled/babel/plugin-proposal-do-expressions.js +1 -0
- package/compiled/babel/plugin-proposal-export-default-from.js +1 -0
- package/compiled/babel/plugin-proposal-export-namespace-from.js +1 -0
- package/compiled/babel/plugin-proposal-function-bind.js +1 -0
- package/compiled/babel/plugin-proposal-partial-application.js +1 -0
- package/compiled/babel/plugin-proposal-pipeline-operator.js +1 -0
- package/compiled/babel/plugin-proposal-record-and-tuple.js +1 -0
- package/compiled/babel/plugin-transform-runtime.js +1 -0
- package/compiled/babel/preset-env.js +1 -0
- package/compiled/babel/preset-react.js +1 -0
- package/compiled/babel/preset-typescript.js +1 -0
- package/compiled/babel/register.js +1 -0
- package/compiled/babel/source-map-support.js +625 -0
- package/compiled/babel/template.d.ts +3 -0
- package/compiled/babel/template.js +1 -0
- package/compiled/babel/traverse.d.ts +3 -0
- package/compiled/babel/traverse.js +1 -0
- package/compiled/babel/types.d.ts +1 -0
- package/compiled/babel/types.js +1 -0
- package/compiled/cjs-module-lexer/LICENSE +10 -0
- package/compiled/cjs-module-lexer/index.js +1 -0
- package/compiled/cjs-module-lexer/lexer.d.ts +7 -0
- package/compiled/cjs-module-lexer/package.json +1 -0
- package/compiled/es-module-lexer/LICENSE +10 -0
- package/compiled/es-module-lexer/index.js +1 -0
- package/compiled/es-module-lexer/package.json +1 -0
- package/compiled/es-module-lexer/types/lexer.d.ts +86 -0
- package/compiled/esbuild/index.d.ts +1 -0
- package/compiled/esbuild/index.js +11 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +5 -0
- package/package.json +70 -14
- package/lib/getBabelOpts.d.ts +0 -42
- package/lib/getBabelOpts.js +0 -112
- package/lib/getTargetsAndBrowsersList.d.ts +0 -10
- package/lib/getTargetsAndBrowsersList.js +0 -50
- package/lib/index.d.ts +0 -2
- package/lib/index.js +0 -42
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"name":"@babel/core","author":"The Babel Team (https://babel.dev/team)","license":"MIT"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2014-present Sebastian McKenzie and other contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
// Type definitions for @babel/generator 7.6
|
|
2
|
+
// Project: https://github.com/babel/babel/tree/master/packages/babel-generator, https://babeljs.io
|
|
3
|
+
// Definitions by: Troy Gerwien <https://github.com/yortus>
|
|
4
|
+
// Johnny Estilles <https://github.com/johnnyestilles>
|
|
5
|
+
// Melvin Groenhoff <https://github.com/mgroenhoff>
|
|
6
|
+
// Cameron Yan <https://github.com/khell>
|
|
7
|
+
// Lyanbin <https://github.com/Lyanbin>
|
|
8
|
+
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
9
|
+
// TypeScript Version: 2.9
|
|
10
|
+
|
|
11
|
+
import * as t from '../../@babel/types';
|
|
12
|
+
|
|
13
|
+
export interface GeneratorOptions {
|
|
14
|
+
/**
|
|
15
|
+
* Optional string to add as a block comment at the start of the output file.
|
|
16
|
+
*/
|
|
17
|
+
auxiliaryCommentBefore?: string | undefined;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Optional string to add as a block comment at the end of the output file.
|
|
21
|
+
*/
|
|
22
|
+
auxiliaryCommentAfter?: string | undefined;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Function that takes a comment (as a string) and returns true if the comment should be included in the output.
|
|
26
|
+
* By default, comments are included if `opts.comments` is `true` or if `opts.minifed` is `false` and the comment
|
|
27
|
+
* contains `@preserve` or `@license`.
|
|
28
|
+
*/
|
|
29
|
+
shouldPrintComment?(comment: string): boolean;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Attempt to use the same line numbers in the output code as in the source code (helps preserve stack traces).
|
|
33
|
+
* Defaults to `false`.
|
|
34
|
+
*/
|
|
35
|
+
retainLines?: boolean | undefined;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Retain parens around function expressions (could be used to change engine parsing behavior)
|
|
39
|
+
* Defaults to `false`.
|
|
40
|
+
*/
|
|
41
|
+
retainFunctionParens?: boolean | undefined;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Should comments be included in output? Defaults to `true`.
|
|
45
|
+
*/
|
|
46
|
+
comments?: boolean | undefined;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Set to true to avoid adding whitespace for formatting. Defaults to the value of `opts.minified`.
|
|
50
|
+
*/
|
|
51
|
+
compact?: boolean | 'auto' | undefined;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Should the output be minified. Defaults to `false`.
|
|
55
|
+
*/
|
|
56
|
+
minified?: boolean | undefined;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Set to true to reduce whitespace (but not as much as opts.compact). Defaults to `false`.
|
|
60
|
+
*/
|
|
61
|
+
concise?: boolean | undefined;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Used in warning messages
|
|
65
|
+
*/
|
|
66
|
+
filename?: string | undefined;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Enable generating source maps. Defaults to `false`.
|
|
70
|
+
*/
|
|
71
|
+
sourceMaps?: boolean | undefined;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* A root for all relative URLs in the source map.
|
|
75
|
+
*/
|
|
76
|
+
sourceRoot?: string | undefined;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* The filename for the source code (i.e. the code in the `code` argument).
|
|
80
|
+
* This will only be used if `code` is a string.
|
|
81
|
+
*/
|
|
82
|
+
sourceFileName?: string | undefined;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Set to true to run jsesc with "json": true to print "\u00A9" vs. "©";
|
|
86
|
+
*/
|
|
87
|
+
jsonCompatibleStrings?: boolean | undefined;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Set to true to enable support for experimental decorators syntax before module exports.
|
|
91
|
+
* Defaults to `false`.
|
|
92
|
+
*/
|
|
93
|
+
decoratorsBeforeExport?: boolean | undefined;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Options for outputting jsesc representation.
|
|
97
|
+
*/
|
|
98
|
+
jsescOption?: {
|
|
99
|
+
/**
|
|
100
|
+
* The default value for the quotes option is 'single'. This means that any occurrences of ' in the input
|
|
101
|
+
* string are escaped as \', so that the output can be used in a string literal wrapped in single quotes.
|
|
102
|
+
*/
|
|
103
|
+
quotes?: 'single' | 'double' | 'backtick' | undefined;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* The default value for the numbers option is 'decimal'. This means that any numeric values are represented
|
|
107
|
+
* using decimal integer literals. Other valid options are binary, octal, and hexadecimal, which result in
|
|
108
|
+
* binary integer literals, octal integer literals, and hexadecimal integer literals, respectively.
|
|
109
|
+
*/
|
|
110
|
+
numbers?: 'binary' | 'octal' | 'decimal' | 'hexadecimal' | undefined;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* The wrap option takes a boolean value (true or false), and defaults to false (disabled). When enabled, the
|
|
114
|
+
* output is a valid JavaScript string literal wrapped in quotes. The type of quotes can be specified through
|
|
115
|
+
* the quotes setting.
|
|
116
|
+
*/
|
|
117
|
+
wrap?: boolean | undefined;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* The es6 option takes a boolean value (true or false), and defaults to false (disabled). When enabled, any
|
|
121
|
+
* astral Unicode symbols in the input are escaped using ECMAScript 6 Unicode code point escape sequences
|
|
122
|
+
* instead of using separate escape sequences for each surrogate half. If backwards compatibility with ES5
|
|
123
|
+
* environments is a concern, don’t enable this setting. If the json setting is enabled, the value for the es6
|
|
124
|
+
* setting is ignored (as if it was false).
|
|
125
|
+
*/
|
|
126
|
+
es6?: boolean | undefined;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* The escapeEverything option takes a boolean value (true or false), and defaults to false (disabled). When
|
|
130
|
+
* enabled, all the symbols in the output are escaped — even printable ASCII symbols.
|
|
131
|
+
*/
|
|
132
|
+
escapeEverything?: boolean | undefined;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* The minimal option takes a boolean value (true or false), and defaults to false (disabled). When enabled,
|
|
136
|
+
* only a limited set of symbols in the output are escaped: \0, \b, \t, \n, \f, \r, \\, \u2028, \u2029.
|
|
137
|
+
*/
|
|
138
|
+
minimal?: boolean | undefined;
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* The isScriptContext option takes a boolean value (true or false), and defaults to false (disabled). When
|
|
142
|
+
* enabled, occurrences of </script and </style in the output are escaped as <\/script and <\/style, and <!--
|
|
143
|
+
* is escaped as \x3C!-- (or \u003C!-- when the json option is enabled). This setting is useful when jsesc’s
|
|
144
|
+
* output ends up as part of a <script> or <style> element in an HTML document.
|
|
145
|
+
*/
|
|
146
|
+
isScriptContext?: boolean | undefined;
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* The compact option takes a boolean value (true or false), and defaults to true (enabled). When enabled,
|
|
150
|
+
* the output for arrays and objects is as compact as possible; it’s not formatted nicely.
|
|
151
|
+
*/
|
|
152
|
+
compact?: boolean | undefined;
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* The indent option takes a string value, and defaults to '\t'. When the compact setting is enabled (true),
|
|
156
|
+
* the value of the indent option is used to format the output for arrays and objects.
|
|
157
|
+
*/
|
|
158
|
+
indent?: string | undefined;
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* The indentLevel option takes a numeric value, and defaults to 0. It represents the current indentation level,
|
|
162
|
+
* i.e. the number of times the value of the indent option is repeated.
|
|
163
|
+
*/
|
|
164
|
+
indentLevel?: number | undefined;
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* The json option takes a boolean value (true or false), and defaults to false (disabled). When enabled, the
|
|
168
|
+
* output is valid JSON. Hexadecimal character escape sequences and the \v or \0 escape sequences are not used.
|
|
169
|
+
* Setting json: true implies quotes: 'double', wrap: true, es6: false, although these values can still be
|
|
170
|
+
* overridden if needed — but in such cases, the output won’t be valid JSON anymore.
|
|
171
|
+
*/
|
|
172
|
+
json?: boolean | undefined;
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* The lowercaseHex option takes a boolean value (true or false), and defaults to false (disabled). When enabled,
|
|
176
|
+
* any alphabetical hexadecimal digits in escape sequences as well as any hexadecimal integer literals (see the
|
|
177
|
+
* numbers option) in the output are in lowercase.
|
|
178
|
+
*/
|
|
179
|
+
lowercaseHex?: boolean | undefined;
|
|
180
|
+
} | undefined;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export class CodeGenerator {
|
|
184
|
+
constructor(ast: t.Node, opts?: GeneratorOptions, code?: string);
|
|
185
|
+
generate(): GeneratorResult;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Turns an AST into code, maintaining sourcemaps, user preferences, and valid output.
|
|
190
|
+
* @param ast - the abstract syntax tree from which to generate output code.
|
|
191
|
+
* @param opts - used for specifying options for code generation.
|
|
192
|
+
* @param code - the original source code, used for source maps.
|
|
193
|
+
* @returns - an object containing the output code and source map.
|
|
194
|
+
*/
|
|
195
|
+
export default function generate(
|
|
196
|
+
ast: t.Node,
|
|
197
|
+
opts?: GeneratorOptions,
|
|
198
|
+
code?: string | { [filename: string]: string },
|
|
199
|
+
): GeneratorResult;
|
|
200
|
+
|
|
201
|
+
export interface GeneratorResult {
|
|
202
|
+
code: string;
|
|
203
|
+
map: {
|
|
204
|
+
version: number;
|
|
205
|
+
sources: string[];
|
|
206
|
+
names: string[];
|
|
207
|
+
sourceRoot?: string | undefined;
|
|
208
|
+
sourcesContent?: string[] | undefined;
|
|
209
|
+
mappings: string;
|
|
210
|
+
file: string;
|
|
211
|
+
} | null;
|
|
212
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"name":"@babel/generator","author":"The Babel Team (https://babel.dev/team)","license":"MIT"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (C) 2012-2014 by various contributors (see AUTHORS)
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
|
11
|
+
all copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
+
THE SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"name":"@babel/parser","author":"The Babel Team (https://babel.dev/team)","license":"MIT","types":"./typings/babel-parser.d.ts"}
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
// Type definitions for @babel/parser
|
|
2
|
+
// Project: https://github.com/babel/babel/tree/main/packages/babel-parser
|
|
3
|
+
// Definitions by: Troy Gerwien <https://github.com/yortus>
|
|
4
|
+
// Marvin Hagemeister <https://github.com/marvinhagemeister>
|
|
5
|
+
// Avi Vahl <https://github.com/AviVahl>
|
|
6
|
+
// TypeScript Version: 2.9
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Parse the provided code as an entire ECMAScript program.
|
|
10
|
+
*/
|
|
11
|
+
export function parse(
|
|
12
|
+
input: string,
|
|
13
|
+
options?: ParserOptions
|
|
14
|
+
): ParseResult<import('../../../@babel/types').File>;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Parse the provided code as a single expression.
|
|
18
|
+
*/
|
|
19
|
+
export function parseExpression(
|
|
20
|
+
input: string,
|
|
21
|
+
options?: ParserOptions
|
|
22
|
+
): ParseResult<import('../../../@babel/types').Expression>;
|
|
23
|
+
|
|
24
|
+
export interface ParserOptions {
|
|
25
|
+
/**
|
|
26
|
+
* By default, import and export declarations can only appear at a program's top level.
|
|
27
|
+
* Setting this option to true allows them anywhere where a statement is allowed.
|
|
28
|
+
*/
|
|
29
|
+
allowImportExportEverywhere?: boolean;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* By default, await use is not allowed outside of an async function.
|
|
33
|
+
* Set this to true to accept such code.
|
|
34
|
+
*/
|
|
35
|
+
allowAwaitOutsideFunction?: boolean;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* By default, a return statement at the top level raises an error.
|
|
39
|
+
* Set this to true to accept such code.
|
|
40
|
+
*/
|
|
41
|
+
allowReturnOutsideFunction?: boolean;
|
|
42
|
+
|
|
43
|
+
allowSuperOutsideMethod?: boolean;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* By default, exported identifiers must refer to a declared variable.
|
|
47
|
+
* Set this to true to allow export statements to reference undeclared variables.
|
|
48
|
+
*/
|
|
49
|
+
allowUndeclaredExports?: boolean;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* By default, Babel attaches comments to adjacent AST nodes.
|
|
53
|
+
* When this option is set to false, comments are not attached.
|
|
54
|
+
* It can provide up to 30% performance improvement when the input code has many comments.
|
|
55
|
+
* @babel/eslint-parser will set it for you.
|
|
56
|
+
* It is not recommended to use attachComment: false with Babel transform,
|
|
57
|
+
* as doing so removes all the comments in output code, and renders annotations such as
|
|
58
|
+
* /* istanbul ignore next *\/ nonfunctional.
|
|
59
|
+
*/
|
|
60
|
+
attachComment?: boolean;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* By default, Babel always throws an error when it finds some invalid code.
|
|
64
|
+
* When this option is set to true, it will store the parsing error and
|
|
65
|
+
* try to continue parsing the invalid input file.
|
|
66
|
+
*/
|
|
67
|
+
errorRecovery?: boolean;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Indicate the mode the code should be parsed in.
|
|
71
|
+
* Can be one of "script", "module", or "unambiguous". Defaults to "script".
|
|
72
|
+
* "unambiguous" will make @babel/parser attempt to guess, based on the presence
|
|
73
|
+
* of ES6 import or export statements.
|
|
74
|
+
* Files with ES6 imports and exports are considered "module" and are otherwise "script".
|
|
75
|
+
*/
|
|
76
|
+
sourceType?: "script" | "module" | "unambiguous";
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Correlate output AST nodes with their source filename.
|
|
80
|
+
* Useful when generating code and source maps from the ASTs of multiple input files.
|
|
81
|
+
*/
|
|
82
|
+
sourceFilename?: string;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* By default, the first line of code parsed is treated as line 1.
|
|
86
|
+
* You can provide a line number to alternatively start with.
|
|
87
|
+
* Useful for integration with other source tools.
|
|
88
|
+
*/
|
|
89
|
+
startLine?: number;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Array containing the plugins that you want to enable.
|
|
93
|
+
*/
|
|
94
|
+
plugins?: ParserPlugin[];
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Should the parser work in strict mode.
|
|
98
|
+
* Defaults to true if sourceType === 'module'. Otherwise, false.
|
|
99
|
+
*/
|
|
100
|
+
strictMode?: boolean;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Adds a ranges property to each node: [node.start, node.end]
|
|
104
|
+
*/
|
|
105
|
+
ranges?: boolean;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Adds all parsed tokens to a tokens property on the File node.
|
|
109
|
+
*/
|
|
110
|
+
tokens?: boolean;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* By default, the parser adds information about parentheses by setting
|
|
114
|
+
* `extra.parenthesized` to `true` as needed.
|
|
115
|
+
* When this option is `true` the parser creates `ParenthesizedExpression`
|
|
116
|
+
* AST nodes instead of using the `extra` property.
|
|
117
|
+
*/
|
|
118
|
+
createParenthesizedExpressions?: boolean;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export type ParserPlugin =
|
|
122
|
+
| "asyncDoExpressions"
|
|
123
|
+
| "asyncGenerators"
|
|
124
|
+
| "bigInt"
|
|
125
|
+
| "classPrivateMethods"
|
|
126
|
+
| "classPrivateProperties"
|
|
127
|
+
| "classProperties"
|
|
128
|
+
| "classStaticBlock" // Enabled by default
|
|
129
|
+
| "decimal"
|
|
130
|
+
| "decorators"
|
|
131
|
+
| "decorators-legacy"
|
|
132
|
+
| "doExpressions"
|
|
133
|
+
| "dynamicImport"
|
|
134
|
+
| "estree"
|
|
135
|
+
| "exportDefaultFrom"
|
|
136
|
+
| "exportNamespaceFrom" // deprecated
|
|
137
|
+
| "flow"
|
|
138
|
+
| "flowComments"
|
|
139
|
+
| "functionBind"
|
|
140
|
+
| "functionSent"
|
|
141
|
+
| "importMeta"
|
|
142
|
+
| "jsx"
|
|
143
|
+
| "logicalAssignment"
|
|
144
|
+
| "importAssertions"
|
|
145
|
+
| "moduleBlocks"
|
|
146
|
+
| "moduleStringNames"
|
|
147
|
+
| "nullishCoalescingOperator"
|
|
148
|
+
| "numericSeparator"
|
|
149
|
+
| "objectRestSpread"
|
|
150
|
+
| "optionalCatchBinding"
|
|
151
|
+
| "optionalChaining"
|
|
152
|
+
| "partialApplication"
|
|
153
|
+
| "pipelineOperator"
|
|
154
|
+
| "placeholders"
|
|
155
|
+
| "privateIn" // Enabled by default
|
|
156
|
+
| "throwExpressions"
|
|
157
|
+
| "topLevelAwait"
|
|
158
|
+
| "typescript"
|
|
159
|
+
| "v8intrinsic"
|
|
160
|
+
| ParserPluginWithOptions;
|
|
161
|
+
|
|
162
|
+
export type ParserPluginWithOptions =
|
|
163
|
+
| ["decorators", DecoratorsPluginOptions]
|
|
164
|
+
| ["pipelineOperator", PipelineOperatorPluginOptions]
|
|
165
|
+
| ["recordAndTuple", RecordAndTuplePluginOptions]
|
|
166
|
+
| ["flow", FlowPluginOptions]
|
|
167
|
+
| ["typescript", TypeScriptPluginOptions];
|
|
168
|
+
|
|
169
|
+
export interface DecoratorsPluginOptions {
|
|
170
|
+
decoratorsBeforeExport?: boolean;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export interface PipelineOperatorPluginOptions {
|
|
174
|
+
proposal: "minimal" | "fsharp" | "hack" | "smart";
|
|
175
|
+
topicToken?: "%" | "#";
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export interface RecordAndTuplePluginOptions {
|
|
179
|
+
syntaxType: "bar" | "hash";
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export interface FlowPluginOptions {
|
|
183
|
+
all?: boolean;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export interface TypeScriptPluginOptions {
|
|
187
|
+
dts?: boolean;
|
|
188
|
+
disallowAmbiguousJSXLike?: boolean;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export const tokTypes: {
|
|
192
|
+
// todo(flow->ts) real token type
|
|
193
|
+
[name: string]: any;
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
export interface ParseError {
|
|
197
|
+
code: string;
|
|
198
|
+
reasonCode: string;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
type ParseResult<Result> = Result & {
|
|
202
|
+
errors: ParseError[];
|
|
203
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2014-present Sebastian McKenzie and other contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// Type definitions for @babel/template 7.4
|
|
2
|
+
// Project: https://github.com/babel/babel/tree/master/packages/babel-template, https://babeljs.io
|
|
3
|
+
// Definitions by: Troy Gerwien <https://github.com/yortus>
|
|
4
|
+
// Marvin Hagemeister <https://github.com/marvinhagemeister>
|
|
5
|
+
// Melvin Groenhoff <https://github.com/mgroenhoff>
|
|
6
|
+
// ExE Boss <https://github.com/ExE-Boss>
|
|
7
|
+
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
8
|
+
|
|
9
|
+
import { ParserOptions } from '../../@babel/parser';
|
|
10
|
+
import { Expression, Program, Statement } from '../../@babel/types';
|
|
11
|
+
|
|
12
|
+
export interface TemplateBuilderOptions extends ParserOptions {
|
|
13
|
+
/**
|
|
14
|
+
* A set of placeholder names to automatically accept.
|
|
15
|
+
* Items in this list do not need to match `placeholderPattern`.
|
|
16
|
+
*
|
|
17
|
+
* This option cannot be used when using `%%foo%%` style placeholders.
|
|
18
|
+
*/
|
|
19
|
+
placeholderWhitelist?: Set<string> | null | undefined;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* A pattern to search for when looking for `Identifier` and `StringLiteral`
|
|
23
|
+
* nodes that should be considered as placeholders.
|
|
24
|
+
*
|
|
25
|
+
* `false` will disable placeholder searching placeholders, leaving only
|
|
26
|
+
* the `placeholderWhitelist` value to find replacements.
|
|
27
|
+
*
|
|
28
|
+
* This option cannot be used when using `%%foo%%` style placeholders.
|
|
29
|
+
*
|
|
30
|
+
* @default /^[_$A-Z0-9]+$/
|
|
31
|
+
*/
|
|
32
|
+
placeholderPattern?: RegExp | false | null | undefined;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Set this to `true` to preserve comments from the template string
|
|
36
|
+
* into the resulting AST, or `false` to automatically discard comments.
|
|
37
|
+
*
|
|
38
|
+
* @default false
|
|
39
|
+
*/
|
|
40
|
+
preserveComments?: boolean | null | undefined;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Set to `true` to use `%%foo%%` style placeholders, `false` to use legacy placeholders
|
|
44
|
+
* described by `placeholderPattern` or `placeholderWhitelist`.
|
|
45
|
+
*
|
|
46
|
+
* When it is not set, it behaves as `true` if there are syntactic placeholders, otherwise as `false`.
|
|
47
|
+
*
|
|
48
|
+
* @since 7.4.0
|
|
49
|
+
*/
|
|
50
|
+
syntacticPlaceholders?: boolean | null | undefined;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface TemplateBuilder<T> {
|
|
54
|
+
/**
|
|
55
|
+
* Build a new builder, merging the given options with the previous ones.
|
|
56
|
+
*/
|
|
57
|
+
(opts: TemplateBuilderOptions): TemplateBuilder<T>;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Building from a string produces an AST builder function by default.
|
|
61
|
+
*/
|
|
62
|
+
(code: string, opts?: TemplateBuilderOptions): (arg?: PublicReplacements) => T;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Building from a template literal produces an AST builder function by default.
|
|
66
|
+
*/
|
|
67
|
+
(tpl: TemplateStringsArray, ...args: unknown[]): (arg?: PublicReplacements) => T;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Allow users to explicitly create templates that produce ASTs,
|
|
71
|
+
* skipping the need for an intermediate function.
|
|
72
|
+
*
|
|
73
|
+
* Does not allow `%%foo%%` style placeholders.
|
|
74
|
+
*/
|
|
75
|
+
ast: {
|
|
76
|
+
(tpl: string, opts?: TemplateBuilderOptions): T;
|
|
77
|
+
(tpl: TemplateStringsArray, ...args: unknown[]): T;
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export type PublicReplacements = { [index: string]: unknown } | unknown[];
|
|
82
|
+
|
|
83
|
+
export const smart: TemplateBuilder<Statement | Statement[]>;
|
|
84
|
+
export const statement: TemplateBuilder<Statement>;
|
|
85
|
+
export const statements: TemplateBuilder<Statement[]>;
|
|
86
|
+
export const expression: TemplateBuilder<Expression>;
|
|
87
|
+
export const program: TemplateBuilder<Program>;
|
|
88
|
+
|
|
89
|
+
type DefaultTemplateBuilder = typeof smart & {
|
|
90
|
+
smart: typeof smart;
|
|
91
|
+
statement: typeof statement;
|
|
92
|
+
statements: typeof statements;
|
|
93
|
+
expression: typeof expression;
|
|
94
|
+
program: typeof program;
|
|
95
|
+
ast: typeof smart.ast;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
declare const templateBuilder: DefaultTemplateBuilder;
|
|
99
|
+
|
|
100
|
+
export default templateBuilder;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"name":"@babel/template","author":"The Babel Team (https://babel.dev/team)","license":"MIT"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2014-present Sebastian McKenzie and other contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|