angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

Vendor source map files not included in /dist

Open jasonswett opened this issue 10 years ago • 8 comments

I'm using Angular CLI version 0.0.39 on Mac OS.

When I run ng serve using a proxy (ng serve --proxy http://localhost:3000) I see a bunch of requests come across like this:

GET /vendor/reflect-metadata/Reflect.js.map 404 507.868 ms - -
GET /vendor/@angular/platform-browser-dynamic/index.js.map 404 209.116 ms - -
GET /vendor/@angular/platform-browser-dynamic/platform_browser_dynamic.js.map 404 341.069 ms - -
GET /vendor/@angular/compiler/index.js.map 404 436.576 ms - -

At port 3000 I have a Rails server running with /public symlinked to /dist, meaning a URL like http://localhost:3000/vendor/reflect-metadata/Reflect.js will load the actual Reflect.js from my Angular project. The Reflect.js.map file is genuinely not in dist next to Reflect.js, and navigating to http://localhost:3000/vendor/reflect-metadata/Reflect.js.map gives a 404.

I would imagine that either Angular should not be looking for these map files or the map files should be present. It's also entirely possible that I'm misinterpreting the situation because a lot of this stuff is new to me.

jasonswett avatar May 10 '16 12:05 jasonswett

I had the same issues with Angular CLI Beta on MacOS. However, it only shows up in Safari, not in Chrome. Here's a screenshot of the error console from both browsers for the same project: http://imgur.com/JwmLsJw

thorstenschaefer avatar May 11 '16 15:05 thorstenschaefer

@thorstenschaefer I'm experiencing the same thing. Did you figure out a way around it or are you still experiencing the problem?

jasonswett avatar May 11 '16 16:05 jasonswett

I just ignored the issue for now and use Chrome for testing. Even when using Safari, everything should work normally despite the 404 errors - I just find it disturbing as "real" error messages might get overlooked. Let's see if someone from the CLI team can tell whether this is a CLI issue or caused in some other Angular part.

thorstenschaefer avatar May 11 '16 16:05 thorstenschaefer

Well it's definitely a genuine problem. I have my Angular app sitting on a backend server which receives all these bad file requests, meaning my logs get polluted with huge amounts of meaningless noise. Fortunately it only happens in dev and not prod, but still I'd like it not to happen at all.

jasonswett avatar May 11 '16 16:05 jasonswett

You can configure the CLI to copy over the map files in the vendorNpmFiles entry in angular-cli-build.js.

These were left out intentionally (by me) because they slowed down the dev rebuilds. I'd like to revisit this though, with a better and faster way of building the project.

filipesilva avatar May 11 '16 16:05 filipesilva

Ooh, awesome! This might be a dumb question but how exactly would I do that? I'm guessing it would end in *.js.map but I don't know what would go ahead of that.

jasonswett avatar May 11 '16 17:05 jasonswett

This is how I fixed it. I'm not sure if this is the absolute best way.

/* global require, module */

var Angular2App = require('angular-cli/lib/broccoli/angular2-app');

module.exports = function(defaults) {
  return new Angular2App(defaults, {
    vendorNpmFiles: [
      'systemjs/dist/system-polyfills.js',
      'systemjs/dist/system.src.js',
      'zone.js/dist/*.{js,js.map}',
      'es6-shim/es6-shim.js',
      'reflect-metadata/*.{js,js.map}',
      'rxjs/**/*.{js,js.map}',
      '@angular/**/*.{js,js.map}'
    ]
  });
};

jasonswett avatar May 12 '16 13:05 jasonswett

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.