diff --git a/crates/swc/tests/fixture/issues-8xxx/8419/input/.swcrc b/crates/swc/tests/fixture/issues-8xxx/8419/input/.swcrc new file mode 100644 index 000000000000..55c45f044356 --- /dev/null +++ b/crates/swc/tests/fixture/issues-8xxx/8419/input/.swcrc @@ -0,0 +1,22 @@ +{ + "jsc": { + "parser": { + "syntax": "typescript", + "tsx": true + }, + "transform": { + "react": { + "runtime": "automatic", + "refresh": true, + "importSource": "@emotion/react" + } + }, + "target": "es2015", + "loose": true + }, + "isModule": true, + "module": { + "type": "es6" + }, + "minify": false +} \ No newline at end of file diff --git a/crates/swc/tests/fixture/issues-8xxx/8419/input/index.js b/crates/swc/tests/fixture/issues-8xxx/8419/input/index.js new file mode 100644 index 000000000000..2bc4225c792f --- /dev/null +++ b/crates/swc/tests/fixture/issues-8xxx/8419/input/index.js @@ -0,0 +1,9 @@ +export const SearchLayoutRoot = ({ + children, + sx, + ...others +}: SearchLayoutRootProps) => ( + + {children} + +); diff --git a/crates/swc/tests/fixture/issues-8xxx/8419/output/index.js b/crates/swc/tests/fixture/issues-8xxx/8419/output/index.js new file mode 100644 index 000000000000..ab60d39a93cd --- /dev/null +++ b/crates/swc/tests/fixture/issues-8xxx/8419/output/index.js @@ -0,0 +1,17 @@ +import { _ as _extends } from "@swc/helpers/_/_extends"; +import { _ as _object_without_properties_loose } from "@swc/helpers/_/_object_without_properties_loose"; +import { jsx as _jsx } from "@emotion/react/jsx-runtime"; +export const SearchLayoutRoot = (_param)=>{ + var { children, sx } = _param, others = _object_without_properties_loose(_param, [ + "children", + "sx" + ]); + return /*#__PURE__*/ _jsx(Box, _extends({ + sx: [ + styles, + ...packSX(sx) + ] + }, others, { + children: children + })); +}; diff --git a/crates/swc/tests/vercel/loader-only/next-33291/1-automatic/output/index.js b/crates/swc/tests/vercel/loader-only/next-33291/1-automatic/output/index.js index 8b25da1d2faf..343cf2e34461 100644 --- a/crates/swc/tests/vercel/loader-only/next-33291/1-automatic/output/index.js +++ b/crates/swc/tests/vercel/loader-only/next-33291/1-automatic/output/index.js @@ -39,11 +39,11 @@ export default function Home() { lineNumber: 15, columnNumber: 17 }, this), - icon.map(function(_param) /*#__PURE__*/ { + icon.map(function(_param) { var href = _param.href, linkProps = _object_without_properties(_param, [ "href" ]); - return _createElement("link", _object_spread_props(_object_spread({ + return /*#__PURE__*/ _createElement("link", _object_spread_props(_object_spread({ href: href }, linkProps), { rel: "icon", diff --git a/crates/swc/tests/vercel/loader-only/next-33291/2-classic/output/index.js b/crates/swc/tests/vercel/loader-only/next-33291/2-classic/output/index.js index c61b5a3ce410..c5f0f6436f32 100644 --- a/crates/swc/tests/vercel/loader-only/next-33291/2-classic/output/index.js +++ b/crates/swc/tests/vercel/loader-only/next-33291/2-classic/output/index.js @@ -48,11 +48,11 @@ export default function Home() { columnNumber: 17 }, __self: this - }), icon.map(function(_param) /*#__PURE__*/ { + }), icon.map(function(_param) { var href = _param.href, linkProps = _object_without_properties(_param, [ "href" ]); - return React.createElement("link", _object_spread_props(_object_spread({ + return /*#__PURE__*/ React.createElement("link", _object_spread_props(_object_spread({ href: href }, linkProps), { rel: "icon", diff --git a/crates/swc_ecma_compat_common/src/macros.rs b/crates/swc_ecma_compat_common/src/macros.rs index a25da938dcd9..fa95706d5abc 100644 --- a/crates/swc_ecma_compat_common/src/macros.rs +++ b/crates/swc_ecma_compat_common/src/macros.rs @@ -24,7 +24,6 @@ macro_rules! impl_visit_mut_fn { BlockStmtOrExpr::Expr(..) => true, _ => false, }; - let body_span = f.body.span(); let (params, mut body) = self.visit_mut_fn_like( &mut f .params @@ -39,7 +38,7 @@ macro_rules! impl_visit_mut_fn { &mut match &mut *f.body { BlockStmtOrExpr::BlockStmt(block) => block.take(), BlockStmtOrExpr::Expr(expr) => BlockStmt { - span: body_span, + span: DUMMY_SP, stmts: vec![Stmt::Return(ReturnStmt { span: DUMMY_SP, arg: Some(expr.take()),