@@ -280,7 +280,7 @@ type Query =
280
280
}
281
281
282
282
function parseVuePartRequest ( id : string ) : Query {
283
- const [ filename , query ] = id . split ( '?' , 2 )
283
+ const [ filename , query ] = id . replace ( / # \. [ \w - ] + $ / , '' ) . split ( '?' , 2 )
284
284
285
285
if ( ! query ) return { vue : false , filename }
286
286
@@ -391,7 +391,12 @@ function getTemplateCode(
391
391
const scopedQuery = hasScoped ? `&scoped=true` : ``
392
392
const srcQuery = descriptor . template . src ? `&src` : ``
393
393
const attrsQuery = attrsToQuery ( descriptor . template . attrs )
394
- const query = `?vue&type=template${ idQuery } ${ srcQuery } ${ scopedQuery } ${ attrsQuery } `
394
+ const ext = extensionFragment (
395
+ 'template' ,
396
+ descriptor . template . attrs . lang as string ,
397
+ 'html'
398
+ )
399
+ const query = `?vue&type=template${ idQuery } ${ srcQuery } ${ scopedQuery } ${ attrsQuery } ${ ext } `
395
400
templateRequest = _ ( src + query )
396
401
templateImport = `import { ${
397
402
isServer ? 'ssrRender' : 'render'
@@ -407,7 +412,12 @@ function getScriptCode(descriptor: SFCDescriptor, resourcePath: string) {
407
412
const src = descriptor . script . src || resourcePath
408
413
const attrsQuery = attrsToQuery ( descriptor . script . attrs , 'js' )
409
414
const srcQuery = descriptor . script . src ? `&src` : ``
410
- const query = `?vue&type=script${ srcQuery } ${ attrsQuery } `
415
+ const ext = extensionFragment (
416
+ 'script' ,
417
+ descriptor . script . attrs . lang as string ,
418
+ 'js'
419
+ )
420
+ const query = `?vue&type=script${ srcQuery } ${ attrsQuery } ${ ext } `
411
421
const scriptRequest = _ ( src + query )
412
422
scriptImport =
413
423
`import script from ${ scriptRequest } \n` + `export * from ${ scriptRequest } ` // support named exports
@@ -435,8 +445,14 @@ function getStyleCode(
435
445
const idQuery = style . scoped ? `&id=${ id } ` : ``
436
446
const srcQuery = style . src ? `&src` : ``
437
447
const query = `?vue&type=style&index=${ i } ${ srcQuery } ${ idQuery } `
438
- const styleRequest = src + query + attrsQuery
439
- const styleRequestWithoutModule = src + query + attrsQueryWithoutModule
448
+ const ext = extensionFragment (
449
+ 'template' ,
450
+ style . attrs . lang as string ,
451
+ 'html'
452
+ )
453
+ const styleRequest = src + query + attrsQuery + ext
454
+ const styleRequestWithoutModule =
455
+ src + query + attrsQueryWithoutModule + ext
440
456
if ( style . module ) {
441
457
if ( ! hasCSSModules ) {
442
458
stylesCode += `\nconst cssModules = script.__cssModules = {}`
@@ -479,6 +495,15 @@ function createRollupError(id: string, error: CompilerError): RollupError {
479
495
// these are built-in query parameters so should be ignored
480
496
// if the user happen to add them as attrs
481
497
const ignoreList = [ 'id' , 'index' , 'src' , 'type' ]
498
+
499
+ function extensionFragment (
500
+ block : string ,
501
+ lang ?: string ,
502
+ langFallback ?: string
503
+ ) {
504
+ return `#.${ lang || langFallback || block } `
505
+ }
506
+
482
507
function attrsToQuery (
483
508
attrs : SFCBlock [ 'attrs' ] ,
484
509
langFallback ?: string ,
0 commit comments