swimlane / angular1-systemjs-seed

AngularJS 1.x + SystemJS Seed
MIT License
210 stars 40 forks source link

Add AMD module to the project #39

Closed marjan-georgiev closed 9 years ago

marjan-georgiev commented 9 years ago

Bundling AMD modules into the project doesn't work after upgrading to systemjs 0.18.4 and systemjs-builder 0.12.2.

This is a use case to demonstrate it.

To test:

You should see the following error when you open the application

Uncaught (in promise) Error: AMD module http://127.0.0.1:8080/lib/countUp/countUp.js did not define
    Error loading http://127.0.0.1:8080/lib/countUp/countUp.js from http://127.0.0.1:8080/dist/app/forms/forms.js
    Error loading http://127.0.0.1:8080/lib/countUp/countUp.js
    at l.<anonymous> (http://127.0.0.1:8080/dist/app/app.js:12:30787)
    at l.n [as instantiate] (http://127.0.0.1:8080/dist/app/app.js:13:4104)
    at http://127.0.0.1:8080/dist/app/app.js:12:3573

Note that everything works fine if I don't bundle and only compile the applicaiton.

Edit: the bundler code is here: https://github.com/Swimlane/systemjs-route-bundler

guybedford commented 9 years ago

@marjan-georgiev it seems this is an issue to do with you upgrade path to SystemJS 0.17/0.18 and builder 0.12.

Are you using the jspm 0.16 beta here or still 0.15? Note that only jspm 0.16 beta is compatible with these versions of SystemJS.

I'm aiming to improve the upgrade guide for the 0.16 jspm release.

The main point seems to be that paths: { '*': '*.js' } is no longer supported. This is because using paths for setting extensions has been deprecated.

marjan-georgiev commented 9 years ago

@guybedford Thanks for the suggestion. I upgraded jspm to 0.16 and updated the paths, but I'm still seeing the same problem.

Here's the built bundle containing that module https://gist.github.com/marjan-georgiev/5186fac0338fb4ce38da

guybedford commented 9 years ago

@marjan-georgiev yes this was a bug in SystemJS - it was fixed in SystemJS 0.18.4. Make sure you run that version and the current issue should resolve.

guybedford commented 9 years ago

@marjan-georgiev actually sorry that was an issue my side. Ok it turns out countUp.js is an AMD module, but it is being built as if it were a global module. So define is undefined. If you add meta to treat it as an AMD module that should fix up the build.

guybedford commented 9 years ago

:+1: