Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Jan 18, 2022. It is now read-only.

Commite334e8c

Browse files
authored
fix: add language fallback for template code (#407)
* fix: add language fallback for template code* tests: expect lang.js in template* fix: always force language fallback
1 parent09c41b7 commite334e8c

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

‎src/index.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ describe('Rollup Plugin Vue', () => {
5353

5454
expect(code).toEqual(
5555
expect.stringContaining(
56-
`import { render } from "example.vue?vue&type=template&id=063a7d4c"`
56+
`import { render } from "example.vue?vue&type=template&id=063a7d4c&lang.js"`
5757
)
5858
)
5959
expect(code).toEqual(expect.stringContaining(`script.render = render`))
@@ -66,7 +66,7 @@ describe('Rollup Plugin Vue', () => {
6666
)
6767
expect(code).toEqual(
6868
expect.stringContaining(
69-
`import { render } from "example.vue?vue&type=template&id=063a7d4c"`
69+
`import { render } from "example.vue?vue&type=template&id=063a7d4c&lang.js"`
7070
)
7171
)
7272
expect(code).toEqual(expect.stringContaining(`script.render = render`))

‎src/index.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,9 @@ export default function PluginVue(userOptions: Partial<Options> = {}): Plugin {
144144
constdescriptor=getDescriptor(query.filename)
145145
consthasScoped=descriptor.styles.some((s)=>s.scoped)
146146
if(query.src){
147-
this.addWatchFile(query.filename);
147+
this.addWatchFile(query.filename)
148148
}
149-
149+
150150
if(query.type==='template'){
151151
debug(`transform(${id})`)
152152
constblock=descriptor.template!
@@ -478,7 +478,7 @@ function getTemplateCode(
478478
constidQuery=`&id=${id}`
479479
constscopedQuery=hasScoped ?`&scoped=true` :``
480480
constsrcQuery=descriptor.template.src ?`&src` :``
481-
constattrsQuery=attrsToQuery(descriptor.template.attrs)
481+
constattrsQuery=attrsToQuery(descriptor.template.attrs,'js',true)
482482
constquery=`?vue&type=template${idQuery}${srcQuery}${scopedQuery}${attrsQuery}`
483483
templateRequest=_(src+query)
484484
templateImport=`import {${renderFnName} } from${templateRequest}`
@@ -638,12 +638,15 @@ function _(any: any) {
638638
returnJSON.stringify(any)
639639
}
640640

641-
functionnormalizeSourceMap(map:SFCTemplateCompileResults['map'],id:string):any{
641+
functionnormalizeSourceMap(
642+
map:SFCTemplateCompileResults['map'],
643+
id:string
644+
):any{
642645
if(!map)returnnullasany
643646

644647
if(!id.includes('type=script')){
645-
map.file=id;
646-
map.sources[0]=id;
648+
map.file=id
649+
map.sources[0]=id
647650
}
648651

649652
return{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp