question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Doesn't work with raw-loader v2.0.0

See original GitHub issue

A 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 to 1.0.0.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:12
  • Comments:8

github_iconTop GitHub Comments

5reactions
cornflourbluecommented, Jun 7, 2019

This has been bugging me for a while, up until now I’ve been keeping raw-loader at version 1.0.0 as a workaround, but just found that you can also fix the problem by using html-loader instead of raw-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/55437d97f6915f3c2a60eb85a455de8bd34d35ff

3reactions
reducktedcommented, Mar 24, 2019

Repro is here: https://github.com/reduckted/repro-angular2-template-loader-86 And also as a zip file: repro-angular2-template-loader-86.zip

npm i
npm run start

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:

Module
default: ":host {
↵    color: lightseagreen;
↵}"
Symbol(Symbol.toStringTag): "Module"
__esModule: true
__proto__: Object
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found