Skip to content

Commit

Permalink
fix: undefined script in modern mode
Browse files Browse the repository at this point in the history
  • Loading branch information
clarkdo committed Jan 10, 2019
1 parent e8083fb commit 0a21d4b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/vue-renderer/src/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@ export default class VueRenderer {
const modernJsFile = this.assetsMapping[legacyJsFile]
const crossorigin = this.context.options.build.crossorigin
const cors = `${crossorigin ? ` crossorigin="${crossorigin}"` : ''}`
const moduleTag = scriptTag.replace('<script', `<script type="module"${cors}`).replace(legacyJsFile, modernJsFile)
const moduleTag = modernJsFile
? scriptTag
.replace('<script', `<script type="module"${cors}`)
.replace(legacyJsFile, modernJsFile)
: ''
const noModuleTag = scriptTag.replace('<script', `<script nomodule${cors}`)
return noModuleTag + moduleTag
})
Expand Down Expand Up @@ -95,6 +99,9 @@ export default class VueRenderer {
return context.renderResourceHints().replace(linkPattern, (linkTag, jsFile) => {
const legacyJsFile = jsFile.replace(publicPath, '')
const modernJsFile = this.assetsMapping[legacyJsFile]
if (!modernJsFile) {
return ''
}
const crossorigin = this.context.options.build.crossorigin
const cors = `${crossorigin ? ` crossorigin="${crossorigin}"` : ''}`
return linkTag.replace('rel="preload"', `rel="modulepreload"${cors}`).replace(legacyJsFile, modernJsFile)
Expand Down

0 comments on commit 0a21d4b

Please sign in to comment.