From 916a96f164ae8962b678555b1f1ee314f4b542a2 Mon Sep 17 00:00:00 2001 From: atanda rasheed Date: Fri, 14 Apr 2023 13:09:44 +0100 Subject: [PATCH] fix: reference project compiler Closes #2031 --- src/descriptorCache.ts | 3 ++- src/formatError.ts | 4 +++- src/index.ts | 3 ++- src/resolveScript.ts | 3 ++- src/stylePostLoader.ts | 4 +++- src/templateLoader.ts | 4 +++- 6 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/descriptorCache.ts b/src/descriptorCache.ts index 121bf0f38..d83111b20 100644 --- a/src/descriptorCache.ts +++ b/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() export function setDescriptor(filename: string, entry: SFCDescriptor) { diff --git a/src/formatError.ts b/src/formatError.ts index 72a8137c7..02b21a7f9 100644 --- a/src/formatError.ts +++ b/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, diff --git a/src/index.ts b/src/index.ts index 88d08328b..d528f3034 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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, @@ -43,6 +43,7 @@ export interface VueLoaderOptions { let errorEmitted = false +const { parse } = compiler const exportHelperPath = JSON.stringify(require.resolve('./exportHelper')) export default function loader( diff --git a/src/resolveScript.ts b/src/resolveScript.ts index 38cccc696..6684a6b87 100644 --- a/src/resolveScript.ts +++ b/src/resolveScript.ts @@ -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() const serverCache = new WeakMap() diff --git a/src/stylePostLoader.ts b/src/stylePostLoader.ts index b5ea8c1d8..76ea526fa 100644 --- a/src/stylePostLoader.ts +++ b/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) diff --git a/src/templateLoader.ts b/src/templateLoader.ts index 6b5fefea7..da80d1a0d 100644 --- a/src/templateLoader.ts +++ b/src/templateLoader.ts @@ -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