-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add
builtin:swc-loader
test case
- Loading branch information
Showing
4 changed files
with
329 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { Addon } from "./common.js"; | ||
|
||
export default class extends Addon { | ||
async afterSetup(ctx) { | ||
ctx.config = | ||
ctx.config + | ||
` | ||
const ReactRefreshPlugin = require("@rspack/plugin-react-refresh"); | ||
const prod = process.env.NODE_ENV === "production"; | ||
module.exports.experiments ||= {}; | ||
module.exports.experiments.rspackFuture ||= {}; | ||
module.exports.experiments.rspackFuture.disableTransformByDefault = true; | ||
(module.exports.plugins ||= []).push(new ReactRefreshPlugin()); | ||
module.exports.module ||= {}; | ||
(module.exports.module.rules ||= []).push({ | ||
test: /\.(j|t)s$/, | ||
exclude: [/[\\/]node_modules[\\/]/], | ||
loader: "builtin:swc-loader", | ||
options: { | ||
sourceMap: true, | ||
jsc: { | ||
parser: { | ||
syntax: "typescript" | ||
}, | ||
externalHelpers: true | ||
}, | ||
env: { | ||
targets: "Chrome >= 48" | ||
} | ||
} | ||
}, | ||
{ | ||
test: /\.(j|t)sx$/, | ||
loader: "builtin:swc-loader", | ||
exclude: [/[\\/]node_modules[\\/]/], | ||
options: { | ||
sourceMap: true, | ||
jsc: { | ||
parser: { | ||
syntax: "typescript", | ||
tsx: true | ||
}, | ||
transform: { | ||
react: { | ||
runtime: "automatic", | ||
development: !prod, | ||
refresh: !prod | ||
} | ||
}, | ||
externalHelpers: true | ||
}, | ||
env: { | ||
targets: "Chrome >= 48" | ||
} | ||
} | ||
}); | ||
`; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.