FG
💻 Software🌐 Web & Full-StackVercel

Add support to transpile modules inside node_modules

Freshover 4 years ago
Mar 14, 20260 views
Confidence Score76%
76%

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

Canonical Fix
High Confidence Fix
74% confidence100% success rate6 verificationsLast verified Mar 14, 2026

Solution: Add support to transpile modules inside node_modules

Low Risk

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: [

74

Trust Score

6 verifications

100% success
  1. 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. 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. 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

Worked: 6
Partial: 2
Last verified Mar 14, 2026

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

nextjsreactssrwebpack