Skip to content

Commit

Permalink
Merge branch 'main' into compat-data
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 authored Aug 12, 2024
2 parents 003cd1b + f4cab32 commit e0a98bd
Show file tree
Hide file tree
Showing 53 changed files with 118 additions and 327 deletions.
5 changes: 0 additions & 5 deletions .changeset/lemon-hornets-attend.md

This file was deleted.

32 changes: 17 additions & 15 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
# Changelog
## [1.7.10] - 2024-08-09

### Bug Fixes



- **(es/typescript)** Strip optional mark and definite mark ([#9411](https://github.com/swc-project/swc/issues/9411)) ([8c161a0](https://github.com/swc-project/swc/commit/8c161a003e741320434f31617bc2de98dd2c9a8f))


- **(es/typescript)** Strip exported default overload function declaration ([#9412](https://github.com/swc-project/swc/issues/9412)) ([b395f48](https://github.com/swc-project/swc/commit/b395f483d1e0cb43b1f96126c5c17f9a8c9d0d32))


- **(es/typescript)** Strip `this` param in getter/setter ([#9414](https://github.com/swc-project/swc/issues/9414)) ([442fb7b](https://github.com/swc-project/swc/commit/442fb7b48715597d62f8d09327f93acc66f2d1b8))


- **(es/typescript)** Update ts-strip type definition ([#9415](https://github.com/swc-project/swc/issues/9415)) ([165c8fa](https://github.com/swc-project/swc/commit/165c8facd42d756077fde99defe91ffe656aede8))

## [1.7.9] - 2024-08-09

### Bug Fixes
Expand Down Expand Up @@ -1287,12 +1304,6 @@



- **(es/minifier)** Fix eval of `toString` of array with holes ([#8727](https://github.com/swc-project/swc/issues/8727)) ([f3fbd9d](https://github.com/swc-project/swc/commit/f3fbd9d54925b708139a37865508430cdcb98f9a))


- **(es/minifier)** Do not evaluate `slice` calls with negative index ([#8726](https://github.com/swc-project/swc/issues/8726)) ([23f9635](https://github.com/swc-project/swc/commit/23f9635d2cb523d63e5d1611dcf55922bcc54a87))


- **(es/minifier)** Handle cyclic references while dropping unused properties ([#8725](https://github.com/swc-project/swc/issues/8725)) ([102241b](https://github.com/swc-project/swc/commit/102241b812b8e815b59575178193bb71b4264bab))


Expand All @@ -1311,15 +1322,6 @@



- **(es/lints)** Add `no-prototype-builtins` rule ([#8684](https://github.com/swc-project/swc/issues/8684)) ([a5dbb17](https://github.com/swc-project/swc/commit/a5dbb17612327c66366086f99b44c6731d125ffc))


- **(es/lints)** Add `prefer-object-spread` rule ([#8696](https://github.com/swc-project/swc/issues/8696)) ([aa9297b](https://github.com/swc-project/swc/commit/aa9297b42e001f6b7319881870f6012a56c50aef))

### Refactor



- **(es)** Prepare `wasm32-wasi-preview1-threads` target support ([#8724](https://github.com/swc-project/swc/issues/8724)) ([e3acd14](https://github.com/swc-project/swc/commit/e3acd1476c2428e5329a359bb7323687c06108d2))

<!-- generated by git-cliff -->
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ APPENDIX: How to apply the Apache License to your work.
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]
Copyright 2024 SWC contributors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
8 changes: 4 additions & 4 deletions bindings/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bindings/binding_core_node/LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ APPENDIX: How to apply the Apache License to your work.
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]
Copyright 2024 SWC contributors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion bindings/binding_core_wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ license = "Apache-2.0"
name = "binding_core_wasm"
publish = false
repository = "https://github.com/swc-project/swc.git"
version = "1.7.9"
version = "1.7.10"

[lib]
bench = false
Expand Down
2 changes: 1 addition & 1 deletion bindings/binding_core_wasm/LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ APPENDIX: How to apply the Apache License to your work.
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]
Copyright 2024 SWC contributors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion bindings/binding_minifier_node/LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ APPENDIX: How to apply the Apache License to your work.
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]
Copyright 2024 SWC contributors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion bindings/binding_minifier_wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ license = "Apache-2.0"
name = "binding_minifier_wasm"
publish = false
repository = "https://github.com/swc-project/swc.git"
version = "1.7.9"
version = "1.7.10"

[lib]
bench = false
Expand Down
2 changes: 1 addition & 1 deletion bindings/binding_minifier_wasm/LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ APPENDIX: How to apply the Apache License to your work.
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]
Copyright 2024 SWC contributors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion bindings/binding_typescript_wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ license = "Apache-2.0"
name = "binding_typescript_wasm"
publish = false
repository = "https://github.com/swc-project/swc.git"
version = "1.7.9"
version = "1.7.10"

[lib]
bench = false
Expand Down
2 changes: 1 addition & 1 deletion bindings/binding_typescript_wasm/LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ APPENDIX: How to apply the Apache License to your work.
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]
Copyright 2024 SWC contributors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
5 changes: 3 additions & 2 deletions bindings/binding_typescript_wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ use wasm_bindgen_futures::{
/// auto generated one, which is not reflecting most of types in detail.
#[wasm_bindgen(typescript_custom_section)]
const INTERFACE_DEFINITIONS: &'static str = r#"
export function transform(src: string, opts?: Options): Promise<TransformOutput>;
export function transformSync(src: string, opts?: Options): TransformOutput;
export declare function transform(src: string, opts?: Options): Promise<TransformOutput>;
export declare function transformSync(src: string, opts?: Options): TransformOutput;
export type { Options, TransformOutput };
"#;

#[wasm_bindgen(skip_typescript)]
Expand Down
2 changes: 1 addition & 1 deletion bindings/swc_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ include = ["Cargo.toml", "src/**/*.rs"]
license = "Apache-2.0"
name = "swc_cli"
repository = "https://github.com/swc-project/swc.git"
version = "0.91.364"
version = "0.91.366"

[[bin]]
bench = false
Expand Down
2 changes: 1 addition & 1 deletion crates/swc_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2021"
license = "Apache-2.0"
name = "swc_core"
repository = "https://github.com/swc-project/swc.git"
version = "0.100.5"
version = "0.100.6"
[package.metadata.docs.rs]
features = [
"allocator_node",
Expand Down
2 changes: 1 addition & 1 deletion crates/swc_fast_ts_strip/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ include = ["Cargo.toml", "src/**/*.rs"]
license = "Apache-2.0"
name = "swc_fast_ts_strip"
repository = { workspace = true }
version = "0.5.2"
version = "0.5.3"


[dependencies]
Expand Down
63 changes: 55 additions & 8 deletions crates/swc_fast_ts_strip/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ use swc_common::{
};
use swc_ecma_ast::{
ArrayPat, ArrowExpr, AutoAccessor, BindingIdent, Class, ClassDecl, ClassMethod, ClassProp,
Constructor, Decl, DoWhileStmt, EsVersion, ExportAll, ExportDecl, ExportDefaultDecl,
ExportSpecifier, FnDecl, ForInStmt, ForOfStmt, ForStmt, IfStmt, ImportDecl, ImportSpecifier,
NamedExport, ObjectPat, Param, Pat, PrivateMethod, PrivateProp, Program, Stmt, TsAsExpr,
TsConstAssertion, TsEnumDecl, TsExportAssignment, TsImportEqualsDecl, TsIndexSignature,
TsInstantiation, TsModuleDecl, TsModuleName, TsNamespaceDecl, TsNonNullExpr, TsParamPropParam,
TsSatisfiesExpr, TsTypeAliasDecl, TsTypeAnn, TsTypeAssertion, TsTypeParamDecl,
TsTypeParamInstantiation, VarDeclarator, WhileStmt,
Constructor, Decl, DefaultDecl, DoWhileStmt, EsVersion, ExportAll, ExportDecl,
ExportDefaultDecl, ExportSpecifier, FnDecl, ForInStmt, ForOfStmt, ForStmt, GetterProp, IfStmt,
ImportDecl, ImportSpecifier, NamedExport, ObjectPat, Param, Pat, PrivateMethod, PrivateProp,
Program, SetterProp, Stmt, TsAsExpr, TsConstAssertion, TsEnumDecl, TsExportAssignment,
TsImportEqualsDecl, TsIndexSignature, TsInstantiation, TsModuleDecl, TsModuleName,
TsNamespaceDecl, TsNonNullExpr, TsParamPropParam, TsSatisfiesExpr, TsTypeAliasDecl, TsTypeAnn,
TsTypeAssertion, TsTypeParamDecl, TsTypeParamInstantiation, VarDeclarator, WhileStmt,
};
use swc_ecma_parser::{
lexer::Lexer,
Expand Down Expand Up @@ -64,8 +64,17 @@ interface Options {
module?: boolean;
filename?: string;
mode?: Mode;
transform?; TransformConfig;
sourceMap?: boolean;
}
interface TransformConfig {
verbatimModuleSyntax?: boolean;
importNotUsedAsValues?: "remove" | "preserve";
noEmptyExport?: boolean;
importExportAssignConfig?: "Classic" | "Preserve" | "NodeNext" | "EsNext";
tsEnumIsMutable?: boolean;
}
"#;

#[derive(Debug, Default, Deserialize)]
Expand Down Expand Up @@ -775,7 +784,7 @@ impl Visit for TsStrip {
}

fn visit_export_default_decl(&mut self, n: &ExportDefaultDecl) {
if n.decl.is_ts_interface_decl() {
if n.decl.is_ts_declare() {
self.add_replacement(n.span);
self.fix_asi(n.span);
return;
Expand Down Expand Up @@ -1069,6 +1078,34 @@ impl Visit for TsStrip {
self.add_overwrite(n.body.span_lo(), b';');
}
}

fn visit_getter_prop(&mut self, n: &GetterProp) {
let l_parern_index = self.get_next_token_index(n.key.span_hi());
let l_parern = &self.tokens[l_parern_index];
debug_assert_eq!(l_parern.token, Token::LParen);

let r_parern_pos = n.type_ann.as_ref().map_or(n.body.span_lo(), |t| t.span.lo) - BytePos(1);
let r_parern = self.get_prev_token(r_parern_pos);
debug_assert_eq!(r_parern.token, Token::RParen);

let span = span(l_parern.span.lo + BytePos(1), r_parern.span.hi - BytePos(1));
self.add_replacement(span);

n.visit_children_with(self);
}

fn visit_setter_prop(&mut self, n: &SetterProp) {
if let Some(this_param) = &n.this_param {
self.add_replacement(this_param.span());

let comma = self.get_prev_token(n.param.span_lo() - BytePos(1));
debug_assert_eq!(comma.token, Token::Comma);

self.add_replacement(comma.span);
}

n.visit_children_with(self);
}
}

trait IsTsDecl {
Expand Down Expand Up @@ -1100,6 +1137,16 @@ impl IsTsDecl for Stmt {
}
}

impl IsTsDecl for DefaultDecl {
fn is_ts_declare(&self) -> bool {
match self {
Self::Class(..) => false,
DefaultDecl::Fn(r#fn) => r#fn.function.body.is_none(),
DefaultDecl::TsInterfaceDecl(..) => true,
}
}
}

trait U8Helper {
fn is_utf8_char_boundary(&self) -> bool;
}
Expand Down
1 change: 1 addition & 0 deletions crates/swc_fast_ts_strip/tests/fixture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ fn reparse(cm: &Lrc<SourceMap>, handler: &Handler, filename: &PathBuf, input: St
let fm = cm.new_source_file(filename.into(), input);

let syntax = Syntax::Es(EsSyntax {
allow_super_outside_method: true,
auto_accessors: true,
decorators: true,
decorators_before_export: true,
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit e0a98bd

Please sign in to comment.