Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: swc-project/swc
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 2a97219e05ac4a55af476bac02bb99c95d7adeb1
Choose a base ref
...
head repository: swc-project/swc
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 694e78059270a0358da51b649e551066dc84b38a
Choose a head ref

Commits on Aug 19, 2022

  1. 1

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    b14d69e View commit details
  2. chore: Publish crates

    swc-bot committed Aug 19, 2022
    Copy the full SHA
    6de0a27 View commit details
  3. chore: Publish v1.2.240

    kdy1 committed Aug 19, 2022
    Copy the full SHA
    620259a View commit details
  4. 1

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    69f8945 View commit details
  5. chore: Publish crates

    swc-bot committed Aug 19, 2022
    Copy the full SHA
    1434376 View commit details
  6. 1

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    7f5095d View commit details
  7. chore: Publish crates

    swc-bot committed Aug 19, 2022
    Copy the full SHA
    ef4fdd8 View commit details
  8. 1

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    f2c1164 View commit details
  9. chore: Publish crates

    swc-bot committed Aug 19, 2022
    Copy the full SHA
    34d366e View commit details
  10. chore: Publish v1.2.241

    kdy1 committed Aug 19, 2022
    Copy the full SHA
    32bb36b View commit details
  11. 1

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    b717a68 View commit details
  12. chore: Publish crates

    swc-bot committed Aug 19, 2022
    Copy the full SHA
    4e9e64f View commit details

Commits on Aug 20, 2022

  1. 1

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    a3c1ac6 View commit details
  2. chore: Publish crates

    swc-bot committed Aug 20, 2022
    Copy the full SHA
    0f5d025 View commit details
  3. 1

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    2f7e322 View commit details
  4. chore: Publish crates

    swc-bot committed Aug 20, 2022
    Copy the full SHA
    ba70a54 View commit details
  5. 1

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    3cb6fc2 View commit details
  6. chore: Publish crates

    swc-bot committed Aug 20, 2022
    Copy the full SHA
    167ceb3 View commit details
  7. 1

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    288ae51 View commit details
  8. chore: Publish crates

    swc-bot committed Aug 20, 2022
    Copy the full SHA
    8b61c90 View commit details
  9. 1

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    82cc3ca View commit details
  10. chore: Publish crates

    swc-bot committed Aug 20, 2022
    Copy the full SHA
    eaf4d98 View commit details
  11. chore: Publish crates

    kdy1 committed Aug 20, 2022
    Copy the full SHA
    76bd04b View commit details
  12. chore: Publish crates

    kdy1 committed Aug 20, 2022
    Copy the full SHA
    38d7227 View commit details
  13. chore: Publish crates

    kdy1 committed Aug 20, 2022
    Copy the full SHA
    f688170 View commit details
  14. 1

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    78dd071 View commit details
  15. chore: Publish crates

    swc-bot committed Aug 20, 2022
    Copy the full SHA
    52250f0 View commit details

Commits on Aug 21, 2022

  1. 1

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    c3f6258 View commit details
  2. chore: Publish crates

    swc-bot committed Aug 21, 2022
    Copy the full SHA
    2c35990 View commit details

Commits on Aug 22, 2022

  1. 1

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    bee26a9 View commit details
  2. chore: Publish crates

    swc-bot committed Aug 22, 2022
    Copy the full SHA
    1d235e0 View commit details
  3. 1

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    0f6649c View commit details
  4. chore: Publish crates

    swc-bot committed Aug 22, 2022
    Copy the full SHA
    b3e03c4 View commit details
  5. 1

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    8645251 View commit details
  6. chore: Publish crates

    swc-bot committed Aug 22, 2022
    Copy the full SHA
    ceb6c2e View commit details
  7. 1

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    610296c View commit details
  8. chore: Publish crates

    swc-bot committed Aug 22, 2022
    Copy the full SHA
    03730d7 View commit details
  9. Copy the full SHA
    694e780 View commit details
Showing 1,773 changed files with 7,960 additions and 22,833 deletions.
1 change: 1 addition & 0 deletions .github/workflows/publish-node.yml
Original file line number Diff line number Diff line change
@@ -334,6 +334,7 @@ jobs:
yarn test
rm -rf node_modules
rm -rf target
rm -rf bindings/target
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
65 changes: 65 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -5,6 +5,53 @@



- **(es)** Improve sourcemap (#5569) ([2f7e322](https://github.com/swc-project/swc/commit/2f7e3222140aba2a0e13e307f18b42f6b39f084d))


- **(es/codgen)** Fix sourcemap of`BlockStmt` (#5570) ([288ae51](https://github.com/swc-project/swc/commit/288ae51fb130d5ea302fa89618921ccc3c57d7bc))


- **(es/compat)** Use separate `SyntaxContext` for class names (#5566) ([b717a68](https://github.com/swc-project/swc/commit/b717a68199fc965632e9513d2c57a47af23231d8))


- **(es/compat)** Fix destructuring assignments and updates of super properties (#5576) ([bee26a9](https://github.com/swc-project/swc/commit/bee26a9abb0478147aec2bedd533150204807057))


- **(es/compat)** Fix destructuring assignments and updates of super properties in async method (#5580) ([8645251](https://github.com/swc-project/swc/commit/86452511e715a7ba8447add81a60ce49905bb45c))


- **(es/helpers)** Fix an import (#5587) ([610296c](https://github.com/swc-project/swc/commit/610296cfa444d1f004cc5967c7f94347a7ccb0e8))


- **(es/parser)** Allow expr to follow `ClassExpr` (#5572) ([78dd071](https://github.com/swc-project/swc/commit/78dd071dabf5f9b5ca9b213bb5f5f0e5d76b40ab))


- **(es/parser)** Fix false-positives of yield used as a parameter in generator (#5564) ([c3f6258](https://github.com/swc-project/swc/commit/c3f62586bfbad6220cdc8cd7a678d9bec2445088))


- **(es/quote)** Allow cloning (#5571) ([82cc3ca](https://github.com/swc-project/swc/commit/82cc3ca7a4f27f932ed4e8b4e620d1d8b5f41bdc))

### Features



- **(css/ast)** Make `keyword` optional (#5543) ([a3c1ac6](https://github.com/swc-project/swc/commit/a3c1ac67d708b6c95ef9a9b0892df90bdb26ffe5))


- **(html/minifier)** Improve minification modes (#5568) ([3cb6fc2](https://github.com/swc-project/swc/commit/3cb6fc2a29b541c32ff95baf0a07021ffe0dd089))

### Testing



- **(es/transforms)** Enable tests for fixed issues (#5583) ([0f6649c](https://github.com/swc-project/swc/commit/0f6649c44fbd35cbb7f0b64bf9b5a175f002fdd9))

## [1.2.241] - 2022-08-19

### Bug Fixes



- **(ast)** Add attributes for `rkyv` (#5489) ([3569b20](https://github.com/swc-project/swc/commit/3569b20645a57999fd09ee62e082e08d2caeebcc))


@@ -16,6 +63,15 @@

- **(css/codegen)** Improve codegen of `@media` (#5544) ([fa7abe2](https://github.com/swc-project/swc/commit/fa7abe26cf2a9eab1d8bcd481cf6fb2dd02188a3))


- **(es/compat)** Handle `async` in class method parameters (#5560) ([f2c1164](https://github.com/swc-project/swc/commit/f2c116402621b64b49181407dba1bb7ae852cf13))


- **(es/fixer)** Wrap `yield` expression in `extends` (#5555) ([b14d69e](https://github.com/swc-project/swc/commit/b14d69e9b0427751a86d2260f10d4af7495d7ae8))


- **(es/helpers)** Add a missing helper (#5551) ([e930fea](https://github.com/swc-project/swc/commit/e930fea4cafce6452ace889a7a17c5abe071c492))

### Features


@@ -29,6 +85,9 @@
- **(es/minifier)** Optimize numeric property names (#5548) ([38b8ca0](https://github.com/swc-project/swc/commit/38b8ca05adf22d7096e4cc6856cd5fb1734656cd))


- **(es/minifier)** Remove more functions and classes (#5552) ([69f8945](https://github.com/swc-project/swc/commit/69f8945911e50d96978b0f49642cb79473178173))


- **(swc_core)** Implement engine diagnostics (#5515) ([f1a4263](https://github.com/swc-project/swc/commit/f1a42639541ef5a356079b7fb177a621ddd5a2c0))

### Miscellaneous Tasks
@@ -40,6 +99,12 @@

- **(ci)** Fix publish action ([bc9aef8](https://github.com/swc-project/swc/commit/bc9aef891e1dd4665c30854b67f6173767d96a22))

### Testing



- **(es/minifier)** Add tests for size (#5561) ([7f5095d](https://github.com/swc-project/swc/commit/7f5095dd5e569eab0e4415453144485aeef4d043))

## [1.2.239] - 2022-08-18

### Bug Fixes
86 changes: 43 additions & 43 deletions Cargo.lock
121 changes: 94 additions & 27 deletions bindings/Cargo.lock
2 changes: 1 addition & 1 deletion bindings/binding_core_node/Cargo.toml
Original file line number Diff line number Diff line change
@@ -48,7 +48,7 @@ tracing-chrome = "0.5.0"
tracing-futures = "0.2.5"
tracing-subscriber = { version = "0.3.9", features = ["env-filter"] }

swc_core = { version = "0.7.20", features = [
swc_core = { version = "0.8.1", features = [
"ast",
"common_concurrent",
"bundler",
4 changes: 2 additions & 2 deletions bindings/binding_core_wasm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ license = "Apache-2.0"
name = "binding_core_wasm"
publish = false
repository = "https://github.com/swc-project/swc.git"
version = "1.2.239"
version = "1.2.241"

[lib]
bench = false
@@ -20,7 +20,7 @@ swc_v2 = []
plugin = ["swc_core/plugin_transform_host_js"]

[dependencies]
swc_core = { version = "0.7.20", features = [
swc_core = { version = "0.8.1", features = [
"common_perf",
"binding_macro_wasm",
] }
2 changes: 1 addition & 1 deletion bindings/swc_cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -26,7 +26,7 @@ rayon = "1"
relative-path = "1.6.1"
serde = { version = "1", features = ["derive"] }
serde_json = { version = "1", features = ["unbounded_depth"] }
swc_core = { version = "0.7.20", features = [
swc_core = { version = "0.8.1", features = [
"trace_macro",
"common_concurrent",
"base",
6 changes: 3 additions & 3 deletions crates/binding_macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ edition = "2021"
license = "Apache-2.0"
name = "binding_macros"
repository = "https://github.com/swc-project/swc.git"
version = "0.3.0"
version = "0.5.0"

[lib]
bench = false
@@ -30,10 +30,10 @@ binding_wasm = [

[dependencies]
# Common deps for the SWC imports
swc = { optional = true, version = "0.215.0", path = "../swc" }
swc = { optional = true, version = "0.217.0", path = "../swc" }
swc_common = { optional = true, version = "0.27.7", path = "../swc_common" }
swc_ecma_ast = { optional = true, version = "0.90.10", path = "../swc_ecma_ast" }
swc_ecma_transforms = { optional = true, version = "0.183.4", path = "../swc_ecma_transforms" }
swc_ecma_transforms = { optional = true, version = "0.185.0", path = "../swc_ecma_transforms" }

# Optional deps for the wasm binding macro
anyhow = { optional = true, version = "1.0.58" }
10 changes: 5 additions & 5 deletions crates/dbg-swc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ edition = "2021"
license = "Apache-2.0"
name = "dbg-swc"
repository = "https://github.com/kdy1/dbg-swc.git"
version = "0.43.6"
version = "0.45.0"

[[bin]]
bench = false
@@ -21,12 +21,12 @@ swc_common = { version = "0.27.7", features = [
"concurrent",
], path = "../swc_common" }
swc_ecma_ast = { version = "0.90.10", path = "../swc_ecma_ast" }
swc_ecma_codegen = { version = "0.121.5", path = "../swc_ecma_codegen" }
swc_ecma_minifier = { version = "0.144.7", path = "../swc_ecma_minifier", features = [
swc_ecma_codegen = { version = "0.122.0", path = "../swc_ecma_codegen" }
swc_ecma_minifier = { version = "0.146.0", path = "../swc_ecma_minifier", features = [
"concurrent",
] }
swc_ecma_parser = { version = "0.117.5", path = "../swc_ecma_parser" }
swc_ecma_transforms_base = { version = "0.103.8", path = "../swc_ecma_transforms_base" }
swc_ecma_parser = { version = "0.118.0", path = "../swc_ecma_parser" }
swc_ecma_transforms_base = { version = "0.104.0", path = "../swc_ecma_transforms_base" }
swc_ecma_visit = { version = "0.76.6", path = "../swc_ecma_visit" }
swc_error_reporters = { version = "0.11.4", path = "../swc_error_reporters" }
swc_timer = { version = "0.15.4", path = "../swc_timer" }
17 changes: 8 additions & 9 deletions crates/dbg-swc/src/minify/compare.rs
Original file line number Diff line number Diff line change
@@ -18,26 +18,25 @@ pub struct CompareCommand {

impl CompareCommand {
pub fn run(self, cm: Arc<SourceMap>) -> Result<()> {
let minified_mangled = get_minified(cm.clone(), &self.path, true, true)?;
let code_mangled = print_js(cm, &minified_mangled.module, true)
.context("failed to convert ast to code")?;
let record = get_minified(cm.clone(), &self.path, true, false)?;
let code = print_js(cm, &record.module, true).context("failed to convert ast to code")?;

let esbuild_mangled = get_terser_output(&self.path, true, true)?;
let terser_mangled = get_terser_output(&self.path, true, false)?;

eprintln!("swc: {} bytes", code_mangled.as_bytes().len());
eprintln!("swc: {} bytes", code.as_bytes().len());
eprintln!(
"swc: {} bytes (newline stripped)",
code_mangled.replace("\\n", "_").as_bytes().len()
code.replace("\\n", "_").as_bytes().len()
);
std::fs::write("swc.output.js", code_mangled.as_bytes())
std::fs::write("swc.output.js", code.as_bytes())
.context("failed to write swc.output.js")?;

make_pretty("swc.output.js".as_ref())?;

std::fs::write("terser.output.js", esbuild_mangled.as_bytes())
std::fs::write("terser.output.js", terser_mangled.as_bytes())
.context("failed to write terser.output.js")?;

eprintln!("terser: {} bytes", esbuild_mangled.as_bytes().len());
eprintln!("terser: {} bytes", terser_mangled.as_bytes().len());
make_pretty("terser.output.js".as_ref())?;

{
10 changes: 9 additions & 1 deletion crates/dbg-swc/src/minify/ensure_size.rs
Original file line number Diff line number Diff line change
@@ -36,14 +36,22 @@ impl EnsureSize {

info!("Using {} files", all_files.len());

let results = GLOBALS.with(|globals| {
let mut results = GLOBALS.with(|globals| {
all_files
.par_iter()
.map(|js_file| GLOBALS.set(globals, || self.check_file(cm.clone(), js_file)))
.filter_map(|v| v.transpose())
.collect::<Result<Vec<_>>>()
})?;

results.sort_by_key(|f| {
if let Some(terser) = &f.terser {
f.swc.mangled_size as isize - terser.mangled_size as isize
} else {
0
}
});

for f in &results {
if let Some(terser) = &f.terser {
if f.swc.mangled_size > terser.mangled_size
20 changes: 10 additions & 10 deletions crates/dbg-swc/src/util/minifier.rs
Original file line number Diff line number Diff line change
@@ -116,15 +116,15 @@ impl VisitMut for Normalizer {
fn visit_mut_prop(&mut self, p: &mut Prop) {
p.visit_mut_children_with(self);

if let Prop::KeyValue(kv) = p {
if let PropName::Ident(k) = &kv.key {
match &*kv.value {
Expr::Ident(value) if k.sym == value.sym => {
*p = Prop::Shorthand(k.clone());
}
_ => {}
}
}
}
// if let Prop::KeyValue(kv) = p {
// if let PropName::Ident(k) = &kv.key {
// match &*kv.value {
// Expr::Ident(value) if k.sym == value.sym => {
// *p = Prop::Shorthand(k.clone());
// }
// _ => {}
// }
// }
// }
}
}
4 changes: 2 additions & 2 deletions crates/jsdoc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ edition = "2021"
include = ["Cargo.toml", "src/**/*.rs"]
license = "Apache-2.0"
name = "jsdoc"
version = "0.86.5"
version = "0.87.0"

[lib]
bench = false
@@ -21,5 +21,5 @@ swc_common = { version = "0.27.7", path = "../swc_common" }
anyhow = "1"
dashmap = "5.1.0"
swc_ecma_ast = { version = "0.90.10", path = "../swc_ecma_ast" }
swc_ecma_parser = { version = "0.117.5", path = "../swc_ecma_parser" }
swc_ecma_parser = { version = "0.118.0", path = "../swc_ecma_parser" }
testing = { version = "0.29.4", path = "../testing" }
30 changes: 15 additions & 15 deletions crates/swc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ include = ["Cargo.toml", "src/**/*.rs"]
license = "Apache-2.0"
name = "swc"
repository = "https://github.com/swc-project/swc.git"
version = "0.215.0"
version = "0.217.2"

[lib]
bench = false
@@ -63,34 +63,34 @@ swc_common = { version = "0.27.7", path = "../swc_common", features = [
] }
swc_config = { version = "0.1.1", path = "../swc_config" }
swc_ecma_ast = { version = "0.90.10", path = "../swc_ecma_ast" }
swc_ecma_codegen = { version = "0.121.5", path = "../swc_ecma_codegen" }
swc_ecma_ext_transforms = { version = "0.85.5", path = "../swc_ecma_ext_transforms" }
swc_ecma_lints = { version = "0.58.5", path = "../swc_ecma_lints" }
swc_ecma_codegen = { version = "0.122.0", path = "../swc_ecma_codegen" }
swc_ecma_ext_transforms = { version = "0.86.0", path = "../swc_ecma_ext_transforms" }
swc_ecma_lints = { version = "0.59.0", path = "../swc_ecma_lints" }
swc_ecma_loader = { version = "0.39.4", path = "../swc_ecma_loader", features = [
"cache",
"node",
"tsc",
] }
swc_ecma_minifier = { version = "0.144.7", path = "../swc_ecma_minifier" }
swc_ecma_parser = { version = "0.117.5", path = "../swc_ecma_parser" }
swc_ecma_preset_env = { version = "0.159.0", path = "../swc_ecma_preset_env" }
swc_ecma_transforms = { version = "0.183.4", path = "../swc_ecma_transforms", features = [
swc_ecma_minifier = { version = "0.146.0", path = "../swc_ecma_minifier" }
swc_ecma_parser = { version = "0.118.0", path = "../swc_ecma_parser" }
swc_ecma_preset_env = { version = "0.161.0", path = "../swc_ecma_preset_env" }
swc_ecma_transforms = { version = "0.185.0", path = "../swc_ecma_transforms", features = [
"compat",
"module",
"optimization",
"proposal",
"react",
"typescript",
] }
swc_ecma_transforms_base = { version = "0.103.8", path = "../swc_ecma_transforms_base" }
swc_ecma_transforms_compat = { version = "0.122.6", path = "../swc_ecma_transforms_compat" }
swc_ecma_transforms_optimization = { version = "0.152.4", path = "../swc_ecma_transforms_optimization" }
swc_ecma_utils = { version = "0.99.5", path = "../swc_ecma_utils" }
swc_ecma_transforms_base = { version = "0.104.0", path = "../swc_ecma_transforms_base" }
swc_ecma_transforms_compat = { version = "0.124.0", path = "../swc_ecma_transforms_compat" }
swc_ecma_transforms_optimization = { version = "0.154.0", path = "../swc_ecma_transforms_optimization" }
swc_ecma_utils = { version = "0.100.0", path = "../swc_ecma_utils" }
swc_ecma_visit = { version = "0.76.6", path = "../swc_ecma_visit" }
swc_error_reporters = { version = "0.11.4", path = "../swc_error_reporters" }
swc_node_comments = { version = "0.14.4", path = "../swc_node_comments" }
swc_plugin_proxy = { version = "0.18.13", path = "../swc_plugin_proxy", optional = true }
swc_plugin_runner = { version = "0.71.15", path = "../swc_plugin_runner", optional = true, default-features = false }
swc_plugin_runner = { version = "0.72.0", path = "../swc_plugin_runner", optional = true, default-features = false }
swc_timer = { version = "0.15.4", path = "../swc_timer" }
swc_visit = { version = "0.5.2", path = "../swc_visit" }
tracing = "0.1.32"
@@ -111,10 +111,10 @@ tracing = "0.1.32"
ansi_term = "0.12"
criterion = "0.3"
rayon = "1.5.1"
swc_ecma_lints = { version = "0.58.5", path = "../swc_ecma_lints", features = [
swc_ecma_lints = { version = "0.59.0", path = "../swc_ecma_lints", features = [
"non_critical_lints",
] }
swc_ecma_testing = { version = "0.14.5", path = "../swc_ecma_testing" }
swc_ecma_testing = { version = "0.15.0", path = "../swc_ecma_testing" }
swc_node_base = { version = "0.5.0", path = "../swc_node_base" }
testing = { version = "0.29.4", path = "../testing" }
walkdir = "2"
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"mappings": "AAAA,OAAO,aAAa,CAAC;AAErB,SAASA,CAAC,GAAG;IACTC,CAAC,EAAE,CAAC;CACP;AAED,SAASA,CAAC,GAAY;QAAXC,CAAC,GAADA,+CAAS,kBAAL,KAAK;IAChB,IAAIA,CAAC,EAAE;QACH,MAAM,IAAIC,KAAK,CAAC,OAAO,CAAC,CAAC;KAC5B;IACDF,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CACT;AAEDD,CAAC,EAAE,CAAC",
"mappings": "AAAA,OAAO,aAAa,CAAC;AAErB,SAASA,CAAC,GAAG;IACTC,CAAC,EAAE,CAAC;AACR,CAAC;AAED,SAASA,CAAC,GAAY;QAAXC,CAAC,GAADA,+CAAS,kBAAL,KAAK;IAChB,IAAIA,CAAC,EAAE;QACH,MAAM,IAAIC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC7B,CAAC;IACDF,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACV,CAAC;AAEDD,CAAC,EAAE,CAAC",
"names": [
"a",
"t",
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"mappings": "AAAA,OAAO,IAAMA,GAAG,GAAG,WAAM;IACrB,OAAO,CAAC,CAAC;CACZ,CAAC",
"mappings": "AAAA,OAAO,IAAMA,GAAG,GAAG,WAAM;IACrB,OAAO,CAAC,CAAC;AACb,CAAC,CAAC",
"names": [
"foo"
],
2 changes: 1 addition & 1 deletion crates/swc/tests/fixture/issues-2xxx/2423/output/index.map
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"mappings": "AAAA;AAAA,IAAUA,CAAC,AAKV;;QAJgBC,CAAC,KAADA,CAAC,GAAG,EAAE,AAAL;IACP,SAASC,CAAC,GAAG;QAChBC,OAAO,CAACC,GAAG,CAACH,CAAC,CAAC,CAAC;KAClB;MAFeC,CAAC,GAADA,CAAC;GAFXF,CAAC,KAADA,CAAC",
"mappings": "AAAA;AAAA,IAAUA,CAAC,AAKV;;QAJgBC,CAAC,KAADA,CAAC,GAAG,EAAE,AAAL;IACP,SAASC,CAAC,GAAG;QAChBC,OAAO,CAACC,GAAG,CAACH,CAAC,CAAC,CAAC;IACnB,CAAC;MAFeC,CAAC,GAADA,CAAC;GAFXF,CAAC,KAADA,CAAC",
"names": [
"A",
"v",
2 changes: 1 addition & 1 deletion crates/swc/tests/fixture/issues-3xxx/3782/output/index.map
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"mappings": "AAAA,WAAW;AACX;;;;;;;;IAAYA,GAAG;IAIFC,IAAI,MAAJA,IAAI;;qBAJI,OAAO;AAIrB,MAAMA,IAAI,GAAG,CAACC,EAAU,GAAsB;IACjD,sBAAsB;IACtB,OAAO,IAAIC,OAAO,CAAC,CAACC,OAAO,GACvBC,UAAU,CAAC,IAAM;YACbD,OAAO,CAAC,QAAQ,CAAC,CAAC;SACrB,EAAE,IAAI,CAAC,CACX,CAAC;CACL,AAAC",
"mappings": "AAAA,WAAW;AACX;;;;;;;;IAAYA,GAAG;IAIFC,IAAI,MAAJA,IAAI;;qBAJI,OAAO;AAIrB,MAAMA,IAAI,GAAG,CAACC,EAAU,GAAsB;IACjD,sBAAsB;IACtB,OAAO,IAAIC,OAAO,CAAC,CAACC,OAAO,GACvBC,UAAU,CAAC,IAAM;YACbD,OAAO,CAAC,QAAQ,CAAC,CAAC;QACtB,CAAC,EAAE,IAAI,CAAC,CACX,CAAC;AACN,CAAC,AAAC",
"names": [
"get",
"byID",
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"mappings": "AAAA,SAASA,IAAI,EAAEC,GAAG,EAAEC,UAAU,QAAQ,KAAK,CAAC;AAE5C,OAAO,MAAMC,GAAG,SAASD,UAAU;IAkB/BE,MAAM,GAAG;QACL,OAAOJ,IAAI,CAAC,UAAU,EAAE,IAAI,CAACK,IAAI,CAAC,KAAK,CAAC,CAAC;KAC5C;IAPDC,aAAc;QACV,KAAK,EAAE,CAAC;QACR,IAAI,CAACD,IAAI,GAAG,UAAU,CAAC;KAC1B;CAKJ;AAlBG,AAHSF,GAAG,CAGLI,MAAM,GAAGN,GAAG,CAAC;;;;IAIpB,CAAC,AAAC;AAEF,AATSE,GAAG,CASLK,UAAU,GAAG;IAChBH,IAAI,EAAE;QAAEI,IAAI,EAAEC,MAAM;KAAE;CACzB,AAAC;AAWNC,cAAc,CAACC,MAAM,CAAC,KAAK,EAAET,GAAG,CAAC,CAAC",
"mappings": "AAAA,SAASA,IAAI,EAAEC,GAAG,EAAEC,UAAU,QAAQ,KAAK,CAAC;AAE5C,OAAO,MAAMC,GAAG,SAASD,UAAU;IAkB/BE,MAAM,GAAG;QACL,OAAOJ,IAAI,CAAC,UAAU,EAAE,IAAI,CAACK,IAAI,CAAC,KAAK,CAAC,CAAC;IAC7C;IAPAC,aAAc;QACV,KAAK,EAAE,CAAC;QACR,IAAI,CAACD,IAAI,GAAG,UAAU,CAAC;IAC3B;CAKH;AAlBG,AAHSF,GAAG,CAGLI,MAAM,GAAGN,GAAG,CAAC;;;;IAIpB,CAAC,AAAC;AAEF,AATSE,GAAG,CASLK,UAAU,GAAG;IAChBH,IAAI,EAAE;QAAEI,IAAI,EAAEC,MAAM;KAAE;CACzB,AAAC;AAWNC,cAAc,CAACC,MAAM,CAAC,KAAK,EAAET,GAAG,CAAC,CAAC",
"names": [
"html",
"css",
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"mappings": "AAAA;AAAA,SAASA,IAAI,GAAG;IACZ,OAAO,GAAa,KAAK,GAAG,IAAI,GAAK,KAAK,GAAG,CAAC;CACjD;AACDA,IAAI,EAAE,CAAC",
"mappings": "AAAA;AAAA,SAASA,IAAI,GAAG;IACZ,OAAO,GAAa,KAAK,GAAG,IAAI,GAAK,KAAK,GAAG,CAAC;AAClD,CAAC;AACDA,IAAI,EAAE,CAAC",
"names": [
"test"
],
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"mappings": "AAAA;AAAA,SAASA,IAAI,GAAG;IACZ,0DAA0D;IAC1D,OAAO,WAAa,KAAK,GAAG,IAAI,KAAK,KAAK,GAAG,CAAC;CACjD;AACDA,IAAI,EAAE,CAAC",
"mappings": "AAAA;AAAA,SAASA,IAAI,GAAG;IACZ,0DAA0D;IAC1D,OAAO,WAAa,KAAK,GAAG,IAAI,KAAK,KAAK,GAAG,CAAC;AAClD,CAAC;AACDA,IAAI,EAAE,CAAC",
"names": [
"test"
],
22 changes: 22 additions & 0 deletions crates/swc/tests/fixture/issues-5xxx/5556/input/.swcrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"jsc": {
"parser": {
"syntax": "ecmascript",
"jsx": false
},
"target": "es5",
"loose": false,
"minify": {
"compress": false,
"mangle": false
}
},
"module": {
"type": "es6",
"strict": false,
"strictMode": false,
"lazy": false,
"noInterop": false
},
"minify": false
}
16 changes: 16 additions & 0 deletions crates/swc/tests/fixture/issues-5xxx/5556/input/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
var app;
var ctx;
x = function (y = app => {
return {
schedule: {
interval: '1m',
type: 'all',
disable: app.config.env === 'local'
},
*task(ctx) {
const res = yield ctx.curl('http://www.api.com/cache', { contentType: 'json' });
ctx.app.cache = res.data;
}
};
}) {
};
32 changes: 32 additions & 0 deletions crates/swc/tests/fixture/issues-5xxx/5556/output/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import regeneratorRuntime from "regenerator-runtime";
var app;
var ctx;
x = function x() {
var y = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : function(app) {
return {
schedule: {
interval: "1m",
type: "all",
disable: app.config.env === "local"
},
task: regeneratorRuntime.mark(function task(ctx) {
var res;
return regeneratorRuntime.wrap(function task$(_ctx) {
while(1)switch(_ctx.prev = _ctx.next){
case 0:
_ctx.next = 2;
return ctx.curl("http://www.api.com/cache", {
contentType: "json"
});
case 2:
res = _ctx.sent;
ctx.app.cache = res.data;
case 4:
case "end":
return _ctx.stop();
}
}, task);
})
};
};
};
22 changes: 22 additions & 0 deletions crates/swc/tests/fixture/issues-5xxx/5557/input/.swcrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"jsc": {
"parser": {
"syntax": "ecmascript",
"jsx": false
},
"target": "es5",
"loose": false,
"minify": {
"compress": false,
"mangle": false
}
},
"module": {
"type": "es6",
"strict": false,
"strictMode": false,
"lazy": false,
"noInterop": false
},
"minify": false
}
16 changes: 16 additions & 0 deletions crates/swc/tests/fixture/issues-5xxx/5557/input/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
var commands;
var command;
function retornaTempoArenaEmMilisegundos(distancia, velocidade) {
let conv = distancia * class LogExit {
constructor({logger}) {
this.logger = logger;
}
handle(commands) {
commands.forEach(command => command.close.subscribe(({exitCode}) => {
this.logger.logCommandEvent(`${ command.command } exited with code ${ exitCode }`, command);
}));
return commands;
}
} / velocidade * 1000;
return Math.round(conv);
}
31 changes: 31 additions & 0 deletions crates/swc/tests/fixture/issues-5xxx/5557/output/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import _class_call_check from "@swc/helpers/src/_class_call_check.mjs";
import _create_class from "@swc/helpers/src/_create_class.mjs";
var commands;
var command;
function retornaTempoArenaEmMilisegundos(distancia, velocidade) {
var conv = distancia * function() {
"use strict";
function LogExit(param) {
var logger = param.logger;
_class_call_check(this, LogExit);
this.logger = logger;
}
_create_class(LogExit, [
{
key: "handle",
value: function handle(commands) {
var _this = this;
commands.forEach(function(command) {
return command.close.subscribe(function(param) {
var exitCode = param.exitCode;
_this.logger.logCommandEvent("".concat(command.command, " exited with code ").concat(exitCode), command);
});
});
return commands;
}
}
]);
return LogExit;
}() / velocidade * 1000;
return Math.round(conv);
}
12 changes: 12 additions & 0 deletions crates/swc/tests/fixture/issues-5xxx/5558/1/input/.swcrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"jsc": {
"parser": {
"syntax": "ecmascript"
},
"target": "es2016"
},
"module": {
"type": "es6"
},
"isModule": true
}
4 changes: 4 additions & 0 deletions crates/swc/tests/fixture/issues-5xxx/5558/1/input/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class Foo {
bar(x = async () => await 1) {
}
}
6 changes: 6 additions & 0 deletions crates/swc/tests/fixture/issues-5xxx/5558/1/output/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs";
class Foo {
bar(x = /*#__PURE__*/ _async_to_generator(function*() {
return yield 1;
})) {}
}
22 changes: 22 additions & 0 deletions crates/swc/tests/fixture/issues-5xxx/5558/2/input/.swcrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"jsc": {
"parser": {
"syntax": "ecmascript",
"jsx": false
},
"target": "es5",
"loose": false,
"minify": {
"compress": false,
"mangle": false
}
},
"module": {
"type": "es6",
"strict": false,
"strictMode": false,
"lazy": false,
"noInterop": false
},
"minify": false
}
4 changes: 4 additions & 0 deletions crates/swc/tests/fixture/issues-5xxx/5558/2/input/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class Foo {
bar(x = async () => await 1) {
}
}
32 changes: 32 additions & 0 deletions crates/swc/tests/fixture/issues-5xxx/5558/2/output/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs";
import _class_call_check from "@swc/helpers/src/_class_call_check.mjs";
import _create_class from "@swc/helpers/src/_create_class.mjs";
import regeneratorRuntime from "regenerator-runtime";
var Foo = function() {
"use strict";
function Foo() {
_class_call_check(this, Foo);
}
_create_class(Foo, [
{
key: "bar",
value: function bar() {
var x = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : _async_to_generator(regeneratorRuntime.mark(function _callee() {
return regeneratorRuntime.wrap(function _callee$(_ctx) {
while(1)switch(_ctx.prev = _ctx.next){
case 0:
_ctx.next = 2;
return 1;
case 2:
return _ctx.abrupt("return", _ctx.sent);
case 3:
case "end":
return _ctx.stop();
}
}, _callee);
}));
}
}
]);
return Foo;
}();
2 changes: 1 addition & 1 deletion crates/swc/tests/fixture/sourcemap/002/output/index.map
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"mappings": "AAAA;;AAAA,eAAe,SAASA,UAAU,CAAC,KAAQ,EAAE;QAAV,AAAEC,IAAI,GAAN,KAAQ,CAANA,IAAI,AAAE;IACvC,qBAAO,oBAACC,KAAG,QAAED,IAAI,CAACE,GAAG,CAAO,CAAC;CAChC,CAAA;AAED,gBAAsBC,cAAc;WAAdA,eAAc;CAQnC;SARqBA,eAAc;IAAdA,eAAc,GAA7B,0DAAA,mBAAgC;;;;iDAC5B;wBACHC,KAAK,EAAE;4BACHJ,IAAI,EAAE;gCACFE,GAAG,EAAE,KAAK;6BACb;yBACJ;qBACJ;;;;;;KACJ,EAAA;WARqBC,eAAc",
"mappings": "AAAA;;AAAA,eAAe,SAASA,UAAU,CAAC,KAAQ,EAAE;QAAV,AAAEC,IAAI,GAAN,KAAQ,CAANA,IAAI,AAAE;IACvC,qBAAO,oBAACC,KAAG,QAAED,IAAI,CAACE,GAAG,CAAO,CAAC;AACjC,CAAC,CAAA;AAED,gBAAsBC,cAAc;WAAdA,eAAc;CAQnC;SARqBA,eAAc;IAAdA,eAAc,GAA7B,0DAAA,mBAAgC;;;;iDAC5B;wBACHC,KAAK,EAAE;4BACHJ,IAAI,EAAE;gCACFE,GAAG,EAAE,KAAK;6BACb;yBACJ;qBACJ;;;;;;IACL,CAAC,EAAA;WARqBC,eAAc",
"names": [
"StaticPage",
"data",
2 changes: 1 addition & 1 deletion crates/swc/tests/fixture/sourcemap/003/output/index.map
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"mappings": "AAAA,0FAAA,gBAAe,SAASA,CAAU,CAAC,CAAQ,CAAE,KAAV,AAAEC,CAAI,CAAN,CAAQ,CAANA,IAAI,AAAE,AACvC,QAAO,oBAACC,KAAG,MAAED,CAAI,CAACE,GAAG,CAAO,AAAC,CAChC,AAED,iBAAsBC,cAAc,UAAdA,CAAc,uBAQnC,SARqBA,CAAc,UAAdA,CAAc,CAA7B,SAAA,YAAgC,wFAC5B,CACHC,KAAK,CAAE,CACHJ,IAAI,CAAE,CACFE,GAAG,CAAE,KAAK,CACb,CACJ,CACJ,wCACJ,EAAA,wBAAA",
"mappings": "AAAA,0FAAA,gBAAe,SAASA,CAAU,CAAC,CAAQ,CAAE,KAAV,AAAEC,CAAI,CAAN,CAAQ,CAANA,IAAI,AAAE,AACvC,QAAO,oBAACC,KAAG,MAAED,CAAI,CAACE,GAAG,CAAO,AAAC,AACjC,CAAC,AAED,iBAAsBC,cAAc,UAAdA,CAAc,uBAQnC,SARqBA,CAAc,UAAdA,CAAc,CAA7B,SAAA,YAAgC,wFAC5B,CACHC,KAAK,CAAE,CACHJ,IAAI,CAAE,CACFE,GAAG,CAAE,KAAK,CACb,CACJ,CACJ,uCACL,CAAC,EAAA,wBAAA",
"names": [
"StaticPage",
"data",
2 changes: 1 addition & 1 deletion crates/swc/tests/fixture/sourcemap/004/output/index.map
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"mappings": "AEACA,CAAAA,IAAI,CAAC,gBAAkB,AAAC,GAAGA,IAAI,CAAC,gBAAkB,AAAC,IAAI,EAAE,CAAA,CAAEC,IAAI,CAAC;IAC7D;AAAC,WAAG;KAAC;IACL;AACU,QAAA,IAAI,EAAQ,SACdC,CAAuB,EACvBC,CAAmB,EACnBC,CAAmB,EACrB;YACE,YAAY,CAAC;gBFNxBC,CAAA,GAAA,SAAAC,CAAA,EAAA;gBAAA,IAAAC,CAAA,GAAAD,CAAA,CAAAC,IAAA;gBAAA,OAAA,CAAA,GCDDC,CAAA,CAAAC,GAAA,CAAA,CAAA,KAAA,EAAA;oBACAC,QAAA,EAAAH,CAAA,CAAAI,GAAA;iBACA,CAAA,CAAA;aACA;YAKYP,CAAmB,CAACQ,CAAC,CAACT,CAAmB,CAAC,EACrBC,CAAmB,CAACS,CAAC,CAACV,CAAmB,EAAE;gBACvCW,OAAO,EAAE,WAAY;oBACtC,OAAqBA,CAAO,CAAC;iBDZzB;gBAAqBC,OAAA,EAAA,WAAA;oBAC3C,OAAOV,CAAA,CAAA;iBAAM;aACd,CAAA;YAAA,IAAAG,CAAA,GAAAJ,CAAA,CAAA,IAAA,CAAA,EAAAU,CAAA,GAAA,CAAA,CAAA;SCKM;AAKP,QAAA,IAAA,EAAA,SAAAZ,CAAA,EAAAc,CAAA,EAAA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,CAAA,CAAA,IAAA,CAAA,EAAAU,CAAA,GAAA,CAAA,CAAA;QCKM,CAAA;AAKP,QAAA,IAAA,EAAA,SAAAZ,CAAA,EAAAc,CAAA,EAAAZ,CAAA,EAAA;YAAAa,CAAAA,MAAA,CAAAC,QAAA,GAAAD,MAAA,CAAAC,QAAA,IAAA,EAAA,CAAA,CAAAjB,IAAA,CAAA;gBAAA,SAAA;gBAAA,WAAA;oBAAA,OAAAG,CAAA,CAAA,IAAA,CAAA,CAAA;gBAAA,CAAA;aAAA,CAAA,CAAA;QAAA,CAAA;KAAA;IAAA,SAAAA,CAAA,EAAA;QAAAA,CAAA,CAAAe,CAAA,CAAA,CAAA,EAAA;AAAA,eAAA;AAAA,eAAA;AAAA,eAAA;SAAA,EAAA,WAAA;YAAA,OAAAf,CAAA,CAAAA,CAAA,CAAAgB,CAAA,GAAA,IAAA,CAAA,CAAA;QAAA,CAAA,CAAA,EAAAC,IAAA,GAAAjB,CAAA,CAAAe,CAAA,EAAA;IAAA,CAAA;CAAA,CAAA,CAAA",
"names": [
"self",
"push",
2 changes: 1 addition & 1 deletion crates/swc/tests/fixture/sourcemap/005/output/index.map
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"mappings": "AAAAA;;AAAAA,EAAE,CAAC,6DAA6D,gBAAE,0DAAA,mBAAY;QACpEC,KAAK,EACLC,IAAI,EAQJC,IAAI,EAQJC,IAAI,EAQJC,IAAI,EACJC,IAAI,EACJC,IAAI;;;;gBA3BJN,KAAK,GAAG;oBAAEO,GAAG,EAAE,WAAW;oBAAEC,CAAC,EAADA,CAAC;oBAAEC,CAAC,EAAE,EAAE;iBAAE,CAAC;;uBAC1BC,YAAY,CAACC,OAAO,EAAE,cAAc,EAAEX,KAAK,EAAE;oBAC5DY,OAAO,EAAE;wBACLC,MAAM,EAAE,YAAY;qBACvB;iBACJ,CAAC;;gBAJIZ,IAAI,YAIR,CAAA;gBACFa,MAAM,CAACb,IAAI,CAACc,MAAM,CAAC,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EX,KAAK,EAAE;oBAC5DY,OAAO,EAAE;wBACLC,MAAM,EAAE,YAAY;qBACvB;iBACJ,CAAC;;gBAJIV,IAAI,YAIR,CAAA;gBACFW,MAAM,CAACX,IAAI,CAACY,MAAM,CAAC,CAACC,IAAI,CAAC,GAAG,CAAC,CAAC;gBAC9BF,MAAM,CAACX,IAAI,CAACS,OAAO,CAACK,GAAG,CAAC,cAAc,CAAC,CAAC,CAACD,IAAI,CAAC,YAAY,CAAC,CAAC;;uBAExCf,IAAI,CAACiB,MAAM,EAAE;;gBAA3Bd,IAAI,GAAG,UAAsBe,UAAU,CAAA;;uBACzBjB,IAAI,CAACgB,MAAM,EAAE;;gBAA3Bb,IAAI,GAAG,UAAsBc,UAAU,CAAA;;uBACzBhB,IAAI,CAACe,MAAM,EAAE;;gBAA3BZ,IAAI,GAAG,UAAsBa,UAAU,CAAA;gBAE7CC,OAAO,CAACC,GAAG,CAAC;oBAAEC,OAAO,EAAPA,OAAO;oBAAEd,CAAC,EAADA,CAAC;oBAAEJ,IAAI,EAAJA,IAAI;oBAAEC,IAAI,EAAJA,IAAI;oBAAEC,IAAI,EAAJA,IAAI;iBAAE,CAAC,CAAC;gBAE9CQ,MAAM,CAACT,IAAI,CAAC,CAACkB,YAAY,CAACjB,IAAI,CAAC,CAAC;gBAChCQ,MAAM,CAACV,IAAI,CAAC,CAACmB,YAAY,CAAClB,IAAI,CAAC,CAAC;;;;;;AACpC,CAAC,EAAA,CAAC,CAAC",
"names": [
"it",
"query",
2 changes: 1 addition & 1 deletion crates/swc/tests/fixture/sourcemap/006/output/index.map
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"mappings": "AAAAA;;AAAAA,EAAE,CAAC,6DAA6D,gBAAE,0DAAA,mBAAY;QAOpEC,KAAK,EACLC,IAAI,EAQJC,IAAI,EAQJC,IAAI,EAQJC,IAAI,EACJC,IAAI,EACJC,IAAI;;;;gBA3BJN,KAAK,GAAG;oBAAEO,GAAG,EAAE,WAAW;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ture/sourcemap/007/output/index.map
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"mappings": "AAAA;;CAEC,GACD,OAAO,IAAMA,WAAW,GAAG,SAACC,IAAI,EAAK;IACjCC,OAAO,CAACC,GAAG,CAACF,IAAI,CAAC,CAAC;IAClBC,OAAO,CAACC,GAAG,CAACF,IAAI,CAAC,CAAC;IAClBC,OAAO,CAACC,GAAG,CAACF,IAAI,CAAC,CAAC;IAClBC,OAAO,CAACC,GAAG,CAACF,IAAI,CAAC,CAAC;CACrB,CAAC",
"mappings": "AAAA;;CAEC,GACD,OAAO,IAAMA,WAAW,GAAG,SAACC,IAAI,EAAK;IACjCC,OAAO,CAACC,GAAG,CAACF,IAAI,CAAC,CAAC;IAClBC,OAAO,CAACC,GAAG,CAACF,IAAI,CAAC,CAAC;IAClBC,OAAO,CAACC,GAAG,CAACF,IAAI,CAAC,CAAC;IAClBC,OAAO,CAACC,GAAG,CAACF,IAAI,CAAC,CAAC;AACtB,CAAC,CAAC",
"names": [
"LogSomeText",
"text",
2 changes: 1 addition & 1 deletion crates/swc/tests/fixture/sourcemap/008/output/index.map
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"mappings": "AAAAA;AAAAA,QAAQ,CAAC,oBAAoB,EAAE,IAAM;IACjCC,EAAE,CAAC,OAAO,EAAE,IAAM;QACdC,MAAM,CAAC,KAAK,CAAC,CAACC,IAAI,CAAC,IAAI,CAAC,CAAC;KAC5B,CAAC,CAAC;IAEHF,EAAE,CAAC,OAAO,EAAE,IAAM;QACd,EAAE,GACFC,MAAM,CAAC,KAAK,CAAC,CAACC,IAAI,CAAC,IAAI,CAAC,CAAC;KAC5B,CAAC,CAAC;IAEHF,EAAE,CAAC,OAAO,EAAE,IAAM;QACd;;SAEC,GACDC,MAAM,CAAC,KAAK,CAAC,CAACC,IAAI,CAAC,IAAI,CAAC,CAAC;KAC5B,CAAC,CAAC;IAEHF,EAAE,CAAC,OAAO,EAAE,IAAM;QACdC,MAAM,CAAC,KAAK,CAAC,CAACC,IAAI,CAAC,IAAI,CAAC,CAAC;KAC5B,CAAC,CAAC;CACN,CAAC,CAAC",
"mappings": "AAAAA;AAAAA,QAAQ,CAAC,oBAAoB,EAAE,IAAM;IACjCC,EAAE,CAAC,OAAO,EAAE,IAAM;QACdC,MAAM,CAAC,KAAK,CAAC,CAACC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAC;IAEHF,EAAE,CAAC,OAAO,EAAE,IAAM;QACd,EAAE,GACFC,MAAM,CAAC,KAAK,CAAC,CAACC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAC;IAEHF,EAAE,CAAC,OAAO,EAAE,IAAM;QACd;;SAEC,GACDC,MAAM,CAAC,KAAK,CAAC,CAACC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAC;IAEHF,EAAE,CAAC,OAAO,EAAE,IAAM;QACdC,MAAM,CAAC,KAAK,CAAC,CAACC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC",
"names": [
"describe",
"it",
16 changes: 16 additions & 0 deletions crates/swc/tests/fixture/sourcemap/011/input/.swcrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"sourceMaps": true,
"jsc": {
"target": "es2022",
"parser": {
"syntax": "typescript",
"tsx": true,
"decorators": true
},
"transform": {
"legacyDecorator": true,
"decoratorMetadata": true
},
"keepClassNames": true
}
}
36 changes: 36 additions & 0 deletions crates/swc/tests/fixture/sourcemap/011/input/CommentControlller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { Body, Controller, Delete, Param, Put, UseGuards, UseInterceptors } from '@nestjs/common';

import {
COMMENT_CONTROLLER_ROUTE,
COMMENT_DELETE_ENDPOINT,
COMMENT_UPDATE_ENDPOINT,
} from '@server/constants/controllers';
import { MongooseClassSerializerInterceptor } from '@server/interceptors/MongooseClassSerializerInterceptor';
import { Comment } from '@server/comment/schemas/CommentSchema';
import { CommentService } from '@server/comment/CommentService';
import { JwtAuthGuard } from '@server/auth/guards/JwtAuthGuard';
import { User } from '@server/decorators/UserDecorator';
import { User as UserType } from '@server/user/schemas/UserSchema';
import { UpdateCommentDto } from '@server/comment/dto/UpdateCommentDto';

@Controller(COMMENT_CONTROLLER_ROUTE)
@UseInterceptors(MongooseClassSerializerInterceptor(Comment))
export class CommentController {
constructor(private commentService: CommentService) { }

@UseGuards(JwtAuthGuard)
@Put(COMMENT_UPDATE_ENDPOINT)
public updateComment(
@Param('id') id: string,
@Body() updateCommentDto: UpdateCommentDto,
@User() user: UserType,
) {
return this.commentService.update(id, updateCommentDto, user.id);
}

@UseGuards(JwtAuthGuard)
@Delete(COMMENT_DELETE_ENDPOINT)
public deleteComment(@Param('id') id: string, @User() user: UserType) {
return this.commentService.delete(id, user.id);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"mappings": "AAAA;;;AAAA,SAASA,IAAI,EAAEC,UAAU,EAAEC,MAAM,EAAEC,KAAK,EAAEC,GAAG,EAAEC,SAAS,EAAEC,eAAe,QAAQ,gBAAgB,CAAC;AAElG,SACIC,wBAAwB,EACxBC,uBAAuB,EACvBC,uBAAuB,QACpB,+BAA+B,CAAC;AACvC,SAASC,kCAAkC,QAAQ,yDAAyD,CAAC;AAC7G,SAASC,OAAO,QAAQ,uCAAuC,CAAC;AAChE,SAASC,cAAc,QAAQ,gCAAgC,CAAC;AAChE,SAASC,YAAY,QAAQ,kCAAkC,CAAC;AAChE,SAASC,IAAI,QAAQ,kCAAkC,CAAC;AACxD,SAASA,IAAI,IAAIC,QAAQ,QAAQ,iCAAiC,CAAC;AACnE,SAASC,gBAAgB,QAAQ,sCAAsC,CAAC;AAIxE,WAAaC,iBAAiB,GAAvB;IACHC,YAAoBC,cAA8B,CAAE;QAAhCA,sBAAAA,cAA8B,CAAA;IAAI;IAI/CC,aAAa,CAChB,AAAaC,EAAU,EACvB,AAAQC,gBAAkC,EAC1C,AAAQC,IAAc,EACxB;QACE,OAAO,IAAI,CAACJ,cAAc,CAACK,MAAM,CAACH,EAAE,EAAEC,gBAAgB,EAAEC,IAAI,CAACF,EAAE,CAAC,CAAC;IACrE;IAIOI,aAAa,CAAC,AAAaJ,EAAU,EAAE,AAAQE,IAAc,EAAE;QAClE,OAAO,IAAI,CAACJ,cAAc,CAACO,MAAM,CAACL,EAAE,EAAEE,IAAI,CAACF,EAAE,CAAC,CAAC;IACnD;CACH,CAAA;;IAfIhB,SAAS,CAACQ,YAAY,CAAC;IACvBT,GAAG,CAACK,uBAAuB,CAAC;IAExBN,aAAAA,KAAK,CAAC,IAAI,CAAC,CAAA;IACXH,aAAAA,IAAI,EAAE,CAAA;IACNc,aAAAA,IAAI,EAAE,CAAA;;;;eADmB,gBAAgB,4BAAhB,gBAAgB;eAC5B,QAAQ,4BAAR,QAAQ;;GARjBG,iBAAiB;;IAazBZ,SAAS,CAACQ,YAAY,CAAC;IACvBX,MAAM,CAACM,uBAAuB,CAAC;IACVL,aAAAA,KAAK,CAAC,IAAI,CAAC,CAAA;IAAcW,aAAAA,IAAI,EAAE,CAAA;;;;eAAO,QAAQ,4BAAR,QAAQ;;GAf3DG,iBAAiB;AAAjBA,iBAAiB;IAF7BhB,UAAU,CAACM,wBAAwB,CAAC;IACpCD,eAAe,CAACI,kCAAkC,CAACC,OAAO,CAAC,CAAC;;;eAErB,cAAc,4BAAd,cAAc;;GADzCM,iBAAiB",
"names": [
"Body",
"Controller",
"Delete",
"Param",
"Put",
"UseGuards",
"UseInterceptors",
"COMMENT_CONTROLLER_ROUTE",
"COMMENT_DELETE_ENDPOINT",
"COMMENT_UPDATE_ENDPOINT",
"MongooseClassSerializerInterceptor",
"Comment",
"CommentService",
"JwtAuthGuard",
"User",
"UserType",
"UpdateCommentDto",
"CommentController",
"constructor",
"commentService",
"updateComment",
"id",
"updateCommentDto",
"user",
"update",
"deleteComment",
"delete"
],
"sources": [
"../../input/CommentControlller.ts"
],
"sourcesContent": [
"import { Body, Controller, Delete, Param, Put, UseGuards, UseInterceptors } from '@nestjs/common';\n\nimport {\n COMMENT_CONTROLLER_ROUTE,\n COMMENT_DELETE_ENDPOINT,\n COMMENT_UPDATE_ENDPOINT,\n} from '@server/constants/controllers';\nimport { MongooseClassSerializerInterceptor } from '@server/interceptors/MongooseClassSerializerInterceptor';\nimport { Comment } from '@server/comment/schemas/CommentSchema';\nimport { CommentService } from '@server/comment/CommentService';\nimport { JwtAuthGuard } from '@server/auth/guards/JwtAuthGuard';\nimport { User } from '@server/decorators/UserDecorator';\nimport { User as UserType } from '@server/user/schemas/UserSchema';\nimport { UpdateCommentDto } from '@server/comment/dto/UpdateCommentDto';\n\n@Controller(COMMENT_CONTROLLER_ROUTE)\n@UseInterceptors(MongooseClassSerializerInterceptor(Comment))\nexport class CommentController {\n constructor(private commentService: CommentService) { }\n\n @UseGuards(JwtAuthGuard)\n @Put(COMMENT_UPDATE_ENDPOINT)\n public updateComment(\n @Param('id') id: string,\n @Body() updateCommentDto: UpdateCommentDto,\n @User() user: UserType,\n ) {\n return this.commentService.update(id, updateCommentDto, user.id);\n }\n\n @UseGuards(JwtAuthGuard)\n @Delete(COMMENT_DELETE_ENDPOINT)\n public deleteComment(@Param('id') id: string, @User() user: UserType) {\n return this.commentService.delete(id, user.id);\n }\n}\n"
],
"version": 3
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import _ts_decorate from "@swc/helpers/src/_ts_decorate.mjs";
import _ts_metadata from "@swc/helpers/src/_ts_metadata.mjs";
import _ts_param from "@swc/helpers/src/_ts_param.mjs";
import { Body, Controller, Delete, Param, Put, UseGuards, UseInterceptors } from '@nestjs/common';
import { COMMENT_CONTROLLER_ROUTE, COMMENT_DELETE_ENDPOINT, COMMENT_UPDATE_ENDPOINT } from '@server/constants/controllers';
import { MongooseClassSerializerInterceptor } from '@server/interceptors/MongooseClassSerializerInterceptor';
import { Comment } from '@server/comment/schemas/CommentSchema';
import { CommentService } from '@server/comment/CommentService';
import { JwtAuthGuard } from '@server/auth/guards/JwtAuthGuard';
import { User } from '@server/decorators/UserDecorator';
import { User as UserType } from '@server/user/schemas/UserSchema';
import { UpdateCommentDto } from '@server/comment/dto/UpdateCommentDto';
export let CommentController = class CommentController {
constructor(commentService){
this.commentService = commentService;
}
updateComment(id, updateCommentDto, user) {
return this.commentService.update(id, updateCommentDto, user.id);
}
deleteComment(id, user) {
return this.commentService.delete(id, user.id);
}
};
_ts_decorate([
UseGuards(JwtAuthGuard),
Put(COMMENT_UPDATE_ENDPOINT),
_ts_param(0, Param('id')),
_ts_param(1, Body()),
_ts_param(2, User()),
_ts_metadata("design:type", Function),
_ts_metadata("design:paramtypes", [
String,
typeof UpdateCommentDto === "undefined" ? Object : UpdateCommentDto,
typeof UserType === "undefined" ? Object : UserType
])
], CommentController.prototype, "updateComment", null);
_ts_decorate([
UseGuards(JwtAuthGuard),
Delete(COMMENT_DELETE_ENDPOINT),
_ts_param(0, Param('id')),
_ts_param(1, User()),
_ts_metadata("design:type", Function),
_ts_metadata("design:paramtypes", [
String,
typeof UserType === "undefined" ? Object : UserType
])
], CommentController.prototype, "deleteComment", null);
CommentController = _ts_decorate([
Controller(COMMENT_CONTROLLER_ROUTE),
UseInterceptors(MongooseClassSerializerInterceptor(Comment)),
_ts_metadata("design:type", Function),
_ts_metadata("design:paramtypes", [
typeof CommentService === "undefined" ? Object : CommentService
])
], CommentController);
16 changes: 16 additions & 0 deletions crates/swc/tests/fixture/sourcemap/012/input/.swcrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"sourceMaps": true,
"jsc": {
"target": "es2022",
"parser": {
"syntax": "typescript",
"tsx": true,
"decorators": true
},
"transform": {
"legacyDecorator": true,
"decoratorMetadata": true
},
"keepClassNames": true
}
}
134 changes: 134 additions & 0 deletions crates/swc/tests/fixture/sourcemap/012/input/CommentService.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
import { Model, Connection as MongooseConnection } from 'mongoose';
import {
ForbiddenException,
Injectable,
InternalServerErrorException,
NotFoundException,
} from '@nestjs/common';
import { InjectModel, InjectConnection } from '@nestjs/mongoose';

import { Comment, CommentDocument } from '@server/comment/schemas/CommentSchema';
import { CreateCommentDto } from '@server/comment/dto/CreateCommentDto';
import { UpdateCommentDto } from '@server/comment/dto/UpdateCommentDto';
import { Post, PostDocument } from '@server/post/schemas/PostSchema';

@Injectable()
export class CommentService {
constructor(
@InjectModel(Comment.name) private commentModel: Model<CommentDocument>,
@InjectModel(Post.name) private postModel: Model<PostDocument>,
@InjectConnection() private readonly connection: MongooseConnection,
) {}

async getById(commentId: string): Promise<CommentDocument> {
const comment = await this.commentModel.findById(commentId);

if (!comment) {
throw new NotFoundException();
}

return comment.populate('author');
}

async create(
comment: CreateCommentDto,
postId: string,
userId: string,
): Promise<CommentDocument> {
const session = await this.connection.startSession();

session.startTransaction();

try {
const createdComment = await this.commentModel.create({
...comment,
author: userId,
postId,
});

if (!createdComment) {
throw new InternalServerErrorException('Comment was not created');
}

const { modifiedCount } = await this.postModel.updateOne(
{ _id: createdComment.postId },
{
$push: { comments: createdComment.id },
},
{ useFindAndModify: false },
);

if (modifiedCount === 0) {
throw new InternalServerErrorException('Comment was not created');
}

await session.commitTransaction();

return createdComment.populate('author');
} catch (error) {
await session.abortTransaction();

throw error;
} finally {
session.endSession();
}
}

async update(
commentId: string,
comment: UpdateCommentDto,
userId: string,
): Promise<CommentDocument> {
const { author } = await this.getById(commentId);

if (author.id !== userId) {
throw new ForbiddenException();
}

const updatedComment = await this.commentModel.findByIdAndUpdate(commentId, comment, {
new: true,
});

if (!updatedComment) {
throw new InternalServerErrorException('Comment was not updated');
}

return updatedComment.populate('author');
}

async delete(commentId: string, userId: string): Promise<void> {
const session = await this.connection.startSession();

session.startTransaction();

try {
const { author, postId } = await this.getById(commentId);

if (author.id !== userId) {
throw new ForbiddenException();
}

const { deletedCount } = await this.commentModel.deleteOne({ _id: commentId });

const { modifiedCount } = await this.postModel.updateOne(
{ _id: postId },
{
$pull: { comments: commentId },
},
{ useFindAndModify: false },
);

if (deletedCount === 0 || modifiedCount === 0) {
throw new InternalServerErrorException('Comment was not deleted');
}

await session.commitTransaction();
} catch (error) {
await session.abortTransaction();

throw error;
} finally {
session.endSession();
}
}
}
61 changes: 61 additions & 0 deletions crates/swc/tests/fixture/sourcemap/012/output/CommentService.map
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"mappings": "AAAA;;;AAAA,SAASA,KAAK,EAAEC,UAAU,IAAIC,kBAAkB,QAAQ,UAAU,CAAC;AACnE,SACEC,kBAAkB,EAClBC,UAAU,EACVC,4BAA4B,EAC5BC,iBAAiB,QACZ,gBAAgB,CAAC;AACxB,SAASC,WAAW,EAAEC,gBAAgB,QAAQ,kBAAkB,CAAC;AAEjE,SAASC,OAAO,QAAyB,uCAAuC,CAAC;AAGjF,SAASC,IAAI,QAAsB,iCAAiC,CAAC;AAGrE,WAAaC,cAAc,GAApB;IACLC,YACqCC,YAAoC,EACvCC,SAA8B,EACzBC,UAA8B,CACnE;QAHmCF,oBAAAA,YAAoC,CAAA;QACvCC,iBAAAA,SAA8B,CAAA;QACzBC,kBAAAA,UAA8B,CAAA;IAClE;UAEGC,OAAO,CAACC,SAAiB,EAA4B;QACzD,MAAMC,OAAO,GAAG,MAAM,IAAI,CAACL,YAAY,CAACM,QAAQ,CAACF,SAAS,CAAC,AAAC;QAE5D,IAAI,CAACC,OAAO,EAAE;YACZ,MAAM,IAAIZ,iBAAiB,EAAE,CAAC;QAChC,CAAC;QAED,OAAOY,OAAO,CAACE,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACpC;UAEMC,MAAM,CACVH,OAAyB,EACzBI,MAAc,EACdC,MAAc,EACY;QAC1B,MAAMC,OAAO,GAAG,MAAM,IAAI,CAACT,UAAU,CAACU,YAAY,EAAE,AAAC;QAErDD,OAAO,CAACE,gBAAgB,EAAE,CAAC;QAE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AAO,CAACc,gBAAgB,EAAE,CAAC;YAEjC,MAAMD,KAAK,CAAC;QACd,CAAC,QAAS;YACRb,OAAO,CAACe,UAAU,EAAE,CAAC;QACvB,CAAC;IACH;CACD,CAAA;AAtHY5B,cAAc;IAD1BP,UAAU,EAAE;IAGRG,aAAAA,WAAW,CAACE,OAAO,CAACuC,IAAI,CAAC,CAAA;IACzBzC,aAAAA,WAAW,CAACG,IAAI,CAACsC,IAAI,CAAC,CAAA;IACtBxC,aAAAA,gBAAgB,EAAE,CAAA;;;eAF8B,KAAK,4BAAL,KAAK;eACX,KAAK,4BAAL,KAAK;eACC,kBAAkB,4BAAlB,kBAAkB;;GAJ1DG,cAAc",
"names": [
"Model",
"Connection",
"MongooseConnection",
"ForbiddenException",
"Injectable",
"InternalServerErrorException",
"NotFoundException",
"InjectModel",
"InjectConnection",
"Comment",
"Post",
"CommentService",
"constructor",
"commentModel",
"postModel",
"connection",
"getById",
"commentId",
"comment",
"findById",
"populate",
"create",
"postId",
"userId",
"session",
"startSession",
"startTransaction",
"createdComment",
"author",
"modifiedCount",
"updateOne",
"_id",
"$push",
"comments",
"id",
"useFindAndModify",
"commitTransaction",
"error",
"abortTransaction",
"endSession",
"update",
"updatedComment",
"findByIdAndUpdate",
"new",
"delete",
"deletedCount",
"deleteOne",
"$pull",
"name"
],
"sources": [
"../../input/CommentService.ts"
],
"sourcesContent": [
"import { Model, Connection as MongooseConnection } from 'mongoose';\nimport {\n ForbiddenException,\n Injectable,\n InternalServerErrorException,\n NotFoundException,\n} from '@nestjs/common';\nimport { InjectModel, InjectConnection } from '@nestjs/mongoose';\n\nimport { Comment, CommentDocument } from '@server/comment/schemas/CommentSchema';\nimport { CreateCommentDto } from '@server/comment/dto/CreateCommentDto';\nimport { UpdateCommentDto } from '@server/comment/dto/UpdateCommentDto';\nimport { Post, PostDocument } from '@server/post/schemas/PostSchema';\n\n@Injectable()\nexport class CommentService {\n constructor(\n @InjectModel(Comment.name) private commentModel: Model<CommentDocument>,\n @InjectModel(Post.name) private postModel: Model<PostDocument>,\n @InjectConnection() private readonly connection: MongooseConnection,\n ) {}\n\n async getById(commentId: string): Promise<CommentDocument> {\n const comment = await this.commentModel.findById(commentId);\n\n if (!comment) {\n throw new NotFoundException();\n }\n\n return comment.populate('author');\n }\n\n async create(\n comment: CreateCommentDto,\n postId: string,\n userId: string,\n ): Promise<CommentDocument> {\n const session = await this.connection.startSession();\n\n session.startTransaction();\n\n try {\n const createdComment = await this.commentModel.create({\n ...comment,\n author: userId,\n postId,\n });\n\n if (!createdComment) {\n throw new InternalServerErrorException('Comment was not created');\n }\n\n const { modifiedCount } = await this.postModel.updateOne(\n { _id: createdComment.postId },\n {\n $push: { comments: createdComment.id },\n },\n { useFindAndModify: false },\n );\n\n if (modifiedCount === 0) {\n throw new InternalServerErrorException('Comment was not created');\n }\n\n await session.commitTransaction();\n\n return createdComment.populate('author');\n } catch (error) {\n await session.abortTransaction();\n\n throw error;\n } finally {\n session.endSession();\n }\n }\n\n async update(\n commentId: string,\n comment: UpdateCommentDto,\n userId: string,\n ): Promise<CommentDocument> {\n const { author } = await this.getById(commentId);\n\n if (author.id !== userId) {\n throw new ForbiddenException();\n }\n\n const updatedComment = await this.commentModel.findByIdAndUpdate(commentId, comment, {\n new: true,\n });\n\n if (!updatedComment) {\n throw new InternalServerErrorException('Comment was not updated');\n }\n\n return updatedComment.populate('author');\n }\n\n async delete(commentId: string, userId: string): Promise<void> {\n const session = await this.connection.startSession();\n\n session.startTransaction();\n\n try {\n const { author, postId } = await this.getById(commentId);\n\n if (author.id !== userId) {\n throw new ForbiddenException();\n }\n\n const { deletedCount } = await this.commentModel.deleteOne({ _id: commentId });\n\n const { modifiedCount } = await this.postModel.updateOne(\n { _id: postId },\n {\n $pull: { comments: commentId },\n },\n { useFindAndModify: false },\n );\n\n if (deletedCount === 0 || modifiedCount === 0) {\n throw new InternalServerErrorException('Comment was not deleted');\n }\n\n await session.commitTransaction();\n } catch (error) {\n await session.abortTransaction();\n\n throw error;\n } finally {\n session.endSession();\n }\n }\n}\n"
],
"version": 3
}
111 changes: 111 additions & 0 deletions crates/swc/tests/fixture/sourcemap/012/output/CommentService.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
import _ts_decorate from "@swc/helpers/src/_ts_decorate.mjs";
import _ts_metadata from "@swc/helpers/src/_ts_metadata.mjs";
import _ts_param from "@swc/helpers/src/_ts_param.mjs";
import { Model, Connection as MongooseConnection } from 'mongoose';
import { ForbiddenException, Injectable, InternalServerErrorException, NotFoundException } from '@nestjs/common';
import { InjectModel, InjectConnection } from '@nestjs/mongoose';
import { Comment } from '@server/comment/schemas/CommentSchema';
import { Post } from '@server/post/schemas/PostSchema';
export let CommentService = class CommentService {
constructor(commentModel, postModel, connection){
this.commentModel = commentModel;
this.postModel = postModel;
this.connection = connection;
}
async getById(commentId) {
const comment = await this.commentModel.findById(commentId);
if (!comment) {
throw new NotFoundException();
}
return comment.populate('author');
}
async create(comment, postId, userId) {
const session = await this.connection.startSession();
session.startTransaction();
try {
const createdComment = await this.commentModel.create({
...comment,
author: userId,
postId
});
if (!createdComment) {
throw new InternalServerErrorException('Comment was not created');
}
const { modifiedCount } = await this.postModel.updateOne({
_id: createdComment.postId
}, {
$push: {
comments: createdComment.id
}
}, {
useFindAndModify: false
});
if (modifiedCount === 0) {
throw new InternalServerErrorException('Comment was not created');
}
await session.commitTransaction();
return createdComment.populate('author');
} catch (error) {
await session.abortTransaction();
throw error;
} finally{
session.endSession();
}
}
async update(commentId, comment, userId) {
const { author } = await this.getById(commentId);
if (author.id !== userId) {
throw new ForbiddenException();
}
const updatedComment = await this.commentModel.findByIdAndUpdate(commentId, comment, {
new: true
});
if (!updatedComment) {
throw new InternalServerErrorException('Comment was not updated');
}
return updatedComment.populate('author');
}
async delete(commentId, userId) {
const session = await this.connection.startSession();
session.startTransaction();
try {
const { author , postId } = await this.getById(commentId);
if (author.id !== userId) {
throw new ForbiddenException();
}
const { deletedCount } = await this.commentModel.deleteOne({
_id: commentId
});
const { modifiedCount } = await this.postModel.updateOne({
_id: postId
}, {
$pull: {
comments: commentId
}
}, {
useFindAndModify: false
});
if (deletedCount === 0 || modifiedCount === 0) {
throw new InternalServerErrorException('Comment was not deleted');
}
await session.commitTransaction();
} catch (error) {
await session.abortTransaction();
throw error;
} finally{
session.endSession();
}
}
};
CommentService = _ts_decorate([
Injectable(),
_ts_param(0, InjectModel(Comment.name)),
_ts_param(1, InjectModel(Post.name)),
_ts_param(2, InjectConnection()),
_ts_metadata("design:type", Function),
_ts_metadata("design:paramtypes", [
typeof Model === "undefined" ? Object : Model,
typeof Model === "undefined" ? Object : Model,
typeof MongooseConnection === "undefined" ? Object : MongooseConnection
])
], CommentService);
16 changes: 16 additions & 0 deletions crates/swc/tests/fixture/sourcemap/013/input/.swcrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"sourceMaps": true,
"jsc": {
"target": "es2022",
"parser": {
"syntax": "typescript",
"tsx": true,
"decorators": true
},
"transform": {
"legacyDecorator": true,
"decoratorMetadata": true
},
"keepClassNames": true
}
}
80 changes: 80 additions & 0 deletions crates/swc/tests/fixture/sourcemap/013/input/PistController.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import {
Body,
Controller,
Delete,
Get,
Param,
Post,
Put,
UseGuards,
UseInterceptors,
} from '@nestjs/common';

import {
POST_CONTROLLER_ROUTE,
POST_DELETE_ENDPOINT,
POST_GET_ALL_ENDPOINT,
POST_GET_ENDPOINT,
POST_CREATE_COMMENT_ENDPOINT,
POST_CREATE_ENDPOINT,
POST_UPDATE_ENDPOINT,
} from '@server/constants/controllers';
import { MongooseClassSerializerInterceptor } from '@server/interceptors/MongooseClassSerializerInterceptor';
import { Post as PostType } from '@server/post/schemas/PostSchema';
import { PostService } from '@server/post/PostService';
import { CreatePostDto } from '@server/post/dto/CreatePostDto';
import { JwtAuthGuard } from '@server/auth/guards/JwtAuthGuard';
import { User } from '@server/decorators/UserDecorator';
import { User as UserType } from '@server/user/schemas/UserSchema';
import { CreateCommentDto } from '@server/comment/dto/CreateCommentDto';
import { CommentService } from '@server/comment/CommentService';
import { Comment } from '@server/comment/schemas/CommentSchema';

@Controller(POST_CONTROLLER_ROUTE)
@UseInterceptors(MongooseClassSerializerInterceptor(PostType))
export class PostController {
constructor(private postService: PostService, private commentService: CommentService) { }

@Get(POST_GET_ALL_ENDPOINT)
public getPosts() {
return this.postService.getAll();
}

@Get(POST_GET_ENDPOINT)
public getPost(@Param('id') id: string) {
return this.postService.getById(id);
}

@UseGuards(JwtAuthGuard)
@Post(POST_CREATE_ENDPOINT)
public createPost(@Body() createPostDto: CreatePostDto, @User() user: UserType) {
return this.postService.create(createPostDto, user.id);
}

@UseGuards(JwtAuthGuard)
@Put(POST_UPDATE_ENDPOINT)
public updatePost(
@Param('id') id: string,
@Body() updatePostDto: CreatePostDto,
@User() user: UserType,
) {
return this.postService.update(id, updatePostDto, user.id);
}

@UseGuards(JwtAuthGuard)
@Delete(POST_DELETE_ENDPOINT)
public deletePost(@Param('id') id: string, @User() user: UserType) {
return this.postService.delete(id, user.id);
}

@UseInterceptors(MongooseClassSerializerInterceptor(Comment))
@UseGuards(JwtAuthGuard)
@Post(POST_CREATE_COMMENT_ENDPOINT)
public createPostComment(
@Param('id') id: string,
@Body() createCommentDto: CreateCommentDto,
@User() user: UserType,
) {
return this.commentService.create(createCommentDto, id, user.id);
}
}
58 changes: 58 additions & 0 deletions crates/swc/tests/fixture/sourcemap/013/output/PistController.map
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"mappings": "AAAA;;;AAAA,SACIA,IAAI,EACJC,UAAU,EACVC,MAAM,EACNC,GAAG,EACHC,KAAK,EACLC,IAAI,EACJC,GAAG,EACHC,SAAS,EACTC,eAAe,QACZ,gBAAgB,CAAC;AAExB,SACIC,qBAAqB,EACrBC,oBAAoB,EACpBC,qBAAqB,EACrBC,iBAAiB,EACjBC,4BAA4B,EAC5BC,oBAAoB,EACpBC,oBAAoB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CAAC,CAAA;IACXJ,aAAAA,IAAI,EAAE,CAAA;IACNqB,aAAAA,IAAI,EAAE,CAAA;;;;eADmB,gBAAgB,4BAAhB,gBAAgB;eAC5B,QAAQ,4BAAR,QAAQ;;GAzCjBK,cAAc;AAAdA,cAAc;IAF1BzB,UAAU,CAACQ,qBAAqB,CAAC;IACjCD,eAAe,CAACQ,kCAAkC,CAACC,QAAQ,CAAC,CAAC;;;eAEzB,WAAW,4BAAX,WAAW;eAA0B,cAAc,4BAAd,cAAc;;GAD3ES,cAAc",
"names": [
"Body",
"Controller",
"Delete",
"Get",
"Param",
"Post",
"Put",
"UseGuards",
"UseInterceptors",
"POST_CONTROLLER_ROUTE",
"POST_DELETE_ENDPOINT",
"POST_GET_ALL_ENDPOINT",
"POST_GET_ENDPOINT",
"POST_CREATE_COMMENT_ENDPOINT",
"POST_CREATE_ENDPOINT",
"POST_UPDATE_ENDPOINT",
"MongooseClassSerializerInterceptor",
"PostType",
"PostService",
"CreatePostDto",
"JwtAuthGuard",
"User",
"UserType",
"CreateCommentDto",
"CommentService",
"Comment",
"PostController",
"constructor",
"postService",
"commentService",
"getPosts",
"getAll",
"getPost",
"id",
"getById",
"createPost",
"createPostDto",
"user",
"create",
"updatePost",
"updatePostDto",
"update",
"deletePost",
"delete",
"createPostComment",
"createCommentDto"
],
"sources": [
"../../input/PistController.ts"
],
"sourcesContent": [
"import {\n Body,\n Controller,\n Delete,\n Get,\n Param,\n Post,\n Put,\n UseGuards,\n UseInterceptors,\n} from '@nestjs/common';\n\nimport {\n POST_CONTROLLER_ROUTE,\n POST_DELETE_ENDPOINT,\n POST_GET_ALL_ENDPOINT,\n POST_GET_ENDPOINT,\n POST_CREATE_COMMENT_ENDPOINT,\n POST_CREATE_ENDPOINT,\n POST_UPDATE_ENDPOINT,\n} from '@server/constants/controllers';\nimport { MongooseClassSerializerInterceptor } from '@server/interceptors/MongooseClassSerializerInterceptor';\nimport { Post as PostType } from '@server/post/schemas/PostSchema';\nimport { PostService } from '@server/post/PostService';\nimport { CreatePostDto } from '@server/post/dto/CreatePostDto';\nimport { JwtAuthGuard } from '@server/auth/guards/JwtAuthGuard';\nimport { User } from '@server/decorators/UserDecorator';\nimport { User as UserType } from '@server/user/schemas/UserSchema';\nimport { CreateCommentDto } from '@server/comment/dto/CreateCommentDto';\nimport { CommentService } from '@server/comment/CommentService';\nimport { Comment } from '@server/comment/schemas/CommentSchema';\n\n@Controller(POST_CONTROLLER_ROUTE)\n@UseInterceptors(MongooseClassSerializerInterceptor(PostType))\nexport class PostController {\n constructor(private postService: PostService, private commentService: CommentService) { }\n\n @Get(POST_GET_ALL_ENDPOINT)\n public getPosts() {\n return this.postService.getAll();\n }\n\n @Get(POST_GET_ENDPOINT)\n public getPost(@Param('id') id: string) {\n return this.postService.getById(id);\n }\n\n @UseGuards(JwtAuthGuard)\n @Post(POST_CREATE_ENDPOINT)\n public createPost(@Body() createPostDto: CreatePostDto, @User() user: UserType) {\n return this.postService.create(createPostDto, user.id);\n }\n\n @UseGuards(JwtAuthGuard)\n @Put(POST_UPDATE_ENDPOINT)\n public updatePost(\n @Param('id') id: string,\n @Body() updatePostDto: CreatePostDto,\n @User() user: UserType,\n ) {\n return this.postService.update(id, updatePostDto, user.id);\n }\n\n @UseGuards(JwtAuthGuard)\n @Delete(POST_DELETE_ENDPOINT)\n public deletePost(@Param('id') id: string, @User() user: UserType) {\n return this.postService.delete(id, user.id);\n }\n\n @UseInterceptors(MongooseClassSerializerInterceptor(Comment))\n @UseGuards(JwtAuthGuard)\n @Post(POST_CREATE_COMMENT_ENDPOINT)\n public createPostComment(\n @Param('id') id: string,\n @Body() createCommentDto: CreateCommentDto,\n @User() user: UserType,\n ) {\n return this.commentService.create(createCommentDto, id, user.id);\n }\n}\n"
],
"version": 3
}
110 changes: 110 additions & 0 deletions crates/swc/tests/fixture/sourcemap/013/output/PistController.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
import _ts_decorate from "@swc/helpers/src/_ts_decorate.mjs";
import _ts_metadata from "@swc/helpers/src/_ts_metadata.mjs";
import _ts_param from "@swc/helpers/src/_ts_param.mjs";
import { Body, Controller, Delete, Get, Param, Post, Put, UseGuards, UseInterceptors } from '@nestjs/common';
import { POST_CONTROLLER_ROUTE, POST_DELETE_ENDPOINT, POST_GET_ALL_ENDPOINT, POST_GET_ENDPOINT, POST_CREATE_COMMENT_ENDPOINT, POST_CREATE_ENDPOINT, POST_UPDATE_ENDPOINT } from '@server/constants/controllers';
import { MongooseClassSerializerInterceptor } from '@server/interceptors/MongooseClassSerializerInterceptor';
import { Post as PostType } from '@server/post/schemas/PostSchema';
import { PostService } from '@server/post/PostService';
import { CreatePostDto } from '@server/post/dto/CreatePostDto';
import { JwtAuthGuard } from '@server/auth/guards/JwtAuthGuard';
import { User } from '@server/decorators/UserDecorator';
import { User as UserType } from '@server/user/schemas/UserSchema';
import { CreateCommentDto } from '@server/comment/dto/CreateCommentDto';
import { CommentService } from '@server/comment/CommentService';
import { Comment } from '@server/comment/schemas/CommentSchema';
export let PostController = class PostController {
constructor(postService, commentService){
this.postService = postService;
this.commentService = commentService;
}
getPosts() {
return this.postService.getAll();
}
getPost(id) {
return this.postService.getById(id);
}
createPost(createPostDto, user) {
return this.postService.create(createPostDto, user.id);
}
updatePost(id, updatePostDto, user) {
return this.postService.update(id, updatePostDto, user.id);
}
deletePost(id, user) {
return this.postService.delete(id, user.id);
}
createPostComment(id, createCommentDto, user) {
return this.commentService.create(createCommentDto, id, user.id);
}
};
_ts_decorate([
Get(POST_GET_ALL_ENDPOINT),
_ts_metadata("design:type", Function),
_ts_metadata("design:paramtypes", [])
], PostController.prototype, "getPosts", null);
_ts_decorate([
Get(POST_GET_ENDPOINT),
_ts_param(0, Param('id')),
_ts_metadata("design:type", Function),
_ts_metadata("design:paramtypes", [
String
])
], PostController.prototype, "getPost", null);
_ts_decorate([
UseGuards(JwtAuthGuard),
Post(POST_CREATE_ENDPOINT),
_ts_param(0, Body()),
_ts_param(1, User()),
_ts_metadata("design:type", Function),
_ts_metadata("design:paramtypes", [
typeof CreatePostDto === "undefined" ? Object : CreatePostDto,
typeof UserType === "undefined" ? Object : UserType
])
], PostController.prototype, "createPost", null);
_ts_decorate([
UseGuards(JwtAuthGuard),
Put(POST_UPDATE_ENDPOINT),
_ts_param(0, Param('id')),
_ts_param(1, Body()),
_ts_param(2, User()),
_ts_metadata("design:type", Function),
_ts_metadata("design:paramtypes", [
String,
typeof CreatePostDto === "undefined" ? Object : CreatePostDto,
typeof UserType === "undefined" ? Object : UserType
])
], PostController.prototype, "updatePost", null);
_ts_decorate([
UseGuards(JwtAuthGuard),
Delete(POST_DELETE_ENDPOINT),
_ts_param(0, Param('id')),
_ts_param(1, User()),
_ts_metadata("design:type", Function),
_ts_metadata("design:paramtypes", [
String,
typeof UserType === "undefined" ? Object : UserType
])
], PostController.prototype, "deletePost", null);
_ts_decorate([
UseInterceptors(MongooseClassSerializerInterceptor(Comment)),
UseGuards(JwtAuthGuard),
Post(POST_CREATE_COMMENT_ENDPOINT),
_ts_param(0, Param('id')),
_ts_param(1, Body()),
_ts_param(2, User()),
_ts_metadata("design:type", Function),
_ts_metadata("design:paramtypes", [
String,
typeof CreateCommentDto === "undefined" ? Object : CreateCommentDto,
typeof UserType === "undefined" ? Object : UserType
])
], PostController.prototype, "createPostComment", null);
PostController = _ts_decorate([
Controller(POST_CONTROLLER_ROUTE),
UseInterceptors(MongooseClassSerializerInterceptor(PostType)),
_ts_metadata("design:type", Function),
_ts_metadata("design:paramtypes", [
typeof PostService === "undefined" ? Object : PostService,
typeof CommentService === "undefined" ? Object : CommentService
])
], PostController);
16 changes: 16 additions & 0 deletions crates/swc/tests/fixture/sourcemap/014/input/.swcrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"sourceMaps": true,
"jsc": {
"target": "es2022",
"parser": {
"syntax": "typescript",
"tsx": true,
"decorators": true
},
"transform": {
"legacyDecorator": true,
"decoratorMetadata": true
},
"keepClassNames": true
}
}
48 changes: 48 additions & 0 deletions crates/swc/tests/fixture/sourcemap/014/input/UserController.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import {
Controller,
Post,
UseGuards,
Body,
Put,
Param,
ForbiddenException,
UseInterceptors,
} from '@nestjs/common';

import {
USER_CONTROLLER_ROUTE,
USER_CREATE_ENDPOINT,
USER_UPDATE_ENDPOINT,
} from '@server/constants/controllers';
import { CreateUserDto } from '@server/user/dto/CreateUserDto';
import { UpdateUserDto } from '@server/user/dto/UpdateUserDto';
import { JwtAuthGuard } from '@server/auth/guards/JwtAuthGuard';
import { User } from '@server/decorators/UserDecorator';
import { User as UserType } from '@server/user/schemas/UserSchema';
import { MongooseClassSerializerInterceptor } from '@server/interceptors/MongooseClassSerializerInterceptor';
import { UserService } from '@server/user/UserService';

@Controller(USER_CONTROLLER_ROUTE)
@UseInterceptors(MongooseClassSerializerInterceptor(UserType))
export class UserController {
constructor(private userService: UserService) { }

@Post(USER_CREATE_ENDPOINT)
async signup(@Body() createUserDto: CreateUserDto) {
return this.userService.create(createUserDto);
}

@UseGuards(JwtAuthGuard)
@Put(USER_UPDATE_ENDPOINT)
async update(
@Param('id') userId: string,
@Body() updateUserDto: UpdateUserDto,
@User() user: UserType,
) {
if (user.id !== userId) {
throw new ForbiddenException();
}

return this.userService.update(userId, updateUserDto);
}
}
41 changes: 41 additions & 0 deletions crates/swc/tests/fixture/sourcemap/014/output/UserController.map
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"mappings": "AAAA;;;AAAA,SACIA,UAAU,EACVC,IAAI,EACJC,SAAS,EACTC,IAAI,EACJC,GAAG,EACHC,KAAK,EACLC,kBAAkB,EAClBC,eAAe,QACZ,gBAAgB,CAAC;AAExB,SACIC,qBAAqB,EACrBC,oBAAoB,EACpBC,oBAAoB,QACjB,+BAA+B,CAAC;AACvC,SAASC,aAAa,QAAQ,gCAAgC,CAAC;AAC/D,SAASC,aAAa,QAAQ,gCAAgC,CAAC;AAC/D,SAASC,Y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
"Param",
"ForbiddenException",
"UseInterceptors",
"USER_CONTROLLER_ROUTE",
"USER_CREATE_ENDPOINT",
"USER_UPDATE_ENDPOINT",
"CreateUserDto",
"UpdateUserDto",
"JwtAuthGuard",
"User",
"UserType",
"MongooseClassSerializerInterceptor",
"UserService",
"UserController",
"constructor",
"userService",
"signup",
"createUserDto",
"create",
"update",
"userId",
"updateUserDto",
"user",
"id"
],
"sources": [
"../../input/UserController.ts"
],
"sourcesContent": [
"import {\n Controller,\n Post,\n UseGuards,\n Body,\n Put,\n Param,\n ForbiddenException,\n UseInterceptors,\n} from '@nestjs/common';\n\nimport {\n USER_CONTROLLER_ROUTE,\n USER_CREATE_ENDPOINT,\n USER_UPDATE_ENDPOINT,\n} from '@server/constants/controllers';\nimport { CreateUserDto } from '@server/user/dto/CreateUserDto';\nimport { UpdateUserDto } from '@server/user/dto/UpdateUserDto';\nimport { JwtAuthGuard } from '@server/auth/guards/JwtAuthGuard';\nimport { User } from '@server/decorators/UserDecorator';\nimport { User as UserType } from '@server/user/schemas/UserSchema';\nimport { MongooseClassSerializerInterceptor } from '@server/interceptors/MongooseClassSerializerInterceptor';\nimport { UserService } from '@server/user/UserService';\n\n@Controller(USER_CONTROLLER_ROUTE)\n@UseInterceptors(MongooseClassSerializerInterceptor(UserType))\nexport class UserController {\n constructor(private userService: UserService) { }\n\n @Post(USER_CREATE_ENDPOINT)\n async signup(@Body() createUserDto: CreateUserDto) {\n return this.userService.create(createUserDto);\n }\n\n @UseGuards(JwtAuthGuard)\n @Put(USER_UPDATE_ENDPOINT)\n async update(\n @Param('id') userId: string,\n @Body() updateUserDto: UpdateUserDto,\n @User() user: UserType,\n ) {\n if (user.id !== userId) {\n throw new ForbiddenException();\n }\n\n return this.userService.update(userId, updateUserDto);\n }\n}\n"
],
"version": 3
}
55 changes: 55 additions & 0 deletions crates/swc/tests/fixture/sourcemap/014/output/UserController.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import _ts_decorate from "@swc/helpers/src/_ts_decorate.mjs";
import _ts_metadata from "@swc/helpers/src/_ts_metadata.mjs";
import _ts_param from "@swc/helpers/src/_ts_param.mjs";
import { Controller, Post, UseGuards, Body, Put, Param, ForbiddenException, UseInterceptors } from '@nestjs/common';
import { USER_CONTROLLER_ROUTE, USER_CREATE_ENDPOINT, USER_UPDATE_ENDPOINT } from '@server/constants/controllers';
import { CreateUserDto } from '@server/user/dto/CreateUserDto';
import { UpdateUserDto } from '@server/user/dto/UpdateUserDto';
import { JwtAuthGuard } from '@server/auth/guards/JwtAuthGuard';
import { User } from '@server/decorators/UserDecorator';
import { User as UserType } from '@server/user/schemas/UserSchema';
import { MongooseClassSerializerInterceptor } from '@server/interceptors/MongooseClassSerializerInterceptor';
import { UserService } from '@server/user/UserService';
export let UserController = class UserController {
constructor(userService){
this.userService = userService;
}
async signup(createUserDto) {
return this.userService.create(createUserDto);
}
async update(userId, updateUserDto, user) {
if (user.id !== userId) {
throw new ForbiddenException();
}
return this.userService.update(userId, updateUserDto);
}
};
_ts_decorate([
Post(USER_CREATE_ENDPOINT),
_ts_param(0, Body()),
_ts_metadata("design:type", Function),
_ts_metadata("design:paramtypes", [
typeof CreateUserDto === "undefined" ? Object : CreateUserDto
])
], UserController.prototype, "signup", null);
_ts_decorate([
UseGuards(JwtAuthGuard),
Put(USER_UPDATE_ENDPOINT),
_ts_param(0, Param('id')),
_ts_param(1, Body()),
_ts_param(2, User()),
_ts_metadata("design:type", Function),
_ts_metadata("design:paramtypes", [
String,
typeof UpdateUserDto === "undefined" ? Object : UpdateUserDto,
typeof UserType === "undefined" ? Object : UserType
])
], UserController.prototype, "update", null);
UserController = _ts_decorate([
Controller(USER_CONTROLLER_ROUTE),
UseInterceptors(MongooseClassSerializerInterceptor(UserType)),
_ts_metadata("design:type", Function),
_ts_metadata("design:paramtypes", [
typeof UserService === "undefined" ? Object : UserService
])
], UserController);
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"mappings": "AAAAA,QAAQ,CAAC,KAAK,EAAE,IAAM;IAClBC,EAAE,CAAC,OAAO,EAAE,IAAM;QACdC,MAAM,CAAC,KAAK,CAAC,CAACC,IAAI,CAAC,IAAI,CAAC,CAAC;KAC5B,CAAC,CAAC;IAEHF,EAAE,CAAC,OAAO,EAAE,IAAM;QACd,MAAMG,GAAG,GAAG,CAAC;;MAEf,CAAC,AAAC;QAEAF,MAAM,CAAC,KAAK,CAAC,CAACC,IAAI,CAAC,IAAI,CAAC,CAAC;KAC5B,CAAC,CAAC;IAEHF,EAAE,CAAC,OAAO,EAAE,IAAM;QACdC,MAAM,CAAC,KAAK,CAAC,CAACC,IAAI,CAAC,IAAI,CAAC,CAAC;KAC5B,CAAC,CAAC;CACN,CAAC,CAAC",
"mappings": "AAAAA,QAAQ,CAAC,KAAK,EAAE,IAAM;IAClBC,EAAE,CAAC,OAAO,EAAE,IAAM;QACdC,MAAM,CAAC,KAAK,CAAC,CAACC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAC;IAEHF,EAAE,CAAC,OAAO,EAAE,IAAM;QACd,MAAMG,GAAG,GAAG,CAAC;;MAEf,CAAC,AAAC;QAEAF,MAAM,CAAC,KAAK,CAAC,CAACC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAC;IAEHF,EAAE,CAAC,OAAO,EAAE,IAAM;QACdC,MAAM,CAAC,KAAK,CAAC,CAACC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC",
"names": [
"describe",
"it",
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"mappings": "AAAA,IAAI,IAAI,EAAE;IACN,IAAIA,CAAC,GAAGC,MAAM,CAACC,GAAG,AAAC;CACtB",
"mappings": "AAAA,IAAI,IAAI,EAAE;IACN,IAAIA,CAAC,GAAGC,MAAM,CAACC,GAAG,AAAC;AACvB,CAAC",
"names": [
"h",
"Symbol",
Loading