fix: miss scope

This commit is contained in:
春希 2020-09-13 17:19:33 +08:00
parent 7ce3df0eda
commit 97242c3c48
3 changed files with 7 additions and 4 deletions

View File

@ -13,6 +13,7 @@
"scripts": {
"start": "ava --watch",
"build": "rimraf lib && build-scripts build --skip-demo",
"build:tsc": "rimraf lib && tsc",
"demo": "node ./demo/demo.js",
"test": "ava",
"template": "node ./tools/createTemplate.js"

View File

@ -5,11 +5,13 @@ import {
FileType,
ICodeStruct,
IContainerInfo,
IScope,
} from '../../../types';
import { REACT_CHUNK_NAME } from './const';
import { createReactNodeGenerator } from '../../../utils/nodeToJSX';
import Scope from '../../../utils/Scope';
type PluginConfig = {
fileType?: string;
@ -26,9 +28,7 @@ const pluginFactory: BuilderComponentPluginFactory<PluginConfig> = (config?) =>
const { nodeTypeMapping } = cfg;
const generator = createReactNodeGenerator({
handlers: {
tagName: (v) => nodeTypeMapping[v] || v,
},
tagMapping: (v) => nodeTypeMapping[v] || v,
});
const plugin: BuilderComponentPlugin = async (pre: ICodeStruct) => {
@ -37,7 +37,8 @@ const pluginFactory: BuilderComponentPluginFactory<PluginConfig> = (config?) =>
};
const ir = next.ir as IContainerInfo;
const jsxContent = generator(ir);
const scope: IScope = Scope.createRootScope();
const jsxContent = generator(ir, scope);
next.chunks.push({
type: ChunkType.STRING,

View File

@ -16,6 +16,7 @@ const pluginFactory: BuilderComponentPluginFactory<unknown> = () => {
};
const ir = next.ir as IParseResult;
// TODO: miniAppBuildType 这个东西是不是不应该在 schema 里面,而是应该由 plugin 的构造参数传入
const miniAppBuildType = ir.project?.config.miniAppBuildType;
const buildCfg = {