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

Add Compiler reference via cpl attr in script tag #425

Open
wants to merge 2 commits 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
2 changes: 1 addition & 1 deletion packages/vue-component/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Package.registerBuildPlugin({
'source-map-merger': '0.2.0',
'generate-source-map': '0.0.5',
'autoprefixer': '9.5.1',
'vue-template-compiler': '2.6.11',
'vue-template-compiler': '2.6.12',
'vue-template-es2015-compiler': '1.9.1',
'colors': '1.3.3',
'app-module-path': '2.2.0',
Expand Down
15 changes: 11 additions & 4 deletions packages/vue-component/plugin/tag-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ VueComponentTagHandler = class VueComponentTagHandler {
let inputFilePath = this.inputFile.getPathInPackage()
let fullInputFilePath = packageName ? '/packages/' + packageName + '/' + inputFilePath : '/' + inputFilePath
let hash = 'data-v-' + Hash(fullInputFilePath)

let js = ''
let styles = []

Expand All @@ -72,9 +72,16 @@ VueComponentTagHandler = class VueComponentTagHandler {

maps.push(generateSourceMap(inputFilePath, source, script, getLineNumber(source, sfcBlock.start)))

// Lang
if (sfcBlock.lang !== undefined) {
let lang = sfcBlock.lang
// Lang or compiler

// cpl is a custom compiler defined by another package
// Specially useful when using vscode+vetur, as the dev experience
// with vetur is affected is not optimal when using lang attr
// in script tag
const cpl = sfcBlock.attrs?.cpl
let lang = sfcBlock.lang || cpl

if (lang !== undefined) {
try {
let compile = global.vue.lang[lang]
if (!compile) {
Expand Down