Skip to content

Commit

Permalink
fix: use swc plugin in preact-refresh demo (#162)
Browse files Browse the repository at this point in the history
  • Loading branch information
LingyuCoder authored Oct 28, 2024
1 parent 0d5b557 commit 85cecf9
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 11 deletions.
20 changes: 15 additions & 5 deletions pnpm-lock.yaml

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

3 changes: 2 additions & 1 deletion rspack/preact-refresh/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"@prefresh/utils": "1.2.0",
"@rspack/cli": "^1.0.14",
"@rspack/core": "^1.0.14",
"@rspack/plugin-preact-refresh": "^1.0.1"
"@rspack/plugin-preact-refresh": "^1.1.0",
"@swc/plugin-prefresh": "^3.0.3"
},
"resolve": {
"alias": {
Expand Down
16 changes: 11 additions & 5 deletions rspack/preact-refresh/rspack.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const rspack = require('@rspack/core');
const dev = process.env.NODE_ENV === 'development';
const PreactRefreshPlugin = require('@rspack/plugin-preact-refresh');
const dev = process.env.NODE_ENV === 'development';
/** @type {import('@rspack/cli').Configuration} */
const config = {
entry: {
Expand All @@ -26,10 +26,15 @@ const config = {
loader: 'builtin:swc-loader',
options: {
sourceMap: true,
rspackExperiments: {
preact: {}, // enable preact swc plugin
},
jsc: {
experimental: {
plugins: [
[
'@swc/plugin-prefresh', // enable prefresh specific transformation
{},
],
],
},
parser: {
syntax: 'ecmascript',
jsx: true,
Expand All @@ -43,7 +48,8 @@ const config = {
pragmaFrag: 'Fragment',
throwIfNamespace: true,
useBuiltins: false,
refresh: true, // enable react hooks hmr compatiblity
development: dev,
refresh: dev, // enable react hooks hmr compatiblity
},
},
},
Expand Down

0 comments on commit 85cecf9

Please sign in to comment.