born2net
born2net

Reputation: 24953

Due to changes in angular 2 rc.6 jspm bundling no longer works

due to changes in angular 2 rc.6 bundling no longer works! As you can see from the changes in rc.6: https://github.com/angular/angular/blob/master/CHANGELOG.md

this was a major overhaul with a bunch of references even in the change log to how systemjs is now used. As a result, we can no longer use the command:

jspm bundle src/App.js ./dist/index.js --minify --skip-source-maps

as this results in the following error:

[08:40:33] 'x_bundle' errored after 18 s
[08:40:33] Error: Command `jspm bundle src/App.js ./dist/index.js --minify --skip-source-maps` failed with exit code 1
    at ChildProcess.exithandler (child_process.js:206:12)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:191:7)
    at maybeClose (internal/child_process.js:877:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
Command `jspm bundle src/App.js ./dist/index.js --minify --skip-source-maps` failed with exit code 1
[08:40:33] 'production' errored after 31 s
[08:40:33] Error in plugin 'run-sequence(x_bundle)'
Message:
    Command `jspm bundle src/App.js ./dist/index.js --minify --skip-source-maps` failed with exit code 1
Details:
    killed: false
    code: 1
    signal: null
    cmd: jspm bundle src/App.js ./dist/index.js --minify --skip-source-maps
    stdout:      Building the bundle tree for src/App.js...

    stderr:
err  Error: SyntaxError: Unexpected token: string (./src/platform-browser-dynamic) (line: 2345, col: 16, pos: 104806)

Error
    at new JS_Parse_Error (eval at <anonymous> (C:\Users\root\AppData\Roaming\npm\node_modules\jspm\node_modules\uglify-js\tools\node.js:28:1), <anonymous>:1545:18)
    at js_error (eval at <anonymous> (C:\Users\root\AppData\Roaming\npm\node_modules\jspm\node_modules\uglify-js\tools\node.js:28:1), <anonymous>:1553:11)
    at croak (eval at <anonymous> (C:\Users\root\AppData\Roaming\npm\node_modules\jspm\node_modules\uglify-js\tools\node.js:28:1), <anonymous>:2092:9)
    at token_error (eval at <anonymous> (C:\Users\root\AppData\Roaming\npm\node_modules\jspm\node_modules\uglify-js\tools\node.js:28:1), <anonymous>:2100:9)
    at unexpected (eval at <anonymous> (C:\Users\root\AppData\Roaming\npm\node_modules\jspm\node_modules\uglify-js\tools\node.js:28:1), <anonymous>:2106:9)
    at semicolon (eval at <anonymous> (C:\Users\root\AppData\Roaming\npm\node_modules\jspm\node_modules\uglify-js\tools\node.js:28:1), <anonymous>:2126:56)
    at simple_statement (eval at <anonymous> (C:\Users\root\AppData\Roaming\npm\node_modules\jspm\node_modules\uglify-js\tools\node.js:28:1), <anonymous>:2317:73)
    at eval (eval at <anonymous> (C:\Users\root\AppData\Roaming\npm\node_modules\jspm\node_modules\uglify-js\tools\node.js:28:1), <anonymous>:2186:19)

let me add that this is the line of failure export * from './src/platform-browser-dynamic'; in /src/platform-browser-dynamic

it is almost as if now minification is failing due to how ng2 rc.6 is working, but I am not sure as there are so many moving parts...

this worked perfectly prior to rc.6

I hope someone from the team can assist as we can not go to production until we get this resolved,

regards

Sean.

Upvotes: 0

Views: 91

Answers (2)

born2net
born2net

Reputation: 24953

after spending 2 days trying to fix jspm with bundling I was finally able to fix it, in jspm you need to remove from packages the statement of : packages: { "@angular/common": { "main": "index.js", "defaultExtension": "js" }, "@angular/compiler": { "main": "index.js", "defaultExtension": "js" }, "@angular/core": { "main": "index.js", "defaultExtension": "js" }, "@angular/http": { "main": "index.js", "defaultExtension": "js" }, "@angular/platform-browser": { "main": "index.js", "defaultExtension": "js" }, "@angular/platform-browser-dynamic": { "main": "index.js", "defaultExtension": "js" }, "@angular/router": { "main": "index.js", "defaultExtension": "js" } ... I have no idea what changed in ng2 prior to rc.6 that would require this removel, but here you go, this fixes it and now I can FINALLY run:

jspm bundle app/main ./dist/index.js --minify --skip-source-maps

hopes it helps someone

Sean

Upvotes: 1

abidmix
abidmix

Reputation: 1748

I had the same problem. After banging my head against the wall for days I finally upgraded my jspm to 0.17. Then instead of bundle use

jspm build src/App.js ./dist/index.js --minify --skip-source-maps

Everything should work as expected after that. This solution will work provided you are running typescript version 1.8.34.

Upvotes: 1

Related Questions