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

ng build chokes on processing Angular source maps #5476

Closed
1 task done
IgorMinar opened this issue Mar 17, 2017 · 11 comments
Closed
1 task done

ng build chokes on processing Angular source maps #5476

IgorMinar opened this issue Mar 17, 2017 · 11 comments
Assignees
Labels
P1 Impacts a large percentage of users; if a workaround exists it is partial or overly painful type: bug/fix

Comments

@IgorMinar
Copy link
Contributor

IgorMinar commented Mar 17, 2017

Bug Report or Feature Request (mark with an x)

  • bug report -> please search issues before submitting

Versions.

@angular/cli: 1.0.0-rc.2
node: 6.9.5
os: darwin x64
@angular/animations: 4.0.0-rc.4
@angular/common: 4.0.0-rc.4
@angular/compiler: 4.0.0-rc.4
@angular/core: 4.0.0-rc.4
@angular/forms: 4.0.0-rc.4
@angular/http: 4.0.0-rc.4
@angular/material: 2.0.0-beta.2
@angular/platform-browser: 4.0.0-rc.4
@angular/platform-browser-dynamic: 4.0.0-rc.4
@angular/platform-server: 4.0.0-rc.4
@angular/router: 4.0.0-rc.4
@angular/service-worker: 1.0.0-beta.7
@angular/cli: 1.0.0-rc.2
@angular/compiler-cli: 4.0.0-rc.2

Repro steps.

  1. upgrade a project to angular 4.0.0-rc.4
  2. modify node_modules/@angular/cli//models/webpack-configs/common.js to no exclude node_modules from the source-map-loader
  3. build the project with ng build or ng build --prod --sm

The log given by the failure.

$ ng build --prod --sm
 92% chunk asset optimization/Users/iminar/Dev/angular/aio/node_modules/source-map/lib/source-node.js:95
          var code = nextLine.substr(0, mapping.generatedColumn -
                             ^

TypeError: Cannot read property 'substr' of undefined
    at Function.<anonymous> (/Users/iminar/Dev/angular/aio/node_modules/source-map/lib/source-node.js:95:30)
    at Array.forEach (native)
    at SourceMapConsumer_eachMapping [as eachMapping] (/Users/iminar/Dev/angular/aio/node_modules/source-map/lib/source-map-consumer.js:155:14)
    at Function.SourceNode_fromStringWithSourceMap [as fromStringWithSourceMap] (/Users/iminar/Dev/angular/aio/node_modules/source-map/lib/source-node.js:80:24)
    at SourceMapSource.node (/Users/iminar/Dev/angular/aio/node_modules/webpack-sources/lib/SourceMapSource.js:42:20)
    at ReplaceSource.node (/Users/iminar/Dev/angular/aio/node_modules/webpack-sources/lib/ReplaceSource.js:69:29)
    at CachedSource.node (/Users/iminar/Dev/angular/aio/node_modules/webpack-sources/lib/CachedSource.js:12:23)
    at /Users/iminar/Dev/angular/aio/node_modules/webpack-sources/lib/ConcatSource.js:40:49
    at Array.map (native)
    at ConcatSource.node (/Users/iminar/Dev/angular/aio/node_modules/webpack-sources/lib/ConcatSource.js:39:60)
    at /Users/iminar/Dev/angular/aio/node_modules/webpack-sources/lib/ConcatSource.js:40:49
    at Array.map (native)
    at ConcatSource.node (/Users/iminar/Dev/angular/aio/node_modules/webpack-sources/lib/ConcatSource.js:39:60)
    at /Users/iminar/Dev/angular/aio/node_modules/webpack-sources/lib/ConcatSource.js:40:49
    at Array.map (native)
    at ConcatSource.node (/Users/iminar/Dev/angular/aio/node_modules/webpack-sources/lib/ConcatSource.js:39:60)

Desired functionality.

should build 😄

Mention any other details that might be useful.

@IgorMinar IgorMinar added this to the 1.0 Final Blocking milestone Mar 17, 2017
@Brocco
Copy link
Contributor

Brocco commented Mar 17, 2017

This was related to an issue in the angular repo angular/angular/pull/15226 and is resolved with the newly released rc5. It will work with the CLI once #5480 is resolved.

@Brocco Brocco closed this as completed Mar 17, 2017
@IgorMinar IgorMinar reopened this Mar 20, 2017
@IgorMinar
Copy link
Contributor Author

Unfortunately, I can still reproduce the issue with @angular/[email protected] and [email protected].

$ ng build
 92% chunk asset optimization/Users/iminar/Dev/angular/aio/node_modules/source-map/lib/source-node.js:95
          var code = nextLine.substr(0, mapping.generatedColumn -
                             ^

TypeError: Cannot read property 'substr' of undefined
    at Function.<anonymous> (/Users/iminar/Dev/angular/aio/node_modules/source-map/lib/source-node.js:95:30)

@hansl
Copy link
Contributor

hansl commented Mar 20, 2017

I can't repro locally with just enabling the node modules source maps. It builds (but takes twice the amount of time):

$ npm ls @angular/core
[email protected] /Users/hansl/Sources/_Temp/test-decorators
├─┬ @angular/[email protected] -> /Users/hansl/Sources/angular-cli
│ ├── @angular/[email protected]  extraneous
│ └── UNMET PEER DEPENDENCY [email protected]

@IgorMinar
Copy link
Contributor Author

@hansl looked into it more and said that it's due to incorrect source maps coming from @angular/[email protected]

If I remove all material source maps using:

for i in `find node_modules/\@angular/material/ -name "*.js.map"`; do echo $i; rm $i; done

the error goes away.

@hansl
Copy link
Contributor

hansl commented Mar 21, 2017

Apparently it's a known error in source-map: mozilla/source-map#247 and related in ionic: ionic-team/ionic-app-scripts#796

As long as that issue is not fixed, we cannot really enable source maps in node_modules. Let's chat tomorrow @IgorMinar

@IgorMinar
Copy link
Contributor Author

@hansl we could fork the project with this patch: mozilla/source-map#257 (comment). I verified that it works.

@hansl
Copy link
Contributor

hansl commented Mar 21, 2017

That would work (but the mapping might be invalid), I'm not sure if that's what we want. Let's talk during the weekly.

@hansl
Copy link
Contributor

hansl commented Mar 21, 2017

Removing this from 1.0 BLOCKING. The plan is to get Mozilla to fix their source-map library (see issues pointed above). If that cannot be done in a timely fashion we will fork it locally in the CLI and use it for a custom loader instead.

@hansl hansl removed this from the 1.0 Final Blocking milestone Mar 21, 2017
@filipesilva filipesilva added command: build P1 Impacts a large percentage of users; if a workaround exists it is partial or overly painful type: bug/fix labels Mar 23, 2017
@zackarychapple
Copy link
Contributor

zackarychapple commented May 16, 2017

This happens without modifying the CLI as well when we pulled in @angular/[email protected]. We have been fighting this today. The only bypass is to do --no-sourcemaps flag.

@angular/cli: 1.0.3
node: 7.5.0
os: darwin x64
@angular/animations: 4.0.1
@angular/common: 4.0.1
@angular/compiler: 4.0.1
@angular/core: 4.0.1
@angular/forms: 4.0.1
@angular/http: 4.0.1
@angular/platform-browser: 4.0.1
@angular/platform-browser-dynamic: 4.0.1
@angular/router: 4.0.1
@angular/cli: 1.0.3
@angular/compiler-cli: 4.0.1
@angular/language-service: 4.0.1

@Brocco
Copy link
Contributor

Brocco commented Jul 14, 2017

I was not able to reproduce this issue...

get latest CLI locally
remote exclude: [nodeModules] from this line

  1. ng new src-map --link-cli
  2. npm install --save @angular/cdk
  3. npm install --save @angular/material2
  4. import MdButtonModule in app.module.ts
  5. update app.component.html to use md-button
  6. run ng build --prod --sm which builds successfully

@Brocco Brocco closed this as completed Jul 14, 2017
@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 Sep 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
P1 Impacts a large percentage of users; if a workaround exists it is partial or overly painful type: bug/fix
Projects
None yet
Development

No branches or pull requests

5 participants