Skip to content
This repository was archived by the owner on Aug 16, 2022. It is now read-only.

Commit 8230efd

Browse files
committed
refactor: sync with vue-loader, remove bustCache, add needCSSMap option in parser
1 parent dfc0ec2 commit 8230efd

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

src/parser.js

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const compiler = require('vue-template-compiler/build.js')
1+
const compiler = require('vue-template-compiler')
22
const { struct } = require('superstruct')
33
const LRU = require('lru-cache')
44
const hash = require('hash-sum')
@@ -13,39 +13,35 @@ const emptyRE = /^(?:\/\/)?\s*$/
1313
const Config = struct(
1414
{
1515
needMap: 'boolean?',
16-
bustCache: 'boolean?'
16+
needCSSMap: 'boolean?'
1717
},
1818
{
1919
needMap: true,
20-
bustCache: false
20+
needCSSMap: false
2121
}
2222
)
2323

24-
module.exports = function (content, filename, config) {
24+
module.exports = function parse (content, filename, config) {
2525
assertType({ content, filename }, 'string')
2626
config = Config(config)
2727

2828
const cacheKey = hash(filename + content)
29-
const filenameWithHash = config.bustCache
30-
? filename + '?' + cacheKey
31-
: filename // source-map cache busting for hot-reloadded modules
32-
3329
if (cache.has(cacheKey)) return cache.get(cacheKey)
3430

3531
const output = compiler.parseComponent(content, { pad: 'line' })
3632
if (config.needMap) {
3733
if (output.script && !output.script.src) {
3834
output.script.map = generateSourceMap(
39-
filenameWithHash,
35+
filename,
4036
content,
4137
output.script.content
4238
)
4339
}
44-
if (output.styles) {
40+
if (config.needCSSMap && output.styles) {
4541
output.styles.forEach(style => {
4642
if (!style.src) {
4743
style.map = generateSourceMap(
48-
filenameWithHash,
44+
filename,
4945
content,
5046
style.content
5147
)

0 commit comments

Comments
 (0)