diff --git a/test/configCases/inner-graph/pr-18342/common/index.js b/test/configCases/inner-graph/pr-18342/common/index.js new file mode 100644 index 00000000000..f402294b264 --- /dev/null +++ b/test/configCases/inner-graph/pr-18342/common/index.js @@ -0,0 +1,5 @@ +import pure from './pure' + +export default () => { + pure() +} diff --git a/test/configCases/inner-graph/pr-18342/common/pure.js b/test/configCases/inner-graph/pr-18342/common/pure.js new file mode 100644 index 00000000000..d70ac6f068b --- /dev/null +++ b/test/configCases/inner-graph/pr-18342/common/pure.js @@ -0,0 +1,5 @@ +function pure() { + console.log('pureFn'); +} + +export default pure diff --git a/test/configCases/inner-graph/pr-18342/entry1/index.js b/test/configCases/inner-graph/pr-18342/entry1/index.js new file mode 100644 index 00000000000..d5fb94c7209 --- /dev/null +++ b/test/configCases/inner-graph/pr-18342/entry1/index.js @@ -0,0 +1,7 @@ +import common from "../common"; + +it("entry1 should compile and run", () => { + common() + console.log('entry1'); + expect(true).toBe(true) +}); diff --git a/test/configCases/inner-graph/pr-18342/entry2/index.js b/test/configCases/inner-graph/pr-18342/entry2/index.js new file mode 100644 index 00000000000..7e6ccae0d4c --- /dev/null +++ b/test/configCases/inner-graph/pr-18342/entry2/index.js @@ -0,0 +1,7 @@ +it("entry2 should compile and run", () => { + import(/* webpackChunkName: "chunk-reason-webpackChunkName" */'../common').then(common => { + common.default() + console.log('entry2'); + expect(true).toBe(true) + }) +}); diff --git a/test/configCases/inner-graph/pr-18342/entry3/a.js b/test/configCases/inner-graph/pr-18342/entry3/a.js new file mode 100644 index 00000000000..90bd54cd7f2 --- /dev/null +++ b/test/configCases/inner-graph/pr-18342/entry3/a.js @@ -0,0 +1 @@ +export default 'a' diff --git a/test/configCases/inner-graph/pr-18342/entry3/index.js b/test/configCases/inner-graph/pr-18342/entry3/index.js new file mode 100644 index 00000000000..1d863a1d7cb --- /dev/null +++ b/test/configCases/inner-graph/pr-18342/entry3/index.js @@ -0,0 +1,7 @@ +it("entry3 should compile and run", () => { + import(/* webpackChunkName: "chunk-reason-webpackChunkName" */'./a.js').then(a => { + console.log(a.default); + console.log('entry3'); + expect(true).toBe(true) + }) +}); diff --git a/test/configCases/inner-graph/pr-18342/test.config.js b/test/configCases/inner-graph/pr-18342/test.config.js new file mode 100644 index 00000000000..716351b0a53 --- /dev/null +++ b/test/configCases/inner-graph/pr-18342/test.config.js @@ -0,0 +1,8 @@ +const findOutputFiles = require("../../../helpers/findOutputFiles"); + +module.exports = { + findBundle(_, options) { + const files = findOutputFiles(options, new RegExp(`^entry`)); + return files; + } +}; diff --git a/test/configCases/inner-graph/pr-18342/webpack.config.js b/test/configCases/inner-graph/pr-18342/webpack.config.js new file mode 100644 index 00000000000..2d487f51dc2 --- /dev/null +++ b/test/configCases/inner-graph/pr-18342/webpack.config.js @@ -0,0 +1,26 @@ +module.exports = { + target: ["node"], + entry: { + entry1: ["./entry1/index.js"], + entry2: ["./entry2/index.js"], + entry3: ["./entry3/index.js"] + }, + output: { + filename: "[name].js", + chunkFilename: "[name].chunk.js" + }, + optimization: { + minimize: false, + runtimeChunk: true, + splitChunks: { + chunks: "initial", + cacheGroups: { + pureFn: { + test: /pure/, + enforce: true, + name: "chunk-reason-split-chunks" + } + } + } + } +};