Skip to content

Add option to exclude certain files from sourcemap. #11305

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
alkampfergit opened this issue Jun 19, 2018 · 6 comments · Fixed by #19446
Closed

Add option to exclude certain files from sourcemap. #11305

alkampfergit opened this issue Jun 19, 2018 · 6 comments · Fixed by #19446
Assignees
Labels
area: @angular-devkit/build-angular feature Issue that requests a new feature
Milestone

Comments

@alkampfergit
Copy link

Bug Report or Feature Request (mark with an x)

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

Area

- [x] devkit
- [ ] schematics

Versions

Repro steps

The log given by the failure

Desired functionality

I have projects where enabling sourcemaps slows down the ng build operation by a factor of 10. It would be useful to add an option to exclude certain files from source maps generation, or, even better, being able to specify only the files you want to use to generate source map.

This will allow us to specify which file we want to debug without slowing a lot the compilation time.

Mention any other details that might be useful

@clydin clydin added the feature Issue that requests a new feature label Jun 20, 2018
@ngbot ngbot bot added this to the Backlog milestone Mar 12, 2019
@cp-fabian-pittroff
Copy link

Hello there,
are there any news on that feature? For better debugging experience I set sourcemap vendor to true. It works, but I get a lot warnings for missing source files.
Is there a way to only set the desired packages to be included in the sourcemaps? Or is it possible to suppress these warnings?

Best regards

@klemenoslaj
Copy link

This is as well relevant for any Angular workspace containing multiple projects.
Libraries in the workspace fall under the vendor setting as well, so either we take all external source maps and our own libraries, or none at all which kinda is suboptimal.

For this issue the bare minimum would be to at least split "libs" and vendor setting for source maps.

@sonntag-philipp
Copy link

I'm also interested in this feature.
It is really annoying to have a completly messed up console due to dependencies that don't have source maps for all files.

@grant77
Copy link

grant77 commented Nov 18, 2020

As @klemenoslaj mentioned, there needs to be a way to include our local libraries without including all vendor source maps. We have recently switched to a MonoRepo pattern using angular libraries, and debugging was a nightmare. For debugging to be possible I had to use a custom builder called "@angular-builders/custom-webpack:browser" so I could modify the webpack configuration.

My webpack.config.js file looks like this:

module.exports = config => {
  // Fix for bad source map paths.  I logged bug (https://github.com/angular/angular-cli/issues/19043) and they said is
  // was fixed in Angular 11
  config.context = __dirname;

  // Exclude all vendor source maps except our own.
  // Hopefully they will fix this soon:  https://github.com/angular/angular-cli/issues/11305
  const rule = config.module.rules.find(x => typeof x.loader === 'string' && x.loader.includes('source-map-loader'));
  if (rule) {
    rule.exclude = [
      /(ngfactory|ngstyle)\.js$/, // <== this was already there
      /node_modules\\(?!@sensor)/ // <= exclude everything in node_modules except our stuff
    ];
  }

  // Return config
  return config;
};

@alan-agius4 alan-agius4 added the needs: discussion On the agenda for team meeting to determine next steps label Nov 18, 2020
@alan-agius4 alan-agius4 self-assigned this Nov 19, 2020
@dgp1130
Copy link
Collaborator

dgp1130 commented Nov 19, 2020

We discussed this in our tooling triage meeting. Sourcemaps can definitely take a long time to process and we agree that the current behavior of vendor: false is unintuitive, as most users would expect libraries in a monorepo to apply sourcemaps.

We'll update vendor: false to retain monorepo library sourcemaps but drop all others. This is more intuitive behavior and more in line with what the user probably expected.

Regarding the performance issue, specifying vendor: false with this new behavior is probably enough to get builds to a good place without sacrificing too much in the debugging experience. There may be some edge cases such as very large monorepositories; these can eject to a custom Webpack config if they absolutely need to. We can also revisit adding more fine-grained control of sourcemap generation in the future if this vendor: false tweak is not sufficient for many users.

For now, we'll start with updating vendor: false to keep libraries in a monorepo, and that flag can be used to improve sourcemap performance by dropping all other modules.

@dgp1130 dgp1130 removed the needs: discussion On the agenda for team meeting to determine next steps label Nov 19, 2020
filipesilva pushed a commit that referenced this issue Nov 24, 2020
…ithout `vendor: true`

With this change we apply sourcemaps of libraries in a monorepo without the need to enable `vendor: true`. This is more intuitive behavior and  in line with what the users expect.

We also suppress the `Failed to parse source map from` in-actionable warning.

Closes #11305
@angular-automatic-lock-bot
Copy link

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 Dec 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: @angular-devkit/build-angular feature Issue that requests a new feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants