Skip to content

Switch to pirates for babel-register.#3609

Closed
hzoo wants to merge 1 commit intomasterfrom
ariporad-pirates
Closed

Switch to pirates for babel-register.#3609
hzoo wants to merge 1 commit intomasterfrom
ariporad-pirates

Conversation

@hzoo
Copy link
Member

@hzoo hzoo commented Jul 27, 2016

Copied from #3139 but fixed merge conflicts @ariporad

Pirates is a simple module that enables easy require hooking. It makes sure that your require hook works properly. It also makes the implimentation of babel-register a lot simpler.

For more on pirates: http://ariporad.link/piratesjs

As was discussed in #3062, this PR uses pirates to implement require hooks. That means that the babel-register require hook implementation is drastically simpler, and plays nicely with other hooks.

This change is completely transparent (a patch version bump), and all the tests still pass.

Fixes #3062.

Pirates is a simple module that enables easy require hooking. It makes sure that your require hook works properly. It also makes the implimentation of babel-register a lot simpler.

For more on pirates: http://ariporad.link/piratesjs
@hzoo hzoo added the PR: Internal 🏠 A type of pull request used for our changelog categories label Jul 27, 2016
@hzoo
Copy link
Member Author

hzoo commented Jul 27, 2016

What is going on with the tests..

/home/travis/build/babel/babel/packages/babel-generator/node_modules/babylon/node_modules/babel-runtime/helpers/typeof.js:19
var _typeof = typeof _symbol2.default === "function" && /istanbul ignore next/(0, _typeof4.default)(_iterator2.default) === "symbol" ? function (obj) {
^
TypeError: (0 , _typeof4.default) is not a function

@danez
Copy link
Member

danez commented Jul 28, 2016

I think one issue is that pirates is not really reverting, before being called twice. which we currently do. And it is replacing module._compile but never reverting it.

@ariporad
Copy link
Contributor

@hzoo: Thanks for opening this!

@danez: Hmm... I'll try to look into that. (It might be a day or two, I'm a bit busy at the moment, sorry.)

@ariporad
Copy link
Contributor

@hzoo: Hmm... I have no idea why we're getting a TypeError, but I've been thinking about this: I think that it would be better to just fix babel's built-in hook, as I haven't really had time to maintain pirates, and I'm thinking about depreciating it. Would you be open to a PR for that?

@hzoo
Copy link
Member Author

hzoo commented Jul 30, 2016

Ah understandable, thats is fine too.

@hzoo
Copy link
Member Author

hzoo commented Aug 3, 2016

Ok let us know - closing

@hzoo hzoo closed this Aug 3, 2016
@hzoo hzoo deleted the ariporad-pirates branch August 5, 2016 00:57
@graingert
Copy link
Contributor

@ariporad what are your thoughts on deprecating pirates? It seems it would still be useful (eg for stacking babel and ts-node)

@ariporad
Copy link
Contributor

@graingert: My primary thoughts are this:

  1. I'm quite busy at the moment, and haven't really been able to dedicate a lot of time to it. (For example, I haven't been able to finish writing the tests.)
  2. I'm not entirely sure that I would be the proper person to maintain it, as I don't actually have any projects that use it.
  3. I'm more than happy to add someone else as a contributor if they're interested. If someone else also really needs it, I could try to make it a higher priority.

So, TL;DR: I don't really have a whole lot of time to allocate to it atm. If someone else needs it, I'm happy to try and find some time to work on it. I'm also happy to add someone as a contributor.

@blakeembrey
Copy link

@hzoo Would you consider applying this update without pirates. I just noticed that babel reading from the filesystem is the primary cause of incompatibility, but it's actually a really easy and quick fix to make it work. Here's the update I did in ts-node (the original hook was based on babel-register, so should look like a familiar change - TypeStrong/ts-node@44c389e#diff-f41e9d04a45c83f3b6f6e630f10117feR288). Basically, just use module._compile and fallback to the previous loader to pass through the contents instead of reading directly from fs.

@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Oct 7, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Internal 🏠 A type of pull request used for our changelog categories

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants