Skip to content
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

momentjs breaks sourcemaps #686

Closed
holiber opened this issue Jun 13, 2016 · 10 comments
Closed

momentjs breaks sourcemaps #686

holiber opened this issue Jun 13, 2016 · 10 comments

Comments

@holiber
Copy link

holiber commented Jun 13, 2016

  • I'm submitting a ...
    [x] bug report
  • What is the current behavior?
    When I import momentjs in clean project all sourcemaps became broken

how to reproduce:

  1. install project from repo
  2. install momentjs: npm install moment
  3. in app.component.ts:
    add import
    import * as moment from 'moment/moment';
    in ngOnInit method add momentjs usage:
    var date = moment(new Date()).format();
  4. run 'npm start'
  5. try to open 'home.component.ts' in chrome devtools:

screenshot

home.component.ts contains main.browser.ts

Any idea how to fix? Maybe it's momentjs problem, or webpack config?

  • Angular version: 2.0.0-rc.1
  • Browser: Chrome 51
@holiber
Copy link
Author

holiber commented Jun 13, 2016

import with const moment = require('moment/moment') also no helps

@PatrickJS
Copy link
Owner

can you set
devtool: 'cheap-module-source-map',
to
devtool: 'source-map',
in
webpack.dev.js
https://github.com/AngularClass/angular2-webpack-starter/blob/master/config/webpack.dev.js#L53

@holiber
Copy link
Author

holiber commented Jun 14, 2016

@gdi2290 with devtool: 'source-map' now I got error in browser console
Failed to parse SourceMap: http://localhost:3000/main.map

main.map.txt

There is an opinion, that this problem caused with some localization characters in map file

@PatrickJS
Copy link
Owner

@holiber
Copy link
Author

holiber commented Jun 15, 2016

@gdi2290 with 'node_modules/moment' in source-map-loader excludes also no effect. Furthermore, moment definitions still present in main.map file.

@PatrickJS
Copy link
Owner

do you have [Disable Cache] on? I can't reproduce it
screen shot 2016-06-15 at 9 34 47 am

screen shot 2016-06-15 at 9 35 21 am

@holiber
Copy link
Author

holiber commented Jun 15, 2016

Yes, my browser cache was disabled. So, after few experiments I found, what it's google chrome v51.0 problem. On chrome "canary" all source maps are valid. @gdi2290, thanks for your answer!

@holiber
Copy link
Author

holiber commented Jun 15, 2016

But it's still strange what helpers.root('node_modules/moment') in sourcemap-loader excludes has no effect =/

@holiber holiber closed this as completed Jun 17, 2016
@yangmillstheory
Copy link

yangmillstheory commented Jun 26, 2016

@holiber how did you find out that this is a Chrome 51 problem? How did you fix it?

Using git bisect today, I found out that the introduction of momentjs into our builds broke source maps on Chrome Version 51.0.2704.103 (64-bit).

Webpack config has devtool: 'cheap-module-source-map'.

A fix for us was to include either of the following as a Webpack plugin:

  • new webpack.ContextReplacementPlugin(/moment[\/\\]locale$/, /en-us/)
  • new webpack.IgnorePlugin(/^\.\/locale/, /moment$/)

Note that the first solution works but is broken, since there's no en-us files in moment/locale for v2.13.0 - I just got it via copy-pasta from another project. The second solution should be preferred.

Ping @lanceharper @ccastarivale; this happened in https://github.com/trueprint/arivale-coach-client/commit/37b7a12b54e4068613b5d487c6cb12bda7a77823.

@holiber
Copy link
Author

holiber commented Jun 28, 2016

@yangmillstheory, I installed "Chome Canary" - version of Google Chrome that contains all last changes and bugfixes. Canary Chrome has no problems with sourcemaps. I don't know how to fix it in Chrome 51.0.

asgerjensen added a commit to asgerjensen/angular2-webpack-starter that referenced this issue Nov 10, 2016
Until univeral issue PatrickJS#686 is resolved, with the new angular2 compiler for 2.1.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants