Socket
Socket
Sign inDemoInstall

next-transpile-modules

Package Overview
Dependencies
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

next-transpile-modules - npm Package Compare versions

Comparing version 6.0.0 to 6.1.0

4

package.json
{
"name": "next-transpile-modules",
"version": "6.0.0",
"version": "6.1.0",
"license": "MIT",

@@ -44,3 +44,3 @@ "author": "Pierre de la Martinière <pierre.de.la.martiniere@gmail.com>",

"enhanced-resolve": "^5.3.2",
"pkg-dir": "^5.0.0"
"escalade": "^3.1.1"
},

@@ -47,0 +47,0 @@ "devDependencies": {

@@ -5,3 +5,5 @@ # Next.js + Transpile `node_modules`

![Dependencies](https://img.shields.io/david/martpie/next-transpile-modules)
[![sponsor: Creative Tim](https://img.shields.io/badge/sponsor-Creative%20Tim-blue)](https://creative-tim.com/?affiliate_id=140482)
Transpile modules from `node_modules` using the Next.js Babel configuration.

@@ -200,26 +202,12 @@

### I have trouble making it work with v5
### I have trouble making it work after upgrading to v5/v6
Please make sure to [read the changelog](https://github.com/martpie/next-transpile-modules/releases).
### I have trouble making it work with Next.js 7
### I have trouble with transpilation and my custom `.babelrc`
Next.js 7 introduced Webpack 4 and Babel 7, [which changed a couple of things](https://github.com/zeit/next.js/issues/5393#issuecomment-458517433), especially for TypeScript and Flow plugins.
If you get a transpilation error when using a custom Babel configuration, make sure you are using a `babel.config.js` and not a `.babelrc`.
If you have a transpilation error when loading a page, check that your `babel.config.js` is up to date and valid, [you may have forgotten a preset](https://github.com/martpie/next-transpile-modules/issues/1#issuecomment-427749256) there.
The former is [a project-wide Babel configuration](https://babeljs.io/docs/en/config-files), when the latter works for relative paths only (and may not work for Yarn for example, as it installs dependencies in a parent directory).
### I have trouble with transpilation and Flow/TypeScript
In your Next.js app, make sure you use a `babel.config.js` and not a `.babelrc` as Babel's configuration file (see explanation below).
**Since Next.js 9, you probably don't need that file anymore**, as TypeScript is supported natively.
### I have trouble with transpilation and Yarn workspaces
If you get a transpilation error when using Yarn workspaces, make sure you are using a `babel.config.js` and not a `.babelrc`. The former is [a project-wide Babel configuration](https://babeljs.io/docs/en/config-files), when the latter works for relative paths only (and won't work as Yarn install dependencies in a parent directory).
### I have trouble with transpilation and my custom `.babelrc`
Make sure you are using a `babel.config.js` and not a `.babelrc`. The former is [a project-wide Babel configuration](https://babeljs.io/docs/en/config-files), when the latter works for relative paths only.
### I have trouble with Yarn and hot reloading

@@ -233,3 +221,3 @@

Lerna's purpose is to publish different packages from a monorepo, **it does not help for and does not intend to help local development with local modules** (<- this, in caps).
Lerna's purpose is to publish different packages from a monorepo, **it does not help for and does not intend to help local development with local modules** (<- this, **IN CAPS**).

@@ -236,0 +224,0 @@ This is not coming from me, but [from Lerna's maintainer](https://github.com/lerna/lerna/issues/1243#issuecomment-401396850).

@@ -5,3 +5,3 @@ const path = require('path');

const enhancedResolve = require('enhanced-resolve');
const pkgDir = require('pkg-dir');
const escalade = require('escalade/sync');

@@ -23,3 +23,3 @@ // Use me when needed

extensions: ['.js', '.jsx', '.ts', '.tsx', '.mjs', '.css', '.scss', '.sass'],
mainFields: ['main', 'source'],
mainFields: ['main', 'module', 'source'],
});

@@ -63,6 +63,10 @@

try {
// Get the location of its package.json
packageRootDirectory = pkgDir.sync(packageDirectory);
} catch (err) {
// Get the location of its package.json
const pkgPath = escalade(packageDirectory, (dir, names) => {
if (names.includes('package.json')) {
return 'package.json';
}
return false;
});
if (pkgPath == null) {
throw new Error(

@@ -72,2 +76,3 @@ `next-transpile-modules - an error happened when trying to get the root directory of "${module}". Is it missing a package.json?\n${err}`

}
packageRootDirectory = path.dirname(pkgPath);
} catch (err) {

@@ -102,3 +107,3 @@ throw new Error(`next-transpile-modules - an unexpected error happened when trying to resolve "${module}"\n${err}`);

* @param {string[]} modules
* @param {{resolveSymlinks?: boolean; debug?: boolean, unstable_webpack5?: boolean}} options
* @param {{resolveSymlinks?: boolean, debug?: boolean, unstable_webpack5?: boolean}} options
*/

@@ -123,8 +128,11 @@ const withTmInitializer = (modules = [], options = {}) => {

// https://webpack.js.org/configuration/module/#ruleinclude
const match = (path) =>
modulesPaths.some((modulePath) => {
const transpiled = path.includes(modulePath);
const match = (path) => {
const lastEntry = path.split(`${path.sep}node_modules${path.sep}`).slice(-1)[0];
return modules.some((modulePath) => {
const transpiled = lastEntry.includes(modulePath);
if (transpiled) logger(`transpiled: ${path}`);
return transpiled;
});
};

@@ -131,0 +139,0 @@ return Object.assign({}, nextConfig, {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc