Skip to content

Commit

Permalink
fix(vue-generator): add builtin componentsMap
Browse files Browse the repository at this point in the history
  • Loading branch information
chilingling committed Apr 17, 2024
1 parent 9776a74 commit 61b5245
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
9 changes: 3 additions & 6 deletions packages/vue-generator/src/generator/vue/sfc/genSetupSFC.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import {
defaultGenMethodHook,
defaultGenLifecycleHook
} from './generateScript'
import { BUILTIN_COMPONENTS_MAP } from '@/constant'

const parseConfig = (config = {}) => {
const {
Expand Down Expand Up @@ -74,10 +73,8 @@ const generateSFCFile = (schema, componentsMap, config = {}) => {
schema.state = {}
}

const combinedComponentsMap = [...componentsMap, ...BUILTIN_COMPONENTS_MAP]

// 解析 import
const { pkgMap, blockPkgMap } = getImportMap(schema, combinedComponentsMap, { blockRelativePath, blockSuffix })
const { pkgMap, blockPkgMap } = getImportMap(schema, componentsMap, { blockRelativePath, blockSuffix })

// 解析 state
let stateRes = {}
Expand Down Expand Up @@ -198,10 +195,10 @@ const generateSFCFile = (schema, componentsMap, config = {}) => {
}

// 解析 template
const templateStr = genTemplateByHook(schema, globalHooks, { ...parsedConfig, componentsMap: combinedComponentsMap })
const templateStr = genTemplateByHook(schema, globalHooks, { ...parsedConfig, componentsMap: componentsMap })

// 生成 script
const scriptStr = genScriptByHook(schema, globalHooks, { ...parsedConfig, componentsMap: combinedComponentsMap })
const scriptStr = genScriptByHook(schema, globalHooks, { ...parsedConfig, componentsMap: componentsMap })

// 生成 style
const styleStr = generateStyleTag(schema, styleConfig)
Expand Down
3 changes: 3 additions & 0 deletions packages/vue-generator/src/plugins/parseSchemaPlugin.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { BUILTIN_COMPONENTS_MAP } from '@/constant'

function parseSchema() {
return {
name: 'tinyEngine-generateCode-plugin-parse-schema',
Expand All @@ -12,6 +14,7 @@ function parseSchema() {
const { pageSchema } = schema
const pagesMap = {}
const resPageTree = []
schema.componentsMap = [...schema.componentsMap, ...BUILTIN_COMPONENTS_MAP]

for (const componentItem of pageSchema) {
pagesMap[componentItem.id] = componentItem
Expand Down

0 comments on commit 61b5245

Please sign in to comment.