Skip to content

Commit

Permalink
refactor: remove @volar/pug-language-service to optionalDependencies
Browse files Browse the repository at this point in the history
close #1092
  • Loading branch information
johnsoncodehk committed Apr 10, 2022
1 parent a437904 commit 1b576b0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 3 additions & 1 deletion packages/vue-typescript/package.json
Expand Up @@ -17,12 +17,14 @@
},
"dependencies": {
"@volar/code-gen": "0.34.2",
"@volar/pug-language-service": "0.34.2",
"@volar/source-map": "0.34.2",
"@volar/vue-code-gen": "0.34.2",
"@vue/compiler-sfc": "^3.2.31",
"@vue/reactivity": "^3.2.31"
},
"optionalDependencies": {
"@volar/pug-language-service": "0.34.2"
},
"browser": {
"./out/plugins/pug.js": "./out/plugins/empty.js"
}
Expand Down
9 changes: 7 additions & 2 deletions packages/vue-typescript/src/plugins/pug.ts
@@ -1,4 +1,3 @@
import * as pug from '@volar/pug-language-service';
import { VueLanguagePlugin } from '../typescriptRuntime';

export default function (): VueLanguagePlugin {
Expand All @@ -9,7 +8,13 @@ export default function (): VueLanguagePlugin {

if (lang === 'pug') {

const pugDoc = pug.baseParse(template);
let pug: typeof import('@volar/pug-language-service') | undefined;

try {
pug = require('@volar/pug-language-service');
} catch { }

const pugDoc = pug?.baseParse(template);

if (pugDoc) {
return {
Expand Down

0 comments on commit 1b576b0

Please sign in to comment.