Doesn't work with raw-loader v2.0.0
See original GitHub issueA few days ago, raw-loader v2.0.0 was published. This release changed to use ES Module exports instead of CommonJS exports (webpack-contrib/raw-loader#69). I believe this has caused angular2-template-loader
to no longer work.
Everything compiles fine, but when you run the Angular application, you get the error:
Error: Expected 'styles' to be an array of strings.
I think this is because this loader is using require(...)
, but that’s now returning an object with a default
property that contains a string, rather than just returning a string. I haven’t confirmed that though. I wanted to submit this issue while it was still fresh in my mind. When I get some time later on, I’ll create a simple repro and investigate a bit further.
Current Workarounds:
- Downgrade
raw-loader
to1.0.0
.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:12
- Comments:8
Top Results From Across the Web
How to fix the non-working of latest raw-loader version in ...
0 version of raw-loader won't work for you (which looks the case here as your example uses CommonJS module syntax).
Read more >raw-loader - npm
A loader for webpack that allows importing files as a String. Latest version: 4.0.2, last published: 2 years ago. Start using raw-loader in ......
Read more >raw-loader@2.0.0 - Snyk Vulnerability Database
Automatically find and fix vulnerabilities affecting your projects. Snyk scans for vulnerabilities (in both your packages & their dependencies) and provides ...
Read more >To v2 or v3 from v1 - webpack
This solves some problems with duplicate modules caused by loaders when using npm link or referencing modules outside of the context . You...
Read more >can't resolve 'file-loader' | The AI Search Engine You Control
so npm install css-loader -D worked. thx @Aritra Chakraborty. Open side panel. Webpack can't resolve file loader js files. Asked Sep 27, 2021...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This has been bugging me for a while, up until now I’ve been keeping
raw-loader
at version1.0.0
as a workaround, but just found that you can also fix the problem by usinghtml-loader
instead ofraw-loader
. I updated my Angular 8 project and it seems to be working fine, here’s the commit with the change - https://github.com/cornflourblue/angular-8-registration-login-example/commit/55437d97f6915f3c2a60eb85a455de8bd34d35ffRepro is here: https://github.com/reduckted/repro-angular2-template-loader-86 And also as a zip file: repro-angular2-template-loader-86.zip
That will compile the application, start the web server and open the URL in a browser. Open the developer console and you’ll see the error.
The result of
require('./src/app.component.css')
is also printed to the console. As I expected, it’s an object, rather than the expected string: