From 6e1c9fde1f0c95a955a11c44474d6f4a57250c74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Donny/=EA=B0=95=EB=8F=99=EC=9C=A4?= Date: Mon, 2 Dec 2024 12:22:37 +0900 Subject: [PATCH] feat(es/minifier): Support `preserve_annotations` of terser (#9775) **Description:** - `jsc.output.preserveAnnotations` (`transform()`/`.swcrc`) - `format.preserve_annotations` (`minify()`) are added to support stripping out PURE comments while preserving license comments. **Related issue:** - https://github.com/swc-project/swc/issues/9674 --- .changeset/lemon-seahorses-work.md | 5 +++++ crates/swc/src/config/mod.rs | 11 +++++++++-- crates/swc/src/lib.rs | 12 ++++++++++-- .../tests/fixture/issues-2xxx/2854/1/output/index.js | 4 ++-- .../tests/fixture/issues-6xxx/6984/1/output/index.js | 2 +- .../swc/tests/fixture/issues-7xxx/7653/output/1.js | 2 +- .../swc/tests/fixture/issues-7xxx/7700/output/1.js | 2 +- .../swc/tests/fixture/issues-7xxx/7700/output/2.js | 2 +- .../swc/tests/fixture/issues-7xxx/7700/output/3.js | 2 +- .../swc/tests/fixture/issues-7xxx/7700/output/4.js | 2 +- .../swc/tests/fixture/issues-7xxx/7700/output/5.js | 2 +- .../swc/tests/fixture/issues-7xxx/7783/output/1.js | 2 +- .../swc/tests/fixture/issues-7xxx/7821/output/1.js | 6 +++--- .../swc/tests/fixture/issues-8xxx/8199/output/1.js | 2 +- .../swc/tests/fixture/issues-8xxx/8210/output/1.js | 4 ++-- .../swc/tests/fixture/issues-8xxx/8243/output/1.js | 4 ++-- .../swc/tests/fixture/issues-8xxx/8243/output/2.js | 4 ++-- .../swc/tests/fixture/issues-8xxx/8243/output/3.js | 4 ++-- .../swc/tests/fixture/issues-8xxx/8243/output/4.js | 4 ++-- .../swc/tests/fixture/issues-8xxx/8275/output/1.js | 2 +- .../tests/fixture/issues-8xxx/8594/output/index.tsx | 2 +- .../tests/fixture/issues-8xxx/8640/output/index.tsx | 4 ++-- .../swc/tests/fixture/issues-9xxx/9204/output/1.js | 2 +- .../swc/tests/fixture/sourcemap/003/output/index.js | 2 +- .../swc/tests/fixture/sourcemap/003/output/index.map | 2 +- ...ckJsxGenericTagHasCorrectInferences.2.minified.js | 2 +- ...nSFXContextualTypeInferredCorrectly.2.minified.js | 4 ++-- .../correctlyMarkAliasAsReferences1.2.minified.js | 2 +- .../correctlyMarkAliasAsReferences2.2.minified.js | 2 +- .../correctlyMarkAliasAsReferences3.2.minified.js | 2 +- .../correctlyMarkAliasAsReferences4.2.minified.js | 2 +- .../inlineJsxAndJsxFragPragma.2.minified.js | 6 +++--- ...xFragPragmaOverridesCompilerOptions.2.minified.js | 4 ++-- .../inlineJsxFactoryDeclarations.2.minified.js | 6 +++--- ...ineJsxFactoryDeclarationsLocalTypes.2.minified.js | 12 ++++++------ ...neJsxFactoryLocalTypeGlobalFallback.2.minified.js | 2 +- ...inlineJsxFactoryWithFragmentIsError.2.minified.js | 4 ++-- .../jsxJsxsCjsTransformCustomImport.2.minified.js | 2 +- ...xJsxsCjsTransformCustomImportPragma.2.minified.js | 4 ++-- .../jsxJsxsCjsTransformKeyProp.2.minified.js | 4 ++-- ...JsxsCjsTransformKeyPropCustomImport.2.minified.js | 4 ++-- ...sTransformKeyPropCustomImportPragma.2.minified.js | 8 ++++---- ...sCjsTransformNestedSelfClosingChild.2.minified.js | 4 ++-- ...jsTransformSubstitutesNamesFragment.2.minified.js | 2 +- .../tsc-references/jsxReactTestSuite.2.minified.js | 10 +++++----- .../swc/tests/tsc-references/multiline.2.minified.js | 2 +- .../tsxAttributeResolution12.2.minified.js | 2 +- .../tsxAttributeResolution3.2.minified.js | 6 +++--- ...sxCorrectlyParseLessThanComparison1.2.minified.js | 2 +- .../tsc-references/tsxDynamicTagName5.2.minified.js | 2 +- .../tsc-references/tsxDynamicTagName7.2.minified.js | 2 +- .../tsc-references/tsxDynamicTagName8.2.minified.js | 2 +- .../tsc-references/tsxDynamicTagName9.2.minified.js | 2 +- .../tsxElementResolution.2.minified.js | 2 +- .../tsxElementResolution17.2.minified.js | 2 +- .../tsxElementResolution19.2.minified.js | 2 +- .../tsxElementResolution7.2.minified.js | 2 +- .../swc/tests/tsc-references/tsxEmit2.2.minified.js | 6 +++--- .../swc/tests/tsc-references/tsxEmit3.2.minified.js | 2 +- .../tsxExternalModuleEmit1.2.minified.js | 4 ++-- .../tsxFragmentPreserveEmit.2.minified.js | 2 +- .../tsxFragmentReactEmit.2.minified.js | 2 +- .../swc/tests/tsc-references/tsxNoJsx.2.minified.js | 1 - .../tsxOpeningClosingNames.2.minified.js | 2 +- .../tsc-references/tsxPreserveEmit1.2.minified.js | 2 +- .../tests/tsc-references/tsxReactEmit2.2.minified.js | 6 +++--- .../tests/tsc-references/tsxReactEmit3.2.minified.js | 2 +- .../tests/tsc-references/tsxReactEmit4.2.minified.js | 2 +- .../tests/tsc-references/tsxReactEmit5.2.minified.js | 2 +- .../tests/tsc-references/tsxReactEmit6.2.minified.js | 2 +- .../tests/tsc-references/tsxReactEmit8.2.minified.js | 1 - .../tsxSpreadAttributesResolution17.2.minified.js | 4 ++-- ...StatelessFunctionComponentOverload1.2.minified.js | 2 +- ...StatelessFunctionComponentOverload2.2.minified.js | 4 ++-- ...StatelessFunctionComponentOverload3.2.minified.js | 4 ++-- ...StatelessFunctionComponentOverload4.2.minified.js | 4 ++-- ...StatelessFunctionComponentOverload5.2.minified.js | 8 ++++---- ...StatelessFunctionComponentOverload6.2.minified.js | 4 ++-- ...unctionComponentsWithTypeArguments1.2.minified.js | 2 +- ...unctionComponentsWithTypeArguments2.2.minified.js | 2 +- .../full-compact/react-autosuggest/1/output/index.js | 2 +- .../vercel/full/firebase/dist/1/output/index.js | 2 +- crates/swc/tests/vercel/full/jsx/1/output/index.js | 2 +- .../swc/tests/vercel/full/next-33088/output/index.js | 10 +++++----- .../vercel/full/react-autosuggest/1/output/index.js | 6 +++--- .../vercel/full/react-autowhatever/1/output/index.js | 4 ++-- .../vercel/full/react-autowhatever/2/output/index.js | 4 ++-- .../tests/vercel/full/react-hooks/1/output/index.js | 2 +- crates/swc_compiler_base/src/lib.rs | 10 ++++++---- 89 files changed, 168 insertions(+), 148 deletions(-) create mode 100644 .changeset/lemon-seahorses-work.md diff --git a/.changeset/lemon-seahorses-work.md b/.changeset/lemon-seahorses-work.md new file mode 100644 index 000000000000..3e60f32db11c --- /dev/null +++ b/.changeset/lemon-seahorses-work.md @@ -0,0 +1,5 @@ +--- +swc_compiler_base: major +--- + +feat(es/minifier): Support `preserve_annotations` of terser diff --git a/crates/swc/src/config/mod.rs b/crates/swc/src/config/mod.rs index 7cd4a43f82fb..07553534b7dd 100644 --- a/crates/swc/src/config/mod.rs +++ b/crates/swc/src/config/mod.rs @@ -802,7 +802,11 @@ impl Options { comments: comments.cloned(), preserve_comments, emit_source_map_columns: cfg.emit_source_map_columns.into_bool(), - output: JscOutputConfig { charset, preamble }, + output: JscOutputConfig { + charset, + preamble, + preserve_annotations: cfg.jsc.output.preserve_annotations, + }, emit_assert_for_import_attributes: experimental .emit_assert_for_import_attributes .into_bool(), @@ -1144,9 +1148,9 @@ where output_path: self.output_path, source_root: self.source_root, source_file_name: self.source_file_name, + comments: self.comments, preserve_comments: self.preserve_comments, inline_sources_content: self.inline_sources_content, - comments: self.comments, emit_source_map_columns: self.emit_source_map_columns, output: self.output, emit_assert_for_import_attributes: self.emit_assert_for_import_attributes, @@ -1212,6 +1216,9 @@ pub struct JscOutputConfig { #[serde(default)] pub preamble: String, + + #[serde(default)] + pub preserve_annotations: BoolConfig, } #[derive(Debug, Clone, Serialize, Deserialize, Default)] diff --git a/crates/swc/src/lib.rs b/crates/swc/src/lib.rs index e4f93bd2063c..3e4330cef0f4 100644 --- a/crates/swc/src/lib.rs +++ b/crates/swc/src/lib.rs @@ -888,7 +888,11 @@ impl Compiler { .clone() .into_inner() .unwrap_or(BoolOr::Data(JsMinifyCommentOption::PreserveSomeComments)); - swc_compiler_base::minify_file_comments(&comments, preserve_comments); + swc_compiler_base::minify_file_comments( + &comments, + preserve_comments, + opts.format.preserve_annotations, + ); self.print( &program, @@ -1018,7 +1022,11 @@ impl Compiler { }); if let Some(comments) = &config.comments { - swc_compiler_base::minify_file_comments(comments, config.preserve_comments); + swc_compiler_base::minify_file_comments( + comments, + config.preserve_comments, + config.output.preserve_annotations.into_bool(), + ); } self.print( diff --git a/crates/swc/tests/fixture/issues-2xxx/2854/1/output/index.js b/crates/swc/tests/fixture/issues-2xxx/2854/1/output/index.js index facec335f2e3..fb6df143c295 100644 --- a/crates/swc/tests/fixture/issues-2xxx/2854/1/output/index.js +++ b/crates/swc/tests/fixture/issues-2xxx/2854/1/output/index.js @@ -1,9 +1,9 @@ export function App() { - return /*#__PURE__*/ React.createElement(Form, null); + return React.createElement(Form, null); } export function Form(param) { var _param_onChange = param.onChange, onChange = _param_onChange === void 0 ? function() {} : _param_onChange; - return /*#__PURE__*/ React.createElement("input", { + return React.createElement("input", { onChange: function onChange1() { onChange(); } diff --git a/crates/swc/tests/fixture/issues-6xxx/6984/1/output/index.js b/crates/swc/tests/fixture/issues-6xxx/6984/1/output/index.js index c78020d9ab4d..106e15329c85 100644 --- a/crates/swc/tests/fixture/issues-6xxx/6984/1/output/index.js +++ b/crates/swc/tests/fixture/issues-6xxx/6984/1/output/index.js @@ -17,7 +17,7 @@ var App = /*#__PURE__*/ function(_React_Component) { key: "render", value: function render() { console.log(this.props); - return /*#__PURE__*/ React.createElement("div", null, "134"); + return React.createElement("div", null, "134"); } } ]); diff --git a/crates/swc/tests/fixture/issues-7xxx/7653/output/1.js b/crates/swc/tests/fixture/issues-7xxx/7653/output/1.js index 923857c623ef..0e2994b7a910 100644 --- a/crates/swc/tests/fixture/issues-7xxx/7653/output/1.js +++ b/crates/swc/tests/fixture/issues-7xxx/7653/output/1.js @@ -1 +1 @@ -export default function Home(){return /*#__PURE__*/React.createElement("div",{dangerouslySetInnerHTML:{__html:"Hello World"}})} +export default function Home(){return React.createElement("div",{dangerouslySetInnerHTML:{__html:"Hello World"}})} diff --git a/crates/swc/tests/fixture/issues-7xxx/7700/output/1.js b/crates/swc/tests/fixture/issues-7xxx/7700/output/1.js index c1493d8b2cc1..fed84e8eb807 100644 --- a/crates/swc/tests/fixture/issues-7xxx/7700/output/1.js +++ b/crates/swc/tests/fixture/issues-7xxx/7700/output/1.js @@ -11,5 +11,5 @@ let positions = { }; export function PositionRender({ isRtl, position }) { let display = ('fe-fe-fe' === isRtl ? rtlPositions : positions)[position]; - return /*#__PURE__*/ React.createElement("h1", null, "PositionRender: ", display); + return React.createElement("h1", null, "PositionRender: ", display); } diff --git a/crates/swc/tests/fixture/issues-7xxx/7700/output/2.js b/crates/swc/tests/fixture/issues-7xxx/7700/output/2.js index 09e55554c840..83f8f8d3417f 100644 --- a/crates/swc/tests/fixture/issues-7xxx/7700/output/2.js +++ b/crates/swc/tests/fixture/issues-7xxx/7700/output/2.js @@ -15,5 +15,5 @@ export function PositionRender({ isRtl, position }) { ] : { positions })[position]; - return /*#__PURE__*/ React.createElement("h1", null, "PositionRender: ", display); + return React.createElement("h1", null, "PositionRender: ", display); } diff --git a/crates/swc/tests/fixture/issues-7xxx/7700/output/3.js b/crates/swc/tests/fixture/issues-7xxx/7700/output/3.js index 2bc0c30c2abf..23372fc464ec 100644 --- a/crates/swc/tests/fixture/issues-7xxx/7700/output/3.js +++ b/crates/swc/tests/fixture/issues-7xxx/7700/output/3.js @@ -15,5 +15,5 @@ export function PositionRender({ isRtl, position }) { ] : { positions })[position]; - return /*#__PURE__*/ React.createElement("h1", null, "PositionRender: ", display); + return React.createElement("h1", null, "PositionRender: ", display); } diff --git a/crates/swc/tests/fixture/issues-7xxx/7700/output/4.js b/crates/swc/tests/fixture/issues-7xxx/7700/output/4.js index 457d61679fc3..034a68fe7954 100644 --- a/crates/swc/tests/fixture/issues-7xxx/7700/output/4.js +++ b/crates/swc/tests/fixture/issues-7xxx/7700/output/4.js @@ -13,5 +13,5 @@ export function PositionRender({ isRtl, position }) { let display = ('fe-fe-fe' === isRtl ? rtlPositions : { a: positions })[position]; - return /*#__PURE__*/ React.createElement("h1", null, "PositionRender: ", display); + return React.createElement("h1", null, "PositionRender: ", display); } diff --git a/crates/swc/tests/fixture/issues-7xxx/7700/output/5.js b/crates/swc/tests/fixture/issues-7xxx/7700/output/5.js index 37dad8c65f0f..49f36e4e4ee8 100644 --- a/crates/swc/tests/fixture/issues-7xxx/7700/output/5.js +++ b/crates/swc/tests/fixture/issues-7xxx/7700/output/5.js @@ -15,5 +15,5 @@ export function PositionRender({ isRtl, position }) { positions ] })[position]; - return /*#__PURE__*/ React.createElement("h1", null, "PositionRender: ", display); + return React.createElement("h1", null, "PositionRender: ", display); } diff --git a/crates/swc/tests/fixture/issues-7xxx/7783/output/1.js b/crates/swc/tests/fixture/issues-7xxx/7783/output/1.js index abe5876246a2..58d2bed8bc9b 100644 --- a/crates/swc/tests/fixture/issues-7xxx/7783/output/1.js +++ b/crates/swc/tests/fixture/issues-7xxx/7783/output/1.js @@ -1 +1 @@ -export default function e(){return /*#__PURE__*/React.createElement("div",null,foo.a)}let foo={get a(){return`a ${this.b}`},get b(){return"b"}}; +export default function e(){return React.createElement("div",null,foo.a)}let foo={get a(){return`a ${this.b}`},get b(){return"b"}}; diff --git a/crates/swc/tests/fixture/issues-7xxx/7821/output/1.js b/crates/swc/tests/fixture/issues-7xxx/7821/output/1.js index 6003ecd08a2c..c189f3216aeb 100644 --- a/crates/swc/tests/fixture/issues-7xxx/7821/output/1.js +++ b/crates/swc/tests/fixture/issues-7xxx/7821/output/1.js @@ -1,9 +1,9 @@ var Blocks = { Block1: function() { - return /*#__PURE__*/ React.createElement(React.Fragment, null, "'Block1xx'"); + return React.createElement(React.Fragment, null, "'Block1xx'"); }, Block2: function() { - return /*#__PURE__*/ React.createElement(React.Fragment, null, "'Block2xx'"); + return React.createElement(React.Fragment, null, "'Block2xx'"); }, Layout1: function() { return [ @@ -14,5 +14,5 @@ var Blocks = { } }; export function render() { - return /*#__PURE__*/ React.createElement(Blocks.Layout1, null); + return React.createElement(Blocks.Layout1, null); } diff --git a/crates/swc/tests/fixture/issues-8xxx/8199/output/1.js b/crates/swc/tests/fixture/issues-8xxx/8199/output/1.js index ea1836b77e99..f366b1b0f4bb 100644 --- a/crates/swc/tests/fixture/issues-8xxx/8199/output/1.js +++ b/crates/swc/tests/fixture/issues-8xxx/8199/output/1.js @@ -1,7 +1,7 @@ import { jsx as _jsx } from "react/jsx-runtime"; export const IconSpecHotkey = (param)=>{ let { icon } = param; - return /*#__PURE__*/ _jsx("div", { + return _jsx("div", { children: icon }); }; diff --git a/crates/swc/tests/fixture/issues-8xxx/8210/output/1.js b/crates/swc/tests/fixture/issues-8xxx/8210/output/1.js index a72c40d2066d..ea1bbedd0ad5 100644 --- a/crates/swc/tests/fixture/issues-8xxx/8210/output/1.js +++ b/crates/swc/tests/fixture/issues-8xxx/8210/output/1.js @@ -1,7 +1,7 @@ const { jsxDEV: _jsxDEV } = require("react/jsx-dev-runtime"); const Component = ()=>{ - return /*#__PURE__*/ _jsxDEV("p", { - thing: /*#__PURE__*/ _jsxDEV("a", {}, void 0, false, { + return _jsxDEV("p", { + thing: _jsxDEV("a", {}, void 0, false, { fileName: "$DIR/tests/fixture/issues-8xxx/8210/input/1.js", lineNumber: 2, columnNumber: 23 diff --git a/crates/swc/tests/fixture/issues-8xxx/8243/output/1.js b/crates/swc/tests/fixture/issues-8xxx/8243/output/1.js index a82e9c58b584..a96e17153e89 100644 --- a/crates/swc/tests/fixture/issues-8xxx/8243/output/1.js +++ b/crates/swc/tests/fixture/issues-8xxx/8243/output/1.js @@ -1,7 +1,7 @@ import { jsx as _jsx } from "react/jsx-runtime"; export const Foo = (props)=>{ - return originalMessage ? /*#__PURE__*/ _jsx(Bar, { - children: /*#__PURE__*/ _jsx(Baz, { + return originalMessage ? _jsx(Bar, { + children: _jsx(Baz, { children: ()=>null }) }) : null; diff --git a/crates/swc/tests/fixture/issues-8xxx/8243/output/2.js b/crates/swc/tests/fixture/issues-8xxx/8243/output/2.js index a82e9c58b584..a96e17153e89 100644 --- a/crates/swc/tests/fixture/issues-8xxx/8243/output/2.js +++ b/crates/swc/tests/fixture/issues-8xxx/8243/output/2.js @@ -1,7 +1,7 @@ import { jsx as _jsx } from "react/jsx-runtime"; export const Foo = (props)=>{ - return originalMessage ? /*#__PURE__*/ _jsx(Bar, { - children: /*#__PURE__*/ _jsx(Baz, { + return originalMessage ? _jsx(Bar, { + children: _jsx(Baz, { children: ()=>null }) }) : null; diff --git a/crates/swc/tests/fixture/issues-8xxx/8243/output/3.js b/crates/swc/tests/fixture/issues-8xxx/8243/output/3.js index a82e9c58b584..a96e17153e89 100644 --- a/crates/swc/tests/fixture/issues-8xxx/8243/output/3.js +++ b/crates/swc/tests/fixture/issues-8xxx/8243/output/3.js @@ -1,7 +1,7 @@ import { jsx as _jsx } from "react/jsx-runtime"; export const Foo = (props)=>{ - return originalMessage ? /*#__PURE__*/ _jsx(Bar, { - children: /*#__PURE__*/ _jsx(Baz, { + return originalMessage ? _jsx(Bar, { + children: _jsx(Baz, { children: ()=>null }) }) : null; diff --git a/crates/swc/tests/fixture/issues-8xxx/8243/output/4.js b/crates/swc/tests/fixture/issues-8xxx/8243/output/4.js index a82e9c58b584..a96e17153e89 100644 --- a/crates/swc/tests/fixture/issues-8xxx/8243/output/4.js +++ b/crates/swc/tests/fixture/issues-8xxx/8243/output/4.js @@ -1,7 +1,7 @@ import { jsx as _jsx } from "react/jsx-runtime"; export const Foo = (props)=>{ - return originalMessage ? /*#__PURE__*/ _jsx(Bar, { - children: /*#__PURE__*/ _jsx(Baz, { + return originalMessage ? _jsx(Bar, { + children: _jsx(Baz, { children: ()=>null }) }) : null; diff --git a/crates/swc/tests/fixture/issues-8xxx/8275/output/1.js b/crates/swc/tests/fixture/issues-8xxx/8275/output/1.js index 019d79c362d6..41a9c9ad507a 100644 --- a/crates/swc/tests/fixture/issues-8xxx/8275/output/1.js +++ b/crates/swc/tests/fixture/issues-8xxx/8275/output/1.js @@ -1,4 +1,4 @@ -/*#__PURE__*/ export const c = (function(strings, ...values) { +export const c = (function(strings, ...values) { return { strings, values diff --git a/crates/swc/tests/fixture/issues-8xxx/8594/output/index.tsx b/crates/swc/tests/fixture/issues-8xxx/8594/output/index.tsx index baaca0bbe3b2..bb1e95a57046 100644 --- a/crates/swc/tests/fixture/issues-8xxx/8594/output/index.tsx +++ b/crates/swc/tests/fixture/issues-8xxx/8594/output/index.tsx @@ -1,6 +1,6 @@ import * as React from 'react'; (function(FooNs) { FooNs.Shared = ()=>'I\'m shared component'; - FooNs.Main = ()=>/*#__PURE__*/ React.createElement(FooNs.Shared, null); + FooNs.Main = ()=>React.createElement(FooNs.Shared, null); })(FooNs || (FooNs = {})); export var FooNs; diff --git a/crates/swc/tests/fixture/issues-8xxx/8640/output/index.tsx b/crates/swc/tests/fixture/issues-8xxx/8640/output/index.tsx index 530e322e0641..c7d94d8591b1 100644 --- a/crates/swc/tests/fixture/issues-8xxx/8640/output/index.tsx +++ b/crates/swc/tests/fixture/issues-8xxx/8640/output/index.tsx @@ -1,6 +1,6 @@ import * as React from 'react'; (function(Ns) { - Ns.Context = /*#__PURE__*/ React.createContext(); - Ns.Component = ()=>/*#__PURE__*/ React.createElement(Ns.Context.Provider, null); + Ns.Context = React.createContext(); + Ns.Component = ()=>React.createElement(Ns.Context.Provider, null); })(Ns || (Ns = {})); export var Ns; diff --git a/crates/swc/tests/fixture/issues-9xxx/9204/output/1.js b/crates/swc/tests/fixture/issues-9xxx/9204/output/1.js index 92161caea324..1c3d2c217274 100644 --- a/crates/swc/tests/fixture/issues-9xxx/9204/output/1.js +++ b/crates/swc/tests/fixture/issues-9xxx/9204/output/1.js @@ -1,4 +1,4 @@ let Foo = createFoo(); export function App() { - return /*#__PURE__*/ React.createElement("view", null, /*#__PURE__*/ React.createElement(Foo, null)); + return React.createElement("view", null, React.createElement(Foo, null)); } diff --git a/crates/swc/tests/fixture/sourcemap/003/output/index.js b/crates/swc/tests/fixture/sourcemap/003/output/index.js index 1775fec347ae..385cbda924f6 100644 --- a/crates/swc/tests/fixture/sourcemap/003/output/index.js +++ b/crates/swc/tests/fixture/sourcemap/003/output/index.js @@ -1 +1 @@ -import{_ as t}from"@swc/helpers/_/_async_to_generator";import{_ as r}from"@swc/helpers/_/_ts_generator";export default function e(t){var r=t.data;return /*#__PURE__*/React.createElement("div",null,r.foo)}export function getStaticProps(){return n.apply(this,arguments)}function n(){return(n=t(function(){return r(this,function(t){return[2,{props:{data:{foo:"bar"}}}]})})).apply(this,arguments)} +import{_ as t}from"@swc/helpers/_/_async_to_generator";import{_ as r}from"@swc/helpers/_/_ts_generator";export default function e(t){var r=t.data;return React.createElement("div",null,r.foo)}export function getStaticProps(){return n.apply(this,arguments)}function n(){return(n=t(function(){return r(this,function(t){return[2,{props:{data:{foo:"bar"}}}]})})).apply(this,arguments)} diff --git a/crates/swc/tests/fixture/sourcemap/003/output/index.map b/crates/swc/tests/fixture/sourcemap/003/output/index.map index 9952fa6732f8..c0259cf305dd 100644 --- a/crates/swc/tests/fixture/sourcemap/003/output/index.map +++ b/crates/swc/tests/fixture/sourcemap/003/output/index.map @@ -1,5 +1,5 @@ { - "mappings": "uGAAA,gBAAe,SAASA,EAAW,CAAQ,MAAR,AAAEC,EAAF,EAAEA,KACjC,oBAAO,oBAACC,WAAKD,EAAKE,GAAG,CACzB,CAEA,gBAAsBC,wBAAAA,iCAAAA,WAAAA,EAAf,EAAA,qCACH,SAAO,CACHC,MAAO,CACHJ,KAAM,CACFE,IAAK,KACT,CACJ,CACJ,IACJ", + "mappings": "uGAAA,gBAAe,SAASA,EAAW,CAAQ,MAAR,AAAEC,EAAF,EAAEA,KACjC,OAAO,oBAACC,WAAKD,EAAKE,GAAG,CACzB,CAEA,gBAAsBC,wBAAAA,iCAAAA,WAAAA,EAAf,EAAA,qCACH,SAAO,CACHC,MAAO,CACHJ,KAAM,CACFE,IAAK,KACT,CACJ,CACJ,IACJ", "names": [ "StaticPage", "data", diff --git a/crates/swc/tests/tsc-references/checkJsxGenericTagHasCorrectInferences.2.minified.js b/crates/swc/tests/tsc-references/checkJsxGenericTagHasCorrectInferences.2.minified.js index 4fab0d97020b..906d4b27fe27 100644 --- a/crates/swc/tests/tsc-references/checkJsxGenericTagHasCorrectInferences.2.minified.js +++ b/crates/swc/tests/tsc-references/checkJsxGenericTagHasCorrectInferences.2.minified.js @@ -1,3 +1,3 @@ //// [file.tsx] import * as React from "react"; -/*#__PURE__*/ GenericComponent, /*#__PURE__*/ GenericComponent, /*#__PURE__*/ GenericComponent, /*#__PURE__*/ GenericComponent; +GenericComponent, GenericComponent, GenericComponent, GenericComponent; diff --git a/crates/swc/tests/tsc-references/checkJsxUnionSFXContextualTypeInferredCorrectly.2.minified.js b/crates/swc/tests/tsc-references/checkJsxUnionSFXContextualTypeInferredCorrectly.2.minified.js index 52929faf0a5a..542d5c237bfa 100644 --- a/crates/swc/tests/tsc-references/checkJsxUnionSFXContextualTypeInferredCorrectly.2.minified.js +++ b/crates/swc/tests/tsc-references/checkJsxUnionSFXContextualTypeInferredCorrectly.2.minified.js @@ -1,10 +1,10 @@ //// [checkJsxUnionSFXContextualTypeInferredCorrectly.tsx] import React from 'react'; export function ComponentWithUnion(props) { - return /*#__PURE__*/ React.createElement("h1", null); + return React.createElement("h1", null); } export function HereIsTheError() { - return /*#__PURE__*/ React.createElement(ComponentWithUnion, { + return React.createElement(ComponentWithUnion, { multi: !1, value: 's', onChange: function(val) { diff --git a/crates/swc/tests/tsc-references/correctlyMarkAliasAsReferences1.2.minified.js b/crates/swc/tests/tsc-references/correctlyMarkAliasAsReferences1.2.minified.js index a9858b6472c3..99fc3418e36a 100644 --- a/crates/swc/tests/tsc-references/correctlyMarkAliasAsReferences1.2.minified.js +++ b/crates/swc/tests/tsc-references/correctlyMarkAliasAsReferences1.2.minified.js @@ -3,6 +3,6 @@ //// [0.tsx] import * as cx from 'classnames'; import * as React from "react"; -/*#__PURE__*/ cx('class1', { +cx('class1', { class2: !0 }); diff --git a/crates/swc/tests/tsc-references/correctlyMarkAliasAsReferences2.2.minified.js b/crates/swc/tests/tsc-references/correctlyMarkAliasAsReferences2.2.minified.js index 7c4db7def62f..05731bfaf67e 100644 --- a/crates/swc/tests/tsc-references/correctlyMarkAliasAsReferences2.2.minified.js +++ b/crates/swc/tests/tsc-references/correctlyMarkAliasAsReferences2.2.minified.js @@ -3,6 +3,6 @@ //// [0.tsx] import * as cx from 'classnames'; import * as React from "react"; -/*#__PURE__*/ cx('class1', { +cx('class1', { class2: !0 }); diff --git a/crates/swc/tests/tsc-references/correctlyMarkAliasAsReferences3.2.minified.js b/crates/swc/tests/tsc-references/correctlyMarkAliasAsReferences3.2.minified.js index c957a4e8f63b..d05448613793 100644 --- a/crates/swc/tests/tsc-references/correctlyMarkAliasAsReferences3.2.minified.js +++ b/crates/swc/tests/tsc-references/correctlyMarkAliasAsReferences3.2.minified.js @@ -3,6 +3,6 @@ //// [0.tsx] import * as cx from 'classnames'; import * as React from "react"; -/*#__PURE__*/ cx('class1', { +cx('class1', { class2: !0 }); diff --git a/crates/swc/tests/tsc-references/correctlyMarkAliasAsReferences4.2.minified.js b/crates/swc/tests/tsc-references/correctlyMarkAliasAsReferences4.2.minified.js index e60cca3d4fa9..0cf7fe55764f 100644 --- a/crates/swc/tests/tsc-references/correctlyMarkAliasAsReferences4.2.minified.js +++ b/crates/swc/tests/tsc-references/correctlyMarkAliasAsReferences4.2.minified.js @@ -6,7 +6,7 @@ import { _ as _object_spread } from "@swc/helpers/_/_object_spread"; import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props"; import * as cx from 'classnames'; import * as React from "react"; -/*#__PURE__*/ _object_spread_props(_object_spread({}, buttonProps), { +_object_spread_props(_object_spread({}, buttonProps), { className: cx('class1', { class2: !0 }) diff --git a/crates/swc/tests/tsc-references/inlineJsxAndJsxFragPragma.2.minified.js b/crates/swc/tests/tsc-references/inlineJsxAndJsxFragPragma.2.minified.js index 9a77cf10a895..b919a7561296 100644 --- a/crates/swc/tests/tsc-references/inlineJsxAndJsxFragPragma.2.minified.js +++ b/crates/swc/tests/tsc-references/inlineJsxAndJsxFragPragma.2.minified.js @@ -4,17 +4,17 @@ export { }; import { h, Fragment } from "./renderer"; //// [snabbdomy.tsx] import { jsx } from "./renderer"; -/*#__PURE__*/ React.Fragment; +React.Fragment; //// [preacty-only-fragment.tsx] import { h, Fragment } from "./renderer"; //// [snabbdomy-only-fragment.tsx] import { jsx } from "./renderer"; -/*#__PURE__*/ React.Fragment; +React.Fragment; //// [preacty-only-fragment-no-jsx.tsx] import { Fragment } from "./renderer"; //// [snabbdomy-only-fragment-no-jsx.tsx] import "./renderer"; -/*#__PURE__*/ React.Fragment; +React.Fragment; //// [preacty-no-fragment.tsx] import { h } from "./renderer"; //// [snabbdomy-no-fragment.tsx] diff --git a/crates/swc/tests/tsc-references/inlineJsxAndJsxFragPragmaOverridesCompilerOptions.2.minified.js b/crates/swc/tests/tsc-references/inlineJsxAndJsxFragPragmaOverridesCompilerOptions.2.minified.js index ae16c2ae337b..5c24fa9e801f 100644 --- a/crates/swc/tests/tsc-references/inlineJsxAndJsxFragPragmaOverridesCompilerOptions.2.minified.js +++ b/crates/swc/tests/tsc-references/inlineJsxAndJsxFragPragmaOverridesCompilerOptions.2.minified.js @@ -6,13 +6,13 @@ export { }; //// [snabbdom.d.ts] export { }; //// [reacty.tsx] -/*#__PURE__*/ React.Fragment; +React.Fragment; export { }; //// [preacty.tsx] import { h, Frag } from "./preact"; //// [snabbdomy.tsx] import { h } from "./snabbdom"; -/*#__PURE__*/ React.Fragment; +React.Fragment; //// [mix-n-match.tsx] import { h } from "./preact"; import { Fragment } from "./react"; diff --git a/crates/swc/tests/tsc-references/inlineJsxFactoryDeclarations.2.minified.js b/crates/swc/tests/tsc-references/inlineJsxFactoryDeclarations.2.minified.js index d0c877e6b250..170de272afd6 100644 --- a/crates/swc/tests/tsc-references/inlineJsxFactoryDeclarations.2.minified.js +++ b/crates/swc/tests/tsc-references/inlineJsxFactoryDeclarations.2.minified.js @@ -4,13 +4,13 @@ export { dom as default }; import * as React from "./renderer"; //// [other.tsx] import { dom as h } from "./renderer"; -export var prerendered = /*#__PURE__*/ h("h", null); +export var prerendered = h("h", null); //// [othernoalias.tsx] import { otherdom } from "./renderer"; -export var prerendered2 = /*#__PURE__*/ otherdom("h", null); +export var prerendered2 = otherdom("h", null); //// [reacty.tsx] import React from "./renderer"; -export var prerendered3 = /*#__PURE__*/ React.createElement("h", null); +export var prerendered3 = React.createElement("h", null); //// [index.tsx] //! x Expression expected //! ,-[3:1] diff --git a/crates/swc/tests/tsc-references/inlineJsxFactoryDeclarationsLocalTypes.2.minified.js b/crates/swc/tests/tsc-references/inlineJsxFactoryDeclarationsLocalTypes.2.minified.js index 938d8a6c2ae7..711af3574632 100644 --- a/crates/swc/tests/tsc-references/inlineJsxFactoryDeclarationsLocalTypes.2.minified.js +++ b/crates/swc/tests/tsc-references/inlineJsxFactoryDeclarationsLocalTypes.2.minified.js @@ -8,7 +8,7 @@ import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array"; var _this = this; import { predom } from "./renderer2"; export var MySFC = function(props) { - return /*#__PURE__*/ predom.apply(void 0, [ + return predom.apply(void 0, [ "p", null, props.x, @@ -23,7 +23,7 @@ export var MyClass = /*#__PURE__*/ function() { _class_call_check(this, MyClass), this.props = props; } return MyClass.prototype.render = function() { - return /*#__PURE__*/ predom.apply(void 0, [ + return predom.apply(void 0, [ "p", null, this.props.x, @@ -34,17 +34,17 @@ export var MyClass = /*#__PURE__*/ function() { ].concat(_to_consumable_array(this.props.children))); }, MyClass; }(); -export var tree = /*#__PURE__*/ predom(MySFC, { +export var tree = predom(MySFC, { x: 1, y: 2 -}, /*#__PURE__*/ predom(MyClass, { +}, predom(MyClass, { x: 3, y: 4 -}), /*#__PURE__*/ predom(MyClass, { +}), predom(MyClass, { x: 5, y: 6 })); -export default /*#__PURE__*/ predom("h", null); +export default predom("h", null); //// [index.tsx] import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array"; diff --git a/crates/swc/tests/tsc-references/inlineJsxFactoryLocalTypeGlobalFallback.2.minified.js b/crates/swc/tests/tsc-references/inlineJsxFactoryLocalTypeGlobalFallback.2.minified.js index b5dd695dc208..6b7f91e6250d 100644 --- a/crates/swc/tests/tsc-references/inlineJsxFactoryLocalTypeGlobalFallback.2.minified.js +++ b/crates/swc/tests/tsc-references/inlineJsxFactoryLocalTypeGlobalFallback.2.minified.js @@ -4,7 +4,7 @@ export { }; export { }; //// [component.tsx] import { predom } from "./renderer2"; -export default /*#__PURE__*/ predom("h", null); +export default predom("h", null); //// [index.tsx] import { dom } from "./renderer"; import prerendered from "./component"; diff --git a/crates/swc/tests/tsc-references/inlineJsxFactoryWithFragmentIsError.2.minified.js b/crates/swc/tests/tsc-references/inlineJsxFactoryWithFragmentIsError.2.minified.js index 1ba918b634a6..7aaf94abb27a 100644 --- a/crates/swc/tests/tsc-references/inlineJsxFactoryWithFragmentIsError.2.minified.js +++ b/crates/swc/tests/tsc-references/inlineJsxFactoryWithFragmentIsError.2.minified.js @@ -2,7 +2,7 @@ export { }; //// [reacty.tsx] import * as React from "./renderer"; -/*#__PURE__*/ React.Fragment; +React.Fragment; //// [index.tsx] import { dom } from "./renderer"; -/*#__PURE__*/ React.Fragment; +React.Fragment; diff --git a/crates/swc/tests/tsc-references/jsxJsxsCjsTransformCustomImport.2.minified.js b/crates/swc/tests/tsc-references/jsxJsxsCjsTransformCustomImport.2.minified.js index 7ee2280a9c7b..0162aa6a9eaa 100644 --- a/crates/swc/tests/tsc-references/jsxJsxsCjsTransformCustomImport.2.minified.js +++ b/crates/swc/tests/tsc-references/jsxJsxsCjsTransformCustomImport.2.minified.js @@ -1,4 +1,4 @@ //// [jsxJsxsCjsTransformCustomImport.tsx] Object.defineProperty(exports, "__esModule", { value: !0 -}), /*#__PURE__*/ React.Fragment; +}), React.Fragment; diff --git a/crates/swc/tests/tsc-references/jsxJsxsCjsTransformCustomImportPragma.2.minified.js b/crates/swc/tests/tsc-references/jsxJsxsCjsTransformCustomImportPragma.2.minified.js index c801fcd3d763..1132370a5489 100644 --- a/crates/swc/tests/tsc-references/jsxJsxsCjsTransformCustomImportPragma.2.minified.js +++ b/crates/swc/tests/tsc-references/jsxJsxsCjsTransformCustomImportPragma.2.minified.js @@ -1,10 +1,10 @@ //// [preact.tsx] Object.defineProperty(exports, "__esModule", { value: !0 -}), /*#__PURE__*/ require("preact/jsx-runtime").Fragment; +}), require("preact/jsx-runtime").Fragment; //// [react.tsx] Object.defineProperty(exports, "__esModule", { value: !0 }); var _jsxruntime = require("react/jsx-runtime"); -require("./preact"), /*#__PURE__*/ _jsxruntime.Fragment; +require("./preact"), _jsxruntime.Fragment; diff --git a/crates/swc/tests/tsc-references/jsxJsxsCjsTransformKeyProp.2.minified.js b/crates/swc/tests/tsc-references/jsxJsxsCjsTransformKeyProp.2.minified.js index 0fb4afe7de1a..da0c8e7df06f 100644 --- a/crates/swc/tests/tsc-references/jsxJsxsCjsTransformKeyProp.2.minified.js +++ b/crates/swc/tests/tsc-references/jsxJsxsCjsTransformKeyProp.2.minified.js @@ -5,8 +5,8 @@ Object.defineProperty(exports, "__esModule", { var _object_spread = require("@swc/helpers/_/_object_spread"), _object_spread_props = require("@swc/helpers/_/_object_spread_props"), props = { answer: 42 }; -/*#__PURE__*/ _object_spread._({ +_object_spread._({ key: "foo" -}, props), /*#__PURE__*/ _object_spread_props._(_object_spread._({}, props), { +}, props), _object_spread_props._(_object_spread._({}, props), { key: "bar" }); diff --git a/crates/swc/tests/tsc-references/jsxJsxsCjsTransformKeyPropCustomImport.2.minified.js b/crates/swc/tests/tsc-references/jsxJsxsCjsTransformKeyPropCustomImport.2.minified.js index 408c2455fda6..106370bd9dde 100644 --- a/crates/swc/tests/tsc-references/jsxJsxsCjsTransformKeyPropCustomImport.2.minified.js +++ b/crates/swc/tests/tsc-references/jsxJsxsCjsTransformKeyPropCustomImport.2.minified.js @@ -5,8 +5,8 @@ Object.defineProperty(exports, "__esModule", { var _object_spread = require("@swc/helpers/_/_object_spread"), _object_spread_props = require("@swc/helpers/_/_object_spread_props"), props = { answer: 42 }; -/*#__PURE__*/ _object_spread._({ +_object_spread._({ key: "foo" -}, props), /*#__PURE__*/ _object_spread_props._(_object_spread._({}, props), { +}, props), _object_spread_props._(_object_spread._({}, props), { key: "bar" }); diff --git a/crates/swc/tests/tsc-references/jsxJsxsCjsTransformKeyPropCustomImportPragma.2.minified.js b/crates/swc/tests/tsc-references/jsxJsxsCjsTransformKeyPropCustomImportPragma.2.minified.js index b18f28fbb234..7887fda63721 100644 --- a/crates/swc/tests/tsc-references/jsxJsxsCjsTransformKeyPropCustomImportPragma.2.minified.js +++ b/crates/swc/tests/tsc-references/jsxJsxsCjsTransformKeyPropCustomImportPragma.2.minified.js @@ -7,9 +7,9 @@ require("preact/jsx-runtime"), require("preact"); var props = { answer: 42 }; -/*#__PURE__*/ _object_spread_props._(_object_spread._({}, props), { +_object_spread_props._(_object_spread._({}, props), { children: "text" -}), /*#__PURE__*/ _object_spread_props._(_object_spread._({}, props), { +}), _object_spread_props._(_object_spread._({}, props), { key: "bar" }); //// [react.tsx] @@ -21,8 +21,8 @@ require("react/jsx-runtime"), require("react"), require("./preact"); var props2 = { answer: 42 }; -/*#__PURE__*/ _object_spread_props._(_object_spread._({}, props2), { +_object_spread_props._(_object_spread._({}, props2), { children: "text" -}), /*#__PURE__*/ _object_spread_props._(_object_spread._({}, props2), { +}), _object_spread_props._(_object_spread._({}, props2), { key: "bar" }); diff --git a/crates/swc/tests/tsc-references/jsxJsxsCjsTransformNestedSelfClosingChild.2.minified.js b/crates/swc/tests/tsc-references/jsxJsxsCjsTransformNestedSelfClosingChild.2.minified.js index 7ce9b60b5ff5..da23879d111f 100644 --- a/crates/swc/tests/tsc-references/jsxJsxsCjsTransformNestedSelfClosingChild.2.minified.js +++ b/crates/swc/tests/tsc-references/jsxJsxsCjsTransformNestedSelfClosingChild.2.minified.js @@ -1,11 +1,11 @@ //// [jsxJsxsCjsTransformNestedSelfClosingChild.tsx] Object.defineProperty(exports, "__esModule", { value: !0 -}), console.log(/*#__PURE__*/ React.createElement("div", null, /*#__PURE__*/ React.createElement("div", null))), console.log(/*#__PURE__*/ React.createElement("div", null, /*#__PURE__*/ React.createElement("div", null), /*#__PURE__*/ React.createElement("div", null))), console.log(/*#__PURE__*/ React.createElement("div", null, [ +}), console.log(React.createElement("div", null, React.createElement("div", null))), console.log(React.createElement("div", null, React.createElement("div", null), React.createElement("div", null))), console.log(React.createElement("div", null, [ 1, 2 ].map(function(i) { - return /*#__PURE__*/ React.createElement("div", { + return React.createElement("div", { key: i }, i); }))); diff --git a/crates/swc/tests/tsc-references/jsxJsxsCjsTransformSubstitutesNamesFragment.2.minified.js b/crates/swc/tests/tsc-references/jsxJsxsCjsTransformSubstitutesNamesFragment.2.minified.js index 996cea92240d..5027af0a3a7c 100644 --- a/crates/swc/tests/tsc-references/jsxJsxsCjsTransformSubstitutesNamesFragment.2.minified.js +++ b/crates/swc/tests/tsc-references/jsxJsxsCjsTransformSubstitutesNamesFragment.2.minified.js @@ -1,4 +1,4 @@ //// [jsxJsxsCjsTransformSubstitutesNamesFragment.tsx] Object.defineProperty(exports, "__esModule", { value: !0 -}), /*#__PURE__*/ React.Fragment; +}), React.Fragment; diff --git a/crates/swc/tests/tsc-references/jsxReactTestSuite.2.minified.js b/crates/swc/tests/tsc-references/jsxReactTestSuite.2.minified.js index 6a937b036578..881f3957d41a 100644 --- a/crates/swc/tests/tsc-references/jsxReactTestSuite.2.minified.js +++ b/crates/swc/tests/tsc-references/jsxReactTestSuite.2.minified.js @@ -1,19 +1,19 @@ //// [jsxReactTestSuite.tsx] import { _ as _object_spread } from "@swc/helpers/_/_object_spread"; import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props"; -/*#__PURE__*/ this.props.children, Component, foo, bar, Composite, this.props.children, Composite, /*#__PURE__*/ Composite2; -var x = /*#__PURE__*/ React.createElement("div", { +this.props.children, Component, foo, bar, Composite, this.props.children, Composite, Composite2; +var x = React.createElement("div", { attr1: "foobar", attr2: "foobarbazbug", attr3: "foobarbazbug", attr4: "baz" }); -/*#__PURE__*/ Component, /*#__PURE__*/ Namespace.Component, /*#__PURE__*/ Namespace.DeepNamespace.Component, Component, _object_spread_props(_object_spread({}, x), { +Component, Namespace.Component, Namespace.DeepNamespace.Component, Component, _object_spread_props(_object_spread({}, x), { y: 2, z: !0 }), Component, _object_spread_props(_object_spread({}, this.props), { sound: "moo" -}), Component, y, /*#__PURE__*/ Component, Component, _object_spread_props(_object_spread({}, x), { +}), Component, y, Component, Component, _object_spread_props(_object_spread({}, x), { y: 2 }), Component, _object_spread_props(_object_spread({}, x), { y: 2, @@ -23,7 +23,7 @@ var x = /*#__PURE__*/ React.createElement("div", { }, y), Component, _object_spread({ x: 1, y: "2" -}, z, z), /*#__PURE__*/ Child, Component, _object_spread_props(_object_spread({ +}, z, z), Child, Component, _object_spread_props(_object_spread({ x: "1" }, z = { y: 2 diff --git a/crates/swc/tests/tsc-references/multiline.2.minified.js b/crates/swc/tests/tsc-references/multiline.2.minified.js index 3a2468b4053e..d167384e8709 100644 --- a/crates/swc/tests/tsc-references/multiline.2.minified.js +++ b/crates/swc/tests/tsc-references/multiline.2.minified.js @@ -4,5 +4,5 @@ texts.push(100), texts.push(100), texts.push("100"); //// [b.tsx] import * as React from "react"; export function MyComponent(props) { - return /*#__PURE__*/ React.createElement("div", null); + return React.createElement("div", null); } diff --git a/crates/swc/tests/tsc-references/tsxAttributeResolution12.2.minified.js b/crates/swc/tests/tsc-references/tsxAttributeResolution12.2.minified.js index 5dd6f7cbb5fa..78ba9285b56f 100644 --- a/crates/swc/tests/tsc-references/tsxAttributeResolution12.2.minified.js +++ b/crates/swc/tests/tsc-references/tsxAttributeResolution12.2.minified.js @@ -1,4 +1,4 @@ //// [tsxAttributeResolution12.tsx] //// [react.d.ts] //// [file.tsx] -TestMod.Test, /*#__PURE__*/ TestMod.Test; +TestMod.Test, TestMod.Test; diff --git a/crates/swc/tests/tsc-references/tsxAttributeResolution3.2.minified.js b/crates/swc/tests/tsc-references/tsxAttributeResolution3.2.minified.js index cd17da1327d4..ad6cee1d359e 100644 --- a/crates/swc/tests/tsc-references/tsxAttributeResolution3.2.minified.js +++ b/crates/swc/tests/tsc-references/tsxAttributeResolution3.2.minified.js @@ -1,17 +1,17 @@ //// [file.tsx] import { _ as _object_spread } from "@swc/helpers/_/_object_spread"; import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props"; -/*#__PURE__*/ _object_spread_props(_object_spread({}, { +_object_spread_props(_object_spread({}, { x: 32, y: 32 }), { x: "ok" -}), /*#__PURE__*/ _object_spread({ +}), _object_spread({ x: "ok" }, { x: 32, y: 32 -}), /*#__PURE__*/ _object_spread({ +}), _object_spread({ x: 32 }, { x: 'foo' diff --git a/crates/swc/tests/tsc-references/tsxCorrectlyParseLessThanComparison1.2.minified.js b/crates/swc/tests/tsc-references/tsxCorrectlyParseLessThanComparison1.2.minified.js index 7d8b389c76aa..e1ed9d1cc174 100644 --- a/crates/swc/tests/tsc-references/tsxCorrectlyParseLessThanComparison1.2.minified.js +++ b/crates/swc/tests/tsc-references/tsxCorrectlyParseLessThanComparison1.2.minified.js @@ -7,6 +7,6 @@ export var ShortDetails = /*#__PURE__*/ function(_React_Component) { return _class_call_check(this, ShortDetails), _call_super(this, ShortDetails, arguments); } return _inherits(ShortDetails, _React_Component), ShortDetails.prototype.render = function() { - if (this.props.id < 1) return /*#__PURE__*/ React.createElement("div", null); + if (this.props.id < 1) return React.createElement("div", null); }, ShortDetails; }(React.Component); diff --git a/crates/swc/tests/tsc-references/tsxDynamicTagName5.2.minified.js b/crates/swc/tests/tsc-references/tsxDynamicTagName5.2.minified.js index e3b123edbd3a..67f87e880934 100644 --- a/crates/swc/tests/tsc-references/tsxDynamicTagName5.2.minified.js +++ b/crates/swc/tests/tsc-references/tsxDynamicTagName5.2.minified.js @@ -11,6 +11,6 @@ export var Text = /*#__PURE__*/ function(_React_Component) { return _class_call_check(this, Text), _this = _call_super(this, Text, arguments), _this._tagName = 'div', _this; } return _inherits(Text, _React_Component), Text.prototype.render = function() { - return /*#__PURE__*/ React.createElement(this._tagName, null); + return React.createElement(this._tagName, null); }, Text; }(React.Component); diff --git a/crates/swc/tests/tsc-references/tsxDynamicTagName7.2.minified.js b/crates/swc/tests/tsc-references/tsxDynamicTagName7.2.minified.js index f3871197d1f8..8f6c6cca0b6c 100644 --- a/crates/swc/tests/tsc-references/tsxDynamicTagName7.2.minified.js +++ b/crates/swc/tests/tsc-references/tsxDynamicTagName7.2.minified.js @@ -11,6 +11,6 @@ export var Text = /*#__PURE__*/ function(_React_Component) { return _class_call_check(this, Text), _this = _call_super(this, Text, arguments), _this._tagName = 'div', _this; } return _inherits(Text, _React_Component), Text.prototype.render = function() { - return /*#__PURE__*/ React.createElement(this, null); + return React.createElement(this, null); }, Text; }(React.Component); diff --git a/crates/swc/tests/tsc-references/tsxDynamicTagName8.2.minified.js b/crates/swc/tests/tsc-references/tsxDynamicTagName8.2.minified.js index 65710a6f393c..c1f04613d627 100644 --- a/crates/swc/tests/tsc-references/tsxDynamicTagName8.2.minified.js +++ b/crates/swc/tests/tsc-references/tsxDynamicTagName8.2.minified.js @@ -11,6 +11,6 @@ export var Text = /*#__PURE__*/ function(_React_Component) { return _class_call_check(this, Text), _this = _call_super(this, Text, arguments), _this._tagName = 'div', _this; } return _inherits(Text, _React_Component), Text.prototype.render = function() { - return /*#__PURE__*/ React.createElement(this._tagName, null, " Hello world "); + return React.createElement(this._tagName, null, " Hello world "); }, Text; }(React.Component); diff --git a/crates/swc/tests/tsc-references/tsxDynamicTagName9.2.minified.js b/crates/swc/tests/tsc-references/tsxDynamicTagName9.2.minified.js index ed176001eb37..28e5be9e773f 100644 --- a/crates/swc/tests/tsc-references/tsxDynamicTagName9.2.minified.js +++ b/crates/swc/tests/tsc-references/tsxDynamicTagName9.2.minified.js @@ -11,6 +11,6 @@ export var Text = /*#__PURE__*/ function(_React_Component) { return _class_call_check(this, Text), _this = _call_super(this, Text, arguments), _this._tagName = 'div', _this; } return _inherits(Text, _React_Component), Text.prototype.render = function() { - return /*#__PURE__*/ React.createElement(this._tagName, null, " Hello world "); + return React.createElement(this._tagName, null, " Hello world "); }, Text; }(React.Component); diff --git a/crates/swc/tests/tsc-references/tsxElementResolution.2.minified.js b/crates/swc/tests/tsc-references/tsxElementResolution.2.minified.js index 61871c6f0bca..3f6a50ffb39d 100644 --- a/crates/swc/tests/tsc-references/tsxElementResolution.2.minified.js +++ b/crates/swc/tests/tsc-references/tsxElementResolution.2.minified.js @@ -3,4 +3,4 @@ var Dotted; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; (Dotted || (Dotted = {})).Name = function Name() { _class_call_check(this, Name); -}, /*#__PURE__*/ Dotted.Name; +}, Dotted.Name; diff --git a/crates/swc/tests/tsc-references/tsxElementResolution17.2.minified.js b/crates/swc/tests/tsc-references/tsxElementResolution17.2.minified.js index 3d54c5986790..e9c42c0d2fc9 100644 --- a/crates/swc/tests/tsc-references/tsxElementResolution17.2.minified.js +++ b/crates/swc/tests/tsc-references/tsxElementResolution17.2.minified.js @@ -14,5 +14,5 @@ define([ ], function(require, exports, _elements1) { Object.defineProperty(exports, "__esModule", { value: !0 - }), /*#__PURE__*/ _elements1.MyElement; + }), _elements1.MyElement; }); diff --git a/crates/swc/tests/tsc-references/tsxElementResolution19.2.minified.js b/crates/swc/tests/tsc-references/tsxElementResolution19.2.minified.js index c3d037b60961..85d91d3369d6 100644 --- a/crates/swc/tests/tsc-references/tsxElementResolution19.2.minified.js +++ b/crates/swc/tests/tsc-references/tsxElementResolution19.2.minified.js @@ -34,5 +34,5 @@ define([ ], function(require, exports, _interop_require_wildcard, _react, _file1) { Object.defineProperty(exports, "__esModule", { value: !0 - }), _react = /*#__PURE__*/ _interop_require_wildcard._(_react), /*#__PURE__*/ _file1.MyClass; + }), _react = /*#__PURE__*/ _interop_require_wildcard._(_react), _file1.MyClass; }); diff --git a/crates/swc/tests/tsc-references/tsxElementResolution7.2.minified.js b/crates/swc/tests/tsc-references/tsxElementResolution7.2.minified.js index e388431ff276..7a17146c7938 100644 --- a/crates/swc/tests/tsc-references/tsxElementResolution7.2.minified.js +++ b/crates/swc/tests/tsc-references/tsxElementResolution7.2.minified.js @@ -1,3 +1,3 @@ //// [file.tsx] var my, q, mine; -my || (my = {}), /*#__PURE__*/ my.div, /*#__PURE__*/ my.other, q || (q = {}), /*#__PURE__*/ (mine = my).div, /*#__PURE__*/ mine.non; +my || (my = {}), my.div, my.other, q || (q = {}), (mine = my).div, mine.non; diff --git a/crates/swc/tests/tsc-references/tsxEmit2.2.minified.js b/crates/swc/tests/tsc-references/tsxEmit2.2.minified.js index cbe10c0d6bd5..48eed89ed72c 100644 --- a/crates/swc/tests/tsc-references/tsxEmit2.2.minified.js +++ b/crates/swc/tests/tsc-references/tsxEmit2.2.minified.js @@ -2,11 +2,11 @@ var p1, p2, p3; import { _ as _object_spread } from "@swc/helpers/_/_object_spread"; import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props"; -/*#__PURE__*/ _object_spread({ +_object_spread({ x: p3 -}, p1), /*#__PURE__*/ _object_spread_props(_object_spread({}, p1), { +}, p1), _object_spread_props(_object_spread({}, p1), { x: p3 -}), /*#__PURE__*/ _object_spread_props(_object_spread({ +}), _object_spread_props(_object_spread({ x: p2 }, p1), { y: p3 diff --git a/crates/swc/tests/tsc-references/tsxEmit3.2.minified.js b/crates/swc/tests/tsc-references/tsxEmit3.2.minified.js index 3ef262764471..b90f0911964c 100644 --- a/crates/swc/tests/tsc-references/tsxEmit3.2.minified.js +++ b/crates/swc/tests/tsc-references/tsxEmit3.2.minified.js @@ -5,4 +5,4 @@ import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; _class_call_check(this, Foo1); }, (M1.S || (M1.S = {})).Bar = function Bar1() { _class_call_check(this, Bar1); -}, Foo, /*#__PURE__*/ Foo, (M2 = M || (M = {})).S || (M2.S = {}), Foo, /*#__PURE__*/ Foo, Bar, /*#__PURE__*/ Bar, M || (M = {}), S.Bar, /*#__PURE__*/ S.Bar, M || (M = {}), Foo, /*#__PURE__*/ Foo; +}, Foo, Foo, (M2 = M || (M = {})).S || (M2.S = {}), Foo, Foo, Bar, Bar, M || (M = {}), S.Bar, S.Bar, M || (M = {}), Foo, Foo; diff --git a/crates/swc/tests/tsc-references/tsxExternalModuleEmit1.2.minified.js b/crates/swc/tests/tsc-references/tsxExternalModuleEmit1.2.minified.js index 70230120319b..9596dd4f999b 100644 --- a/crates/swc/tests/tsc-references/tsxExternalModuleEmit1.2.minified.js +++ b/crates/swc/tests/tsc-references/tsxExternalModuleEmit1.2.minified.js @@ -14,7 +14,7 @@ var _call_super = require("@swc/helpers/_/_call_super"), _class_call_check = req return _class_call_check._(this, App), _call_super._(this, App, arguments); } return _inherits._(App, _React_Component), App.prototype.render = function() { - return /*#__PURE__*/ _react.createElement(_button.Button, null); + return _react.createElement(_button.Button, null); }, App; }(_react.Component); //// [button.tsx] @@ -31,6 +31,6 @@ var _call_super = require("@swc/helpers/_/_call_super"), _class_call_check = req return _class_call_check._(this, Button), _call_super._(this, Button, arguments); } return _inherits._(Button, _React_Component), Button.prototype.render = function() { - return /*#__PURE__*/ _react.createElement("button", null, "Some button"); + return _react.createElement("button", null, "Some button"); }, Button; }(_react.Component); diff --git a/crates/swc/tests/tsc-references/tsxFragmentPreserveEmit.2.minified.js b/crates/swc/tests/tsc-references/tsxFragmentPreserveEmit.2.minified.js index b819ab993bf7..6d678e6a6251 100644 --- a/crates/swc/tests/tsc-references/tsxFragmentPreserveEmit.2.minified.js +++ b/crates/swc/tests/tsc-references/tsxFragmentPreserveEmit.2.minified.js @@ -1,2 +1,2 @@ //// [file.tsx] -/*#__PURE__*/ React.Fragment, /*#__PURE__*/ React.Fragment, /*#__PURE__*/ React.Fragment, /*#__PURE__*/ React.Fragment, /*#__PURE__*/ React.Fragment, React.Fragment, /*#__PURE__*/ React.Fragment, /*#__PURE__*/ React.Fragment; +React.Fragment, React.Fragment, React.Fragment, React.Fragment, React.Fragment, React.Fragment, React.Fragment, React.Fragment; diff --git a/crates/swc/tests/tsc-references/tsxFragmentReactEmit.2.minified.js b/crates/swc/tests/tsc-references/tsxFragmentReactEmit.2.minified.js index b819ab993bf7..6d678e6a6251 100644 --- a/crates/swc/tests/tsc-references/tsxFragmentReactEmit.2.minified.js +++ b/crates/swc/tests/tsc-references/tsxFragmentReactEmit.2.minified.js @@ -1,2 +1,2 @@ //// [file.tsx] -/*#__PURE__*/ React.Fragment, /*#__PURE__*/ React.Fragment, /*#__PURE__*/ React.Fragment, /*#__PURE__*/ React.Fragment, /*#__PURE__*/ React.Fragment, React.Fragment, /*#__PURE__*/ React.Fragment, /*#__PURE__*/ React.Fragment; +React.Fragment, React.Fragment, React.Fragment, React.Fragment, React.Fragment, React.Fragment, React.Fragment, React.Fragment; diff --git a/crates/swc/tests/tsc-references/tsxNoJsx.2.minified.js b/crates/swc/tests/tsc-references/tsxNoJsx.2.minified.js index 6fd93721427b..3320b929581b 100644 --- a/crates/swc/tests/tsc-references/tsxNoJsx.2.minified.js +++ b/crates/swc/tests/tsc-references/tsxNoJsx.2.minified.js @@ -1,2 +1 @@ //// [tsxNoJsx.tsx] -/*#__PURE__*/ diff --git a/crates/swc/tests/tsc-references/tsxOpeningClosingNames.2.minified.js b/crates/swc/tests/tsc-references/tsxOpeningClosingNames.2.minified.js index 75b2fe879519..f87f3d02fd78 100644 --- a/crates/swc/tests/tsc-references/tsxOpeningClosingNames.2.minified.js +++ b/crates/swc/tests/tsc-references/tsxOpeningClosingNames.2.minified.js @@ -1,2 +1,2 @@ //// [file.tsx] -/*#__PURE__*/ A.B.C.D; +A.B.C.D; diff --git a/crates/swc/tests/tsc-references/tsxPreserveEmit1.2.minified.js b/crates/swc/tests/tsc-references/tsxPreserveEmit1.2.minified.js index 6e29cf55e39a..e08b93bc3891 100644 --- a/crates/swc/tests/tsc-references/tsxPreserveEmit1.2.minified.js +++ b/crates/swc/tests/tsc-references/tsxPreserveEmit1.2.minified.js @@ -16,5 +16,5 @@ define([ var M; Object.defineProperty(exports, "__esModule", { value: !0 - }), _reactrouter.Route, M || (M = {}), M || (M = {}), /*#__PURE__*/ X; + }), _reactrouter.Route, M || (M = {}), M || (M = {}), X; }); diff --git a/crates/swc/tests/tsc-references/tsxReactEmit2.2.minified.js b/crates/swc/tests/tsc-references/tsxReactEmit2.2.minified.js index cbe10c0d6bd5..48eed89ed72c 100644 --- a/crates/swc/tests/tsc-references/tsxReactEmit2.2.minified.js +++ b/crates/swc/tests/tsc-references/tsxReactEmit2.2.minified.js @@ -2,11 +2,11 @@ var p1, p2, p3; import { _ as _object_spread } from "@swc/helpers/_/_object_spread"; import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props"; -/*#__PURE__*/ _object_spread({ +_object_spread({ x: p3 -}, p1), /*#__PURE__*/ _object_spread_props(_object_spread({}, p1), { +}, p1), _object_spread_props(_object_spread({}, p1), { x: p3 -}), /*#__PURE__*/ _object_spread_props(_object_spread({ +}), _object_spread_props(_object_spread({ x: p2 }, p1), { y: p3 diff --git a/crates/swc/tests/tsc-references/tsxReactEmit3.2.minified.js b/crates/swc/tests/tsc-references/tsxReactEmit3.2.minified.js index 66caa74c7ed7..2dc9c2dc400e 100644 --- a/crates/swc/tests/tsc-references/tsxReactEmit3.2.minified.js +++ b/crates/swc/tests/tsc-references/tsxReactEmit3.2.minified.js @@ -1,2 +1,2 @@ //// [test.tsx] -/*#__PURE__*/ Foo, /*#__PURE__*/ Bar, /*#__PURE__*/ Bar, /*#__PURE__*/ Bar, /*#__PURE__*/ Bar; +Foo, Bar, Bar, Bar, Bar; diff --git a/crates/swc/tests/tsc-references/tsxReactEmit4.2.minified.js b/crates/swc/tests/tsc-references/tsxReactEmit4.2.minified.js index 85f45c7a791a..b2e24f3f3546 100644 --- a/crates/swc/tests/tsc-references/tsxReactEmit4.2.minified.js +++ b/crates/swc/tests/tsc-references/tsxReactEmit4.2.minified.js @@ -2,6 +2,6 @@ var p; import { _ as _object_spread } from "@swc/helpers/_/_object_spread"; import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props"; -/*#__PURE__*/ blah, /*#__PURE__*/ _object_spread_props(_object_spread({}, p), { +blah, _object_spread_props(_object_spread({}, p), { x: 0 }); diff --git a/crates/swc/tests/tsc-references/tsxReactEmit5.2.minified.js b/crates/swc/tests/tsc-references/tsxReactEmit5.2.minified.js index e4242f154677..635699a978ed 100644 --- a/crates/swc/tests/tsc-references/tsxReactEmit5.2.minified.js +++ b/crates/swc/tests/tsc-references/tsxReactEmit5.2.minified.js @@ -15,7 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: !0 }); var foo, _object_spread = require("@swc/helpers/_/_object_spread"), _object_spread_props = require("@swc/helpers/_/_object_spread_props"); -require("./test"), /*#__PURE__*/ _object_spread_props._(_object_spread._({ +require("./test"), _object_spread_props._(_object_spread._({ x: "" }, foo), { y: "" diff --git a/crates/swc/tests/tsc-references/tsxReactEmit6.2.minified.js b/crates/swc/tests/tsc-references/tsxReactEmit6.2.minified.js index c677ba2ee387..09adcfbc269d 100644 --- a/crates/swc/tests/tsc-references/tsxReactEmit6.2.minified.js +++ b/crates/swc/tests/tsc-references/tsxReactEmit6.2.minified.js @@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", { value: !0 }); var foo, M, _object_spread = require("@swc/helpers/_/_object_spread"); -M || (M = {}), M || (M = {}), /*#__PURE__*/ require("@swc/helpers/_/_object_spread_props")._(_object_spread._({ +M || (M = {}), M || (M = {}), require("@swc/helpers/_/_object_spread_props")._(_object_spread._({ x: "" }, foo), { y: "" diff --git a/crates/swc/tests/tsc-references/tsxReactEmit8.2.minified.js b/crates/swc/tests/tsc-references/tsxReactEmit8.2.minified.js index ebb688898b7d..b4a77ef0f778 100644 --- a/crates/swc/tests/tsc-references/tsxReactEmit8.2.minified.js +++ b/crates/swc/tests/tsc-references/tsxReactEmit8.2.minified.js @@ -1,2 +1 @@ //// [tsxReactEmit8.tsx] -/*#__PURE__*/ diff --git a/crates/swc/tests/tsc-references/tsxSpreadAttributesResolution17.2.minified.js b/crates/swc/tests/tsc-references/tsxSpreadAttributesResolution17.2.minified.js index 3eecce017757..3d2f57b39b9c 100644 --- a/crates/swc/tests/tsc-references/tsxSpreadAttributesResolution17.2.minified.js +++ b/crates/swc/tests/tsc-references/tsxSpreadAttributesResolution17.2.minified.js @@ -7,7 +7,7 @@ export var Empty = /*#__PURE__*/ function(_React_Component) { return _class_call_check(this, Empty), _call_super(this, Empty, arguments); } return _inherits(Empty, _React_Component), Empty.prototype.render = function() { - return /*#__PURE__*/ React.createElement("div", null, "Hello"); + return React.createElement("div", null, "Hello"); }, Empty; }(React.Component); -/*#__PURE__*/ obj; +obj; diff --git a/crates/swc/tests/tsc-references/tsxStatelessFunctionComponentOverload1.2.minified.js b/crates/swc/tests/tsc-references/tsxStatelessFunctionComponentOverload1.2.minified.js index 97fedaf3801d..f4b879bc672d 100644 --- a/crates/swc/tests/tsc-references/tsxStatelessFunctionComponentOverload1.2.minified.js +++ b/crates/swc/tests/tsc-references/tsxStatelessFunctionComponentOverload1.2.minified.js @@ -6,5 +6,5 @@ define([ ], function(require, exports, _react) { Object.defineProperty(exports, "__esModule", { value: !0 - }), /*#__PURE__*/ OneThing, /*#__PURE__*/ OneThing, /*#__PURE__*/ OneThing, /*#__PURE__*/ OneThing, /*#__PURE__*/ OneThing, /*#__PURE__*/ TestingOneThing, /*#__PURE__*/ TestingOneThing, /*#__PURE__*/ TestingOneThing, /*#__PURE__*/ TestingOneThing, /*#__PURE__*/ TestingOneThing, /*#__PURE__*/ TestingOptional, /*#__PURE__*/ TestingOptional, /*#__PURE__*/ TestingOptional, /*#__PURE__*/ TestingOptional, /*#__PURE__*/ TestingOptional, /*#__PURE__*/ TestingOptional; + }), OneThing, OneThing, OneThing, OneThing, OneThing, TestingOneThing, TestingOneThing, TestingOneThing, TestingOneThing, TestingOneThing, TestingOptional, TestingOptional, TestingOptional, TestingOptional, TestingOptional, TestingOptional; }); diff --git a/crates/swc/tests/tsc-references/tsxStatelessFunctionComponentOverload2.2.minified.js b/crates/swc/tests/tsc-references/tsxStatelessFunctionComponentOverload2.2.minified.js index fcf160ea7fc7..e98ba89f17ea 100644 --- a/crates/swc/tests/tsc-references/tsxStatelessFunctionComponentOverload2.2.minified.js +++ b/crates/swc/tests/tsc-references/tsxStatelessFunctionComponentOverload2.2.minified.js @@ -15,7 +15,7 @@ define([ }, obj1 = { yy: !0 }; - /*#__PURE__*/ OneThing, /*#__PURE__*/ OneThing, /*#__PURE__*/ OneThing, OneThing, _object_spread._({}, obj1, obj), OneThing, _object_spread_props._(_object_spread._({}, obj1), { + OneThing, OneThing, OneThing, OneThing, _object_spread._({}, obj1, obj), OneThing, _object_spread_props._(_object_spread._({}, obj1), { yy: 42, yy1: "hi" }), OneThing, _object_spread_props._(_object_spread._({}, obj1), { @@ -23,7 +23,7 @@ define([ yy1: "true" }), OneThing, _object_spread._(_object_spread_props._(_object_spread._({}, defaultObj), { yy: !0 - }), obj), /*#__PURE__*/ OneThing, /*#__PURE__*/ OneThing, OneThing, _object_spread_props._(_object_spread._({}, { + }), obj), OneThing, OneThing, OneThing, _object_spread_props._(_object_spread._({}, { yy: 500, "ignore-prop": "hello" }), { diff --git a/crates/swc/tests/tsc-references/tsxStatelessFunctionComponentOverload3.2.minified.js b/crates/swc/tests/tsc-references/tsxStatelessFunctionComponentOverload3.2.minified.js index 47ab83468ee1..95d827e8602c 100644 --- a/crates/swc/tests/tsc-references/tsxStatelessFunctionComponentOverload3.2.minified.js +++ b/crates/swc/tests/tsc-references/tsxStatelessFunctionComponentOverload3.2.minified.js @@ -8,11 +8,11 @@ define([ var obj2; Object.defineProperty(exports, "__esModule", { value: !0 - }), /*#__PURE__*/ ZeroThingOrTwoThing, /*#__PURE__*/ ZeroThingOrTwoThing, /*#__PURE__*/ ZeroThingOrTwoThing, ZeroThingOrTwoThing, _object_spread._({ + }), ZeroThingOrTwoThing, ZeroThingOrTwoThing, ZeroThingOrTwoThing, ZeroThingOrTwoThing, _object_spread._({ yy: 1000 }, obj2), ZeroThingOrTwoThing, _object_spread_props._(_object_spread._({}, obj2), { yy: 1000 - }), /*#__PURE__*/ ThreeThing, /*#__PURE__*/ ThreeThing, ThreeThing, _object_spread_props._(_object_spread._({}, obj2), { + }), ThreeThing, ThreeThing, ThreeThing, _object_spread_props._(_object_spread._({}, obj2), { y2: 10 }); }); diff --git a/crates/swc/tests/tsc-references/tsxStatelessFunctionComponentOverload4.2.minified.js b/crates/swc/tests/tsc-references/tsxStatelessFunctionComponentOverload4.2.minified.js index 964e68a5f4c1..4de4c0619a1b 100644 --- a/crates/swc/tests/tsc-references/tsxStatelessFunctionComponentOverload4.2.minified.js +++ b/crates/swc/tests/tsc-references/tsxStatelessFunctionComponentOverload4.2.minified.js @@ -13,7 +13,7 @@ define([ yy: 10, yy1: "hello" }; - /*#__PURE__*/ OneThing, /*#__PURE__*/ OneThing, OneThing, _object_spread_props._(_object_spread._({}, obj), { + OneThing, OneThing, OneThing, _object_spread_props._(_object_spread._({}, obj), { yy1: !0 }), OneThing, _object_spread_props._(_object_spread._({}, obj), { extra: "extra attr" @@ -25,5 +25,5 @@ define([ extra: "extra attr" }), OneThing, _object_spread_props._(_object_spread._({}, obj2), { yy: !0 - }), /*#__PURE__*/ TestingOneThing, /*#__PURE__*/ TestingOneThing, /*#__PURE__*/ TestingOptional, /*#__PURE__*/ TestingOptional, /*#__PURE__*/ TestingOptional, /*#__PURE__*/ TestingOptional; + }), TestingOneThing, TestingOneThing, TestingOptional, TestingOptional, TestingOptional, TestingOptional; }); diff --git a/crates/swc/tests/tsc-references/tsxStatelessFunctionComponentOverload5.2.minified.js b/crates/swc/tests/tsc-references/tsxStatelessFunctionComponentOverload5.2.minified.js index 630012b88a0f..6aaad2575af8 100644 --- a/crates/swc/tests/tsc-references/tsxStatelessFunctionComponentOverload5.2.minified.js +++ b/crates/swc/tests/tsc-references/tsxStatelessFunctionComponentOverload5.2.minified.js @@ -20,15 +20,15 @@ define([ function MainButton(props) { return props.to ? this._buildMainLink(props) : this._buildMainButton(props); } - /*#__PURE__*/ _object_spread._({ + _object_spread._({ onClick: function(e) {} - }, obj0), /*#__PURE__*/ _object_spread._({ + }, obj0), _object_spread._({ to: "10000" }, { onClick: function() {} - }), /*#__PURE__*/ _object_spread_props._(_object_spread._({}, obj3), { + }), _object_spread_props._(_object_spread._({}, obj3), { to: !0 - }), /*#__PURE__*/ _object_spread._({ + }), _object_spread._({ onClick: function(e) {} }, obj0); }); diff --git a/crates/swc/tests/tsc-references/tsxStatelessFunctionComponentOverload6.2.minified.js b/crates/swc/tests/tsc-references/tsxStatelessFunctionComponentOverload6.2.minified.js index e23b03c2d905..2b5f421fb29f 100644 --- a/crates/swc/tests/tsc-references/tsxStatelessFunctionComponentOverload6.2.minified.js +++ b/crates/swc/tests/tsc-references/tsxStatelessFunctionComponentOverload6.2.minified.js @@ -17,12 +17,12 @@ define([ get: function() { return MainButton; } - }), /*#__PURE__*/ _object_spread._({ + }), _object_spread._({ to: 10000 }, { children: "hi", to: "boo" - }), /*#__PURE__*/ _object_spread_props._(_object_spread._({}, obj1), { + }), _object_spread_props._(_object_spread._({}, obj1), { to: "/to/somewhere" }); }); diff --git a/crates/swc/tests/tsc-references/tsxStatelessFunctionComponentsWithTypeArguments1.2.minified.js b/crates/swc/tests/tsc-references/tsxStatelessFunctionComponentsWithTypeArguments1.2.minified.js index beeccc705c0d..9e3034872c3d 100644 --- a/crates/swc/tests/tsc-references/tsxStatelessFunctionComponentsWithTypeArguments1.2.minified.js +++ b/crates/swc/tests/tsc-references/tsxStatelessFunctionComponentsWithTypeArguments1.2.minified.js @@ -6,5 +6,5 @@ define([ ], function(require, exports, _react) { Object.defineProperty(exports, "__esModule", { value: !0 - }), /*#__PURE__*/ InferParamComponent; + }), InferParamComponent; }); diff --git a/crates/swc/tests/tsc-references/tsxStatelessFunctionComponentsWithTypeArguments2.2.minified.js b/crates/swc/tests/tsc-references/tsxStatelessFunctionComponentsWithTypeArguments2.2.minified.js index 76fcb201a771..0caadeb2feab 100644 --- a/crates/swc/tests/tsc-references/tsxStatelessFunctionComponentsWithTypeArguments2.2.minified.js +++ b/crates/swc/tests/tsc-references/tsxStatelessFunctionComponentsWithTypeArguments2.2.minified.js @@ -8,5 +8,5 @@ define([ ], function(require, exports, _object_spread, _object_spread_props, _react) { Object.defineProperty(exports, "__esModule", { value: !0 - }), /*#__PURE__*/ InferParamComponent; + }), InferParamComponent; }); diff --git a/crates/swc/tests/vercel/full-compact/react-autosuggest/1/output/index.js b/crates/swc/tests/vercel/full-compact/react-autosuggest/1/output/index.js index 65a1b9839aa1..75ab211e87ef 100644 --- a/crates/swc/tests/vercel/full-compact/react-autosuggest/1/output/index.js +++ b/crates/swc/tests/vercel/full-compact/react-autosuggest/1/output/index.js @@ -1 +1 @@ -"use strict";var e,t=require("@swc/helpers/_/_instanceof");Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var r=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!==i(e)&&"function"!=typeof e)return{default:e};var t=o();if(t&&t.has(e))return t.get(e);var r={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var u in e)if(Object.prototype.hasOwnProperty.call(e,u)){var c=n?Object.getOwnPropertyDescriptor(e,u):null;c&&(c.get||c.set)?Object.defineProperty(r,u,c):r[u]=e[u]}return r.default=e,t&&t.set(e,r),r}(require("react")),n=(e=require("prop-types"))&&e.__esModule?e:{default:e};function o(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return o=function(){return e},e}function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function u(){return(u=Object.assign||function(e){for(var t=1;t { pub fn minify_file_comments( comments: &SingleThreadedComments, preserve_comments: BoolOr, + preserve_annotations: bool, ) { match preserve_comments { BoolOr::Bool(true) | BoolOr::Data(JsMinifyCommentOption::PreserveAllComments) => {} @@ -356,10 +357,11 @@ pub fn minify_file_comments( || c.text.contains("@preserve") || c.text.contains("@copyright") || c.text.contains("@cc_on") - || c.text.contains("__PURE__") - || c.text.contains("__INLINE__") - || c.text.contains("__NOINLINE__") - || c.text.contains("@vite-ignore") + || (preserve_annotations + && (c.text.contains("__PURE__") + || c.text.contains("__INLINE__") + || c.text.contains("__NOINLINE__") + || c.text.contains("@vite-ignore"))) || (c.kind == CommentKind::Block && c.text.starts_with('!')) }); !vc.is_empty()