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 options argument to addHook to pass to pirates.addHook #571

Merged
merged 1 commit into from
Dec 29, 2020

Conversation

gordonmleigh
Copy link

I've added an optional argument to addHook to pass through to pirates. You would use it like this:

addHook(".js", { transforms: ["imports"] }, { ignoreNodeModules: false });

I also removed the ts-ignore comment because pirates has types now.

Copy link
Owner

@alangpierce alangpierce left a comment

Choose a reason for hiding this comment

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

Looks great, thank you!

@alangpierce
Copy link
Owner

To manually test, I added a print to Sucrase to print which files it processes, then ran the require hook from a node shell setting ignoreNodeModules to false, then I required a third-party package and confirmed that it worked.

yarn build
node
> r = require('./dist/register.js')
> r.addHook(".js", {transforms: ["imports"]}, {ignoreNodeModules: false})
> require('prettier')
Transforming /Users/alanpierce/code/sucrase/node_modules/prettier/index.js
Transforming /Users/alanpierce/code/sucrase/node_modules/prettier/third-party.js

I'd also be happy to accept a PR extending the param to the other wrappers in register.ts.

Unfortunately, looks like CI isn't running anymore, so I'll investigate that as a follow-up, but tests pass for me.

@alangpierce alangpierce merged commit 5795a83 into alangpierce:master Dec 29, 2020
alangpierce pushed a commit that referenced this pull request Dec 30, 2020
Further to #571, this PR exposes the new addHook options argument to the register* functions too.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants