webpack-contrib / file-loader

File Loader
MIT License
1.86k stars 255 forks source link

6.2.0 breaks file-loader for me #395

Closed pkokliaguine-opentext-com closed 3 years ago

pkokliaguine-opentext-com commented 3 years ago

Expected Behavior

.SVG files should be loaded

Actual Behavior

.SVG file loading breaks with ERROR in ./~/angular-ui-grid/fonts/ui-grid.svg Module build failed: TypeError [ERR_INVALID_ARG_TYPE]: The "from" argument must be of type string. Received undefined at validateString (internal/validators.js:124:11) at Object.relative (path.js:1053:5) at Object.loader (//node_modules/file-loader/dist/index.js:80:72) @ ./~/css-loader!./~/angular-ui-grid/ui-grid.css 6:16600-16630 @ ./~/angular-ui-grid/ui-grid.css @ ./src/js/app.js

Code

The issue seems to be around line ~78 in src/index.js (https://github.com/webpack-contrib/file-loader/compare/v6.1.1...v6.2.0#diff-bfe9874d239014961b1ae4e89875a6155667db834a410aaaa2ebe3cf89820556) Call to path.relative(this.rootContext, this.resourcePath) fails because this.rootContext is undefined. There is the context variable set prior and it is also undefined; however code in interpolateName() (line ~20, same file) seems to handle this situation.

6.1.1 works fine.

 assetInfo.sourceFilename = normalizePath(
      path.relative(this.rootContext, this.resourcePath)
    );

How Do We Reproduce?

Don't have enough knowledge about the webpack, but it the this.rootContext isn't set it should be reproducible. Also, looks like you don't support web pack versions below 4, I am not sure if that's the issue here.

alexander-akait commented 3 years ago

We don't support webpack Version: ^2.7.0, sorry

alexander-akait commented 3 years ago

Please update webpack version to 5 (or to 4 - not recommend)

pkokliaguine-opentext-com commented 3 years ago

Cannot update at this point -- it's easier for me to stay on 6.1.1 fore the time being. No ya, konechno, popravil by.