Skip to content
This repository has been archived by the owner on Mar 25, 2018. It is now read-only.

iojs -t #11

Open
rauchg opened this issue Mar 10, 2015 · 9 comments
Open

iojs -t #11

rauchg opened this issue Mar 10, 2015 · 9 comments

Comments

@rauchg
Copy link

rauchg commented Mar 10, 2015

Transpilation is here to stay. Even though IOJS ships with some ES6 features, I find myself using babel-node all the time because I want other features that are not presently supported.

It's not only about ES6 compatibility, though. Transpilation can enable the usage of hygienic macros, add better instrumentation and enhance debugging, introduce proprietary features (JSX), among other things.

I propose the support of first-class source transformations in two ways:

Declarative (CLI)

This is essentially the same as browserify -t. It's possible that due to the usage of streams (yay for great abstractions), we can even reuse some of the same transforms.

$ iojs -t babelify woot.js

should make ES6 code work.

Programmatic

This is a substitute to what I consider a weird API / implementation detail: custom extension handlers.

require.transform(require('babelify'));

it's possible that this API could be polyfilled to use extension handlers for BC or compatibility with Node.

@rvagg
Copy link
Member

rvagg commented Mar 10, 2015

note this may be at least partially solved by nodejs/node#881 if it ever lands

@chrisdickinson
Copy link

My feels on this subject carry over from nodejs/node#881 as well.

@rauchg
Copy link
Author

rauchg commented Mar 10, 2015

@chrisdickinson #2 is very valid. I still advocate for always transpiling prior to publish to remove the runtime performance penalties.

However, for things like instrumentation, you still want to quickly toggle between transpilation and no transpilation.

@sam-github
Copy link

What does this have to do with weakening our stance that all npm modules should publish as vanilla js? npm published modules can't change the command line arguments of node, publish modules relying on node's arguments doesn't work well (koa withstanding).

Any use of this for transpilation would be occurring pre-publish during development, for example:

/bin/ls | entr -cr node -r 6to5 test/fu.js

@tellnes
Copy link

tellnes commented Mar 12, 2015

I really like how browserify does this by adding a browserify.transform field to package.json. If that is implemented, then the modules can use transforms without needing to do the transformation pre-running. That is really useful when you are writing substack-style and are working on multiple modules at once.

@mikeal
Copy link
Contributor

mikeal commented Mar 12, 2015

I've spent a fair amount of time screaming at browserify transform and overlay declarations in package.json. In general I think it's better to enable a single endpoint (like, "install" or "build") that calls some code and allow people to write things in code rather than through configurations.

@chrisdickinson
Copy link

@rauchg Do you think the (newly-added) -r feature addresses this concern, or would you like to have something more full-fledged on top of that (some sort of way for require.extensions to cooperate, for example?)

@rlidwka
Copy link

rlidwka commented Mar 30, 2015

I was thinking about something like a shebang for node.js modules to make require.extensions cooperate with each other. So you would specify package@version in such a file, and node.js will load it with an appropriate module. Not sure now useful it is.

@Fishrock123
Copy link

@rauchg Does the -r flag solve this?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants