Skip to content

Commit d653f3b

Browse files
committed
feat: support css v-bind (requires 2.7.0-beta.3)
1 parent ac12698 commit d653f3b

File tree

4 files changed

+17
-15
lines changed

4 files changed

+17
-15
lines changed

Diff for: lib/index.js

+12-13
Original file line numberDiff line numberDiff line change
@@ -66,32 +66,31 @@ module.exports = function (source) {
6666
// cache descriptor
6767
setDescriptor(resourcePath, descriptor)
6868

69+
// module id for scoped CSS & hot-reload
70+
const rawShortFilePath = path
71+
.relative(context, resourcePath)
72+
.replace(/^(\.\.[\/\\])+/, '')
73+
const shortFilePath = rawShortFilePath.replace(/\\/g, '/')
74+
const id = hash(
75+
isProduction
76+
? shortFilePath + '\n' + source.replace(/\r\n/g, '\n')
77+
: shortFilePath
78+
)
79+
6980
// if the query has a type field, this is a language block request
7081
// e.g. foo.vue?type=template&id=xxxxx
7182
// and we will return early
7283
if (incomingQuery.type) {
7384
return selectBlock(
7485
descriptor,
86+
id,
7587
options,
7688
loaderContext,
7789
incomingQuery,
7890
!!options.appendExtension
7991
)
8092
}
8193

82-
// module id for scoped CSS & hot-reload
83-
const rawShortFilePath = path
84-
.relative(context, resourcePath)
85-
.replace(/^(\.\.[\/\\])+/, '')
86-
87-
const shortFilePath = rawShortFilePath.replace(/\\/g, '/') + resourceQuery
88-
89-
const id = hash(
90-
isProduction
91-
? shortFilePath + '\n' + source.replace(/\r\n/g, '\n')
92-
: shortFilePath
93-
)
94-
9594
// feature information
9695
const hasScoped = descriptor.styles.some((s) => s.scoped)
9796
const hasFunctional =

Diff for: lib/loaders/templateLoader.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ module.exports = function (source) {
3939
const { compiler, templateCompiler } = resolveCompiler(ctx, loaderContext)
4040

4141
const descriptor = getDescriptor(filename, options, loaderContext)
42-
const script = resolveScript(descriptor, options, loaderContext)
42+
const script = resolveScript(descriptor, id, options, loaderContext)
4343

4444
// for vue/compiler-sfc OR @vue/component-compiler-utils
4545
const finalOptions = {

Diff for: lib/resolveScript.js

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const serverCache = new WeakMap()
55

66
exports.resolveScript = function resolveScript(
77
descriptor,
8+
scopeId,
89
options,
910
loaderContext
1011
) {
@@ -37,6 +38,7 @@ exports.resolveScript = function resolveScript(
3738

3839
try {
3940
resolved = compiler.compileScript(descriptor, {
41+
id: scopeId,
4042
isProd,
4143
babelParserPlugins: options.babelParserPlugins
4244
})

Diff for: lib/select.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const { resolveScript } = require('./resolveScript')
22

33
module.exports = function selectBlock(
44
descriptor,
5+
scopeId,
56
options,
67
loaderContext,
78
query,
@@ -22,7 +23,7 @@ module.exports = function selectBlock(
2223

2324
// script
2425
if (query.type === `script`) {
25-
const script = resolveScript(descriptor, options, loaderContext)
26+
const script = resolveScript(descriptor, scopeId, options, loaderContext)
2627
if (appendExtension) {
2728
loaderContext.resourcePath += '.' + (script.lang || 'js')
2829
}

0 commit comments

Comments
 (0)