Skip to content

Commit

Permalink
fix: reference project compiler, fixes #2031 (#2038)
Browse files Browse the repository at this point in the history
  • Loading branch information
heywhy committed Apr 17, 2023
1 parent 1b1a195 commit cc6fa9e
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/descriptorCache.ts
@@ -1,7 +1,8 @@
import * as fs from 'fs'
import type { SFCDescriptor } from 'vue/compiler-sfc'
import { parse } from 'vue/compiler-sfc'
import { compiler } from './compiler'

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

export function setDescriptor(filename: string, entry: SFCDescriptor) {
Expand Down
4 changes: 3 additions & 1 deletion src/formatError.ts
@@ -1,7 +1,9 @@
import type { CompilerError } from 'vue/compiler-sfc'
import { generateCodeFrame } from 'vue/compiler-sfc'
import { compiler } from './compiler'
import chalk = require('chalk')

const { generateCodeFrame } = compiler

export function formatError(
err: SyntaxError | CompilerError,
source: string,
Expand Down
3 changes: 2 additions & 1 deletion src/index.ts
Expand Up @@ -5,7 +5,7 @@ import * as loaderUtils from 'loader-utils'

import hash = require('hash-sum')

import { parse } from 'vue/compiler-sfc'
import { compiler } from './compiler'
import type {
TemplateCompiler,
CompilerOptions,
Expand Down Expand Up @@ -43,6 +43,7 @@ export interface VueLoaderOptions {

let errorEmitted = false

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

export default function loader(
Expand Down
3 changes: 2 additions & 1 deletion src/resolveScript.ts
Expand Up @@ -6,8 +6,9 @@ import type {
} from 'vue/compiler-sfc'
import type { VueLoaderOptions } from 'src'
import { resolveTemplateTSOptions } from './util'
import { compileScript } from 'vue/compiler-sfc'
import { compiler } from './compiler'

const { compileScript } = compiler
const clientCache = new WeakMap<SFCDescriptor, SFCScriptBlock | null>()
const serverCache = new WeakMap<SFCDescriptor, SFCScriptBlock | null>()

Expand Down
4 changes: 3 additions & 1 deletion src/stylePostLoader.ts
@@ -1,6 +1,8 @@
import * as qs from 'querystring'
import webpack = require('webpack')
import { compileStyle } from 'vue/compiler-sfc'
import { compiler } from './compiler'

const { compileStyle } = compiler

// This is a post loader that handles scoped CSS transforms.
// Injected right before css-loader by the global pitcher (../pitch.js)
Expand Down
4 changes: 3 additions & 1 deletion src/templateLoader.ts
Expand Up @@ -7,7 +7,9 @@ import type { TemplateCompiler } from 'vue/compiler-sfc'
import { getDescriptor } from './descriptorCache'
import { resolveScript } from './resolveScript'
import { resolveTemplateTSOptions } from './util'
import { compileTemplate } from 'vue/compiler-sfc'
import { compiler } from './compiler'

const { compileTemplate } = compiler

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

0 comments on commit cc6fa9e

Please sign in to comment.