Skip to content

Commit

Permalink
fix: compatibility with asset modules (#656)
Browse files Browse the repository at this point in the history
  • Loading branch information
evilebottnawi authored Nov 12, 2020
1 parent 3dce50d commit bea1f4d
Show file tree
Hide file tree
Showing 15 changed files with 1,093 additions and 200 deletions.
789 changes: 603 additions & 186 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"del": "^6.0.0",
"del-cli": "^3.0.1",
"es-check": "^5.1.2",
"eslint": "^7.12.1",
"eslint": "^7.13.0",
"eslint-config-prettier": "^6.15.0",
"eslint-plugin-import": "^2.22.1",
"file-loader": "^6.2.0",
Expand All @@ -75,7 +75,7 @@
"prettier": "^2.1.2",
"standard-version": "^9.0.0",
"webpack": "^5.4.0",
"webpack-cli": "^4.1.0",
"webpack-cli": "^4.2.0",
"webpack-dev-server": "^3.7.2"
},
"keywords": [
Expand Down
18 changes: 15 additions & 3 deletions src/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,6 @@ export function pitch(request) {
: compilation.hooks.normalModuleLoader;

normalModuleHook.tap(`${pluginName} loader`, (loaderContext, module) => {
// eslint-disable-next-line no-param-reassign
loaderContext.emitFile = this.emitFile;

if (module.request === request) {
// eslint-disable-next-line no-param-reassign
module.loaders = loaders.map((loader) => {
Expand Down Expand Up @@ -139,6 +136,21 @@ export function pitch(request) {
const callback = this.async();

childCompiler.runAsChild((err, entries, compilation) => {
for (const asset of compilation.getAssets()) {
const { buildInfo } = this._module;

if (!buildInfo.assets) {
buildInfo.assets = Object.create(null);
}

if (!buildInfo.assetsInfo) {
buildInfo.assetsInfo = new Map();
}

buildInfo.assets[asset.name] = asset.source;
buildInfo.assetsInfo.set(asset.name, asset.info);
}

const addDependencies = (dependencies) => {
if (!Array.isArray(dependencies) && dependencies != null) {
throw new Error(
Expand Down
Loading

0 comments on commit bea1f4d

Please sign in to comment.