Skip to content
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

Add ability to seamlessly transpile non-es6 formatted modules #768

Closed
isadovskiy opened this issue Jun 27, 2016 · 8 comments
Closed

Add ability to seamlessly transpile non-es6 formatted modules #768

isadovskiy opened this issue Jun 27, 2016 · 8 comments

Comments

@isadovskiy
Copy link

We have modules in CJS format contained ES6 statements (arrow functions, etc). These are library modules, which could be used both with NodeJS and inside the browser (via Steal). I don't see how it possible to transpile them while loading into browser in dev mode or building with StealTools.

Please point me to an option if such exists. If not, probably mixed module formats should be supported (like "format": "es6+cjs"), which tells the steal to eanspile the module first.

@matthewp
Copy link
Member

Yeah, so the issue, as you pointed out, is that Steal only transpiles modules with import/export statements. The plan is to release #671 which will allow creating more robust plugins. From there I hope to create a babel plugin that allows you to set options like "transpile everything" or "transpile everything, except what's in node_modules", etc.

@isadovskiy
Copy link
Author

Thanks for letting me know, @matthewp. Any idea when in could be available (roughly)?

@matthewp
Copy link
Member

I would say ~1 month before a beta-ish version is ready.

@isadovskiy
Copy link
Author

I see. Should I closwe this issue then?

@matthewp
Copy link
Member

No, need the reminder to create this plugin.

@matthewp
Copy link
Member

matthewp commented Mar 8, 2017

The plugins issue has gone cold for a variety of issues (I will update that issue with explanation). However, we are working on improving our Babel integration in #1040 so I think we can provide a way to do this.

I can see a couple of ways of doing this, neither of which feel great. Adding here for discussion.

transpileFiles

This is a new configuration object that lets you optionally transpile certain files.

{
  "steal": {
    "transpileFiles": "*.js"
  }
}

Then a translate hook looks for loader.transpileFiles and if the load.address is a match, runs the transpiler.

plugins

Another option is to utilize plugins. We could have a "steal-babel" plugin that adds the translate hook.

However, how would it add the translate hook? I think it would have to be done in configDependencies. However configDependencies currently doesn't run on dependency packages. And it would likely break things badly if we changed that.

An option could be for a new type of config that is like configDependencies but runs on dependency packages.

This was referenced Mar 8, 2017
@matthewp
Copy link
Member

matthewp commented Mar 8, 2017

For a possible path towards the "plugins" API from above, see this comment.

@matthewp
Copy link
Member

I have a firmer proposal on this now: #1276

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

No branches or pull requests

2 participants