diff --git a/crates/rspack_plugin_javascript/src/visitors/dependency/parser/walk.rs b/crates/rspack_plugin_javascript/src/visitors/dependency/parser/walk.rs index 72b77a23ddd..c466fb88e26 100644 --- a/crates/rspack_plugin_javascript/src/visitors/dependency/parser/walk.rs +++ b/crates/rspack_plugin_javascript/src/visitors/dependency/parser/walk.rs @@ -535,18 +535,18 @@ impl<'parser> JavascriptParser<'parser> { fn walk_sequence_expression(&mut self, expr: &SeqExpr) { let exprs = expr.exprs.iter().map(|expr| &**expr); - if self.is_statement_level_expression(expr.span()) - && let Some(old) = self.statement_path.pop() - { - for expr in exprs { - self.statement_path.push(expr.span().into()); - self.walk_expression(expr); - self.statement_path.pop(); - } - self.statement_path.push(old); - } else { - self.walk_expressions(exprs); - } + // if self.is_statement_level_expression(expr.span()) + // && let Some(old) = self.statement_path.pop() + // { + // for expr in exprs { + // self.statement_path.push(expr.span().into()); + // self.walk_expression(expr); + // self.statement_path.pop(); + // } + // self.statement_path.push(old); + // } else { + self.walk_expressions(exprs); + // } } fn walk_object_expression(&mut self, expr: &ObjectLit) { diff --git a/packages/rspack-plugin-preact-refresh/tests/hotCases/hook/useContext#initial/__snapshots__/web/1.snap.txt b/packages/rspack-plugin-preact-refresh/tests/hotCases/hook/useContext#initial/__snapshots__/web/1.snap.txt index b256df90eff..2cb8c1bbe50 100644 --- a/packages/rspack-plugin-preact-refresh/tests/hotCases/hook/useContext#initial/__snapshots__/web/1.snap.txt +++ b/packages/rspack-plugin-preact-refresh/tests/hotCases/hook/useContext#initial/__snapshots__/web/1.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 5180 +- Update: main.LAST_HASH.hot-update.js, size: 5353 ## Manifest @@ -38,6 +38,7 @@ __webpack_require__.d(__webpack_exports__, { App: function() { return App; } }); /* harmony import */var react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react/jsx-dev-runtime */ "../../../../../../node_modules/preact/compat/jsx-dev-runtime.js"); +/* harmony import */var react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */var preact_compat__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! preact/compat */ "../../../../../../node_modules/preact/compat/dist/compat.js"); /* harmony import */var preact_compat__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(preact_compat__WEBPACK_IMPORTED_MODULE_1__); /* harmony import */var preact_hooks__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! preact/hooks */ "../../../../../../node_modules/preact/hooks/dist/hooks.js"); diff --git a/packages/rspack-plugin-preact-refresh/tests/hotCases/hook/useContext#keep/__snapshots__/web/1.snap.txt b/packages/rspack-plugin-preact-refresh/tests/hotCases/hook/useContext#keep/__snapshots__/web/1.snap.txt index 804acdb12ae..9a6c068d95d 100644 --- a/packages/rspack-plugin-preact-refresh/tests/hotCases/hook/useContext#keep/__snapshots__/web/1.snap.txt +++ b/packages/rspack-plugin-preact-refresh/tests/hotCases/hook/useContext#keep/__snapshots__/web/1.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 5489 +- Update: main.LAST_HASH.hot-update.js, size: 5662 ## Manifest @@ -38,6 +38,7 @@ __webpack_require__.d(__webpack_exports__, { App: function() { return App; } }); /* harmony import */var react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react/jsx-dev-runtime */ "../../../../../../node_modules/preact/compat/jsx-dev-runtime.js"); +/* harmony import */var react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */var preact_compat__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! preact/compat */ "../../../../../../node_modules/preact/compat/dist/compat.js"); /* harmony import */var preact_compat__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(preact_compat__WEBPACK_IMPORTED_MODULE_1__); /* harmony import */var preact_hooks__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! preact/hooks */ "../../../../../../node_modules/preact/hooks/dist/hooks.js"); diff --git a/packages/rspack-plugin-preact-refresh/tests/hotCases/hook/useContext#provide/__snapshots__/web/1.snap.txt b/packages/rspack-plugin-preact-refresh/tests/hotCases/hook/useContext#provide/__snapshots__/web/1.snap.txt index 9673b68f9e0..4911374f2a1 100644 --- a/packages/rspack-plugin-preact-refresh/tests/hotCases/hook/useContext#provide/__snapshots__/web/1.snap.txt +++ b/packages/rspack-plugin-preact-refresh/tests/hotCases/hook/useContext#provide/__snapshots__/web/1.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 5502 +- Update: main.LAST_HASH.hot-update.js, size: 5675 ## Manifest @@ -38,6 +38,7 @@ __webpack_require__.d(__webpack_exports__, { App: function() { return App; } }); /* harmony import */var react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react/jsx-dev-runtime */ "../../../../../../node_modules/preact/compat/jsx-dev-runtime.js"); +/* harmony import */var react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */var preact_compat__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! preact/compat */ "../../../../../../node_modules/preact/compat/dist/compat.js"); /* harmony import */var preact_compat__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(preact_compat__WEBPACK_IMPORTED_MODULE_1__); /* harmony import */var preact_hooks__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! preact/hooks */ "../../../../../../node_modules/preact/hooks/dist/hooks.js"); diff --git a/packages/rspack-plugin-preact-refresh/tests/hotCases/hook/useState#keep/__snapshots__/web/1.snap.txt b/packages/rspack-plugin-preact-refresh/tests/hotCases/hook/useState#keep/__snapshots__/web/1.snap.txt index 159591cc1d2..0192013cc90 100644 --- a/packages/rspack-plugin-preact-refresh/tests/hotCases/hook/useState#keep/__snapshots__/web/1.snap.txt +++ b/packages/rspack-plugin-preact-refresh/tests/hotCases/hook/useState#keep/__snapshots__/web/1.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 4606 +- Update: main.LAST_HASH.hot-update.js, size: 4779 ## Manifest @@ -39,6 +39,7 @@ __webpack_require__.d(__webpack_exports__, { }); /* harmony import */var _swc_helpers_sliced_to_array__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @swc/helpers/_/_sliced_to_array */ "../../../../../../node_modules/@swc/helpers/esm/_sliced_to_array.js"); /* harmony import */var react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react/jsx-dev-runtime */ "../../../../../../node_modules/preact/compat/jsx-dev-runtime.js"); +/* harmony import */var react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */var preact_hooks__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! preact/hooks */ "../../../../../../node_modules/preact/hooks/dist/hooks.js"); /* module decorator */ module = __webpack_require__.hmd(module); /* provided dependency */ var __prefresh_utils__ = __webpack_require__(/*! ../../../../client/prefresh.cjs */ "../../../../client/prefresh.cjs"); diff --git a/packages/rspack-plugin-preact-refresh/tests/hotCases/hook/useState#reset/__snapshots__/web/1.snap.txt b/packages/rspack-plugin-preact-refresh/tests/hotCases/hook/useState#reset/__snapshots__/web/1.snap.txt index e14ab2ae7a5..ec231ba5896 100644 --- a/packages/rspack-plugin-preact-refresh/tests/hotCases/hook/useState#reset/__snapshots__/web/1.snap.txt +++ b/packages/rspack-plugin-preact-refresh/tests/hotCases/hook/useState#reset/__snapshots__/web/1.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 4497 +- Update: main.LAST_HASH.hot-update.js, size: 4670 ## Manifest @@ -39,6 +39,7 @@ __webpack_require__.d(__webpack_exports__, { }); /* harmony import */var _swc_helpers_sliced_to_array__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @swc/helpers/_/_sliced_to_array */ "../../../../../../node_modules/@swc/helpers/esm/_sliced_to_array.js"); /* harmony import */var react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react/jsx-dev-runtime */ "../../../../../../node_modules/preact/compat/jsx-dev-runtime.js"); +/* harmony import */var react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */var preact_hooks__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! preact/hooks */ "../../../../../../node_modules/preact/hooks/dist/hooks.js"); /* module decorator */ module = __webpack_require__.hmd(module); /* provided dependency */ var __prefresh_utils__ = __webpack_require__(/*! ../../../../client/prefresh.cjs */ "../../../../client/prefresh.cjs"); diff --git a/packages/rspack-plugin-preact-refresh/tests/hotCases/jsx/basic/__snapshots__/web/1.snap.txt b/packages/rspack-plugin-preact-refresh/tests/hotCases/jsx/basic/__snapshots__/web/1.snap.txt index 3d73366a2e2..0ab6b30e742 100644 --- a/packages/rspack-plugin-preact-refresh/tests/hotCases/jsx/basic/__snapshots__/web/1.snap.txt +++ b/packages/rspack-plugin-preact-refresh/tests/hotCases/jsx/basic/__snapshots__/web/1.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 3787 +- Update: main.LAST_HASH.hot-update.js, size: 3960 ## Manifest @@ -38,6 +38,7 @@ __webpack_require__.d(__webpack_exports__, { App: function() { return App; } }); /* harmony import */var react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react/jsx-dev-runtime */ "../../../../../../node_modules/preact/compat/jsx-dev-runtime.js"); +/* harmony import */var react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__); /* module decorator */ module = __webpack_require__.hmd(module); /* provided dependency */ var __prefresh_utils__ = __webpack_require__(/*! ../../../../client/prefresh.cjs */ "../../../../client/prefresh.cjs"); diff --git a/packages/rspack-plugin-preact-refresh/tests/hotCases/jsx/basic/__snapshots__/web/2.snap.txt b/packages/rspack-plugin-preact-refresh/tests/hotCases/jsx/basic/__snapshots__/web/2.snap.txt index 410b1898204..c8dcd253c6d 100644 --- a/packages/rspack-plugin-preact-refresh/tests/hotCases/jsx/basic/__snapshots__/web/2.snap.txt +++ b/packages/rspack-plugin-preact-refresh/tests/hotCases/jsx/basic/__snapshots__/web/2.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 3787 +- Update: main.LAST_HASH.hot-update.js, size: 3960 ## Manifest @@ -38,6 +38,7 @@ __webpack_require__.d(__webpack_exports__, { App: function() { return App; } }); /* harmony import */var react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react/jsx-dev-runtime */ "../../../../../../node_modules/preact/compat/jsx-dev-runtime.js"); +/* harmony import */var react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__); /* module decorator */ module = __webpack_require__.hmd(module); /* provided dependency */ var __prefresh_utils__ = __webpack_require__(/*! ../../../../client/prefresh.cjs */ "../../../../client/prefresh.cjs"); diff --git a/packages/rspack-plugin-preact-refresh/tests/hotCases/jsx/child/__snapshots__/web/1.snap.txt b/packages/rspack-plugin-preact-refresh/tests/hotCases/jsx/child/__snapshots__/web/1.snap.txt index ca6bdb35e32..2ed15b37650 100644 --- a/packages/rspack-plugin-preact-refresh/tests/hotCases/jsx/child/__snapshots__/web/1.snap.txt +++ b/packages/rspack-plugin-preact-refresh/tests/hotCases/jsx/child/__snapshots__/web/1.snap.txt @@ -7,7 +7,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 7210 +- Update: main.LAST_HASH.hot-update.js, size: 7556 ## Manifest @@ -40,6 +40,7 @@ __webpack_require__.d(__webpack_exports__, { App: function() { return App; } }); /* harmony import */var react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react/jsx-dev-runtime */ "../../../../../../node_modules/preact/compat/jsx-dev-runtime.js"); +/* harmony import */var react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */var _child__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./child */ "./child.jsx"); /* module decorator */ module = __webpack_require__.hmd(module); /* provided dependency */ var __prefresh_utils__ = __webpack_require__(/*! ../../../../client/prefresh.cjs */ "../../../../client/prefresh.cjs"); @@ -143,6 +144,7 @@ __webpack_require__.d(__webpack_exports__, { Child: function() { return Child; } }); /* harmony import */var react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react/jsx-dev-runtime */ "../../../../../../node_modules/preact/compat/jsx-dev-runtime.js"); +/* harmony import */var react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__); /* module decorator */ module = __webpack_require__.hmd(module); /* provided dependency */ var __prefresh_utils__ = __webpack_require__(/*! ../../../../client/prefresh.cjs */ "../../../../client/prefresh.cjs"); diff --git a/packages/rspack-plugin-preact-refresh/tests/hotCases/jsx/child/__snapshots__/web/2.snap.txt b/packages/rspack-plugin-preact-refresh/tests/hotCases/jsx/child/__snapshots__/web/2.snap.txt index d765701da77..5b719fb2308 100644 --- a/packages/rspack-plugin-preact-refresh/tests/hotCases/jsx/child/__snapshots__/web/2.snap.txt +++ b/packages/rspack-plugin-preact-refresh/tests/hotCases/jsx/child/__snapshots__/web/2.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 3523 +- Update: main.LAST_HASH.hot-update.js, size: 3696 ## Manifest @@ -38,6 +38,7 @@ __webpack_require__.d(__webpack_exports__, { Child: function() { return Child; } }); /* harmony import */var react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react/jsx-dev-runtime */ "../../../../../../node_modules/preact/compat/jsx-dev-runtime.js"); +/* harmony import */var react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__); /* module decorator */ module = __webpack_require__.hmd(module); /* provided dependency */ var __prefresh_utils__ = __webpack_require__(/*! ../../../../client/prefresh.cjs */ "../../../../client/prefresh.cjs"); diff --git a/packages/rspack-plugin-preact-refresh/tests/hotCases/jsx/value/__snapshots__/web/1.snap.txt b/packages/rspack-plugin-preact-refresh/tests/hotCases/jsx/value/__snapshots__/web/1.snap.txt index 8693f4f2284..69a13f6092b 100644 --- a/packages/rspack-plugin-preact-refresh/tests/hotCases/jsx/value/__snapshots__/web/1.snap.txt +++ b/packages/rspack-plugin-preact-refresh/tests/hotCases/jsx/value/__snapshots__/web/1.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 3810 +- Update: main.LAST_HASH.hot-update.js, size: 3983 ## Manifest @@ -38,6 +38,7 @@ __webpack_require__.d(__webpack_exports__, { App: function() { return App; } }); /* harmony import */var react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react/jsx-dev-runtime */ "../../../../../../node_modules/preact/compat/jsx-dev-runtime.js"); +/* harmony import */var react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__); /* module decorator */ module = __webpack_require__.hmd(module); /* provided dependency */ var __prefresh_utils__ = __webpack_require__(/*! ../../../../client/prefresh.cjs */ "../../../../client/prefresh.cjs"); diff --git a/packages/rspack-plugin-preact-refresh/tests/hotCases/jsx/value/__snapshots__/web/2.snap.txt b/packages/rspack-plugin-preact-refresh/tests/hotCases/jsx/value/__snapshots__/web/2.snap.txt index 98a4356f9e9..81db11b0b2d 100644 --- a/packages/rspack-plugin-preact-refresh/tests/hotCases/jsx/value/__snapshots__/web/2.snap.txt +++ b/packages/rspack-plugin-preact-refresh/tests/hotCases/jsx/value/__snapshots__/web/2.snap.txt @@ -6,7 +6,7 @@ ## Asset Files - Bundle: bundle.js - Manifest: main.LAST_HASH.hot-update.json, size: 28 -- Update: main.LAST_HASH.hot-update.js, size: 3810 +- Update: main.LAST_HASH.hot-update.js, size: 3983 ## Manifest @@ -38,6 +38,7 @@ __webpack_require__.d(__webpack_exports__, { App: function() { return App; } }); /* harmony import */var react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react/jsx-dev-runtime */ "../../../../../../node_modules/preact/compat/jsx-dev-runtime.js"); +/* harmony import */var react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__); /* module decorator */ module = __webpack_require__.hmd(module); /* provided dependency */ var __prefresh_utils__ = __webpack_require__(/*! ../../../../client/prefresh.cjs */ "../../../../client/prefresh.cjs"); diff --git a/packages/rspack-test-tools/tests/normalCases/parsing/asi-sequence-expression/a.js b/packages/rspack-test-tools/tests/normalCases/parsing/asi-sequence-expression/a.js new file mode 100644 index 00000000000..f3a232ce208 --- /dev/null +++ b/packages/rspack-test-tools/tests/normalCases/parsing/asi-sequence-expression/a.js @@ -0,0 +1,3 @@ +export const foo = function(f) { + f() +} diff --git a/packages/rspack-test-tools/tests/normalCases/parsing/asi-sequence-expression/index.js b/packages/rspack-test-tools/tests/normalCases/parsing/asi-sequence-expression/index.js new file mode 100644 index 00000000000..9c6dbcdf7f0 --- /dev/null +++ b/packages/rspack-test-tools/tests/normalCases/parsing/asi-sequence-expression/index.js @@ -0,0 +1,7 @@ +var s=0; +import { foo as b } from "./a"; +b(()=>{s++}),b(()=>{s++}),b(()=>{s++}),b(()=>{ + it("should generate correct code", () => { + expect(s).toBe(3) + }) +})