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 如下:
整体编译流程: