webpack-contrib/raw-loader

Warning/Failure Using Raw Loader 2.0.0 in Angular CLI

corvinrok opened this issue ยท 4 comments

  • Operating System: Windows 7
  • Node Version: 11.13.0
  • NPM Version: 6.7.0
  • webpack Version: webpack included in Angular 7.2.11/ Angular CLI 7.3.7
  • raw-loader Version: 2.0.0

Expected Behavior

I expect raw-loader uses to properly read the text contents of my files and stream them into the assigned variable.

Actual Behavior

The following warning is given during build...

"export 'toString' (imported as 'iconSvgs') was not found in '!raw-loader!../../../../styles/my-icons/dist/fonts/icons.svg'

This warning initially seems in line with the started info on the inline section of the README.md page (https://github.com/webpack-contrib/raw-loader/blob/master/README.md#inline) . If the warning is ignored and you continue to try to run the code, of course, the variable is not created (in this case, below, iconSvgs) and the later loading code fails (since raw-loader has not worked).

However, if you make any of the changes as suggested on the page, with the update to 2.0.0, the old referencing notation of raw-loader no longer works inside of Angular CLI projects, and the instructions for how to update the reference do NOT work.

IMPORTANT NOTE: Yes, I did try to change the reference from

import * as iconSvgs from '!raw-loader!../../../../styles/my-icons/dist/fonts/icons.svg';

to

import * as iconSvgs from 'raw-loader!../../../../styles/my-icons/dist/fonts/icons.svg';

and

import * as iconSvgs from '!!raw-loader!../../../../styles/my-icons/dist/fonts/icons.svg';

..However, both those changes resulting in the compile failing outright (as opposed to the warning of the original !raw-loader! syntax). For example, changing to the '!!raw-loader!' format gives the following error:

ERROR in src/app/my-container/components/DrawingSupport/icons.ts(7,27): error TS2307: Cannot find module '!!raw-loader!../../../../styles/my-icons/dist/fonts/icons.svg'.

Code

import * as iconSvgs from '!raw-loader!../../../../styles/my-icons/dist/fonts/icons.svg';

How Do We Reproduce?

Upgrade from raw-loader 1.0.0 to 2.0.0 on a project using latest version of angular cli/angular (Angular 7.2.11/ Angular CLI 7.3.7 ). Using raw-loader 2.0.0 with the default configuration for Angular CLI breaks builds when trying to access this plugin as shown above (the plugin is included and configured inside of Angular CLI and not in angular.json directly).

And in future please provide minimum reproducible test repo, it is open source, some developers don't have time on create env as you have, thanks

First to answer your first response. I read https://github.com/webpack-contrib/raw-loader/releases/tag/v2.0.0 . It only says there were breaking changes, but nothing about how to solve those breaking changes. I DID use your recommended code changes found in your README (that are listed in the https://github.com/webpack-contrib/raw-loader/blob/master/README.md#inline ). They do NOT work.

Second, I gave all the code pertinent to this discussion and bug listed directly the submission of the original post.

Your attitude and action of closing this bug without a reasonable response seems very unprofessional and unhelpful. That is not how open source projects are supposed to operate.

Since it appears that Angular CLI may have intersection on this particular issue, I will submit it to them, as you refuse to consider it or provide a sensible explanation for not doing so.

@corvinrok
First: if you continue talking to me in that tone you will get banned
Second: I don't see how you try to fix issue
Third: no config, reproducible test repo and other stuff what can help to fix/resolve problem, i can't fix something in anything
Fourthly: it is your personal problem with your project. Angular CLI works as expected with latest raw-loader, before moving to a rough tone you can read documentation about !!, post problem in gitter (I help many people) or just put feedback here with minimum reproducible test repo and if problem will be really exists i am reopen issue and will start to search how to solve

Thanks