Skip to content

Commit

Permalink
fix: update compileVueTemplate error
Browse files Browse the repository at this point in the history
  • Loading branch information
Jevon617 committed May 6, 2023
1 parent e858936 commit ea6273c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
"@types/etag": "^1.8.1",
"@types/node": "^18.16.4",
"@types/svgo": "^2.6.4",
"@vue/compiler-sfc": "^3.2.47",
"bumpp": "^8.2.1",
"debug": "^4.3.4",
"eslint": "^8.39.0",
Expand Down
2 changes: 2 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions src/core/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,9 @@ async function genComponent(options: Options, isVueProject: boolean) {

async function compileVueTemplate(template: string, vueVerison: string): Promise<string> {
const pkgInfo = await getPackageInfo('@vue/compiler-sfc')
if (pkgInfo?.version[0] !== vueVerison.slice(-1))
throw new Error(`The current major version of @vue/compiler-sfc(${pkgInfo?.version[0]}.x.x) is not matching the major version of Vue(${vueVerison.slice(-1)}.x.x).`)
if (!pkgInfo || pkgInfo?.version[0] !== vueVerison.slice(-1))
throw new Error(`Cannot find module \'@vue/compiler-sfc@${vueVerison.slice(-1)}.x.x\'. Please install it.`)

const pkg = await importModule('@vue/compiler-sfc')
const { compileTemplate } = pkg
const { code } = compileTemplate({
Expand Down

0 comments on commit ea6273c

Please sign in to comment.