Skip to content

feat(@angular-devkit/build-angular): show warnings when depending on CommonJS#17250

Merged
dgp1130 merged 1 commit into
angular:masterfrom
alan-agius4:feature-common-js-warning
Mar 23, 2020
Merged

feat(@angular-devkit/build-angular): show warnings when depending on CommonJS#17250
dgp1130 merged 1 commit into
angular:masterfrom
alan-agius4:feature-common-js-warning

Conversation

@alan-agius4
Copy link
Copy Markdown
Collaborator

@alan-agius4 alan-agius4 commented Mar 18, 2020

feat(@angular-devkit/build-angular): show warnings when depending on CommonJS.

Depending on CommonJS modules is know to cause optimization bailouts. With this change when running a browser build and scripts optimization is enabled we display a warning.

To suppress the warning for a particular package, users can use the allowedCommonJsDepedencies builder options.

Example:

"build": {
  "builder": "@angular-devkit/build-angular:browser",
  "options": {
    ...
    "allowedCommonJsDepedencies": ["bootstrap"]
  },
}

Reference: TOOL-1328

@alan-agius4 alan-agius4 added PR state: blocked target: major This PR is targeted for the next major release labels Mar 18, 2020
@alan-agius4
Copy link
Copy Markdown
Collaborator Author

Blocking until 9.1 branch is created.

@alan-agius4 alan-agius4 requested a review from filipesilva March 18, 2020 12:12
@alan-agius4 alan-agius4 added the needs: discussion On the agenda for team meeting to determine next steps label Mar 18, 2020
@alan-agius4 alan-agius4 added this to the V10-candidates milestone Mar 19, 2020
@alan-agius4
Copy link
Copy Markdown
Collaborator Author

To discuss:

  • Should end users be able to disable these warnings? (If yes, discuss how)
  • How to handle features for majors when there is no major branch yet.

@alan-agius4
Copy link
Copy Markdown
Collaborator Author

Decided that we should go with an builder option that allows a list of packages to suppress the warning for.


it('should not show warning when depending on a Common JS bundle which is allowed', async () => {
const overrides = {
allowedCommonJsDepedencies: [
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@filipesilva / @clydin should allowing a CommonJS dep allow also it's CommonJS transitive dependency automatically?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm that's a tricky one. Transitive dependencies in general really.

Realistically speaking many project, especially larger ones, will have dozens of transitive commonjs dependencies. So they get these changes and see a screenful of names they have to allow. That's not great.

On the other hand the whole point of these warnings is to let users know where in their dep graph are there deoptimizations. So it's not any help to not show the transitives.

To make informed decisions the user will also need the full dependency path to the commonjs dependency.

Which then leads to your specific question: should we just show deps up to a commonjs dep, then ignore that subgraph? Yeah that seems a good way to cut down on the total shown.

@alan-agius4 alan-agius4 removed the needs: discussion On the agenda for team meeting to determine next steps label Mar 20, 2020
Copy link
Copy Markdown
Contributor

@filipesilva filipesilva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just needs that typo fixed.

Comment thread packages/angular_devkit/build_angular/src/browser/schema.json Outdated
…CommonJS.

Depending on CommonJS modules is know to cause optimization bailouts. With this change when running a browser build and scripts optimization is enabled we display a warning.

To suppress the warning for a particular package, users can use the `allowedCommonJsDepedencies` builder options.

Example:
```
"build": {
  "builder": "@angular-devkit/build-angular:browser",
  "options": {
    ...
    "allowedCommonJsDepedencies": ["bootstrap"]
  },
}
```

Reference: TOOL-1328
@alan-agius4 alan-agius4 added action: merge The PR is ready for merge by the caretaker and removed PR state: blocked labels Mar 23, 2020
@ngbot
Copy link
Copy Markdown

ngbot Bot commented Mar 23, 2020

I see that you just added the PR action: merge label, but the following checks are still failing:
    failure status "ci/angular: size" is failing
    failure status "ci/circleci: e2e-cli" is failing

If you want your PR to be merged, it has to pass all the CI checks.

If you can't get the PR to a green state due to flakes or broken master, please try rebasing to master and/or restarting the CI job. If that fails and you believe that the issue is not due to your change, please contact the caretaker and ask for help.

@dgp1130 dgp1130 merged commit ea11c55 into angular:master Mar 23, 2020
@alan-agius4 alan-agius4 deleted the feature-common-js-warning branch March 23, 2020 21:35
@angular-automatic-lock-bot
Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot Bot locked and limited conversation to collaborators Apr 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker target: major This PR is targeted for the next major release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants