Skip to content

Commit

Permalink
fix: fix chunkname mismatch (#332)
Browse files Browse the repository at this point in the history
Closes #331
  • Loading branch information
gregberge committed May 12, 2019
1 parent d65c5bb commit 7ffaa4c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
3 changes: 3 additions & 0 deletions examples/server-side-rendering/src/client/App.js
Expand Up @@ -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
Expand All @@ -31,6 +32,8 @@ const App = () => (
<br />
<Sub letter="Z" />
<br />
<RootSub letter="Y" />
<br />
<Moment>{moment => moment().format('HH:mm')}</Moment>
</div>
)
Expand Down
1 change: 1 addition & 0 deletions examples/server-side-rendering/src/client/Y/file.js
@@ -0,0 +1 @@
export default () => 'Y'
4 changes: 2 additions & 2 deletions packages/babel-plugin/src/__snapshots__/index.test.js.snap
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
5 changes: 2 additions & 3 deletions packages/babel-plugin/src/properties/chunkName.js
Expand Up @@ -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) {
Expand Down

0 comments on commit 7ffaa4c

Please sign in to comment.