-
Notifications
You must be signed in to change notification settings - Fork 49
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
Broccoli coffee upgrade #124
Conversation
It would be really awesome to get this merged. I'll try this out on my computer to confirm that it works. |
@mriska - did you have a chance to test it? |
I was testing this out today and I did run into an issue when using the new version in an add-on. In a normal ember project it looks like it is working, but in two addons I tested with, I got the following error: ➜ coffee-test git:(master) ✗ ember test
WARNING: Node v7.1.0 has currently not been tested against Ember CLI and may result in unexpected behaviour.
cleaning up...
Build failed.
File: dummy/components/bar-bar.coffee (1)
The Broccoli Plugin: [CoffeeScriptFilter] failed with:
[stdin]:1:1: error: reserved word 'export'
export { default } from 'coffee-test/components/bar-bar'
^^^^^^ I had a component in the addon that I tried to use in the It also looks like at least the import Ember from 'ember'
import layout from '../templates/components/bar-bar'; Note: the semicolon at the end. The contents for |
@mriska can you send me a link to the test repo? I'll try fixing the issue today. |
Hi @jakesjews, I'll try to get a test repo published for you later tonight. |
@jakesjews I have pushed a repo with my test now: https://github.com/mriska/coffee-test
|
@mriska so it looks like theres a bug in coffeescript's module syntax where an error is being throw if default is being used like I'm not sure if we should hold off until this is fixed upstream or for now just use backticks whenever we need to use |
@jakesjews, If we reintroduce backticks around the exports, it should include a semi-colon also, right? |
Whoops your right. I'll add that back in. |
@mriska actually I'm having a little trouble finding where I forgot to restore the semi-colon where is it at? |
Keep in mind |
@jakesjews I was thinking mainly about the templates in this commit: 452f83d |
@mriska I restored them back to what they were on master so I'm assuming they are ok. |
Ok, I see that now. I just assumed that the export statement should have a semicolon, but I was mistaken. |
I have retested with your changes and the exports now work correct. However, we run into a new problem: ➜ coffee-test git:(master) ember test
WARNING: Node v7.1.0 has currently not been tested against Ember CLI and may result in unexpected behaviour.
cleaning up...
Built project successfully. Stored in "/Users/mriska/work/coffee-test/tmp/core_object-tests_dist-GR5Iu3vK.tmp".
ok 1 PhantomJS 2.1 - JSHint | modules/coffee-test/components/js-component.js: should pass jshint
ok 2 PhantomJS 2.1 - JSHint | app.js: should pass jshint
ok 3 PhantomJS 2.1 - JSHint | helpers/destroy-app.js: should pass jshint
ok 4 PhantomJS 2.1 - JSHint | helpers/module-for-acceptance.js: should pass jshint
ok 5 PhantomJS 2.1 - JSHint | helpers/resolver.js: should pass jshint
ok 6 PhantomJS 2.1 - JSHint | helpers/start-app.js: should pass jshint
not ok 7 PhantomJS 2.1 - Integration | Component | coffee component2: it renders
---
actual: >
null
message: >
Died on test #1 http://localhost:7357/assets/tests.js:116:24
exports@http://localhost:7357/assets/vendor.js:132:37
requireModule@http://localhost:7357/assets/vendor.js:32:25
require@http://localhost:7357/assets/test-support.js:7051:14
loadModules@http://localhost:7357/assets/test-support.js:7043:21
load@http://localhost:7357/assets/test-support.js:7073:33
http://localhost:7357/assets/test-support.js:6956:22: Assertion Failed: Using a custom `.render` function is no longer supported.
Log: |
...
ok 8 PhantomJS 2.1 - Integration | Component | js component: it renders
ok 9 PhantomJS 2.1 - JSHint | integration/components/js-component-test.js: should pass jshint
ok 10 PhantomJS 2.1 - JSHint | resolver.js: should pass jshint
ok 11 PhantomJS 2.1 - JSHint | router.js: should pass jshint
ok 12 PhantomJS 2.1 - JSHint | test-helper.js: should pass jshint
1..12
# tests 12
# pass 11
# skip 0
# fail 1
Not all tests passed.
Error: Not all tests passed.
at App.getExitCode (/Users/mriska/work/coffee-test/node_modules/testem/lib/app.js:434:15)
at App.exit (/Users/mriska/work/coffee-test/node_modules/testem/lib/app.js:189:23)
at /Users/mriska/work/coffee-test/node_modules/testem/lib/app.js:103:14
at tryCatcher (/Users/mriska/work/coffee-test/node_modules/testem/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/Users/mriska/work/coffee-test/node_modules/testem/node_modules/bluebird/js/release/promise.js:510:31)
at Promise._settlePromise (/Users/mriska/work/coffee-test/node_modules/testem/node_modules/bluebird/js/release/promise.js:567:18)
at Promise._settlePromise0 (/Users/mriska/work/coffee-test/node_modules/testem/node_modules/bluebird/js/release/promise.js:612:10)
at Promise._settlePromises (/Users/mriska/work/coffee-test/node_modules/testem/node_modules/bluebird/js/release/promise.js:691:18)
at Async._drainQueue (/Users/mriska/work/coffee-test/node_modules/testem/node_modules/bluebird/js/release/async.js:138:16)
at Async._drainQueues (/Users/mriska/work/coffee-test/node_modules/testem/node_modules/bluebird/js/release/async.js:148:10)
at Immediate.Async.drainQueues (/Users/mriska/work/coffee-test/node_modules/testem/node_modules/bluebird/js/release/async.js:17:14)
at runCallback (timers.js:637:20)
at tryOnImmediate (timers.js:610:5)
at processImmediate [as _immediateCallback] (timers.js:582:5) I believe this is due to how this.render(hbs`{{js-component}}`); which the coffeescript version of the test tries to use as: @render hbs """{{coffee-component2}}""" These are obviously not the same thing and it looks like ES6 tagged template literals is simply not compatible with coffeescript at all at the moment:
I honestly don't know how to proceed on this issue. From my perspective, it looks like using coffeescript will be very difficult when tagged template literals is used and they are not supported in coffeescript. |
I have been reading up some more on tagged template literals, and from what I understand, this PR jashkenas/coffeescript#4352 that was merged into master a week ago supports it. I guess this means that 1.12 should support tagged template literals. We should probably wait for that to land? @jakesjews: the other Coffeescript error that you mentioned you have a failing error for. Do you have a reference for that? Is it an uncontroversial fix that might be possible to get fixed quickly, and into 1.12? |
@mriska It seems like htmlbars-inline-precompile should still work with coffeescript strings since I make pretty heavy use of it with the older version of cli-coffeescript. The test I was referring to was a test I made locally in https://github.com/jashkenas/coffeescript/blob/master/test/modules.coffee.
I don't think the change in coffeescript should be controversial assuming that it is spec compliant (which I hope it is since ember is using it) |
@jakesjews You are correct, the error I am seeing is probably due to something else. According to https://github.com/ember-cli/ember-cli-htmlbars-inline-precompile#coffeescript-support coffeescript should be supported using I will need to dig deeper to see what is causing this error. |
It looks like the module fix is in coffeescript 1.12.1. After joliss/broccoli-coffee#19 is merged we should be good to remove all backticks |
@jakesjews awesome, thank you for carrying this forward. |
Just pulled in the latest broccoli-coffee and it looks like the build is green now! |
Awesome work @jakesjews 🥇 |
@kimroen is there anything I should do with this PR or are we good to merge now? |
Hi again @jakesjews, thanks for checking in (and awesome job on this!). I haven't merged this because it's a pretty big diff and I wanted to make sure it all all still worked. I haven't gotten around to verifying this, because I don't have any projects that use this addon at the moment, so the time just isn't there. That said I want to fix that, and a good way is to have automated tests for everything so I don't have to try everything manually. Thanks to the I just have the very basic stuff so far (one test for each blueprint), but I think that's enough for a smoke test. What is missing though before I can merge this with confidence and avoid problems like the one @mriska found, is to also test that the CoffeeScript the blueprints generate are valid. I made an issue describing what I'm looking for over here: #132 I'll get to it myself (hopefully soon, but you know…), but if you'd like to have a stab at it then please go right ahead. After that, the tests need to be updated on this branch to remove the backticks and pass, then I think it's good to go. Thanks again! The conflicting file in this PR has been renamed - that was done here: d397293 |
@kimroen thanks for the response! I'll get those test merged and de-backticked. |
…cript into broccoli-coffee-upgrade
.to.contain("`import Ember from 'ember'`") | ||
.to.contain("`import { module, test } from 'qunit'`") | ||
.to.contain("`import startApp from 'my-app/tests/helpers/start-app'`") | ||
.to.contain("import Ember from 'ember") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ending singlequote after ember
is missing here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch fixed now. Although now I'm concerned that the tests passed even with the typo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's just checking that the file contains that string, and 'ember'
does contain 'ember
. I think it's fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ha makes perfect sense still the morning for me 🤦♂️
@@ -16,7 +16,7 @@ describe('Acceptance: ember generate and destroy addon-import', function() { | |||
return emberNew() | |||
.then(() => emberGenerateDestroy(args, (file) => { | |||
expect(file('app/addon-imports/foo.coffee')) | |||
.to.contain(`export { default } from 'my-app/addon-imports/foo'`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch 👍
@kimroen I updated the node tests to verify that the coffee-script in the blueprints is valid. The tests are all passing on stable but it looks like beta scenario on CI is failing. Running |
@@ -15,8 +16,12 @@ describe('Acceptance: ember generate and destroy component-addon', function() { | |||
|
|||
return emberNew({target: 'addon'}) | |||
.then(() => emberGenerateDestroy(args, (file) => { | |||
var componentFile = file('app/components/foo-bar.coffee'); | |||
|
|||
expect(file('app/components/foo-bar.coffee')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missed a spot - this should refer to componentFile
.
coffeescript.compile(file.content); | ||
} | ||
|
||
expect(compileFunc).to.not.throw(Error); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you verified that this actually throws Error
if it fails?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup! Atleast running expectCoffee('asjdnasdjk');
does
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Running the literal expectCoffee('asjdnasdjk');
might throw an error for the wrong reasons though - on line 6 it would call 'asjdnasdjk'.content
and get undefined
, which is then passed into coffeescript.compile()
. Would you mind testing by passing in a random string to coffeescript.compile()
directly instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no problem. Just tried it out with a random string but apparently thats valid coffeescript so it doesn't throw. However calling coffeescript.compile('var x = 1;');
does throw an error. Do you want me to add a unit test in for the helper?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want me to add a unit test in for the helper?
That's a great idea. Yes please.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kimroen just pushed out some tests
It is. It just fails on beta sometimes saying there were no tests to run, and then pass when I rerun. I have yet to figure out why. |
@kimroen I was seeing those intermittent test failures in a private addon repo of ours as well. They seem to have disappeared since I changed from |
Great work @jakesjews, thanks for having the patience to see this through. |
@mriska Thanks for sharing your experience! I'll take a look :) |
This updates coffeescript to 1.11.1 and removes the need to use backticks for modules.
Fixes #126