Skip to content

feat: Add compilerFile for options #1533

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
8 changes: 8 additions & 0 deletions docs/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ sidebar: auto

Override the default compiler used to compile `<template>` blocks in single file components.


## compilerFile

- Type: `string`
- default: `undefined`

Supplementary option for `compiler`. Override the default compiler with the compiler in file path, to compile `<template>` blocks in single file components.

## compilerOptions

- type: `Object`
Expand Down
8 changes: 8 additions & 0 deletions docs/zh/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ sidebar: auto

覆写用来编译单文件组件中 `<template>` 块的默认编译器。


## compilerFile

- 类型:`string`
- 默认值:`undefined`

compiler 参数的替换参数,传入指定编译器的 js 文件路径,覆写用来编译单文件组件中 `<template>` 块的默认编译器。

## compilerOptions

- 类型:`Object`
Expand Down
6 changes: 3 additions & 3 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ const { NS } = require('./plugin')

let errorEmitted = false

function loadTemplateCompiler (loaderContext) {
function loadTemplateCompiler (loaderContext, options) {
try {
return require('vue-template-compiler')
return require(options.compilerFile || 'vue-template-compiler')
} catch (e) {
if (/version mismatch/.test(e.toString())) {
loaderContext.emitError(e)
Expand Down Expand Up @@ -66,7 +66,7 @@ module.exports = function (source) {

const descriptor = parse({
source,
compiler: options.compiler || loadTemplateCompiler(loaderContext),
compiler: options.compiler || loadTemplateCompiler(loaderContext, options),
filename,
sourceRoot,
needMap: sourceMap
Expand Down