Skip to content

fix: compatibility with asset modules #656

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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