Skip to content

Use pirates for require hooks.#3139

Closed
ariporad wants to merge 1 commit intobabel:masterfrom
ariporad:pirates
Closed

Use pirates for require hooks.#3139
ariporad wants to merge 1 commit intobabel:masterfrom
ariporad:pirates

Conversation

@ariporad
Copy link
Contributor

@ariporad ariporad commented Dec 6, 2015

Hi!

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.

@sebmck
Copy link
Contributor

sebmck commented Dec 6, 2015

cc @babel/contributors

@jamiebuilds
Copy link
Contributor

This seems like a great idea to me

@jamestalmage
Copy link
Contributor

See: danez/pirates#3

Breaking changes already being discussed. Should be sorted soon.

@ariporad
Copy link
Contributor Author

ariporad commented Dec 6, 2015

@thejameskyle: thanks!

@sebmck: actually, could you wait till tomorrow morning (PST) to move forward with this? We're going to make some API changes (danez/pirates#3), so may as well wait for that. (I'll update the PR with the new version at the time). Thanks!

@jamiebuilds
Copy link
Contributor

Will hold off, please ping us when you've finalized it

@ariporad
Copy link
Contributor Author

ariporad commented Dec 6, 2015

@thejameskyle: Thanks, should be tomorrow, but I'll ping you regardless.

@ariporad
Copy link
Contributor Author

ariporad commented Dec 8, 2015

Ok, @sebmck, @thejameskyle, @jamestalmage, @babel/contributors: Breaking API changes have been dealt with, Pirates@2.0.0 has been published, and this PR has been updated. I hope you enjoy!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is revert an array if you only ever have one?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Umm... I'll fix that. Thanks!

@ariporad
Copy link
Contributor Author

ariporad commented Dec 8, 2015

@thejameskyle: fixed, Sorry!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

travis just has a linting error after removing the each - just remove this line.

@ariporad
Copy link
Contributor Author

@hzoo: Fixed. (Although for some reason that was never a problem on my machine)

@sebmck
Copy link
Contributor

sebmck commented Dec 11, 2015

Looks like Travis is still failing. Happy to merge this once CI is passing and all commits have been squashed. Thanks for doing this!

@ariporad ariporad force-pushed the pirates branch 2 times, most recently from 28e9d02 to 28e3d73 Compare December 13, 2015 16:40
@ariporad
Copy link
Contributor Author

@sebmck: I can't really figure out why travis is failing, because it appears to be completely unrelated to this PR. I also don't really have any experience with the babel build process, so it might be obvious to someone with experience. Is there any way you might be able to take a look at it? If not, or it's not immediately obvious, I'll just try re-implementing this, as it wasn't that difficult.

@ariporad ariporad force-pushed the pirates branch 2 times, most recently from dda5fd4 to 077a893 Compare December 13, 2015 20:59
@ariporad
Copy link
Contributor Author

Ok, @sebmck: I've done some debugging, I really think it's something else (I could be wrong though).

@hzoo
Copy link
Member

hzoo commented Dec 13, 2015

@ariporad Yeah you can probbaly see the output of the test had something to do with babel-plugin-flow-comments. I'm not sure why you're pr is the only one that has the issue but the problem is that the plugin doens't have a babel 6 version and its trying to run the plugin with babel 6 - I have a PR for it #3157

@ariporad
Copy link
Contributor Author

@hzoo: Ok, Thanks! It's good to know it's not me.

@ariporad
Copy link
Contributor Author

Actually, @hzoo: I figured out the problem, and it's not that. The problem is that istanbul@<1.0.0 improperly hooks require. Before the PR, babel improperly hooked require too. This meant that code that went through babel never actually went through istanbul (or vis versa, I can't tell). Now that it's fixed, we get this problem. So the solutions are:

  1. Upgrade to istanbul@1.0.0 alpha
  2. Wait for istanbul@1.0.0 to come out, then switch to it.

Istanbul 1.0.0 hooks require properly, and by the time it's released will actually use pirates.

@jamiebuilds
Copy link
Contributor

ping

@loganfsmyth
Copy link
Member

Given the complexity with integrating with Istanbul that you mentioned in https://phabricator.babeljs.io/T6997, is there a chance this PR is going to be a breaking change? If so, I'd worry about releasing it in a non-major release.

@ariporad
Copy link
Contributor Author

@loganfsmyth: Well...
Well....

It shouldn't be. The current implementation of babel-register is objectively broken, as is the current implementation of istanbul.

Since you have the proper permissions, could you try re-running the travis build? I have a sneaking suspicion of what the problem might be.

@hzoo
Copy link
Member

hzoo commented Jan 21, 2016

Looks like there's conflicts but yeah can rebuild after that

@ariporad
Copy link
Contributor Author

What... What did I do?

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
Copy link
Member

hzoo commented Jan 21, 2016

😢 I would rebase your changes on top if you can/haven't lost those changes

@ariporad
Copy link
Contributor Author

@hzoo: I thought... I thought I did.

Ok, that fixed it. (The git history, not the travis build, unfortunately).

@hzoo
Copy link
Member

hzoo commented Jan 21, 2016

rebuilding

@hzoo
Copy link
Member

hzoo commented Jan 22, 2016

Ok this again (which doesn't make sense)

ReferenceError: [BABEL] /home/travis/build/babel/babel/node_modules/babel-plugin-flow-comments/lib/index.js: Unknown option: base.stage

@ariporad
Copy link
Contributor Author

@hzoo: I have no clue what that's about. It looks like the version of babel-plugin-flow-comments that babel depends upon is really old. I'm going to try bumping it.

@ariporad
Copy link
Contributor Author

Nope, that didn't work.

@hzoo: I'm not really familiar with babel-plugin-flow-comments, but it looks like it's still setup for babel 5. Any ideas?

@hzoo
Copy link
Member

hzoo commented Jan 22, 2016

Yeah I still don't get why only this PR has that error. Nah, we don't need to bump it since babel is built with babel 5.

@hzoo hzoo added the PR: Internal 🏠 A type of pull request used for our changelog categories label Jan 23, 2016
@graingert
Copy link
Contributor

graingert commented Jul 22, 2016

FYI babel-plugin-istanbul works great with babel-register

@danez
Copy link
Member

danez commented Jul 22, 2016

Now that babel is build with babel 6 maybe this issue can be finally tackled?

@hzoo
Copy link
Member

hzoo commented Jul 22, 2016

uh ya just need to rebase

@hzoo
Copy link
Member

hzoo commented Aug 2, 2016

Closing in favor of #3609, maybe another PR

@hzoo hzoo closed this Aug 2, 2016
@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.

8 participants