Skip to content

Commit cc6fa9e

Browse files
authored
fix: reference project compiler, fixes #2031 (#2038)
1 parent 1b1a195 commit cc6fa9e

6 files changed

+15
-6
lines changed

src/descriptorCache.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import * as fs from 'fs'
22
import type { SFCDescriptor } from 'vue/compiler-sfc'
3-
import { parse } from 'vue/compiler-sfc'
3+
import { compiler } from './compiler'
44

5+
const { parse } = compiler
56
const cache = new Map<string, SFCDescriptor>()
67

78
export function setDescriptor(filename: string, entry: SFCDescriptor) {

src/formatError.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import type { CompilerError } from 'vue/compiler-sfc'
2-
import { generateCodeFrame } from 'vue/compiler-sfc'
2+
import { compiler } from './compiler'
33
import chalk = require('chalk')
44

5+
const { generateCodeFrame } = compiler
6+
57
export function formatError(
68
err: SyntaxError | CompilerError,
79
source: string,

src/index.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import * as loaderUtils from 'loader-utils'
55

66
import hash = require('hash-sum')
77

8-
import { parse } from 'vue/compiler-sfc'
8+
import { compiler } from './compiler'
99
import type {
1010
TemplateCompiler,
1111
CompilerOptions,
@@ -43,6 +43,7 @@ export interface VueLoaderOptions {
4343

4444
let errorEmitted = false
4545

46+
const { parse } = compiler
4647
const exportHelperPath = JSON.stringify(require.resolve('./exportHelper'))
4748

4849
export default function loader(

src/resolveScript.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ import type {
66
} from 'vue/compiler-sfc'
77
import type { VueLoaderOptions } from 'src'
88
import { resolveTemplateTSOptions } from './util'
9-
import { compileScript } from 'vue/compiler-sfc'
9+
import { compiler } from './compiler'
1010

11+
const { compileScript } = compiler
1112
const clientCache = new WeakMap<SFCDescriptor, SFCScriptBlock | null>()
1213
const serverCache = new WeakMap<SFCDescriptor, SFCScriptBlock | null>()
1314

src/stylePostLoader.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import * as qs from 'querystring'
22
import webpack = require('webpack')
3-
import { compileStyle } from 'vue/compiler-sfc'
3+
import { compiler } from './compiler'
4+
5+
const { compileStyle } = compiler
46

57
// This is a post loader that handles scoped CSS transforms.
68
// Injected right before css-loader by the global pitcher (../pitch.js)

src/templateLoader.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ import type { TemplateCompiler } from 'vue/compiler-sfc'
77
import { getDescriptor } from './descriptorCache'
88
import { resolveScript } from './resolveScript'
99
import { resolveTemplateTSOptions } from './util'
10-
import { compileTemplate } from 'vue/compiler-sfc'
10+
import { compiler } from './compiler'
11+
12+
const { compileTemplate } = compiler
1113

1214
// Loader that compiles raw template into JavaScript functions.
1315
// This is injected by the global pitcher (../pitch) for template

0 commit comments

Comments
 (0)