Skip to content
This repository has been archived by the owner on May 3, 2024. It is now read-only.

Commit

Permalink
fix(send-html): ignore async chunks
Browse files Browse the repository at this point in the history
  • Loading branch information
Francois-Esquire committed Jun 16, 2020
1 parent de1e264 commit 49a3826
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions __tests__/server/middleware/sendHtml.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,14 @@ describe('sendHtml', () => {
expect(/<script.*nonce="54321"/.test(res.send.mock.calls[0][0])).toBe(true);
});

describe('dynamic chunks', () => {
it('does not add service-worker-client.js to the document script tags', () => {
sendHtml(req, res);
expect(res.send).toHaveBeenCalledTimes(1);
expect(res.send.mock.calls[0][0]).not.toContain('service-worker-client.js');
});
});

describe('PWA config rendering', () => {
it('includes __pwa_metadata__ with disabled values', () => {
sendHtml(req, res);
Expand Down
2 changes: 1 addition & 1 deletion src/server/middleware/sendHtml.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function getChunkAssets(assetsByChunkName) {
return Object
.entries(assetsByChunkName)
// i18n is different per request, app needs to be the last chunk loaded
.filter(([chunkName]) => !chunkName.startsWith('i18n/') && chunkName !== 'app')
.filter(([chunkName]) => !chunkName.startsWith('i18n/') && !['app', 'service-worker-client'].includes(chunkName))
.map(([, assets]) => (typeof assets === 'string' ? assets : assets[0]));
}

Expand Down

0 comments on commit 49a3826

Please sign in to comment.