Skip to content

Commit bea1f4d

Browse files
fix: compatibility with asset modules (#656)
1 parent 3dce50d commit bea1f4d

15 files changed

+1093
-200
lines changed

package-lock.json

+603-186
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
"del": "^6.0.0",
6363
"del-cli": "^3.0.1",
6464
"es-check": "^5.1.2",
65-
"eslint": "^7.12.1",
65+
"eslint": "^7.13.0",
6666
"eslint-config-prettier": "^6.15.0",
6767
"eslint-plugin-import": "^2.22.1",
6868
"file-loader": "^6.2.0",
@@ -75,7 +75,7 @@
7575
"prettier": "^2.1.2",
7676
"standard-version": "^9.0.0",
7777
"webpack": "^5.4.0",
78-
"webpack-cli": "^4.1.0",
78+
"webpack-cli": "^4.2.0",
7979
"webpack-dev-server": "^3.7.2"
8080
},
8181
"keywords": [

src/loader.js

+15-3
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,6 @@ export function pitch(request) {
8383
: compilation.hooks.normalModuleLoader;
8484

8585
normalModuleHook.tap(`${pluginName} loader`, (loaderContext, module) => {
86-
// eslint-disable-next-line no-param-reassign
87-
loaderContext.emitFile = this.emitFile;
88-
8986
if (module.request === request) {
9087
// eslint-disable-next-line no-param-reassign
9188
module.loaders = loaders.map((loader) => {
@@ -139,6 +136,21 @@ export function pitch(request) {
139136
const callback = this.async();
140137

141138
childCompiler.runAsChild((err, entries, compilation) => {
139+
for (const asset of compilation.getAssets()) {
140+
const { buildInfo } = this._module;
141+
142+
if (!buildInfo.assets) {
143+
buildInfo.assets = Object.create(null);
144+
}
145+
146+
if (!buildInfo.assetsInfo) {
147+
buildInfo.assetsInfo = new Map();
148+
}
149+
150+
buildInfo.assets[asset.name] = asset.source;
151+
buildInfo.assetsInfo.set(asset.name, asset.info);
152+
}
153+
142154
const addDependencies = (dependencies) => {
143155
if (!Array.isArray(dependencies) && dependencies != null) {
144156
throw new Error(

0 commit comments

Comments
 (0)