mirror of
https://github.com/denoland/deno.git
synced 2025-03-03 17:34:47 -05:00
parent
fdcc78500c
commit
272e9b82eb
8 changed files with 64 additions and 5 deletions
|
@ -298,6 +298,7 @@ impl ParsedModule {
|
||||||
legacy: true,
|
legacy: true,
|
||||||
emit_metadata: options.emit_metadata
|
emit_metadata: options.emit_metadata
|
||||||
}),
|
}),
|
||||||
|
helpers::inject_helpers(),
|
||||||
typescript::strip(),
|
typescript::strip(),
|
||||||
fixer(Some(&self.comments)),
|
fixer(Some(&self.comments)),
|
||||||
);
|
);
|
||||||
|
@ -413,6 +414,7 @@ pub fn transpile_module(
|
||||||
src: &str,
|
src: &str,
|
||||||
media_type: &MediaType,
|
media_type: &MediaType,
|
||||||
emit_options: &EmitOptions,
|
emit_options: &EmitOptions,
|
||||||
|
globals: &Globals,
|
||||||
cm: Rc<SourceMap>,
|
cm: Rc<SourceMap>,
|
||||||
) -> Result<(Rc<SourceFile>, Module), AnyError> {
|
) -> Result<(Rc<SourceFile>, Module), AnyError> {
|
||||||
// TODO(@kitsonk) DRY-up with ::parse()
|
// TODO(@kitsonk) DRY-up with ::parse()
|
||||||
|
@ -464,10 +466,11 @@ pub fn transpile_module(
|
||||||
legacy: true,
|
legacy: true,
|
||||||
emit_metadata: emit_options.emit_metadata
|
emit_metadata: emit_options.emit_metadata
|
||||||
}),
|
}),
|
||||||
|
helpers::inject_helpers(),
|
||||||
typescript::strip(),
|
typescript::strip(),
|
||||||
fixer(Some(&comments)),
|
fixer(Some(&comments)),
|
||||||
);
|
);
|
||||||
let module = swc_common::GLOBALS.set(&Globals::new(), || {
|
let module = swc_common::GLOBALS.set(globals, || {
|
||||||
helpers::HELPERS.set(&helpers::Helpers::new(false), || {
|
helpers::HELPERS.set(&helpers::Helpers::new(false), || {
|
||||||
module.fold_with(&mut passes)
|
module.fold_with(&mut passes)
|
||||||
})
|
})
|
||||||
|
|
|
@ -120,20 +120,23 @@ impl Error for GraphError {}
|
||||||
/// avoid a circular dependency with `ast`.
|
/// avoid a circular dependency with `ast`.
|
||||||
struct BundleLoader<'a> {
|
struct BundleLoader<'a> {
|
||||||
cm: Rc<swc_common::SourceMap>,
|
cm: Rc<swc_common::SourceMap>,
|
||||||
graph: &'a Graph2,
|
|
||||||
emit_options: &'a ast::EmitOptions,
|
emit_options: &'a ast::EmitOptions,
|
||||||
|
globals: &'a swc_common::Globals,
|
||||||
|
graph: &'a Graph2,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> BundleLoader<'a> {
|
impl<'a> BundleLoader<'a> {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
graph: &'a Graph2,
|
graph: &'a Graph2,
|
||||||
emit_options: &'a ast::EmitOptions,
|
emit_options: &'a ast::EmitOptions,
|
||||||
|
globals: &'a swc_common::Globals,
|
||||||
cm: Rc<swc_common::SourceMap>,
|
cm: Rc<swc_common::SourceMap>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
BundleLoader {
|
BundleLoader {
|
||||||
cm,
|
cm,
|
||||||
graph,
|
|
||||||
emit_options,
|
emit_options,
|
||||||
|
globals,
|
||||||
|
graph,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -158,6 +161,7 @@ impl swc_bundler::Load for BundleLoader<'_> {
|
||||||
&src,
|
&src,
|
||||||
&media_type,
|
&media_type,
|
||||||
self.emit_options,
|
self.emit_options,
|
||||||
|
self.globals,
|
||||||
self.cm.clone(),
|
self.cm.clone(),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
|
@ -965,9 +969,9 @@ impl Graph2 {
|
||||||
let cm = Rc::new(swc_common::SourceMap::new(
|
let cm = Rc::new(swc_common::SourceMap::new(
|
||||||
swc_common::FilePathMapping::empty(),
|
swc_common::FilePathMapping::empty(),
|
||||||
));
|
));
|
||||||
let loader = BundleLoader::new(self, emit_options, cm.clone());
|
|
||||||
let hook = Box::new(BundleHook);
|
|
||||||
let globals = swc_common::Globals::new();
|
let globals = swc_common::Globals::new();
|
||||||
|
let loader = BundleLoader::new(self, emit_options, &globals, cm.clone());
|
||||||
|
let hook = Box::new(BundleHook);
|
||||||
let bundler = swc_bundler::Bundler::new(
|
let bundler = swc_bundler::Bundler::new(
|
||||||
&globals,
|
&globals,
|
||||||
cm.clone(),
|
cm.clone(),
|
||||||
|
|
|
@ -2570,6 +2570,11 @@ itest!(no_check {
|
||||||
http_server: true,
|
http_server: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
itest!(no_check_decorators {
|
||||||
|
args: "run --quiet --reload --no-check no_check_decorators.ts",
|
||||||
|
output: "no_check_decorators.ts.out",
|
||||||
|
});
|
||||||
|
|
||||||
itest!(lib_ref {
|
itest!(lib_ref {
|
||||||
args: "run --quiet --unstable --reload lib_ref.ts",
|
args: "run --quiet --unstable --reload lib_ref.ts",
|
||||||
output: "lib_ref.ts.out",
|
output: "lib_ref.ts.out",
|
||||||
|
|
21
cli/tests/no_check_decorators.ts
Normal file
21
cli/tests/no_check_decorators.ts
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
/* eslint-disable */
|
||||||
|
function a() {
|
||||||
|
console.log("a(): evaluated");
|
||||||
|
return (
|
||||||
|
_target: any,
|
||||||
|
_propertyKey: string,
|
||||||
|
_descriptor: PropertyDescriptor,
|
||||||
|
) => {
|
||||||
|
console.log("a(): called");
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
class B {
|
||||||
|
@a()
|
||||||
|
method() {
|
||||||
|
console.log("method");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const b = new B();
|
||||||
|
b.method();
|
3
cli/tests/no_check_decorators.ts.out
Normal file
3
cli/tests/no_check_decorators.ts.out
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
a(): evaluated
|
||||||
|
a(): called
|
||||||
|
method
|
18
cli/tests/subdir/more_decorators.ts
Normal file
18
cli/tests/subdir/more_decorators.ts
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
/* eslint-disable */
|
||||||
|
function a() {
|
||||||
|
console.log("a(): evaluated");
|
||||||
|
return (
|
||||||
|
_target: any,
|
||||||
|
_propertyKey: string,
|
||||||
|
_descriptor: PropertyDescriptor,
|
||||||
|
) => {
|
||||||
|
console.log("a(): called");
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export class B {
|
||||||
|
@a()
|
||||||
|
method() {
|
||||||
|
console.log("method");
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,3 +1,5 @@
|
||||||
[WILDCARD]
|
[WILDCARD]
|
||||||
|
function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) {
|
||||||
|
[WILDCARD]
|
||||||
new SomeClass().test();
|
new SomeClass().test();
|
||||||
[WILDCARD]
|
[WILDCARD]
|
|
@ -1,5 +1,7 @@
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
|
|
||||||
|
import { B } from "./subdir/more_decorators.ts";
|
||||||
|
|
||||||
function Decorator() {
|
function Decorator() {
|
||||||
return function (
|
return function (
|
||||||
target: Record<string, any>,
|
target: Record<string, any>,
|
||||||
|
@ -20,3 +22,4 @@ class SomeClass {
|
||||||
}
|
}
|
||||||
|
|
||||||
new SomeClass().test();
|
new SomeClass().test();
|
||||||
|
new B().method();
|
||||||
|
|
Loading…
Add table
Reference in a new issue