@swc/core 1.15.40 → 1.16.2
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/Visitor.d.ts +4 -2
- package/Visitor.js +21 -13
- package/binding.d.ts +1 -0
- package/index.d.ts +1 -16
- package/index.js +58 -35
- package/package.json +14 -14
package/Visitor.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Accessibility, Argument, ArrayExpression, ArrayPattern, ArrowFunctionExpression, AssignmentExpression, AssignmentPattern, AssignmentPatternProperty, AssignmentProperty, AwaitExpression, BigIntLiteral, BinaryExpression, BindingIdentifier, BlockStatement, BooleanLiteral, BreakStatement, CallExpression, CatchClause, Class, ClassDeclaration, ClassExpression, ClassMember, ClassMethod, ClassProperty, ComputedPropName, ConditionalExpression, Constructor, ContinueStatement, DebuggerStatement, Declaration, Decorator, DefaultDecl, DoWhileStatement, EmptyStatement, ExportAllDeclaration, ExportDeclaration, ExportDefaultDeclaration, ExportDefaultExpression, ExportDefaultSpecifier, ExportNamedDeclaration, ExportNamespaceSpecifier, ExportSpecifier, ExprOrSpread, Expression, ExpressionStatement, Fn, ForInStatement, ForOfStatement, ForStatement, FunctionDeclaration, FunctionExpression, GetterProperty, Identifier, IfStatement, Import, ImportDeclaration, ImportDefaultSpecifier, ImportNamespaceSpecifier, ImportSpecifier, JSXAttrValue, JSXAttribute, JSXAttributeName, JSXAttributeOrSpread, JSXClosingElement, JSXClosingFragment, JSXElement, JSXElementChild, JSXElementName, JSXEmptyExpression, JSXExpressionContainer, JSXFragment, JSXMemberExpression, JSXNamespacedName, JSXObject, JSXOpeningElement, JSXOpeningFragment, JSXSpreadChild, JSXText, KeyValuePatternProperty, KeyValueProperty, LabeledStatement, MemberExpression, MetaProperty, MethodProperty, Module, ModuleDeclaration, ModuleExportName, ModuleItem, NamedExportSpecifier, NamedImportSpecifier, NewExpression, NullLiteral, NumericLiteral, ObjectExpression, ObjectPattern, ObjectPatternProperty, OptionalChainingCall, OptionalChainingExpression, Param, ParenthesisExpression, Pattern, PrivateMethod, PrivateName, PrivateProperty, Program, Property, PropertyName, RegExpLiteral, RestElement, ReturnStatement, Script, SequenceExpression, SetterProperty, SpreadElement, Statement, StaticBlock, StringLiteral, Super, SuperPropExpression, SwitchCase, SwitchStatement, TaggedTemplateExpression, TemplateLiteral, ThisExpression, ThrowStatement, TryStatement, TsAsExpression, TsCallSignatureDeclaration, TsConstAssertion, TsConstructSignatureDeclaration, TsEntityName, TsEnumDeclaration, TsEnumMember, TsEnumMemberId, TsExportAssignment, TsExpressionWithTypeArguments, TsExternalModuleReference, TsFnParameter, TsGetterSignature, TsImportEqualsDeclaration, TsIndexSignature, TsInstantiation, TsInterfaceBody, TsInterfaceDeclaration, TsMethodSignature, TsModuleBlock, TsModuleDeclaration, TsModuleName, TsModuleReference, TsNamespaceBody, TsNamespaceDeclaration, TsNamespaceExportDeclaration, TsNonNullExpression, TsParameterProperty, TsParameterPropertyParameter, TsPropertySignature, TsQualifiedName, TsSatisfiesExpression, TsSetterSignature, TsType, TsTypeAliasDeclaration, TsTypeAnnotation, TsTypeAssertion, TsTypeElement, TsTypeParameter, TsTypeParameterDeclaration, TsTypeParameterInstantiation, UnaryExpression, UpdateExpression, VariableDeclaration, VariableDeclarator, WhileStatement, WithStatement, YieldExpression } from "@swc/types";
|
|
1
|
+
import { Accessibility, Argument, ArrayExpression, ArrayPattern, ArrowFunctionExpression, AssignmentExpression, AssignmentPattern, AssignmentPatternProperty, AssignmentProperty, AwaitExpression, BigIntLiteral, BinaryExpression, BindingIdentifier, BlockStatement, BooleanLiteral, BreakStatement, CallExpression, CatchClause, Class, ClassDeclaration, ClassExpression, ClassMember, ClassMethod, ClassProperty, ComputedPropName, ConditionalExpression, Constructor, ContinueStatement, DebuggerStatement, Declaration, Decorator, DefaultDecl, DoWhileStatement, EmptyStatement, ExportAllDeclaration, ExportDeclaration, ExportDefaultDeclaration, ExportDefaultExpression, ExportDefaultSpecifier, ExportNamedDeclaration, ExportNamespaceSpecifier, ExportSpecifier, ExprOrSpread, Expression, ExpressionStatement, Fn, ForInStatement, ForOfStatement, ForStatement, FunctionBody, FunctionDeclaration, FunctionExpression, GetterProperty, Identifier, IfStatement, Import, ImportDeclaration, ImportDefaultSpecifier, ImportNamespaceSpecifier, ImportSpecifier, JSXAttrValue, JSXAttribute, JSXAttributeName, JSXAttributeOrSpread, JSXClosingElement, JSXClosingFragment, JSXElement, JSXElementChild, JSXElementName, JSXEmptyExpression, JSXExpressionContainer, JSXFragment, JSXMemberExpression, JSXNamespacedName, JSXObject, JSXOpeningElement, JSXOpeningFragment, JSXSpreadChild, JSXText, KeyValuePatternProperty, KeyValueProperty, LabeledStatement, MemberExpression, MetaProperty, MethodProperty, Module, ModuleDeclaration, ModuleExportName, ModuleItem, NamedExportSpecifier, NamedImportSpecifier, NewExpression, NullLiteral, NumericLiteral, ObjectExpression, ObjectPattern, ObjectPatternProperty, OptionalChainingCall, OptionalChainingExpression, Param, ParenthesisExpression, Pattern, PrivateMethod, PrivateName, PrivateProperty, Program, Property, PropertyName, RegExpLiteral, RestElement, ReturnStatement, Script, SequenceExpression, SetterProperty, SpreadElement, Statement, StaticBlock, StringLiteral, Super, SuperPropExpression, SwitchCase, SwitchStatement, TaggedTemplateExpression, TemplateLiteral, ThisExpression, ThrowStatement, TryStatement, TsAsExpression, TsCallSignatureDeclaration, TsConstAssertion, TsConstructSignatureDeclaration, TsEntityName, TsEnumDeclaration, TsEnumMember, TsEnumMemberId, TsExportAssignment, TsExpressionWithTypeArguments, TsExternalModuleReference, TsFnParameter, TsGetterSignature, TsImportEqualsDeclaration, TsIndexSignature, TsInstantiation, TsInterfaceBody, TsInterfaceDeclaration, TsMethodSignature, TsModuleBlock, TsModuleDeclaration, TsModuleName, TsModuleReference, TsNamespaceBody, TsNamespaceDeclaration, TsNamespaceExportDeclaration, TsNonNullExpression, TsParameterProperty, TsParameterPropertyParameter, TsPropertySignature, TsThisParameter, TsQualifiedName, TsSatisfiesExpression, TsSetterSignature, TsType, TsTypeAliasDeclaration, TsTypeAnnotation, TsTypeAssertion, TsTypeElement, TsTypeParameter, TsTypeParameterDeclaration, TsTypeParameterInstantiation, UnaryExpression, UpdateExpression, VariableDeclaration, VariableDeclarator, WhileStatement, WithStatement, YieldExpression } from "@swc/types";
|
|
2
2
|
/**
|
|
3
3
|
* @deprecated JavaScript API is deprecated. Please use Wasm plugin instead.
|
|
4
4
|
*/
|
|
@@ -36,7 +36,8 @@ export declare class Visitor {
|
|
|
36
36
|
visitSpreadElement(e: SpreadElement): SpreadElement;
|
|
37
37
|
visitOptionalExpression(e: Expression | undefined): Expression | undefined;
|
|
38
38
|
visitArrowFunctionExpression(e: ArrowFunctionExpression): Expression;
|
|
39
|
-
visitArrowBody(body:
|
|
39
|
+
visitArrowBody(body: FunctionBody | Expression): FunctionBody | Expression;
|
|
40
|
+
visitFunctionBody(body: FunctionBody): FunctionBody;
|
|
40
41
|
visitBlockStatement(block: BlockStatement): BlockStatement;
|
|
41
42
|
visitStatements(stmts: Statement[]): Statement[];
|
|
42
43
|
visitStatement(stmt: Statement): Statement;
|
|
@@ -90,6 +91,7 @@ export declare class Visitor {
|
|
|
90
91
|
visitTsIndexSignature(n: TsIndexSignature): TsIndexSignature;
|
|
91
92
|
visitTsFnParameters(params: TsFnParameter[]): TsFnParameter[];
|
|
92
93
|
visitTsFnParameter(n: TsFnParameter): TsFnParameter;
|
|
94
|
+
visitTsThisParameter(n: TsThisParameter): TsThisParameter;
|
|
93
95
|
visitPrivateProperty(n: PrivateProperty): ClassMember;
|
|
94
96
|
visitPrivateMethod(n: PrivateMethod): ClassMember;
|
|
95
97
|
visitPrivateName(n: PrivateName): PrivateName;
|
package/Visitor.js
CHANGED
|
@@ -210,12 +210,16 @@ class Visitor {
|
|
|
210
210
|
}
|
|
211
211
|
visitArrowBody(body) {
|
|
212
212
|
switch (body.type) {
|
|
213
|
-
case "
|
|
214
|
-
return this.
|
|
213
|
+
case "FunctionBody":
|
|
214
|
+
return this.visitFunctionBody(body);
|
|
215
215
|
default:
|
|
216
216
|
return this.visitExpression(body);
|
|
217
217
|
}
|
|
218
218
|
}
|
|
219
|
+
visitFunctionBody(body) {
|
|
220
|
+
body.stmts = this.visitStatements(body.stmts);
|
|
221
|
+
return body;
|
|
222
|
+
}
|
|
219
223
|
visitBlockStatement(block) {
|
|
220
224
|
block.stmts = this.visitStatements(block.stmts);
|
|
221
225
|
return block;
|
|
@@ -591,6 +595,10 @@ class Visitor {
|
|
|
591
595
|
n.typeAnnotation = this.visitTsTypeAnnotation(n.typeAnnotation);
|
|
592
596
|
return n;
|
|
593
597
|
}
|
|
598
|
+
visitTsThisParameter(n) {
|
|
599
|
+
n.typeAnnotation = this.visitTsTypeAnnotation(n.typeAnnotation);
|
|
600
|
+
return n;
|
|
601
|
+
}
|
|
594
602
|
visitPrivateProperty(n) {
|
|
595
603
|
n.decorators = this.visitDecorators(n.decorators);
|
|
596
604
|
n.key = this.visitPrivateName(n.key);
|
|
@@ -612,7 +620,7 @@ class Visitor {
|
|
|
612
620
|
n.key = this.visitPropertyName(n.key);
|
|
613
621
|
n.params = this.visitConstructorParameters(n.params);
|
|
614
622
|
if (n.body) {
|
|
615
|
-
n.body = this.
|
|
623
|
+
n.body = this.visitFunctionBody(n.body);
|
|
616
624
|
}
|
|
617
625
|
return n;
|
|
618
626
|
}
|
|
@@ -688,9 +696,12 @@ class Visitor {
|
|
|
688
696
|
}
|
|
689
697
|
visitFunction(n) {
|
|
690
698
|
n.decorators = this.visitDecorators(n.decorators);
|
|
699
|
+
if (n.thisParam) {
|
|
700
|
+
n.thisParam = this.visitTsThisParameter(n.thisParam);
|
|
701
|
+
}
|
|
691
702
|
n.params = this.visitParameters(n.params);
|
|
692
703
|
if (n.body) {
|
|
693
|
-
n.body = this.
|
|
704
|
+
n.body = this.visitFunctionBody(n.body);
|
|
694
705
|
}
|
|
695
706
|
n.returnType = this.visitTsTypeAnnotation(n.returnType);
|
|
696
707
|
n.typeParameters = this.visitTsTypeParameterDeclaration(n.typeParameters);
|
|
@@ -980,16 +991,16 @@ class Visitor {
|
|
|
980
991
|
}
|
|
981
992
|
visitSetterProperty(n) {
|
|
982
993
|
n.key = this.visitPropertyName(n.key);
|
|
983
|
-
n.
|
|
984
|
-
if (n.body) {
|
|
985
|
-
n.body = this.visitBlockStatement(n.body);
|
|
986
|
-
}
|
|
994
|
+
n.function = this.visitFunction(n.function);
|
|
987
995
|
return n;
|
|
988
996
|
}
|
|
989
997
|
visitMethodProperty(n) {
|
|
990
998
|
n.key = this.visitPropertyName(n.key);
|
|
999
|
+
if (n.thisParam) {
|
|
1000
|
+
n.thisParam = this.visitTsThisParameter(n.thisParam);
|
|
1001
|
+
}
|
|
991
1002
|
if (n.body) {
|
|
992
|
-
n.body = this.
|
|
1003
|
+
n.body = this.visitFunctionBody(n.body);
|
|
993
1004
|
}
|
|
994
1005
|
n.decorators = this.visitDecorators(n.decorators);
|
|
995
1006
|
n.params = this.visitParameters(n.params);
|
|
@@ -1004,10 +1015,7 @@ class Visitor {
|
|
|
1004
1015
|
}
|
|
1005
1016
|
visitGetterProperty(n) {
|
|
1006
1017
|
n.key = this.visitPropertyName(n.key);
|
|
1007
|
-
|
|
1008
|
-
n.body = this.visitBlockStatement(n.body);
|
|
1009
|
-
}
|
|
1010
|
-
n.typeAnnotation = this.visitTsTypeAnnotation(n.typeAnnotation);
|
|
1018
|
+
n.function = this.visitFunction(n.function);
|
|
1011
1019
|
return n;
|
|
1012
1020
|
}
|
|
1013
1021
|
visitAssignmentProperty(n) {
|
package/binding.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export declare function bundle(confItems: Buffer, signal?: AbortSignal | undefin
|
|
|
12
12
|
|
|
13
13
|
export declare function getTargetTriple(): string
|
|
14
14
|
|
|
15
|
+
/** @deprecated Trace profiling is disabled. This function is kept as a no-op for compatibility. */
|
|
15
16
|
export declare function initCustomTraceSubscriber(traceOutFilePath?: string | undefined | null): void
|
|
16
17
|
|
|
17
18
|
export declare function minify(code: Buffer, opts: Buffer, isJson: boolean, extras: NapiMinifyExtra, signal?: AbortSignal | undefined | null): Promise<TransformOutput>
|
package/index.d.ts
CHANGED
|
@@ -84,22 +84,7 @@ export declare function bundle(options?: BundleInput | string): Promise<{
|
|
|
84
84
|
export declare function minify(src: string | Buffer, opts?: JsMinifyOptions, extras?: NapiMinifyExtra): Promise<Output>;
|
|
85
85
|
export declare function minifySync(src: string | Buffer, opts?: JsMinifyOptions, extras?: NapiMinifyExtra): Output;
|
|
86
86
|
/**
|
|
87
|
-
*
|
|
88
|
-
* Currently only chromium's trace event format is supported.
|
|
89
|
-
* (https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU/preview)
|
|
90
|
-
*
|
|
91
|
-
* This should be called before calling any binding interfaces exported in `@swc/core`, such as
|
|
92
|
-
* `transform*`, or `parse*` or anything. To avoid breaking changes, each binding fn internally
|
|
93
|
-
* sets default trace subscriber if not set.
|
|
94
|
-
*
|
|
95
|
-
* Unlike other configuration, this does not belong to individual api surface using swcrc
|
|
96
|
-
* or api's parameters (`transform(..., {trace})`). This is due to current tracing subscriber
|
|
97
|
-
* can be configured only once for the global scope. Calling `registerGlobalTraceConfig` multiple
|
|
98
|
-
* time won't cause error, subsequent calls will be ignored.
|
|
99
|
-
*
|
|
100
|
-
* As name implies currently this is experimental interface may change over time without semver
|
|
101
|
-
* major breaking changes. Please provide feedbacks,
|
|
102
|
-
* or bug report at https://github.com/swc-project/swc/discussions.
|
|
87
|
+
* @deprecated Trace profiling is disabled. This function is kept as a no-op for compatibility.
|
|
103
88
|
*/
|
|
104
89
|
export declare function __experimental_registerGlobalTraceConfig(traceConfig: {
|
|
105
90
|
type: "traceEvent";
|
package/index.js
CHANGED
|
@@ -91,6 +91,50 @@ const bindings = (() => {
|
|
|
91
91
|
return binding;
|
|
92
92
|
}
|
|
93
93
|
})();
|
|
94
|
+
const programSourceContextKey = Symbol("@swc/core.programSourceContext");
|
|
95
|
+
function attachProgramSourceContext(program, sourceContext) {
|
|
96
|
+
if (!sourceContext || typeof program !== "object" || program === null) {
|
|
97
|
+
return program;
|
|
98
|
+
}
|
|
99
|
+
try {
|
|
100
|
+
Object.defineProperty(program, programSourceContextKey, {
|
|
101
|
+
configurable: true,
|
|
102
|
+
enumerable: false,
|
|
103
|
+
value: sourceContext,
|
|
104
|
+
writable: true,
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
catch (_) {
|
|
108
|
+
// Frozen user-created ASTs keep the legacy raw Program behavior.
|
|
109
|
+
}
|
|
110
|
+
return program;
|
|
111
|
+
}
|
|
112
|
+
function getProgramSourceContext(program) {
|
|
113
|
+
return program[programSourceContextKey];
|
|
114
|
+
}
|
|
115
|
+
function copyProgramSourceContext(from, to) {
|
|
116
|
+
return attachProgramSourceContext(to, getProgramSourceContext(from));
|
|
117
|
+
}
|
|
118
|
+
function parseProgramJson(json) {
|
|
119
|
+
const value = JSON.parse(json);
|
|
120
|
+
if (value &&
|
|
121
|
+
typeof value === "object" &&
|
|
122
|
+
"program" in value &&
|
|
123
|
+
value.program) {
|
|
124
|
+
return attachProgramSourceContext(value.program, value.sourceContext);
|
|
125
|
+
}
|
|
126
|
+
return value;
|
|
127
|
+
}
|
|
128
|
+
function stringifyProgram(program) {
|
|
129
|
+
const sourceContext = getProgramSourceContext(program);
|
|
130
|
+
if (sourceContext) {
|
|
131
|
+
return JSON.stringify({
|
|
132
|
+
program,
|
|
133
|
+
sourceContext,
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
return JSON.stringify(program);
|
|
137
|
+
}
|
|
94
138
|
/**
|
|
95
139
|
* Version of the swc binding.
|
|
96
140
|
*/
|
|
@@ -143,7 +187,7 @@ class Compiler {
|
|
|
143
187
|
}
|
|
144
188
|
if (bindings) {
|
|
145
189
|
const res = yield bindings.parse(src, toBuffer(options), filename);
|
|
146
|
-
return
|
|
190
|
+
return parseProgramJson(res);
|
|
147
191
|
}
|
|
148
192
|
else if (fallbackBindings) {
|
|
149
193
|
return fallbackBindings.parse(src, options);
|
|
@@ -155,7 +199,7 @@ class Compiler {
|
|
|
155
199
|
options = options || { syntax: "ecmascript" };
|
|
156
200
|
options.syntax = options.syntax || "ecmascript";
|
|
157
201
|
if (bindings) {
|
|
158
|
-
return
|
|
202
|
+
return parseProgramJson(bindings.parseSync(src, toBuffer(options), filename));
|
|
159
203
|
}
|
|
160
204
|
else if (fallbackBindings) {
|
|
161
205
|
return fallbackBindings.parseSync(src, options);
|
|
@@ -173,7 +217,7 @@ class Compiler {
|
|
|
173
217
|
throw new Error("Bindings not found.");
|
|
174
218
|
}
|
|
175
219
|
const res = yield bindings.parseFile(path, toBuffer(options));
|
|
176
|
-
return
|
|
220
|
+
return parseProgramJson(res);
|
|
177
221
|
});
|
|
178
222
|
}
|
|
179
223
|
parseFileSync(path, options) {
|
|
@@ -185,7 +229,7 @@ class Compiler {
|
|
|
185
229
|
else if (!bindings) {
|
|
186
230
|
throw new Error("Bindings not found.");
|
|
187
231
|
}
|
|
188
|
-
return
|
|
232
|
+
return parseProgramJson(bindings.parseFileSync(path, toBuffer(options)));
|
|
189
233
|
}
|
|
190
234
|
/**
|
|
191
235
|
* Note: this method should be invoked on the compiler instance used
|
|
@@ -195,7 +239,7 @@ class Compiler {
|
|
|
195
239
|
return __awaiter(this, void 0, void 0, function* () {
|
|
196
240
|
options = options || {};
|
|
197
241
|
if (bindings) {
|
|
198
|
-
return bindings.print(
|
|
242
|
+
return bindings.print(stringifyProgram(m), toBuffer(options));
|
|
199
243
|
}
|
|
200
244
|
else if (fallbackBindings) {
|
|
201
245
|
return fallbackBindings.print(m, options);
|
|
@@ -210,7 +254,7 @@ class Compiler {
|
|
|
210
254
|
printSync(m, options) {
|
|
211
255
|
options = options || {};
|
|
212
256
|
if (bindings) {
|
|
213
|
-
return bindings.printSync(
|
|
257
|
+
return bindings.printSync(stringifyProgram(m), toBuffer(options));
|
|
214
258
|
}
|
|
215
259
|
else if (fallbackBindings) {
|
|
216
260
|
return fallbackBindings.printSync(m, options);
|
|
@@ -232,9 +276,9 @@ class Compiler {
|
|
|
232
276
|
const m = typeof src === "string"
|
|
233
277
|
? yield this.parse(src, (_c = options === null || options === void 0 ? void 0 : options.jsc) === null || _c === void 0 ? void 0 : _c.parser, options.filename)
|
|
234
278
|
: src;
|
|
235
|
-
return this.transform(plugin(m), newOptions);
|
|
279
|
+
return this.transform(copyProgramSourceContext(m, plugin(m)), newOptions);
|
|
236
280
|
}
|
|
237
|
-
return bindings.transform(isModule ?
|
|
281
|
+
return bindings.transform(isModule ? stringifyProgram(src) : src, isModule, toBuffer(newOptions));
|
|
238
282
|
}
|
|
239
283
|
else if (fallbackBindings) {
|
|
240
284
|
if (plugin && !this.fallbackBindingsPluginWarningDisplayed) {
|
|
@@ -260,9 +304,9 @@ class Compiler {
|
|
|
260
304
|
const m = typeof src === "string"
|
|
261
305
|
? this.parseSync(src, (_c = options === null || options === void 0 ? void 0 : options.jsc) === null || _c === void 0 ? void 0 : _c.parser, options.filename)
|
|
262
306
|
: src;
|
|
263
|
-
return this.transformSync(plugin(m), newOptions);
|
|
307
|
+
return this.transformSync(copyProgramSourceContext(m, plugin(m)), newOptions);
|
|
264
308
|
}
|
|
265
|
-
return bindings.transformSync(isModule ?
|
|
309
|
+
return bindings.transformSync(isModule ? stringifyProgram(src) : src, isModule, toBuffer(newOptions));
|
|
266
310
|
}
|
|
267
311
|
else if (fallbackBindings) {
|
|
268
312
|
if (plugin && !this.fallbackBindingsPluginWarningDisplayed) {
|
|
@@ -291,7 +335,7 @@ class Compiler {
|
|
|
291
335
|
newOptions.filename = path;
|
|
292
336
|
if (plugin) {
|
|
293
337
|
const m = yield this.parseFile(path, (_c = options === null || options === void 0 ? void 0 : options.jsc) === null || _c === void 0 ? void 0 : _c.parser);
|
|
294
|
-
return this.transform(plugin(m), newOptions);
|
|
338
|
+
return this.transform(copyProgramSourceContext(m, plugin(m)), newOptions);
|
|
295
339
|
}
|
|
296
340
|
return bindings.transformFile(path, false, toBuffer(newOptions));
|
|
297
341
|
});
|
|
@@ -313,7 +357,7 @@ class Compiler {
|
|
|
313
357
|
newOptions.filename = path;
|
|
314
358
|
if (plugin) {
|
|
315
359
|
const m = this.parseFileSync(path, (_c = options === null || options === void 0 ? void 0 : options.jsc) === null || _c === void 0 ? void 0 : _c.parser);
|
|
316
|
-
return this.transformSync(plugin(m), newOptions);
|
|
360
|
+
return this.transformSync(copyProgramSourceContext(m, plugin(m)), newOptions);
|
|
317
361
|
}
|
|
318
362
|
return bindings.transformFileSync(path,
|
|
319
363
|
/* isModule */ false, toBuffer(newOptions));
|
|
@@ -388,31 +432,10 @@ function minifySync(src, opts, extras) {
|
|
|
388
432
|
return compiler.minifySync(src, opts, extras);
|
|
389
433
|
}
|
|
390
434
|
/**
|
|
391
|
-
*
|
|
392
|
-
* Currently only chromium's trace event format is supported.
|
|
393
|
-
* (https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU/preview)
|
|
394
|
-
*
|
|
395
|
-
* This should be called before calling any binding interfaces exported in `@swc/core`, such as
|
|
396
|
-
* `transform*`, or `parse*` or anything. To avoid breaking changes, each binding fn internally
|
|
397
|
-
* sets default trace subscriber if not set.
|
|
398
|
-
*
|
|
399
|
-
* Unlike other configuration, this does not belong to individual api surface using swcrc
|
|
400
|
-
* or api's parameters (`transform(..., {trace})`). This is due to current tracing subscriber
|
|
401
|
-
* can be configured only once for the global scope. Calling `registerGlobalTraceConfig` multiple
|
|
402
|
-
* time won't cause error, subsequent calls will be ignored.
|
|
403
|
-
*
|
|
404
|
-
* As name implies currently this is experimental interface may change over time without semver
|
|
405
|
-
* major breaking changes. Please provide feedbacks,
|
|
406
|
-
* or bug report at https://github.com/swc-project/swc/discussions.
|
|
435
|
+
* @deprecated Trace profiling is disabled. This function is kept as a no-op for compatibility.
|
|
407
436
|
*/
|
|
408
437
|
function __experimental_registerGlobalTraceConfig(traceConfig) {
|
|
409
|
-
|
|
410
|
-
// this ever.
|
|
411
|
-
if (bindings) {
|
|
412
|
-
if (traceConfig.type === "traceEvent") {
|
|
413
|
-
bindings.initCustomTraceSubscriber(traceConfig.fileName);
|
|
414
|
-
}
|
|
415
|
-
}
|
|
438
|
+
void traceConfig;
|
|
416
439
|
}
|
|
417
440
|
/**
|
|
418
441
|
* @ignore
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@swc/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.16.2",
|
|
4
4
|
"description": "Super-fast alternative for babel",
|
|
5
5
|
"homepage": "https://swc.rs",
|
|
6
6
|
"main": "./index.js",
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
],
|
|
84
84
|
"dependencies": {
|
|
85
85
|
"@swc/counter": "^0.1.3",
|
|
86
|
-
"@swc/types": "^0.1.
|
|
86
|
+
"@swc/types": "^0.1.28"
|
|
87
87
|
},
|
|
88
88
|
"devDependencies": {
|
|
89
89
|
"@napi-rs/cli": "^3.2.0",
|
|
@@ -92,18 +92,18 @@
|
|
|
92
92
|
"typescript": "^5.3.3"
|
|
93
93
|
},
|
|
94
94
|
"optionalDependencies": {
|
|
95
|
-
"@swc/core-darwin-x64": "1.
|
|
96
|
-
"@swc/core-win32-x64-msvc": "1.
|
|
97
|
-
"@swc/core-linux-x64-gnu": "1.
|
|
98
|
-
"@swc/core-linux-ppc64-gnu": "1.
|
|
99
|
-
"@swc/core-linux-s390x-gnu": "1.
|
|
100
|
-
"@swc/core-linux-x64-musl": "1.
|
|
101
|
-
"@swc/core-win32-ia32-msvc": "1.
|
|
102
|
-
"@swc/core-linux-arm-gnueabihf": "1.
|
|
103
|
-
"@swc/core-darwin-arm64": "1.
|
|
104
|
-
"@swc/core-linux-arm64-gnu": "1.
|
|
105
|
-
"@swc/core-linux-arm64-musl": "1.
|
|
106
|
-
"@swc/core-win32-arm64-msvc": "1.
|
|
95
|
+
"@swc/core-darwin-x64": "1.16.2",
|
|
96
|
+
"@swc/core-win32-x64-msvc": "1.16.2",
|
|
97
|
+
"@swc/core-linux-x64-gnu": "1.16.2",
|
|
98
|
+
"@swc/core-linux-ppc64-gnu": "1.16.2",
|
|
99
|
+
"@swc/core-linux-s390x-gnu": "1.16.2",
|
|
100
|
+
"@swc/core-linux-x64-musl": "1.16.2",
|
|
101
|
+
"@swc/core-win32-ia32-msvc": "1.16.2",
|
|
102
|
+
"@swc/core-linux-arm-gnueabihf": "1.16.2",
|
|
103
|
+
"@swc/core-darwin-arm64": "1.16.2",
|
|
104
|
+
"@swc/core-linux-arm64-gnu": "1.16.2",
|
|
105
|
+
"@swc/core-linux-arm64-musl": "1.16.2",
|
|
106
|
+
"@swc/core-win32-arm64-msvc": "1.16.2"
|
|
107
107
|
},
|
|
108
108
|
"scripts": {
|
|
109
109
|
"postinstall": "node postinstall.js",
|