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

Update build system to use jspm and allow using typescript for polymer components. #31

Merged
merged 2 commits into from
Aug 12, 2015

Conversation

maffoo
Copy link
Contributor

@maffoo maffoo commented Aug 11, 2015

Updates the gulp build setup to use jspm instead of webpack for bundling dependencies. This lets us use the typescript compiler directly instead of a webpack plugin, which also fixes #16 because typescript errors get reported by the typescript compilation step, not swallowed by the webpack plugin. We still need to use bower for third-party polymer elements, unfortunately (see Polymer/polymer#1133), but I hope that issue will be resolved soon and we can just use jspm, which seems to be becoming the de facto standard for browser package management. This does however allow us to define the code for our own polymer elements in typescript, so we can import code from other modules and use it, without having to duplicate logic in plain javascript in the element html files. I've also added the tsd definition files to version control so that users will not have to mess with tsd in order to use the project.

If you check this out, you'll might have to remove the existing typings/ folder since the branch will want to overwrite some of the files. I'd suggest renaming the existing folder so you can rename it back when you switch back to another branch, at least until this is merged. In addition, you'll have to run npm install -g jspm && jspm install to get jspm set up. Before merging this in I'll add that to the setup instructions in the README.

@maffoo
Copy link
Contributor Author

maffoo commented Aug 11, 2015

Just pushed a change that allows writing the polymer component definitions fully in typescript with the PolymerTS library.

@joshmutus
Copy link
Contributor

So I just removed my typings folder and switched into this branch, I ran npm install -g jspm && jspm install and just accepted the defaults. I got a bunch of errors from the client server after I tried to refresh the page:


ERROR in ./app/scripts/app.ts
(Line: 3, Char: 13) '=' expected.

ERROR in ./app/scripts/app.ts
(Line: 3, Char: 18) ';' expected.

ERROR in ./app/scripts/app.ts
(Line: 5, Char: 1) Declaration or statement expected.

ERROR in ./app/scripts/app.ts
(Line: 5, Char: 8) Expression expected.

ERROR in ./app/scripts/app.ts
(Line: 5, Char: 13) ';' expected.

ERROR in ./app/scripts/app.ts
(Line: 5, Char: 21) ';' expected.

ERROR in ./app/scripts/app.ts
(Line: 5, Char: 26) ';' expected.

ERROR in ./app/scripts/app.ts
(Line: 6, Char: 1) Declaration or statement expected.

ERROR in ./app/scripts/app.ts
(Line: 6, Char: 8) Expression expected.

ERROR in ./app/scripts/app.ts
(Line: 6, Char: 13) ';' expected.

ERROR in ./app/scripts/app.ts
(Line: 6, Char: 22) ';' expected.

ERROR in ./app/scripts/app.ts
(Line: 6, Char: 27) ';' expected.

ERROR in ./app/scripts/app.ts
(Line: 7, Char: 1) Declaration or statement expected.

ERROR in ./app/scripts/app.ts
(Line: 7, Char: 8) Expression expected.

ERROR in ./app/scripts/app.ts
(Line: 7, Char: 13) ';' expected.

ERROR in ./app/scripts/app.ts
(Line: 7, Char: 23) ';' expected.

ERROR in ./app/scripts/app.ts
(Line: 7, Char: 28) ';' expected.

ERROR in ./app/scripts/app.ts
(Line: 8, Char: 1) Declaration or statement expected.

ERROR in ./app/scripts/app.ts
(Line: 8, Char: 8) Expression expected.

ERROR in ./app/scripts/app.ts
(Line: 8, Char: 13) ';' expected.

ERROR in ./app/scripts/app.ts
(Line: 8, Char: 21) ';' expected.

ERROR in ./app/scripts/app.ts
(Line: 8, Char: 26) ';' expected.

ERROR in ./app/scripts/app.ts
(Line: 9, Char: 1) Declaration or statement expected.

ERROR in ./app/scripts/app.ts
(Line: 9, Char: 8) Expression expected.

ERROR in ./app/scripts/app.ts
(Line: 9, Char: 13) ';' expected.

ERROR in ./app/scripts/app.ts
(Line: 9, Char: 17) ';' expected.

ERROR in ./app/scripts/app.ts
(Line: 9, Char: 22) ';' expected.

ERROR in ./app/scripts/app.ts
(Line: 11, Char: 1) Declaration or statement expected.

ERROR in ./app/scripts/app.ts
(Line: 11, Char: 30) ';' expected.

ERROR in ./app/scripts/app.ts
(Line: 3, Char: 1) Cannot find name 'from'.

ERROR in ./app/scripts/app.ts
(Line: 5, Char: 10) Cannot find name 'as'.

ERROR in ./app/scripts/app.ts
(Line: 5, Char: 13) Cannot find name 'manager'.

ERROR in ./app/scripts/app.ts
(Line: 5, Char: 21) Cannot find name 'from'.

ERROR in ./app/scripts/app.ts
(Line: 6, Char: 10) Cannot find name 'as'.

ERROR in ./app/scripts/app.ts
(Line: 6, Char: 13) Cannot find name 'registry'.

ERROR in ./app/scripts/app.ts
(Line: 6, Char: 22) Cannot find name 'from'.

ERROR in ./app/scripts/app.ts
(Line: 7, Char: 10) Cannot find name 'as'.

ERROR in ./app/scripts/app.ts
(Line: 7, Char: 13) Cannot find name 'datavault'.

ERROR in ./app/scripts/app.ts
(Line: 7, Char: 23) Cannot find name 'from'.

ERROR in ./app/scripts/app.ts
(Line: 8, Char: 10) Cannot find name 'as'.

ERROR in ./app/scripts/app.ts
(Line: 8, Char: 13) Cannot find name 'nodeApi'.

ERROR in ./app/scripts/app.ts
(Line: 8, Char: 21) Cannot find name 'from'.

ERROR in ./app/scripts/app.ts
(Line: 9, Char: 10) Cannot find name 'as'.

ERROR in ./app/scripts/app.ts
(Line: 9, Char: 13) Cannot find name 'rpc'.

ERROR in ./app/scripts/app.ts
(Line: 9, Char: 17) Cannot find name 'from'.

ERROR in ./app/scripts/app.ts
(Line: 11, Char: 9) Cannot find name 'LabradRegistry'.

ERROR in ./app/scripts/app.ts
(Line: 11, Char: 25) Cannot find name 'from'.

ERROR in ./app/scripts/app.ts
(Line: 26, Char: 3) Cannot find name 'LabradRegistry'.

ERROR in ./app/scripts/app.ts
(Line: 49, Char: 20) Cannot find name 'rpc'.

ERROR in ./app/scripts/app.ts
(Line: 50, Char: 17) Cannot find name 'manager'.

ERROR in ./app/scripts/app.ts
(Line: 51, Char: 17) Cannot find name 'registry'.

ERROR in ./app/scripts/app.ts
(Line: 52, Char: 16) Cannot find name 'datavault'.

ERROR in ./app/scripts/app.ts
(Line: 53, Char: 18) Cannot find name 'nodeApi'.
[21:09:53] Finished 'webpack' after 541 ms
[BS] Reloading Browsers...

So I closed the server and now I can't gulp serve and I get the followin error:

 throw err;
    ^
Error: Cannot find module 'merge2'
    at Function.Module._resolveFilename (module.js:336:15)
    at Function.Module._load (module.js:278:25)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (/usr/local/google/home/mutus/programming/scalabrad-web/client-js/gulpfile.js:19:13)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)

what am I missing?

@maffoo
Copy link
Contributor Author

maffoo commented Aug 12, 2015

you need to upgrade typescript, e.g. npm update typescript. But note that this newer version of typescript doesn't work with webpack, so to switch back you'll need to downgrade the typescript version to something that works with webpack (check what version you have now). This is why I wanted to ditch webpack, but it does mean that in the interim it's tricky to switch branches.

@joshmutus
Copy link
Contributor

$ npm update typescript
npm WARN prefer global typescript@1.5.3 should be installed with -g
typescript@1.5.3 node_modules/typescript

which i assume is telling me to do:

$ npm update typescript -g

which returned without error, but didn't say anything

I get the same error when I try to run gulp

@maffoo
Copy link
Contributor Author

maffoo commented Aug 12, 2015

Rebased off the latest master. @joshmutus, can you take a look now?

@@ -0,0 +1,195 @@
import {RegistryApi, RegistryListing} from '../scripts/registry';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it a bit odd that the scripts for the polymer elements aren't in the /scripts folder?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe; I wanted to keep them close to the html files because they're tightly coordinated with each other. We can certainly discuss reorganizing things.

@joshmutus
Copy link
Contributor

This looks really nice and will help things scale nicely.
You're still going to update the README before merging?
otherwise LGTM

@maffoo
Copy link
Contributor Author

maffoo commented Aug 12, 2015

yeah, thanks for the reminder about the README. will fix.

@maffoo maffoo merged commit 8a328a9 into master Aug 12, 2015
@maffoo maffoo deleted the u/maffoo/js-build branch August 12, 2015 22:24
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

Successfully merging this pull request may close these issues.

Make error messages on typescript compilation failure more clear.
2 participants