Refactoring mit RSPACK + Solid-JS + Solid-Store + PNPM + Monorepo;
Die Gesamtstruktur des Players ist in Spielerschicht, Speichern und Pluginschicht unterteilt.
tsconfig.json konfigurieren experimentalDecoratoren auf true
{
"compilerOptions" : {
"target" : "ESNext" ,
"module" : "ES6" ,
"experimentalDecorators" : true
}
} rspack.config.cjs babel-loader-Plugins-Konfiguration **["@babel/plugin-proposal-decorators", { "legacy": true}] ]**
// @ts-check
const { defineConfig } = require ( '@rspack/cli' ) ;
const path = require ( 'path' ) ;
const config = defineConfig ( {
module : {
rules : [
{
test : / .(j|t)sx?$ / ,
use : [
{
loader : 'babel-loader' ,
options : {
presets : [ 'solid' , '@babel/preset-typescript' ] ,
plugins : [ 'solid-styled-jsx/babel' , [ "@babel/plugin-proposal-decorators" , { "legacy" : true } ] ]
} ,
} ,
] ,
}
]
}
} ) ;Standardmäßig kompiliert TSX VDOM mit Reacts React.createlement (einschließlich React/JSX-Runtime, die auch für JSX-Typ-Eingabeaufforderungen gefunden wird). Wenn Sie also eine solide-js + TSX-Kombination verwenden möchten, müssen Sie eine spezielle Konfiguration in tsconfig.json und rspack.config.cJs durchführen:
tsconfig.json
{
"compilerOptions" : {
"jsx" : "preserve" ,
"jsxImportSource" : "solid-js" ,
"module" : "ESNext" ,
"moduleResolution" : "Bundler"
}
}rspack.config.cjs konfiguriert Babel-Loader wie folgt:
Gesamtkompilierungsprozess: