mirror of
https://github.com/swc-project/swc.git
synced 2024-11-24 02:06:08 +03:00
fix(node-swc): Don't remove plugin from options (#1390)
This commit is contained in:
parent
8ef78a9e08
commit
a0898e8ce3
@ -106,18 +106,17 @@ export class Compiler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const plugin = options.plugin;
|
const { plugin, ...newOptions } = options;
|
||||||
delete options.plugin;
|
|
||||||
|
|
||||||
if (plugin) {
|
if (plugin) {
|
||||||
const m =
|
const m =
|
||||||
typeof src === "string"
|
typeof src === "string"
|
||||||
? await this.parse(src, options?.jsc?.parser)
|
? await this.parse(src, options?.jsc?.parser)
|
||||||
: src;
|
: src;
|
||||||
return this.transform(plugin(m), options);
|
return this.transform(plugin(m), newOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
return bindings.transform(isModule ? JSON.stringify(src) : src, isModule, toBuffer(options))
|
return bindings.transform(isModule ? JSON.stringify(src) : src, isModule, toBuffer(newOptions))
|
||||||
}
|
}
|
||||||
|
|
||||||
transformSync(src: string | Program, options?: Options): Output {
|
transformSync(src: string | Program, options?: Options): Output {
|
||||||
@ -129,19 +128,18 @@ export class Compiler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const plugin = options.plugin;
|
const { plugin, ...newOptions } = options;
|
||||||
delete options.plugin;
|
|
||||||
|
|
||||||
if (plugin) {
|
if (plugin) {
|
||||||
const m =
|
const m =
|
||||||
typeof src === "string" ? this.parseSync(src, options?.jsc?.parser) : src;
|
typeof src === "string" ? this.parseSync(src, options?.jsc?.parser) : src;
|
||||||
return this.transformSync(plugin(m), options);
|
return this.transformSync(plugin(m), newOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
return bindings.transformSync(
|
return bindings.transformSync(
|
||||||
isModule ? JSON.stringify(src) : src,
|
isModule ? JSON.stringify(src) : src,
|
||||||
isModule,
|
isModule,
|
||||||
toBuffer(options),
|
toBuffer(newOptions),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,15 +151,14 @@ export class Compiler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const plugin = options.plugin;
|
const { plugin, ...newOptions } = options;
|
||||||
delete options.plugin;
|
|
||||||
|
|
||||||
if (plugin) {
|
if (plugin) {
|
||||||
const m = await this.parseFile(path, options?.jsc?.parser);
|
const m = await this.parseFile(path, options?.jsc?.parser);
|
||||||
return this.transform(plugin(m), options);
|
return this.transform(plugin(m), newOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
return bindings.transformFile(path, false, toBuffer(options))
|
return bindings.transformFile(path, false, toBuffer(newOptions))
|
||||||
}
|
}
|
||||||
|
|
||||||
transformFileSync(path: string, options?: Options): Output {
|
transformFileSync(path: string, options?: Options): Output {
|
||||||
@ -172,15 +169,14 @@ export class Compiler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const plugin = options?.plugin;
|
const { plugin, ...newOptions } = options;
|
||||||
delete options?.plugin;
|
|
||||||
|
|
||||||
if (plugin) {
|
if (plugin) {
|
||||||
const m = this.parseFileSync(path, options?.jsc?.parser);
|
const m = this.parseFileSync(path, options?.jsc?.parser);
|
||||||
return this.transformSync(plugin(m), options);
|
return this.transformSync(plugin(m), newOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
return bindings.transformFileSync(path, /* isModule */ false, toBuffer(options));
|
return bindings.transformFileSync(path, /* isModule */ false, toBuffer(newOptions));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user