Skip to content

Commit

Permalink
feat: 替换 react/jsx-runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
lc-soft committed Apr 14, 2024
1 parent 0dafd1d commit d6c1e46
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/compiler/ts-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export default async function TsLoader(content) {
};
}

// TODO: 考虑改成从项目目录内的 tsconfig.json 读取配置
const tsResult = ts.transpileModule(`${content}`, {
compilerOptions: {
target: ts.ScriptTarget.ESNext,
Expand All @@ -58,7 +59,12 @@ export default async function TsLoader(content) {
const assets = (await Promise.all(modules)).filter(
(m) => m?.metadata?.type === "asset"
);
await loader.generateModule(loader.resourcePath, () => tsResult.outputText);
await loader.generateModule(loader.resourcePath, () =>
tsResult.outputText.replace(
"react/jsx-runtime",
"@lcui/react/lib/jsx-runtime.js"
)
);
const { default: componentFunc } = await loader.importModule(
loader.resourcePath
);
Expand Down

0 comments on commit d6c1e46

Please sign in to comment.