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.

CustomWebpack with Devkit/CLI 8.2 causes build options to get overridden/ignored

See original GitHub issue

Update: Related issue in Angular CLI repo: https://github.com/angular/angular-cli/issues/16098

Describe the bug This is a hard bug to describe, but when using custom-webpack for both dev-server and browser, certain options in the browser build get ignored. I spent a lot of time trying to debug what’s going on (the devkit was very hard to debug), and it seems that when getTargetOptions is called within custom-webpack/dev-server, it includes the options, but when getTargetOptions is called again inside of executeDevServerBuilder, it is missing some of the options specified.

This manifested for me with ‘showCircularDependencies’ (which is set to false for my browser build) getting ignored in the dev server build but respected in the browser build).]

This seems to repro pretty easily by simply calling getTargetOptions twice inside of dev server, e.g.

    async function setup() {
        const browserTarget = targetFromTargetString(options.browserTarget);

        const targetOptions1 = context.getTargetOptions(browserTarget).then(opts => // correct);
        const targetOptions2 = context.getTargetOptions(browserTarget).then(opts => // missing some parameters)

        return context.getTargetOptions(browserTarget) as unknown as CustomWebpackSchema;
    }

I hope this is enough to investigate, I can provide more details as well

To Reproduce Steps to reproduce the behavior:

  1. Create a project that uses dev-server
  2. Add a non-default property to the browser build, e.g. showCircularDependencies: false
  3. Target dev-server at build:browser
  4. Notice that the property showCircularDeps is ignored

Expected behavior Properties specified in the browser build are ignored

Libraries

@angular-builders/custom-webpack: "8.1.0"
@angular-devkit/architect: "0.802.0"
@angular-devkit/build-angular: "0.802.0"
@angular-devkit/build-optimizer: "0.802.0"
@angular/cli: "8.2.0"
@angular/compiler-cli: "8.2.0"
@angular/language-service: "8.2.0"

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:9
  • Comments:35 (14 by maintainers)

github_iconTop GitHub Comments

2reactions
just-jebcommented, Sep 6, 2019

@flash-me the code (both Angular’s and custom-webpack’) seems completely fine to me. The custom config is still applied after the base one - note that the base one is passed to a transform, which, in turn, merges the config while the custom overrides the base.
Regarding the if, yes, you are right, this is for reason. If custom config exports a function, the base config is passed into this function and then the function is supposed to modify it and return the new config. It’s described in the docs.
I’ll try to figure out why you’re getting this weird behavior, but from the first glance the code seems OK. One thing I need you to try though. If you run the dev-server build with aot the problem still persists?

2reactions
flash-mecommented, Aug 23, 2019

The problem here is that @angular-builders will apply its config onto the base webpack config. This was okay, because the CLI webpack-config has been applied before the custom one. But this Commit changed the behaviour.

On a quick look into the code I’d assume that using mergeConfigs in both cases might solve the issue, but I can image that there was a reason for the if when providing a function. I donno 😕

Read more comments on GitHub >

github_iconTop Results From Across the Web

CustomWebpack with Devkit/CLI 8.2 causes build options to get ...
This is a hard bug to describe, but when using custom-webpack for both dev-server and browser, certain options in the browser build get...
Read more >
@angular-devkit/build-webpack | Yarn - Package Manager
The Angular CLI is a command-line interface tool that you use to initialize, develop, scaffold, and maintain Angular applications directly from a command...
Read more >
angular-builders/custom-webpack - npm
Custom webpack builders for Angular build facade. Allow to modify Angular build configuration without ejecting it. Latest version: 15.0.0, ...
Read more >
Incompatible peer dependencies found - upgrading Angular ...
Package "@ngtools/webpack" has an incompatible peer dependency to "typescript" (requires ">=3.4 < 3.6", would install "3.7.5").
Read more >
Configuration - webpack
createapp.dev is an online tool for creating custom webpack configurations. ... All the available configuration options are specified below.
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