Skip to content

@ngtools/webpack doesn't chain loaders correctly #7258

@andrewpmontgomery

Description

@andrewpmontgomery

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request

Versions.

@angular/cli: 1.2.6 (e)
node: 8.2.1
os: win32 x64
@angular/(all of them): 4.3.3
npm: 5.3.0
node: 8.2.1

Repro steps.

  1. ng new bugdemo
  2. cd bugdemo
  3. ng eject
  4. Create a very basic Webpack loader called dummy-loader.js:
    module.exports = function dummyLoader(source) {
    return source.replace("title = 'app'", "title = 'FOOBAR app'");
    }
  5. Edit webpack.config.js, change:
    "loader": "@ngtools/webpack"
    to:
    "loader": ["@ngtools/webpack","./dummy-loader"]
  6. npm start
  7. Browse to http://localhost:4200/

The log given by the failure.

Actual output: Welcome to app!

Desired functionality.

Expected output: Welcome to FOOBAR app!

Mention any other details that might be useful.

The default project created by ng new generates app.component.html containing this:
Welcome to {{title}}!
and corresponding app.component.ts containing this:
title = 'app';
The dummy-loader.js simply rewrites it to this:
title = 'FOOBAR app';

If we edit webpack.config.js, remove:
"loader": ["@ngtools/webpack","./dummy-loader"]
and replace with:
"loader": ["awesome-typescript-loader", "angular2-template-loader", "./dummy-loader"]
then install the extra modules
npm i awesome-typescript-loader angular2-template-loader
then we get the correct output. So this is definitely a bug in @ngtools/webpack

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions