-
Notifications
You must be signed in to change notification settings - Fork 17
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
Document side-effects free programmatical usage #93
Comments
Short answer, not at the moment, however with the appropriate compile options, such a change could be made - I'll have a go in the next few days. It will restrict the compilation targets; requiring noRuntime and Promises, and would prevent the use of ES7-mode and generators, both of which require runtime support. You can control the names of the modifications, which should allow you to avoid clashes. You can also compile via the './nodent.js' script (with the --output option) in a seperate process, which obviously won't modify your runtime. Is this what you're trying to achieve? |
Yes, ideally I want to handle compilation of async/await in scripts which do also other things, and I would prefer that individual tasks do not "leak" undesired changes outside (especially that in that specific case of nodent usage, there's no need for environment changes) Thanks for answering! |
Just had a quick look, and right now this is a bit of a mess for legacy reasons. I could possibly provide a secondary "compileOnly" module (as in |
Yes, that would be great. I think it'll be also possible (but not in a clean, straightforward way) if |
Actually, that's (also) historic - the Function.prototypes are set in the |
I've pushed a new branch which extracts the compiler into a new file which has no runtime dependency or pollution. It's not published yet, so update your project with:
With this revision, you can require I have a little test file:
Note that it does_not respect the If this meets your requirements, let me know and I'll do a little tidying up and publish on npm. I'm happy to receive a PR to on that branch to document the new feature too! |
Thanks @matAtWork, looks great. I've tried my best in updating documentation at: #94 |
NP. I may well actually separate the CLI, from the core compiler mainly as I like clean dependencies, and the compiler has no dependency on I need to run some further tests and make sure I don't other people's stuff, but hopefully I'll have this ready to go tomorrow. When I have, I'll remove the branch and publish via npm as normal. |
The compiler has been shipped as the npm module 'nodent-compiler', which has no runtime or global side-effects. 'nodent' has been updated to refer to the compiler as a sub-module, leaving it purely for running the CLI and require hook mechanism. Shipped in https://github.com/MatAtBread/nodent/releases/tag/3.1.0 |
Looks great, thank you! |
I'd like to use this package programmatically in a script (to recompile some JS files), but with no side effects (e.g. extending natives prototypes or messing with Node.js require system).
The best I probably can get is via:
Still if I read correctly, it still implies some side effects:
Function.prototype
global
Object
Is there any chance to obtain a clean run programmaticaly?
The text was updated successfully, but these errors were encountered: