0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-03-03 09:31:22 -05:00

fix: panic in bundler (#8168)

This commit fixes panic in bundler which was caused
by not setting thread-local slots.
This commit is contained in:
Bartek Iwańczuk 2020-10-30 12:19:49 +01:00 committed by GitHub
parent 5aeac00971
commit 4f57ca0daf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 35 additions and 1 deletions

View file

@ -467,7 +467,11 @@ pub fn transpile_module(
typescript::strip(),
fixer(Some(&comments)),
);
let module = module.fold_with(&mut passes);
let module = swc_common::GLOBALS.set(&Globals::new(), || {
helpers::HELPERS.set(&helpers::Helpers::new(false), || {
module.fold_with(&mut passes)
})
});
Ok((source_file, module))
}

View file

@ -2637,6 +2637,11 @@ itest!(ts_decorators {
output: "ts_decorators.ts.out",
});
itest!(ts_decorators_bundle {
args: "bundle ts_decorators_bundle.ts",
output: "ts_decorators_bundle.out",
});
itest!(ts_type_only_import {
args: "run --reload ts_type_only_import.ts",
output: "ts_type_only_import.ts.out",

View file

@ -0,0 +1,3 @@
[WILDCARD]
new SomeClass().test();
[WILDCARD]

View file

@ -0,0 +1,22 @@
/* eslint-disable */
function Decorator() {
return function (
target: Record<string, any>,
propertyKey: string,
descriptor: TypedPropertyDescriptor<any>,
) {
const originalFn: Function = descriptor.value as Function;
descriptor.value = async function (...args: any[]) {
return await originalFn.apply(this, args);
};
return descriptor;
};
}
class SomeClass {
@Decorator()
async test(): Promise<void> {}
}
new SomeClass().test();