diff --git a/client/intercept.cjs b/client/intercept.js similarity index 100% rename from client/intercept.cjs rename to client/intercept.js diff --git a/client/package.json b/client/package.json new file mode 100644 index 0000000..3dbc1ca --- /dev/null +++ b/client/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} diff --git a/client/prefresh.cjs b/client/prefresh.js similarity index 94% rename from client/prefresh.cjs rename to client/prefresh.js index 07ad060..4ee6c14 100644 --- a/client/prefresh.cjs +++ b/client/prefresh.js @@ -8,7 +8,7 @@ * https://github.com/preactjs/prefresh/blob/018f5cc907629b82ffb201c32e948efe4b40098a/LICENSE */ -const { isComponent, flush } = require('@prefresh/utils'); +import { flush, isComponent } from '@prefresh/utils'; // eslint-disable-next-line const getExports = (m) => m.exports || m.__proto__.exports; @@ -62,7 +62,7 @@ const shouldBind = (m) => { return isCitizen; }; -module.exports = Object.freeze({ +export default Object.freeze({ getExports, shouldBind, flush, diff --git a/src/index.ts b/src/index.ts index 2b9bb75..6eb5476 100644 --- a/src/index.ts +++ b/src/index.ts @@ -43,8 +43,8 @@ interface NormalizedPluginOptions extends IPreactRefreshRspackPluginOptions { const PREFRESH_CORE_PATH = require.resolve('@prefresh/core'); const PREFRESH_UTILS_PATH = require.resolve('@prefresh/utils'); -const RUNTIME_UTIL_PATH = require.resolve('../client/prefresh.cjs'); -const RUNTIME_INTERCEPT_PATH = require.resolve('../client/intercept.cjs'); +const RUNTIME_UTIL_PATH = require.resolve('../client/prefresh.js'); +const RUNTIME_INTERCEPT_PATH = require.resolve('../client/intercept.js'); const runtimeSource = fs.readFileSync(RUNTIME_INTERCEPT_PATH, 'utf-8'); @@ -79,7 +79,7 @@ class PreactRefreshRspackPlugin implements RspackPluginInstance { ]; new compiler.webpack.ProvidePlugin({ - __prefresh_utils__: RUNTIME_UTIL_PATH, + __prefresh_utils__: [RUNTIME_UTIL_PATH, 'default'], ...(this.options.overlay ? { __prefresh_errors__: require.resolve(this.options.overlay.module), diff --git a/test/hotCases/hook/useContext#initial/__snapshots__/web/1.snap.txt b/test/hotCases/hook/useContext#initial/__snapshots__/web/1.snap.txt index f1f9dc5..eafba79 100644 --- a/test/hotCases/hook/useContext#initial/__snapshots__/web/1.snap.txt +++ b/test/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: 5127 +- Update: main.LAST_HASH.hot-update.js, size: 5136 ## Manifest @@ -41,7 +41,7 @@ __webpack_require__.d(__webpack_exports__, { /* ESM import */var preact_compat__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! preact/compat */ "../../../../node_modules/.pnpm/preact@10.24.3/node_modules/preact/compat/dist/compat.module.js"); /* ESM import */var preact_hooks__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! preact/hooks */ "../../../../node_modules/.pnpm/preact@10.24.3/node_modules/preact/hooks/dist/hooks.module.js"); /* module decorator */ module = __webpack_require__.hmd(module); -/* provided dependency */ var __prefresh_utils__ = __webpack_require__(/*! ../../../../client/prefresh.cjs */ "../../../../client/prefresh.cjs"); +/* provided dependency */ var __prefresh_utils__ = __webpack_require__(/*! ../../../../client/prefresh.js */ "../../../../client/prefresh.js")["default"]; var _s = $RefreshSig$(); diff --git a/test/hotCases/hook/useContext#keep/__snapshots__/web/1.snap.txt b/test/hotCases/hook/useContext#keep/__snapshots__/web/1.snap.txt index ead0886..d61fa95 100644 --- a/test/hotCases/hook/useContext#keep/__snapshots__/web/1.snap.txt +++ b/test/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: 5432 +- Update: main.LAST_HASH.hot-update.js, size: 5441 ## Manifest @@ -41,7 +41,7 @@ __webpack_require__.d(__webpack_exports__, { /* ESM import */var preact_compat__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! preact/compat */ "../../../../node_modules/.pnpm/preact@10.24.3/node_modules/preact/compat/dist/compat.module.js"); /* ESM import */var preact_hooks__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! preact/hooks */ "../../../../node_modules/.pnpm/preact@10.24.3/node_modules/preact/hooks/dist/hooks.module.js"); /* module decorator */ module = __webpack_require__.hmd(module); -/* provided dependency */ var __prefresh_utils__ = __webpack_require__(/*! ../../../../client/prefresh.cjs */ "../../../../client/prefresh.cjs"); +/* provided dependency */ var __prefresh_utils__ = __webpack_require__(/*! ../../../../client/prefresh.js */ "../../../../client/prefresh.js")["default"]; var _s = $RefreshSig$(); diff --git a/test/hotCases/hook/useContext#provide/__snapshots__/web/1.snap.txt b/test/hotCases/hook/useContext#provide/__snapshots__/web/1.snap.txt index 1bf1212..3fc09ac 100644 --- a/test/hotCases/hook/useContext#provide/__snapshots__/web/1.snap.txt +++ b/test/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: 5448 +- Update: main.LAST_HASH.hot-update.js, size: 5457 ## Manifest @@ -41,7 +41,7 @@ __webpack_require__.d(__webpack_exports__, { /* ESM import */var preact_compat__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! preact/compat */ "../../../../node_modules/.pnpm/preact@10.24.3/node_modules/preact/compat/dist/compat.module.js"); /* ESM import */var preact_hooks__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! preact/hooks */ "../../../../node_modules/.pnpm/preact@10.24.3/node_modules/preact/hooks/dist/hooks.module.js"); /* module decorator */ module = __webpack_require__.hmd(module); -/* provided dependency */ var __prefresh_utils__ = __webpack_require__(/*! ../../../../client/prefresh.cjs */ "../../../../client/prefresh.cjs"); +/* provided dependency */ var __prefresh_utils__ = __webpack_require__(/*! ../../../../client/prefresh.js */ "../../../../client/prefresh.js")["default"]; var _s = $RefreshSig$(); diff --git a/test/hotCases/hook/useState#keep/__snapshots__/web/1.snap.txt b/test/hotCases/hook/useState#keep/__snapshots__/web/1.snap.txt index 287cf3e..c64193c 100644 --- a/test/hotCases/hook/useState#keep/__snapshots__/web/1.snap.txt +++ b/test/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: 4704 +- Update: main.LAST_HASH.hot-update.js, size: 4713 ## Manifest @@ -41,7 +41,7 @@ __webpack_require__.d(__webpack_exports__, { /* ESM import */var react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react/jsx-dev-runtime */ "../../../../node_modules/.pnpm/preact@10.24.3/node_modules/preact/compat/jsx-dev-runtime.js"); /* ESM import */var preact_hooks__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! preact/hooks */ "../../../../node_modules/.pnpm/preact@10.24.3/node_modules/preact/hooks/dist/hooks.module.js"); /* module decorator */ module = __webpack_require__.hmd(module); -/* provided dependency */ var __prefresh_utils__ = __webpack_require__(/*! ../../../../client/prefresh.cjs */ "../../../../client/prefresh.cjs"); +/* provided dependency */ var __prefresh_utils__ = __webpack_require__(/*! ../../../../client/prefresh.js */ "../../../../client/prefresh.js")["default"]; var _s = $RefreshSig$(); diff --git a/test/hotCases/hook/useState#reset/__snapshots__/web/1.snap.txt b/test/hotCases/hook/useState#reset/__snapshots__/web/1.snap.txt index 07a6c93..81aed6b 100644 --- a/test/hotCases/hook/useState#reset/__snapshots__/web/1.snap.txt +++ b/test/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: 4596 +- Update: main.LAST_HASH.hot-update.js, size: 4605 ## Manifest @@ -41,7 +41,7 @@ __webpack_require__.d(__webpack_exports__, { /* ESM import */var react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react/jsx-dev-runtime */ "../../../../node_modules/.pnpm/preact@10.24.3/node_modules/preact/compat/jsx-dev-runtime.js"); /* ESM import */var preact_hooks__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! preact/hooks */ "../../../../node_modules/.pnpm/preact@10.24.3/node_modules/preact/hooks/dist/hooks.module.js"); /* module decorator */ module = __webpack_require__.hmd(module); -/* provided dependency */ var __prefresh_utils__ = __webpack_require__(/*! ../../../../client/prefresh.cjs */ "../../../../client/prefresh.cjs"); +/* provided dependency */ var __prefresh_utils__ = __webpack_require__(/*! ../../../../client/prefresh.js */ "../../../../client/prefresh.js")["default"]; var _s = $RefreshSig$(); diff --git a/test/hotCases/jsx/basic/__snapshots__/web/1.snap.txt b/test/hotCases/jsx/basic/__snapshots__/web/1.snap.txt index ef89269..218db07 100644 --- a/test/hotCases/jsx/basic/__snapshots__/web/1.snap.txt +++ b/test/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: 3809 +- Update: main.LAST_HASH.hot-update.js, size: 3818 ## Manifest @@ -39,7 +39,7 @@ __webpack_require__.d(__webpack_exports__, { }); /* ESM import */var react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react/jsx-dev-runtime */ "../../../../node_modules/.pnpm/preact@10.24.3/node_modules/preact/compat/jsx-dev-runtime.js"); /* module decorator */ module = __webpack_require__.hmd(module); -/* provided dependency */ var __prefresh_utils__ = __webpack_require__(/*! ../../../../client/prefresh.cjs */ "../../../../client/prefresh.cjs"); +/* provided dependency */ var __prefresh_utils__ = __webpack_require__(/*! ../../../../client/prefresh.js */ "../../../../client/prefresh.js")["default"]; function App() { return /*#__PURE__*/ (0,react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxDEV)("div", { diff --git a/test/hotCases/jsx/basic/__snapshots__/web/2.snap.txt b/test/hotCases/jsx/basic/__snapshots__/web/2.snap.txt index 970dae0..8787fba 100644 --- a/test/hotCases/jsx/basic/__snapshots__/web/2.snap.txt +++ b/test/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: 3809 +- Update: main.LAST_HASH.hot-update.js, size: 3818 ## Manifest @@ -39,7 +39,7 @@ __webpack_require__.d(__webpack_exports__, { }); /* ESM import */var react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react/jsx-dev-runtime */ "../../../../node_modules/.pnpm/preact@10.24.3/node_modules/preact/compat/jsx-dev-runtime.js"); /* module decorator */ module = __webpack_require__.hmd(module); -/* provided dependency */ var __prefresh_utils__ = __webpack_require__(/*! ../../../../client/prefresh.cjs */ "../../../../client/prefresh.cjs"); +/* provided dependency */ var __prefresh_utils__ = __webpack_require__(/*! ../../../../client/prefresh.js */ "../../../../client/prefresh.js")["default"]; function App() { return /*#__PURE__*/ (0,react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxDEV)("div", { diff --git a/test/hotCases/jsx/child/__snapshots__/web/1.snap.txt b/test/hotCases/jsx/child/__snapshots__/web/1.snap.txt index da87251..495d409 100644 --- a/test/hotCases/jsx/child/__snapshots__/web/1.snap.txt +++ b/test/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: 7251 +- Update: main.LAST_HASH.hot-update.js, size: 7269 ## Manifest @@ -42,7 +42,7 @@ __webpack_require__.d(__webpack_exports__, { /* ESM import */var react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react/jsx-dev-runtime */ "../../../../node_modules/.pnpm/preact@10.24.3/node_modules/preact/compat/jsx-dev-runtime.js"); /* ESM 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"); +/* provided dependency */ var __prefresh_utils__ = __webpack_require__(/*! ../../../../client/prefresh.js */ "../../../../client/prefresh.js")["default"]; function App() { @@ -144,7 +144,7 @@ __webpack_require__.d(__webpack_exports__, { }); /* ESM import */var react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react/jsx-dev-runtime */ "../../../../node_modules/.pnpm/preact@10.24.3/node_modules/preact/compat/jsx-dev-runtime.js"); /* module decorator */ module = __webpack_require__.hmd(module); -/* provided dependency */ var __prefresh_utils__ = __webpack_require__(/*! ../../../../client/prefresh.cjs */ "../../../../client/prefresh.cjs"); +/* provided dependency */ var __prefresh_utils__ = __webpack_require__(/*! ../../../../client/prefresh.js */ "../../../../client/prefresh.js")["default"]; function Child() { return /*#__PURE__*/ (0,react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxDEV)("span", { diff --git a/test/hotCases/jsx/child/__snapshots__/web/2.snap.txt b/test/hotCases/jsx/child/__snapshots__/web/2.snap.txt index c343faa..1db2ade 100644 --- a/test/hotCases/jsx/child/__snapshots__/web/2.snap.txt +++ b/test/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: 3546 +- Update: main.LAST_HASH.hot-update.js, size: 3555 ## Manifest @@ -39,7 +39,7 @@ __webpack_require__.d(__webpack_exports__, { }); /* ESM import */var react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react/jsx-dev-runtime */ "../../../../node_modules/.pnpm/preact@10.24.3/node_modules/preact/compat/jsx-dev-runtime.js"); /* module decorator */ module = __webpack_require__.hmd(module); -/* provided dependency */ var __prefresh_utils__ = __webpack_require__(/*! ../../../../client/prefresh.cjs */ "../../../../client/prefresh.cjs"); +/* provided dependency */ var __prefresh_utils__ = __webpack_require__(/*! ../../../../client/prefresh.js */ "../../../../client/prefresh.js")["default"]; function Child() { return /*#__PURE__*/ (0,react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxDEV)("span", { diff --git a/test/hotCases/jsx/value/__snapshots__/web/1.snap.txt b/test/hotCases/jsx/value/__snapshots__/web/1.snap.txt index e165a3e..b0aa6b6 100644 --- a/test/hotCases/jsx/value/__snapshots__/web/1.snap.txt +++ b/test/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: 3832 +- Update: main.LAST_HASH.hot-update.js, size: 3841 ## Manifest @@ -39,7 +39,7 @@ __webpack_require__.d(__webpack_exports__, { }); /* ESM import */var react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react/jsx-dev-runtime */ "../../../../node_modules/.pnpm/preact@10.24.3/node_modules/preact/compat/jsx-dev-runtime.js"); /* module decorator */ module = __webpack_require__.hmd(module); -/* provided dependency */ var __prefresh_utils__ = __webpack_require__(/*! ../../../../client/prefresh.cjs */ "../../../../client/prefresh.cjs"); +/* provided dependency */ var __prefresh_utils__ = __webpack_require__(/*! ../../../../client/prefresh.js */ "../../../../client/prefresh.js")["default"]; function App() { var value = "content 2"; diff --git a/test/hotCases/jsx/value/__snapshots__/web/2.snap.txt b/test/hotCases/jsx/value/__snapshots__/web/2.snap.txt index 7d2eae8..f42b4ae 100644 --- a/test/hotCases/jsx/value/__snapshots__/web/2.snap.txt +++ b/test/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: 3832 +- Update: main.LAST_HASH.hot-update.js, size: 3841 ## Manifest @@ -39,7 +39,7 @@ __webpack_require__.d(__webpack_exports__, { }); /* ESM import */var react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react/jsx-dev-runtime */ "../../../../node_modules/.pnpm/preact@10.24.3/node_modules/preact/compat/jsx-dev-runtime.js"); /* module decorator */ module = __webpack_require__.hmd(module); -/* provided dependency */ var __prefresh_utils__ = __webpack_require__(/*! ../../../../client/prefresh.cjs */ "../../../../client/prefresh.cjs"); +/* provided dependency */ var __prefresh_utils__ = __webpack_require__(/*! ../../../../client/prefresh.js */ "../../../../client/prefresh.js")["default"]; function App() { var value = "content 3";