From d343068a3783b280a8466f63b7f5ed79ca838e76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Greg=20Berg=C3=A9?= Date: Sun, 12 May 2019 21:47:58 +0200 Subject: [PATCH] fix: fix chunkname mismatch Closes #331 --- examples/server-side-rendering/src/client/App.js | 3 +++ examples/server-side-rendering/src/client/Y/file.js | 1 + packages/babel-plugin/src/__snapshots__/index.test.js.snap | 4 ++-- packages/babel-plugin/src/properties/chunkName.js | 5 ++--- 4 files changed, 8 insertions(+), 5 deletions(-) create mode 100644 examples/server-side-rendering/src/client/Y/file.js diff --git a/examples/server-side-rendering/src/client/App.js b/examples/server-side-rendering/src/client/App.js index 64c91f4f..14eea717 100644 --- a/examples/server-side-rendering/src/client/App.js +++ b/examples/server-side-rendering/src/client/App.js @@ -10,6 +10,7 @@ const D = loadable(() => import(/* webpackPrefetch: true */ './letters/D')) const E = loadable(() => import('./letters/E'), { ssr: false }) const X = loadable(props => import(`./letters/${props.letter}`)) const Sub = loadable(props => import(`./letters/${props.letter}/file`)) +const RootSub = loadable(props => import(`./${props.letter}/file`)) // We keep some references to prevent uglify remove A.C = C @@ -31,6 +32,8 @@ const App = () => (

+ +
{moment => moment().format('HH:mm')} ) diff --git a/examples/server-side-rendering/src/client/Y/file.js b/examples/server-side-rendering/src/client/Y/file.js new file mode 100644 index 00000000..9f4b3bb2 --- /dev/null +++ b/examples/server-side-rendering/src/client/Y/file.js @@ -0,0 +1 @@ +export default () => 'Y' diff --git a/packages/babel-plugin/src/__snapshots__/index.test.js.snap b/packages/babel-plugin/src/__snapshots__/index.test.js.snap index e972e762..9da516a9 100644 --- a/packages/babel-plugin/src/__snapshots__/index.test.js.snap +++ b/packages/babel-plugin/src/__snapshots__/index.test.js.snap @@ -263,7 +263,7 @@ exports[`plugin aggressive import without "webpackChunkName" should support comp }, requireAsync: props => import( - /* webpackChunkName: \\"dir-[request]-test\\" */ + /* webpackChunkName: \\"dir-[request]\\" */ \`./dir/\${props.foo}/test\`), requireSync(props) { @@ -306,7 +306,7 @@ exports[`plugin aggressive import without "webpackChunkName" should support dest requireAsync: ({ foo }) => import( - /* webpackChunkName: \\"dir-[request]-test\\" */ + /* webpackChunkName: \\"dir-[request]\\" */ \`./dir/\${foo}/test\`), requireSync(props) { diff --git a/packages/babel-plugin/src/properties/chunkName.js b/packages/babel-plugin/src/properties/chunkName.js index 384be0eb..dee90a36 100644 --- a/packages/babel-plugin/src/properties/chunkName.js +++ b/packages/babel-plugin/src/properties/chunkName.js @@ -114,11 +114,10 @@ export default function chunkNameProperty({ types: t }) { } function chunkNameFromTemplateLiteral(node) { - const [q1, q2] = node.quasis + const [q1] = node.quasis const v1 = q1 ? q1.value.cooked : '' - const v2 = q2 ? q2.value.cooked : '' if (!node.expressions.length) return v1 - return `${v1}[request]${v2}` + return `${v1}[request]` } function sanitizeChunkNameTemplateLiteral(node) {