Add support to transpile modules inside node_modules
Problem
Now some of us ships NPM packages (specially components) written in ES2015 without transpiling them. That's a pretty good thing specially if they are gonna used in a project like Next.js or CRA (which does transpiling). They offer benefits like: No need to transpile before shipping to NPM Get the benefit of Webpack 2's tree-shaking But we can't do this now we exclude everything inside node_modules from babel transpiling. So, here's the proposed solution. We have an entry in `next.config.js` to include modules which needs to go through babel. See: [code block]
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Solution: Add support to transpile modules inside node_modules
Very much agree @slorber - this would be very handy for internal modules if you're breaking your project up and isolating things as much as possible. And @rauchg / @arunoda supporting RegExp's would be really nice, so you could have one entry that catches all the company internal modules, using say the NPM org namespace: // next.config.js module.exports = { transpileModules: [
Trust Score
6 verifications
- 1
Very much agree @slorber - this would be very handy for internal modules if you'
Very much agree @slorber - this would be very handy for internal modules if you're breaking your project up and isolating things as much as possible.
- 2
And @rauchg / @arunoda supporting RegExp's would be really nice, so you could ha
And @rauchg / @arunoda supporting RegExp's would be really nice, so you could have one entry that catches all the company internal modules, using say the NPM org namespace:
- 3
// next.config.js
module.exports = { transpileModules: [ /^\@my-npm-org\/.*/ ] }
Validation
Resolved in vercel/next.js GitHub issue #706. Community reactions: 27 upvotes.
Verification Summary
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep