Closed arv closed 8 years ago
I'm back working on this. It works pretty good with commonjs already. We are currently publishing runtime modules at traceur/dist/commonjs/runtime/modules/
but these are in commonjs format. We can use traceur/src/runtime/modules/
for es6 modules but that still depends on nodejs resolving the path correctly.
It might be worth publishing a differnt npm package for the runtime once this work is done.
It might also be worth switching to 1.0
and keep versioning correct from then on.
@johnjbarton This is now ready for review
LGTM very cool
I actually think I need some tests =P
Initially I thought of compiling the feature tests over to a temp directory and then run mocha on that. However, this does not work because different test files have different compile options. If we had rc files #2101 we could move the options out of the headers and into those and then restructure the tests... but that would not work well for in browser tests...
Any ideas?
If you can self-build with the option and w/o the script runtime, then featureTestRunner could check for the global $traceurRuntime
(or perhaps some non-trivial properties) and run the tests with the import runtime option added. This execution of the featureTestRunner would not have $traceurRuntime
that the tests would see and each time we transformers we would import the runtime needed. So all of the cases would be covered and only one additional run of the suite would be needed (vs lots of compile commands).
One simple option would be to compile all files in test/features if and only if they do not have an // Options:
comment. Then we know that the options we should compile with is the default option. This gives a partial coverage but it might be good enough.
We found a Contributor License Agreement for you (the sender of this pull request) and all commit authors, but as best as we can tell these commits were authored by someone else. If that's the case, please add them to this pull request and have them confirm that they're okay with these commits being contributed to Google. If we're mistaken and you did author these commits, just reply here to confirm.
CLAs look good, thanks!
Almost there with tests. Two failing test; #2118 and something related to __moduleName
that I haven't grokked yet.
@johnjbarton PTAL
The test should pass when #2120 is merged.
@johnjbarton
Now with (partial) tests. The tests run mocha --compilers=js:test/cjs-mocha-compiler.js
which compiles the files on the fly using --modules=commonjs --import-runtime
. This "compiler" wraps the feature test in a mocha test function.
I think this (most long runnning PR in Traceur's history) is ready to land if you want to take a final look.
LGTM
Oops, I forgot to update the make rule name... fix coming asap
This is some work in progress for #1628
For
--modules=commonjs
it allows usingrequire
to import the minimal runtime.The goal is to allow commonjs target to work without any bin/traceur-runtime.js
@johnjbarton Feedback wanted