-
Notifications
You must be signed in to change notification settings - Fork 581
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
Import runtime as modules #1979
Conversation
@@ -299,7 +302,7 @@ git-update-publish: git-gh-rebase | |||
|
|||
# --- | |||
|
|||
prepublish: bin/traceur.js bin/traceur-runtime.js | |||
prepublish: bin/traceur.js bin/traceur-runtime.js commonjs-modules |
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.
Not sure where this change came from
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.
Figured it out... needed to be runtime/
4208964
to
4dbd105
Compare
I'm back working on this. It works pretty good with commonjs already. We are currently publishing runtime modules at It might be worth publishing a differnt npm package for the runtime once this work is done. It might also be worth switching to |
b5da773
to
0520814
Compare
@johnjbarton This is now ready for review |
!options.transformOptions.blockBinding ? CONST : VAR; | ||
} | ||
|
||
export default function ImportRuntimeTrait(ParseTreeTransformerClass) { |
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 gather that this Trait will prepend runtime imports iff option is true (obvious) and the ParseTreeTransformerClass needs the import as indicated by tree !== transformed
. The latter is not obvious so I think a comment here or in the top level transform functions would help,
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 |
One simple option would be to compile all files in test/features if and only if they do not have an |
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 |
@johnjbarton PTAL The test should pass when #2120 is merged. |
When using `--modules=commonjs --import-runtime` or `--modules=parse --import-runtime` the generated code will output require/import statements that import the runtime function as a module. This means that if you are compiling to commonjs or es6 modules you can get a minimal runtime and no external runtime file is needed. Fixes google#1628
Now with (partial) tests. The tests run I think this (most long runnning PR in Traceur's history) is ready to land if you want to take a final look. |
@@ -118,6 +119,10 @@ test/features: bin/traceur.js bin/traceur-runtime.js $(FEATURE_TESTS) | |||
test/%-run: test/% bin/traceur.js | |||
node_modules/.bin/mocha $(MOCHA_OPTIONS) $< | |||
|
|||
test/mocha: bin/traceur.js |
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.
maybe test/module-compiled
? Since we use mocha through out...
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