-
Notifications
You must be signed in to change notification settings - Fork 27.8k
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
[WIP] Add support for transpile packages installed via NPM #749
Conversation
presets: [require.resolve('./build/babel/preset')], | ||
extensions: ['.js'], | ||
only: this.config.transpileModules || [] | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Umm, babel-register is not for production. I'm not sure if it's acceptable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure about that too. Need to read the source to dig more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep. I think we can go some kind of pre-compilation system.
For now, we can use this to test the functionality.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/standard-things/esm looks promising. Maybe we could use this in production and babel-register
in dev mode?
|
||
In the above example, Next.js will transpile any module inside the `node_modules` directory which has "react-button" in it's pathname. | ||
|
||
> Note: Currently, Next.js only supports modules installed into `node_modules`. So, transpiling modules installed with `npm link <my-comp-name>` doesn't work well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so it does not work with symlinks (like Lerna do?) not sure to understand that comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now yes it is.
Where are we at with this feature? I just ran into this problem and would be lovely to not have to add transpiled code to the component repo. |
I need this to work with symlink support (my project makes heavy use of Lerna). I'd love to help contribute to get symlink support up and running. What steps need to be taken? |
Any possible workarounds to use Next.js with Lerna? |
@arunoda do we still want to take this? |
Let's keep this open. I want to work on this someday. |
any status update on this issue @arunoda ? thx! |
|
||
if (pattern.test(str)) return false | ||
} | ||
|
||
return /node_modules/.test(str) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would be cool if this was more generic to support monorepo scenarios. I'm happy to lend a hand to this feature if needed
will this ever get merged? |
What happened here? Looks like the feature died? |
Yes, would really like my Lerna packages to be able to get transpiled. |
@timneutkens when you closed this, was it merged? Should the original example @arunoda gave work?
|
@philcockfield no, check #3319 |
Thanks @timneutkens |
Fixes #706
Instructions
Add a field called
transpileModules
with an array of regexp patterns like this:Here Next.js checks every imported module with above patterns and transpile them if matched. By default it uses
next/babel
preset, but you can use a.babelrc
file to customize it as you want.In the above example, Next.js will transpile any module inside the
node_modules
directory which has "react-button" in it's pathname.