From f2dd05200f9e271c4a6c820f943c21afb451acf1 Mon Sep 17 00:00:00 2001 From: Gaetan Covelli Date: Mon, 22 Jul 2019 14:43:54 +0200 Subject: [PATCH 1/2] Removes prefetch for the components mounted asynchronously. --- .../__tests__/__snapshots__/CompilerSpec.js.snap | 12 ++++++------ packages/melody-plugin-idom/src/visitors/mount.js | 2 -- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/packages/melody-compiler/__tests__/__snapshots__/CompilerSpec.js.snap b/packages/melody-compiler/__tests__/__snapshots__/CompilerSpec.js.snap index acf0174..3db6dc1 100644 --- a/packages/melody-compiler/__tests__/__snapshots__/CompilerSpec.js.snap +++ b/packages/melody-compiler/__tests__/__snapshots__/CompilerSpec.js.snap @@ -1605,7 +1605,7 @@ _template.render = function (_context) { foo: \\"bar\\" }); component(AsyncComponent, \\"bar\\", { - promisedComponent: () => import( /* webpackChunkName: \\"bar\\", webpackPrefetch: true */\\"foo.twig\\"), + promisedComponent: () => import( /* webpackChunkName: \\"bar\\" */\\"foo.twig\\"), delayLoadingAnimation: 0, whileLoading: () => { text(\\" Loading... \\"); @@ -1620,7 +1620,7 @@ _template.render = function (_context) { } }); component(AsyncComponent, \\"bar\\", { - promisedComponent: () => import( /* webpackChunkName: \\"bar\\", webpackPrefetch: true */\\"foo.twig\\"), + promisedComponent: () => import( /* webpackChunkName: \\"bar\\" */\\"foo.twig\\"), delayLoadingAnimation: 500, whileLoading: () => { text(\\" Loading... \\"); @@ -1635,7 +1635,7 @@ _template.render = function (_context) { } }); component(AsyncComponent, \\"bar\\", { - promisedComponent: () => import( /* webpackChunkName: \\"bar\\", webpackPrefetch: true */\\"foo.twig\\"), + promisedComponent: () => import( /* webpackChunkName: \\"bar\\" */\\"foo.twig\\"), delayLoadingAnimation: 1000, whileLoading: () => { text(\\" Loading... \\"); @@ -1651,7 +1651,7 @@ _template.render = function (_context) { } }); component(AsyncComponent, \\"\\" + (\\"bar-\\" + _context.part), { - promisedComponent: () => import( /* webpackPrefetch: true */\\"./parts/\\" + _context.part + \\".twig\\"), + promisedComponent: () => import( /* */\\"./parts/\\" + _context.part + \\".twig\\"), delayLoadingAnimation: 1000, whileLoading: () => { text(\\" Loading... \\"); @@ -1666,7 +1666,7 @@ _template.render = function (_context) { } }); component(AsyncComponent, \\"bar\\", { - promisedComponent: () => import( /* webpackChunkName: \\"bar\\", webpackPrefetch: true */\\"./parts/\\" + _context.part + \\".twig\\"), + promisedComponent: () => import( /* webpackChunkName: \\"bar\\" */\\"./parts/\\" + _context.part + \\".twig\\"), delayLoadingAnimation: 1000, whileLoading: () => { text(\\" Loading... \\"); @@ -1677,7 +1677,7 @@ _template.render = function (_context) { } }); component(AsyncComponent, \\"bar\\", { - promisedComponent: () => import( /* webpackChunkName: \\"bar\\", webpackPrefetch: true */\\"./parts/\\" + _context.part + \\".twig\\"), + promisedComponent: () => import( /* webpackChunkName: \\"bar\\" */\\"./parts/\\" + _context.part + \\".twig\\"), delayLoadingAnimation: 1000, whileLoading: () => { elementOpen(\\"strong\\", null, null); diff --git a/packages/melody-plugin-idom/src/visitors/mount.js b/packages/melody-plugin-idom/src/visitors/mount.js index 3dc6f02..cf08d09 100644 --- a/packages/melody-plugin-idom/src/visitors/mount.js +++ b/packages/melody-plugin-idom/src/visitors/mount.js @@ -108,7 +108,6 @@ export default { } if (isAsync) { - /* webpackPrefetch: true */ const source = path.node.source; source.leadingComments = [ @@ -120,7 +119,6 @@ export default { args[args.length - 1].value }"` : '', - 'webpackPrefetch: true', ] .filter(Boolean) .join(', ')} `, From 6717b8ade5b51d8b16f11787ef90b53855ea98ae Mon Sep 17 00:00:00 2001 From: Gaetan Covelli Date: Mon, 22 Jul 2019 14:55:50 +0200 Subject: [PATCH 2/2] Updates changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d1f6d4..028a19c 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ## master - Do not log warning for component first emission in `melody-streams` in production [#128](https://github.com/trivago/melody/pull/128) +- Removes prefetch for asynchronously mounted components [#129](https://github.com/trivago/melody/issues/129) ## 1.2.0