@umijs/bundler-utils 4.0.7 → 4.0.10

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.
@@ -17,7 +17,7 @@ import * as t from '../../@babel/types';
17
17
  export { ParserOptions, GeneratorOptions, t as types, template, traverse, NodePath, Visitor };
18
18
 
19
19
  export type Node = t.Node;
20
- export type ParseResult = t.File | t.Program;
20
+ export type ParseResult = ReturnType<typeof import('../../@babel/parser').parse>;
21
21
  export const version: string;
22
22
  export const DEFAULT_EXTENSIONS: ['.js', '.jsx', '.es6', '.es', '.mjs'];
23
23
 
@@ -97,6 +97,32 @@ export interface TransformOptions {
97
97
  */
98
98
  babelrcRoots?: boolean | MatchPattern | MatchPattern[] | null | undefined;
99
99
 
100
+ /**
101
+ * Toggles whether or not browserslist config sources are used, which includes searching for any browserslist files or referencing the browserslist key inside package.json.
102
+ * This is useful for projects that use a browserslist config for files that won't be compiled with Babel.
103
+ *
104
+ * If a string is specified, it must represent the path of a browserslist configuration file. Relative paths are resolved relative to the configuration file which specifies
105
+ * this option, or to `cwd` when it's passed as part of the programmatic options.
106
+ *
107
+ * Default: `true`
108
+ */
109
+ browserslistConfigFile?: boolean | null | undefined;
110
+
111
+ /**
112
+ * The Browserslist environment to use.
113
+ *
114
+ * Default: `undefined`
115
+ */
116
+ browserslistEnv?: string | null | undefined;
117
+
118
+ /**
119
+ * By default `babel.transformFromAst` will clone the input AST to avoid mutations.
120
+ * Specifying `cloneInputAst: false` can improve parsing performance if the input AST is not used elsewhere.
121
+ *
122
+ * Default: `true`
123
+ */
124
+ cloneInputAst?: boolean | null | undefined;
125
+
100
126
  /**
101
127
  * Defaults to environment variable `BABEL_ENV` if set, or else `NODE_ENV` if set, or else it defaults to `"development"`
102
128
  *
@@ -460,9 +486,11 @@ export interface BabelFile {
460
486
  export interface PluginPass {
461
487
  file: BabelFile;
462
488
  key: string;
463
- opts: PluginOptions;
489
+ opts: object;
464
490
  cwd: string;
465
491
  filename: string | undefined;
492
+ get(key: unknown): any;
493
+ set(key: unknown, value: unknown): void;
466
494
  [key: string]: unknown;
467
495
  }
468
496
 
@@ -1,7 +1,6 @@
1
1
  // Type definitions for @babel/generator 7.6
2
2
  // Project: https://github.com/babel/babel/tree/master/packages/babel-generator, https://babeljs.io
3
3
  // Definitions by: Troy Gerwien <https://github.com/yortus>
4
- // Johnny Estilles <https://github.com/johnnyestilles>
5
4
  // Melvin Groenhoff <https://github.com/mgroenhoff>
6
5
  // Cameron Yan <https://github.com/khell>
7
6
  // Lyanbin <https://github.com/Lyanbin>
@@ -88,6 +88,13 @@ export interface ParserOptions {
88
88
  */
89
89
  startLine?: number;
90
90
 
91
+ /**
92
+ * By default, the parsed code is treated as if it starts from line 1, column 0.
93
+ * You can provide a column number to alternatively start with.
94
+ * Useful for integration with other source tools.
95
+ */
96
+ startColumn?: number;
97
+
91
98
  /**
92
99
  * Array containing the plugins that you want to enable.
93
100
  */
@@ -129,6 +136,8 @@ export type ParserPlugin =
129
136
  | "decimal"
130
137
  | "decorators"
131
138
  | "decorators-legacy"
139
+ | "decoratorAutoAccessors"
140
+ | "destructuringPrivate"
132
141
  | "doExpressions"
133
142
  | "dynamicImport"
134
143
  | "estree"
@@ -153,6 +162,7 @@ export type ParserPlugin =
153
162
  | "pipelineOperator"
154
163
  | "placeholders"
155
164
  | "privateIn" // Enabled by default
165
+ | "regexpUnicodeSets"
156
166
  | "throwExpressions"
157
167
  | "topLevelAwait"
158
168
  | "typescript"
@@ -172,7 +182,7 @@ export interface DecoratorsPluginOptions {
172
182
 
173
183
  export interface PipelineOperatorPluginOptions {
174
184
  proposal: "minimal" | "fsharp" | "hack" | "smart";
175
- topicToken?: "%" | "#";
185
+ topicToken?: "%" | "#" | "@@" | "^^" | "^";
176
186
  }
177
187
 
178
188
  export interface RecordAndTuplePluginOptions {
@@ -181,6 +191,7 @@ export interface RecordAndTuplePluginOptions {
181
191
 
182
192
  export interface FlowPluginOptions {
183
193
  all?: boolean;
194
+ enums?: boolean;
184
195
  }
185
196
 
186
197
  export interface TypeScriptPluginOptions {
@@ -1,4 +1,4 @@
1
- // Type definitions for @babel/traverse 7.14
1
+ // Type definitions for @babel/traverse 7.17
2
2
  // Project: https://github.com/babel/babel/tree/main/packages/babel-traverse, https://babeljs.io
3
3
  // Definitions by: Troy Gerwien <https://github.com/yortus>
4
4
  // Marvin Hagemeister <https://github.com/marvinhagemeister>
@@ -140,7 +140,12 @@ export class Scope {
140
140
 
141
141
  crawl(): void;
142
142
 
143
- push(opts: { id: t.LVal; init?: t.Expression | undefined; unique?: boolean | undefined; kind?: 'var' | 'let' | 'const' | undefined }): void;
143
+ push(opts: {
144
+ id: t.LVal;
145
+ init?: t.Expression | undefined;
146
+ unique?: boolean | undefined;
147
+ kind?: 'var' | 'let' | 'const' | undefined;
148
+ }): void;
144
149
 
145
150
  getProgramParent(): Scope;
146
151
 
@@ -194,13 +199,11 @@ export class Binding {
194
199
  constantViolations: NodePath[];
195
200
  }
196
201
 
197
- export type Visitor<S = {}> = VisitNodeObject<S, Node> &
198
- {
199
- [Type in Node['type']]?: VisitNode<S, Extract<Node, { type: Type }>>;
200
- } &
201
- {
202
- [K in keyof t.Aliases]?: VisitNode<S, t.Aliases[K]>;
203
- };
202
+ export type Visitor<S = {}> = VisitNodeObject<S, Node> & {
203
+ [Type in Node['type']]?: VisitNode<S, Extract<Node, { type: Type }>>;
204
+ } & {
205
+ [K in keyof t.Aliases]?: VisitNode<S, t.Aliases[K]>;
206
+ };
204
207
 
205
208
  export type VisitNode<S, P extends Node> = VisitNodeFunction<S, P> | VisitNodeObject<S, P>;
206
209
 
@@ -254,6 +257,8 @@ export class NodePath<T = Node> {
254
257
 
255
258
  getData(key: string, def?: any): any;
256
259
 
260
+ hasNode(): this is NodePath<NonNullable<this['node']>>;
261
+
257
262
  buildCodeFrameError<TError extends Error>(msg: string, Error?: new (msg: string) => TError): TError;
258
263
 
259
264
  traverse<T>(visitor: Visitor<T>, state: T): void;
@@ -548,6 +553,8 @@ export class NodePath<T = Node> {
548
553
  context?: boolean | TraversalContext,
549
554
  ): T[K] extends Array<Node | null | undefined>
550
555
  ? Array<NodePath<T[K][number]>>
556
+ : T[K] extends Array<Node | null | undefined> | null | undefined
557
+ ? Array<NodePath<NonNullable<T[K]>[number]>> | NodePath<null | undefined>
551
558
  : T[K] extends Node | null | undefined
552
559
  ? NodePath<T[K]>
553
560
  : never;