Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vue-loader
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
pi-plusplus
fork-from-github
vue-loader
Commits
22155854
Commit
22155854
authored
Jan 11, 2019
by
Evan You
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: support for compiler 2.6 outputSourceRange
parent
7275ae42
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
6 deletions
+21
-6
templateLoader.js
lib/loaders/templateLoader.js
+21
-6
No files found.
lib/loaders/templateLoader.js
View file @
22155854
...
...
@@ -20,7 +20,10 @@ module.exports = function (source) {
// allow using custom compiler via options
const
compiler
=
options
.
compiler
||
require
(
'vue-template-compiler'
)
const
compilerOptions
=
Object
.
assign
({},
options
.
compilerOptions
,
{
const
compilerOptions
=
Object
.
assign
({
outputSourceRange
:
true
},
options
.
compilerOptions
,
{
scopeId
:
query
.
scoped
?
`data-v-
${
id
}
`
:
null
,
comments
:
query
.
comments
})
...
...
@@ -45,17 +48,29 @@ module.exports = function (source) {
// tips
if
(
compiled
.
tips
&&
compiled
.
tips
.
length
)
{
compiled
.
tips
.
forEach
(
tip
=>
{
loaderContext
.
emitWarning
(
tip
)
loaderContext
.
emitWarning
(
t
ypeof
tip
===
'object'
?
tip
.
msg
:
t
ip
)
})
}
// errors
if
(
compiled
.
errors
&&
compiled
.
errors
.
length
)
{
loaderContext
.
emitError
(
`\n Error compiling template:\n
${
pad
(
compiled
.
source
)}
\n`
+
compiled
.
errors
.
map
(
e
=>
` -
${
e
}
`
).
join
(
'
\
n'
)
+
// 2.6 compiler outputs errors as objects with range
if
(
compiler
.
generateCodeFrame
&&
finalOptions
.
outputSourceRange
)
{
loaderContext
.
emitError
(
`\n\n Errors compiling template:\n\n`
+
compiled
.
errors
.
map
(({
msg
,
start
,
end
})
=>
{
const
frame
=
compiler
.
generateCodeFrame
(
source
,
start
,
end
)
return
`
${
msg
}
\n\n
${
pad
(
frame
)}
`
}).
join
(
`\n\n`
)
+
'
\
n'
)
)
}
else
{
loaderContext
.
emitError
(
`\n Error compiling template:\n
${
pad
(
compiled
.
source
)}
\n`
+
compiled
.
errors
.
map
(
e
=>
` -
${
e
}
`
).
join
(
'
\
n'
)
+
'
\
n'
)
}
}
const
{
code
}
=
compiled
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment