NiPlayer
V1.4.3
使用rspack + solid-js + solid-store + pnpm + monorepo 進行重構;
播放器整體結構劃分為player層,store層,plugin層;
tsconfig.json 配置experimentalDecorators 為true
{
"compilerOptions" : {
"target" : "ESNext" ,
"module" : "ES6" ,
"experimentalDecorators" : true
}
} rspack.config.cjs babel-loader plugins 處配置**["@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 } ] ]
} ,
} ,
] ,
}
]
}
} ) ;tsx默認其編譯是使用react的React.creatElement創建Vdom(包括jsx類型提示也是找的react/jsx-runtime); 因此若想使用solid-js + tsx 組合,需要分別在tsconfig.json 和rspack.config.cjs 進行特殊配置:
tsconfig.json
{
"compilerOptions" : {
"jsx" : "preserve" ,
"jsxImportSource" : "solid-js" ,
"module" : "ESNext" ,
"moduleResolution" : "Bundler"
}
}rspack.config.cjs 配置babel-loader 如下:
整體編譯流程: