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

Does not work with babel-register and babel-polyfill #89

Closed
Morriz opened this issue Sep 6, 2016 · 7 comments
Closed

Does not work with babel-register and babel-polyfill #89

Morriz opened this issue Sep 6, 2016 · 7 comments

Comments

@Morriz
Copy link

Morriz commented Sep 6, 2016

If I do a
node -r babel-register -r babel-polyfill node_modules/.bin/micro -p 3000 src/index.js
I still get errors about import/export statements:

micro: Error when importing ...
(function (exports, require, module, __filename, __dirname) { import ...
                                                              ^^^^^^

And yes, transpiling works (with preset-node6):
babel src --out-dir build

Any idea what might cause this?

@Morriz
Copy link
Author

Morriz commented Sep 6, 2016

I believe it's a poor choice to go with async-to-gen, as it does not play nice with other extensions. I contacted the author and suggested to become part of the babel solution:

leebyron/async-to-gen#15

Please make micro so it plays well with babel! async-to-gen does not have to become part of your build distribution, so something like the previous -no-babel should be made into --no-transform (or something that makes more sense), not doing any transforms on the fly.

And why remove the babel dependency if most of the javascript programmers use it?

@amio
Copy link
Contributor

amio commented Sep 28, 2016

Maybe when Node.js 7.0 is out, which won't be too long, this problem could be solved.

@timneutkens
Copy link
Member

@amio Seems like Lee Byron worked on a solution in async-to-gen: leebyron/async-to-gen#15 (comment)

@amio
Copy link
Contributor

amio commented Sep 29, 2016

Cool, thanks @timneutkens

@leo leo changed the title zeit does not work with babel-register and babel-polyfill Does not work with babel-register and babel-polyfill Oct 8, 2016
@timneutkens
Copy link
Member

@amio @Morriz #114 was just merged which checks for async before executing async-to-gen's register. This will allow you to use node 7 with --harmony-async-await also leebyron/async-to-gen#15 was merged. This ticket can be closed 👍

@rauchg rauchg closed this as completed Dec 24, 2016
@zachariahtimothy
Copy link

Apologies if this is a dumb question, but I am still unclear how to use Micro with babel. Any tips on setting it up? I have tried several solutions and nothing seems to work. Thanks in advance!

@aboutlo
Copy link

aboutlo commented Jul 11, 2017

@zachariahtimothy

@zachariahtimothy I got micro working with babel with these scripts in the package.json
"start": "node -r babel-register ./node_modules/.bin/micro src",

Below the settings, I used to deploy via now

"scripts": {
    "build": "babel -d build src",
    "start": "node -r babel-register ./node_modules/.bin/micro src",
    "now-start": "micro build"
  },

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

7 participants