Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: reference project compiler, fixes #2031 #2038

Merged
merged 1 commit into from
Apr 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/descriptorCache.ts
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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