Skip to content
Permalink
Browse files

fix: SafariFix is not injected in client modern mode

  • Loading branch information...
clarkdo committed Jan 8, 2019
1 parent a053e58 commit ecf76d91f1bec8dcab8f2c7715e0e07a19d0b6fe
Showing with 11 additions and 7 deletions.
  1. +6 −7 packages/webpack/src/plugins/vue/modern.js
  2. +5 −0 test/unit/modern.client.test.js
@@ -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))
@@ -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}`
)
})
})
}
@@ -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()

0 comments on commit ecf76d9

Please sign in to comment.
You can’t perform that action at this time.