Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix bug which prevented some chunks to show up in Chunk.getAllAsyncCh…
…unks fixes #6931
- Loading branch information
Showing
8 changed files
with
106 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
const should = require("should"); | ||
const FakeDocument = require("../../../helpers/FakeDocument"); | ||
|
||
beforeEach(() => { | ||
global.document = new FakeDocument(); | ||
}); | ||
|
||
afterEach(() => { | ||
delete global.document; | ||
}) | ||
|
||
it("should be able to load the split chunk on demand", () => { | ||
const promise = import(/* webpackChunkName: "shared" */ "./shared"); | ||
|
||
const script = document.head._children[0]; | ||
should(script.src).be.eql("dep~b~shared.js"); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import "./shared"; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = { | ||
findBundle: function(i, options) { | ||
return ["runtime.js", "a.js"]; | ||
} | ||
}; |
24 changes: 24 additions & 0 deletions
24
test/configCases/split-chunks/runtime-chunk/webpack.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
const path = require("path"); | ||
|
||
module.exports = { | ||
entry: { | ||
a: "./a", | ||
b: "./b" | ||
}, | ||
target: "web", | ||
output: { | ||
filename: "[name].js" | ||
}, | ||
optimization: { | ||
runtimeChunk: "single", | ||
splitChunks: { | ||
cacheGroups: { | ||
dep: { | ||
chunks: "all", | ||
test: path.resolve(__dirname, "shared.js"), | ||
enforce: true | ||
} | ||
} | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
module.exports = class FakeDocument { | ||
constructor() { | ||
this.head = this.createElement("head"); | ||
} | ||
|
||
createElement(type) { | ||
return new FakeElement(type); | ||
} | ||
|
||
getElementsByTagName(name) { | ||
if (name === "head") return [this.head]; | ||
throw new Error( | ||
`FakeDocument.getElementsByTagName(${name}): not implemented` | ||
); | ||
} | ||
}; | ||
|
||
class FakeElement { | ||
constructor(type) { | ||
this._type = type; | ||
this._children = []; | ||
this._attributes = Object.create(null); | ||
} | ||
|
||
appendChild(node) { | ||
this._children.push(node); | ||
} | ||
|
||
setAttribute(name, value) { | ||
this._attributes[name] = value; | ||
} | ||
|
||
getAttribute(name) { | ||
return this._attributes[name]; | ||
} | ||
} |