Skip to content

Commit

Permalink
fix: SafariFix is not injected in client modern mode
Browse files Browse the repository at this point in the history
  • Loading branch information
clarkdo committed Jan 8, 2019
1 parent a053e58 commit ecf76d9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
13 changes: 6 additions & 7 deletions packages/webpack/src/plugins/vue/modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,6 @@ export default class ModernModePlugin {
}
})

// inject Safari 10 nomodule fix
data.body.push({
tagName: 'script',
closeTag: true,
innerHTML: ModernModePlugin.safariFix
})

// inject links for legacy assets as <script nomodule>
const fileName = data.plugin.options.filename
const legacyAssets = (await this.getAssets(fileName))
Expand All @@ -100,6 +93,12 @@ export default class ModernModePlugin {

compilation.hooks.htmlWebpackPluginAfterHtmlProcessing.tap(ID, (data) => {
data.html = data.html.replace(/\snomodule="">/g, ' nomodule>')

// inject Safari 10 nomodule fix
data.html = data.html.replace(
/(<\/body\s*>)/i,
match => `<script>${ModernModePlugin.safariFix}</script>${match}`
)
})
})
}
Expand Down
5 changes: 5 additions & 0 deletions test/unit/modern.client.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ describe('modern client mode (SSR)', () => {
].join(', '))
})

test('should contain safari fix script', async () => {
const response = await rp(url('/'))
expect(response).toContain('"noModule"')
})

// Close server and ask nuxt to stop listening to file changes
afterAll(async () => {
await nuxt.close()
Expand Down

0 comments on commit ecf76d9

Please sign in to comment.