Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(es): Preserve more comments #9449

Merged
merged 4 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var _ClassB;
module.exports = ((_ClassB = function() {
module.exports = ((_ClassB = /*#__PURE__*/ function() {
"use strict";
function t() {}
return t.prototype.it = function() {
Expand Down
4 changes: 2 additions & 2 deletions crates/swc/tests/fixture/issues-2xxx/2854/1/output/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
export function App() {
return React.createElement(Form, null);
return /*#__PURE__*/ React.createElement(Form, null);
}
export function Form(param) {
var _param_onChange = param.onChange, onChange = _param_onChange === void 0 ? function() {} : _param_onChange;
return React.createElement("input", {
return /*#__PURE__*/ React.createElement("input", {
onChange: function onChange1() {
onChange();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export var CompanyBgStore = function CompanyBgStore() {
_class_call_check(this, CompanyBgStore);
var _this = this;
_define_property(this, "corpName", 123);
_define_property(this, "getBusinessInfo", _async_to_generator(function() {
_define_property(this, "getBusinessInfo", /*#__PURE__*/ _async_to_generator(function() {
var corpName;
var _arguments = arguments;
return _ts_generator(this, function(_state) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { _ as _class_private_field_loose_base } from "@swc/helpers/_/_class_private_field_loose_base";
import { _ as _class_private_field_loose_key } from "@swc/helpers/_/_class_private_field_loose_key";
var _channelName = _class_private_field_loose_key("_channelName"), _listeners = _class_private_field_loose_key("_listeners");
var _channelName = /*#__PURE__*/ _class_private_field_loose_key("_channelName"), _listeners = /*#__PURE__*/ _class_private_field_loose_key("_listeners");
export class LocalStorageChannel {
constructor(channelName){
Object.defineProperty(this, _channelName, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var _create_class = require("@swc/helpers/_/_create_class");
var commands;
var command;
function retornaTempoArenaEmMilisegundos(distancia, velocidade) {
var conv = distancia * function() {
var conv = distancia * /*#__PURE__*/ function() {
"use strict";
function LogExit(param) {
var logger = param.logger;
Expand Down
4 changes: 2 additions & 2 deletions crates/swc/tests/fixture/issues-5xxx/5558/2/output/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ var _async_to_generator = require("@swc/helpers/_/_async_to_generator");
var _class_call_check = require("@swc/helpers/_/_class_call_check");
var _create_class = require("@swc/helpers/_/_create_class");
var _ts_generator = require("@swc/helpers/_/_ts_generator");
var Foo = function() {
var Foo = /*#__PURE__*/ function() {
"use strict";
function Foo() {
_class_call_check._(this, Foo);
Expand All @@ -11,7 +11,7 @@ var Foo = function() {
{
key: "bar",
value: function bar() {
var x = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : _async_to_generator._(function() {
var x = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : /*#__PURE__*/ _async_to_generator._(function() {
return _ts_generator._(this, function(_state) {
switch(_state.label){
case 0:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Base {
return 'good';
}
}
var _privateMethod = new WeakSet();
var _privateMethod = /*#__PURE__*/ new WeakSet();
class Sub extends Base {
superMethod() {
return 'bad';
Expand Down
4 changes: 2 additions & 2 deletions crates/swc/tests/fixture/issues-6xxx/6984/1/output/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { _ as _create_super } from "@swc/helpers/_/_create_super";
import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate";
import React from 'react';
import { withRouter } from 'react-router-dom';
var App = function(_React_Component) {
var App = /*#__PURE__*/ function(_React_Component) {
"use strict";
_inherits(App, _React_Component);
var _super = _create_super(App);
Expand All @@ -18,7 +18,7 @@ var App = function(_React_Component) {
key: "render",
value: function render() {
console.log(this.props);
return React.createElement("div", null, "134");
return /*#__PURE__*/ React.createElement("div", null, "134");
}
}
]);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var _class_private_field_get = require("@swc/helpers/_/_class_private_field_get");
var _class_private_field_init = require("@swc/helpers/_/_class_private_field_init");
var _x = new WeakMap();
var _x = /*#__PURE__*/ new WeakMap();
class Foo {
test() {
var _this, _this_y;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var _class_private_field_get = require("@swc/helpers/_/_class_private_field_get");
var _class_private_field_init = require("@swc/helpers/_/_class_private_field_init");
var _x = new WeakMap();
var _x = /*#__PURE__*/ new WeakMap();
class Foo {
test() {
var _this, _this_y;
Expand Down
2 changes: 1 addition & 1 deletion crates/swc/tests/fixture/issues-7xxx/7653/output/1.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export default function Home(){return React.createElement("div",{dangerouslySetInnerHTML:{__html:"Hello World"}})}
export default function Home(){return /*#__PURE__*/React.createElement("div",{dangerouslySetInnerHTML:{__html:"Hello World"}})}
2 changes: 1 addition & 1 deletion crates/swc/tests/fixture/issues-7xxx/7700/output/1.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ let positions = {
};
export function PositionRender({ isRtl, position }) {
let display = ('fe-fe-fe' === isRtl ? rtlPositions : positions)[position];
return React.createElement("h1", null, "PositionRender: ", display);
return /*#__PURE__*/ React.createElement("h1", null, "PositionRender: ", display);
}
2 changes: 1 addition & 1 deletion crates/swc/tests/fixture/issues-7xxx/7700/output/2.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ export function PositionRender({ isRtl, position }) {
] : {
positions
})[position];
return React.createElement("h1", null, "PositionRender: ", display);
return /*#__PURE__*/ React.createElement("h1", null, "PositionRender: ", display);
}
2 changes: 1 addition & 1 deletion crates/swc/tests/fixture/issues-7xxx/7700/output/3.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ export function PositionRender({ isRtl, position }) {
] : {
positions
})[position];
return React.createElement("h1", null, "PositionRender: ", display);
return /*#__PURE__*/ React.createElement("h1", null, "PositionRender: ", display);
}
2 changes: 1 addition & 1 deletion crates/swc/tests/fixture/issues-7xxx/7700/output/4.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ export function PositionRender({ isRtl, position }) {
let display = ('fe-fe-fe' === isRtl ? rtlPositions : {
a: positions
})[position];
return React.createElement("h1", null, "PositionRender: ", display);
return /*#__PURE__*/ React.createElement("h1", null, "PositionRender: ", display);
}
2 changes: 1 addition & 1 deletion crates/swc/tests/fixture/issues-7xxx/7700/output/5.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ export function PositionRender({ isRtl, position }) {
positions
]
})[position];
return React.createElement("h1", null, "PositionRender: ", display);
return /*#__PURE__*/ React.createElement("h1", null, "PositionRender: ", display);
}
2 changes: 1 addition & 1 deletion crates/swc/tests/fixture/issues-7xxx/7783/output/1.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export default function e(){return React.createElement("div",null,foo.a)}let foo={get a(){return`a ${this.b}`},get b(){return"b"}};
export default function e(){return /*#__PURE__*/React.createElement("div",null,foo.a)}let foo={get a(){return`a ${this.b}`},get b(){return"b"}};
6 changes: 3 additions & 3 deletions crates/swc/tests/fixture/issues-7xxx/7821/output/1.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
var Blocks = {
Block1: function() {
return React.createElement(React.Fragment, null, "'Block1xx'");
return /*#__PURE__*/ React.createElement(React.Fragment, null, "'Block1xx'");
},
Block2: function() {
return React.createElement(React.Fragment, null, "'Block2xx'");
return /*#__PURE__*/ React.createElement(React.Fragment, null, "'Block2xx'");
},
Layout1: function() {
return [
Expand All @@ -14,5 +14,5 @@ var Blocks = {
}
};
export function render() {
return React.createElement(Blocks.Layout1, null);
return /*#__PURE__*/ React.createElement(Blocks.Layout1, null);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ var _class_call_check = require("@swc/helpers/_/_class_call_check");
var _create_class = require("@swc/helpers/_/_create_class");
var _ts_decorate = require("@swc/helpers/_/_ts_decorate");
var _class;
var foo = (_class = function() {
var foo = (_class = /*#__PURE__*/ function() {
"use strict";
function _class() {
_class_call_check._(this, _class);
Expand Down
2 changes: 1 addition & 1 deletion crates/swc/tests/fixture/issues-8xxx/8199/output/1.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { jsx as _jsx } from "react/jsx-runtime";
export const IconSpecHotkey = (param)=>{
let { icon } = param;
return _jsx("div", {
return /*#__PURE__*/ _jsx("div", {
children: icon
});
};
4 changes: 2 additions & 2 deletions crates/swc/tests/fixture/issues-8xxx/8210/output/1.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { jsxDEV: _jsxDEV } = require("react/jsx-dev-runtime");
const Component = ()=>{
return _jsxDEV("p", {
thing: _jsxDEV("a", {}, void 0, false, {
return /*#__PURE__*/ _jsxDEV("p", {
thing: /*#__PURE__*/ _jsxDEV("a", {}, void 0, false, {
fileName: "$DIR/tests/fixture/issues-8xxx/8210/input/1.js",
lineNumber: 2,
columnNumber: 23
Expand Down
4 changes: 2 additions & 2 deletions crates/swc/tests/fixture/issues-8xxx/8243/output/1.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { jsx as _jsx } from "react/jsx-runtime";
export const Foo = (props)=>{
return originalMessage ? _jsx(Bar, {
children: _jsx(Baz, {
return originalMessage ? /*#__PURE__*/ _jsx(Bar, {
children: /*#__PURE__*/ _jsx(Baz, {
children: ()=>null
})
}) : null;
Expand Down
4 changes: 2 additions & 2 deletions crates/swc/tests/fixture/issues-8xxx/8243/output/2.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { jsx as _jsx } from "react/jsx-runtime";
export const Foo = (props)=>{
return originalMessage ? _jsx(Bar, {
children: _jsx(Baz, {
return originalMessage ? /*#__PURE__*/ _jsx(Bar, {
children: /*#__PURE__*/ _jsx(Baz, {
children: ()=>null
})
}) : null;
Expand Down
4 changes: 2 additions & 2 deletions crates/swc/tests/fixture/issues-8xxx/8243/output/3.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { jsx as _jsx } from "react/jsx-runtime";
export const Foo = (props)=>{
return originalMessage ? _jsx(Bar, {
children: _jsx(Baz, {
return originalMessage ? /*#__PURE__*/ _jsx(Bar, {
children: /*#__PURE__*/ _jsx(Baz, {
children: ()=>null
})
}) : null;
Expand Down
4 changes: 2 additions & 2 deletions crates/swc/tests/fixture/issues-8xxx/8243/output/4.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { jsx as _jsx } from "react/jsx-runtime";
export const Foo = (props)=>{
return originalMessage ? _jsx(Bar, {
children: _jsx(Baz, {
return originalMessage ? /*#__PURE__*/ _jsx(Bar, {
children: /*#__PURE__*/ _jsx(Baz, {
children: ()=>null
})
}) : null;
Expand Down
2 changes: 1 addition & 1 deletion crates/swc/tests/fixture/issues-8xxx/8275/output/1.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const c = (function(strings, ...values) {
/*#__PURE__*/ export const c = (function(strings, ...values) {
return {
strings,
values
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var _class_call_check = require("@swc/helpers/_/_class_call_check");
var _create_class = require("@swc/helpers/_/_create_class");
var Foo = function() {
var Foo = /*#__PURE__*/ function() {
"use strict";
function Foo() {
_class_call_check._(this, Foo);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import * as React from 'react';
export var FooNs;
(function(FooNs) {
FooNs.Shared = ()=>'I\'m shared component';
FooNs.Main = ()=>React.createElement(FooNs.Shared, null);
FooNs.Main = ()=>/*#__PURE__*/ React.createElement(FooNs.Shared, null);
})(FooNs || (FooNs = {}));
4 changes: 2 additions & 2 deletions crates/swc/tests/fixture/issues-8xxx/8640/output/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
export var Ns;
(function(Ns) {
Ns.Context = React.createContext();
Ns.Component = ()=>React.createElement(Ns.Context.Provider, null);
Ns.Context = /*#__PURE__*/ React.createContext();
Ns.Component = ()=>/*#__PURE__*/ React.createElement(Ns.Context.Provider, null);
})(Ns || (Ns = {}));
2 changes: 1 addition & 1 deletion crates/swc/tests/fixture/issues-9xxx/9204/output/1.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
let Foo = createFoo();
export function App() {
return React.createElement("view", null, React.createElement(Foo, null));
return /*#__PURE__*/ React.createElement("view", null, /*#__PURE__*/ React.createElement(Foo, null));
}
2 changes: 1 addition & 1 deletion crates/swc/tests/fixture/sourcemap/003/output/index.js

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

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": "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",
"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",
"names": [
"StaticPage",
"data",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//// [ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndGenericClassStaticFunctionOfTheSameName.ts]
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
var clodule = function() {
var clodule = /*#__PURE__*/ function() {
function clodule() {
_class_call_check(this, clodule);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//// [ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndNonGenericClassStaticFunctionOfTheSameName.ts]
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
var clodule = function() {
var clodule = /*#__PURE__*/ function() {
function clodule() {
_class_call_check(this, clodule);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//// [ClassAndModuleThatMergeWithModulesExportedStaticFunctionUsingClassPrivateStatics.ts]
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
var clodule, clodule1 = function() {
var clodule, clodule1 = /*#__PURE__*/ function() {
function clodule() {
_class_call_check(this, clodule);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//// [ClassAndModuleThatMergeWithStaticFunctionAndExportedFunctionThatShareAName.ts]
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
var A, Point, A1, Point1 = function() {
var A, Point, A1, Point1 = /*#__PURE__*/ function() {
function Point(x, y) {
_class_call_check(this, Point), this.x = x, this.y = y;
}
Expand All @@ -13,7 +13,7 @@ var A, Point, A1, Point1 = function() {
}();
(Point1 || (Point1 = {})).Origin = function() {
return null;
}, A = A1 || (A1 = {}), Point = function() {
}, A = A1 || (A1 = {}), Point = /*#__PURE__*/ function() {
function Point(x, y) {
_class_call_check(this, Point), this.x = x, this.y = y;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//// [ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts]
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
var A, Point, A1, Point1 = function() {
var A, Point, A1, Point1 = /*#__PURE__*/ function() {
function Point(x, y) {
_class_call_check(this, Point), this.x = x, this.y = y;
}
Expand All @@ -11,7 +11,7 @@ var A, Point, A1, Point1 = function() {
};
}, Point;
}();
Point1 || (Point1 = {}), A = A1 || (A1 = {}), Point = function() {
Point1 || (Point1 = {}), A = A1 || (A1 = {}), Point = /*#__PURE__*/ function() {
function Point(x, y) {
_class_call_check(this, Point), this.x = x, this.y = y;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//// [ES5For-ofTypeCheck10.ts]
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
var StringIterator = function() {
var StringIterator = /*#__PURE__*/ function() {
function StringIterator() {
_class_call_check(this, StringIterator);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//// [ES5SymbolProperty2.ts]
var M, M1, _$Symbol, C;
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
M1 = M || (M = {}), C = function() {
M1 = M || (M = {}), C = /*#__PURE__*/ function() {
function C() {
_class_call_check(this, C);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//// [ES5SymbolProperty3.ts]
var Symbol;
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
(new (function() {
(new /*#__PURE__*/ (function() {
function C() {
_class_call_check(this, C);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//// [ES5SymbolProperty4.ts]
var Symbol;
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
(new (function() {
(new /*#__PURE__*/ (function() {
function C() {
_class_call_check(this, C);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//// [ES5SymbolProperty5.ts]
var Symbol;
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
(new (function() {
(new /*#__PURE__*/ (function() {
function C() {
_class_call_check(this, C);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//// [ES5SymbolProperty6.ts]
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
(new (function() {
(new /*#__PURE__*/ (function() {
function C() {
_class_call_check(this, C);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//// [ES5SymbolProperty7.ts]
var Symbol;
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
(new (function() {
(new /*#__PURE__*/ (function() {
function C() {
_class_call_check(this, C);
}
Expand Down
Loading
Loading