From b7e256ba01c837b982365283699d9295a0303727 Mon Sep 17 00:00:00 2001 From: Tim Neutkens Date: Wed, 15 Aug 2018 12:42:56 -0700 Subject: [PATCH] Make onClick Link tests more consistent (#4954) --- .../webpack/plugins/build-manifest-plugin.js | 4 +- server/document.js | 3 +- server/render.js | 2 + test/integration/basic/pages/nav/index.js | 2 +- test/integration/basic/pages/nav/on-click.js | 25 +++-- .../basic/test/client-navigation.js | 94 +++++++++++-------- test/integration/basic/test/index.test.js | 1 + 7 files changed, 80 insertions(+), 51 deletions(-) diff --git a/build/webpack/plugins/build-manifest-plugin.js b/build/webpack/plugins/build-manifest-plugin.js index f7319054..fc2c346e 100644 --- a/build/webpack/plugins/build-manifest-plugin.js +++ b/build/webpack/plugins/build-manifest-plugin.js @@ -8,14 +8,14 @@ export default class BuildManifestPlugin { apply (compiler: any) { compiler.hooks.emit.tapAsync('NextJsBuildManifest', (compilation, callback) => { const {chunks} = compilation - const assetMap = {pages: {}} + const assetMap = {devFiles: [], pages: {}} const mainJsChunk = chunks.find((c) => c.name === CLIENT_STATIC_FILES_RUNTIME_MAIN) const mainJsFiles = mainJsChunk && mainJsChunk.files.length > 0 ? mainJsChunk.files.filter((file) => /\.js$/.test(file)) : [] for (const filePath of Object.keys(compilation.assets)) { if (/^static\/dll\//.test(filePath)) { - mainJsFiles.push(filePath) + assetMap.devFiles.push(filePath) } } diff --git a/server/document.js b/server/document.js index 361bb437..7e1dcf34 100644 --- a/server/document.js +++ b/server/document.js @@ -199,11 +199,12 @@ export class NextScript extends Component { } render () { - const { staticMarkup, assetPrefix, __NEXT_DATA__ } = this.context._documentProps + const { staticMarkup, assetPrefix, devFiles, __NEXT_DATA__ } = this.context._documentProps const { page, pathname, buildId } = __NEXT_DATA__ const pagePathname = getPagePathname(pathname) return + {devFiles ? devFiles.map((file) =>