-
Notifications
You must be signed in to change notification settings - Fork 780
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
export.js: Export in all CommonJS environments #540
Conversation
This will throw an error if From previous chats with @jdalton, I believe there are a few more variations necessary to thoroughly export for all CommonJS environments, none of which require a |
We ended up with |
@jdalton: Ah, makes sense. Thanks for the correction and explanation. |
This currently fails against jshint, which shouldn't be a big deal to address. The bigger issue though is the lack of actual tests. We had similar exports before I removed them in 2b9f0ee, since we had and still have no test coverage for those other "CommonJS" environments. Any improvement to exports must come with relevant tests that will prevent future regressions. |
How would you recommend the tests be done? |
I'll see what I can come up with, I use QUnit to test in a variety of cli environments. I bet we can come up with something that hooks into travis-ci as well. |
@@ -129,7 +129,7 @@ grunt.registerTask( "test-on-node", function() { | |||
var testActive = false, | |||
runDone = false, | |||
done = this.async(), | |||
QUnit = require( "./dist/qunit" ); | |||
QUnit = require( "./dist/qunit" ).QUnit; |
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.
This is wrong.
I've looked at current versions of UMD, and neither returnExports nor commonjsStrict use the pattern proposed here. As to my comment "This is wrong" above: Nodejs is the one env we currently test against, and the usage there is pretty clear. Requiring qunit should return the QUnit object, not something that has a QUnit property. |
This is why we must use |
Ok, I'll detect if module.exports is available and then use it, otherwise use exports instead. |
I would hold this till we have a patch to test it on the multiple target environments. Otherwise this would demand manual testing and create doubt on further changes on this piece of code. It would be great to see QUnit on many environments, even though, we need to keep it reliable anywhere. |
@jdalton can you help me review this change? For some reason the tests are still failing, not sure what exactly I'm doing wrongly. |
Addressing the missing global should be reasonable. If you look at some of the code you removed, in the I don't know what to do about the |
I'm trying to fix the issues about undefined |
Search the issue tracker for throws to see several reported issues. Under ES3 |
|
@D10 I suspect this line might be the problem:
After the first one runs, it adds another Ee.g. |
Question: Is there a missing assignment of |
Fixed most of the issues already, but builds still fail on narwhal and phantomjs. @jdalton am I missing anything? |
grunt.log.ok( Buffer.concat(output, outputLength) ); | ||
} | ||
done(); | ||
process.chdir( oldWorkingDir ); |
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.
There should be nothing after done()
, swap these lines. Unless it's this way on purpose, in which case I'm curious to learn why.
It now works on Node, Narwhal, Rhino and Ringo, although Ringo doesn't log out the assertions. Not sure why... |
@D10: How do you know it works on Ringo if the assertions aren't logged? |
You’re right, can’t test this now, maybe @jdalton can help when he’s free. |
Just tested on Ringo on my machine, it works, will try to debug. :) |
Travis doesn't seem to be testing new commits? |
Looks like the hook failed at some point. There's no known incident on Travis' status site. |
process.exit( succeeded ? 0 : 1 ); | ||
} catch( e ) { } | ||
|
||
// exit out of Narwhal, Rhino, or RingoJS |
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 more Narwhal, let's remove the reference.
Finally did an actual code review. There's some stuff to address, but we're on a good way. Thank you @D10 for your effort. Might be good to extend this with Nashorn support, but I think we can finish this first before looking into that env. |
Thanks for reviewing. Will amend commit and rebase on master this weekend. |
Friendly ping for @D10. ☝️ |
Sorry, I’ve been rather busy lately. Will try to update by this week. |
We appreciate the effort, @D10. Of course, do make sure you rebase before doing your updates. 👍 |
Ping @D10. 💝 |
Working on it, rebasing now ;) ❤️ |
This includes tests for Node.js, Rhino, and RingoJS. Closes #521
I've updated it, however it no longer works on Node, as Additionally, I eventually intend to use packaged binaries for Rhino and Ringo on |
We are close to solve this. Although, I would like to have an console reporter implemented as an option in the core, I'm not sure if the other collaborators agree with this, but I believe it's good to report to the log when HTML is not present. Regarding this, we can implement a compatible reporter with those envs and use your contributions to run the tests on them. |
module.exports = QUnit; | ||
QUnit.QUnit = QUnit; |
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.
I still can't tell what the purpose of this is.
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.
For envs without module.export
support, we need to export the whole QUnit
object, so properties like QUnit.config
can be accessed.
faf5e97
to
150ecaf
Compare
I've extracted the discussion about As for this PR itself and more importantly, the underlying issue #521: I've just tested rhino, ringo and nashorn by doing a simple Speaking of which, the |
#663 is fixed, 1.16 will ship with Since there was no reaction to my last comment, I don't see anything else that we can do here. |
Looking at src/export.js you're missing the |
@jdalton can you please create a regular bug report for that? Steps to reproduce mostly, otherwise we're stuck in the same place again. |
Closes #521