next-transpile-modules
Advanced tools
Comparing version 3.1.0 to 3.2.0
{ | ||
"name": "next-transpile-modules", | ||
"version": "3.1.0", | ||
"version": "3.2.0", | ||
"main": "src/next-transpile-modules.js", | ||
@@ -11,3 +11,4 @@ "license": "MIT", | ||
"test:lint": "eslint .", | ||
"test:formatting": "prettier --check \"**/*.js\"" | ||
"test:formatting": "prettier --check \"**/*.js\"", | ||
"test:formatting:fix": "prettier --check \"**/*.js\" --write" | ||
}, | ||
@@ -14,0 +15,0 @@ "files": [ |
# Next.js + Transpile `node_modules` | ||
[![Build Status](https://img.shields.io/circleci/project/github/martpie/next-transpile-modules.svg)](https://circleci.com/gh/martpie/next-transpile-modules) | ||
![Build Status](https://github.com/martpie/next-transpile-modules/workflows/tests/badge.svg) | ||
![Dependencies](https://img.shields.io/david/martpie/next-transpile-modules) | ||
@@ -9,2 +9,4 @@ | ||
Supports all extensions supported by Next.js: `.js`, `.jsx`, `.ts`, `.tsx`, `.mjs`, `.css`, `.scss` and `.sass`. | ||
## What problems does it solve? | ||
@@ -81,5 +83,5 @@ | ||
### CSS support | ||
### CSS/SCSS support | ||
Since `next-transpile-modules@3` and `next@>9.2`, this plugin will also transpile CSS included in your transpiled packages: | ||
Since `next-transpile-modules@3` and `next@>9.2`, this plugin can also transpile CSS included in your transpiled packages. SCSS/SASS is also supported since `next-transpile-modules@3.1.0`. | ||
@@ -155,2 +157,3 @@ In your transpiled package: | ||
- it supports CSS modules (since Next.js 9.2) | ||
- it supports `.mjs` | ||
@@ -173,2 +176,6 @@ ### I have trouble making it work with Next.js 7 | ||
### 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 | ||
@@ -182,3 +189,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**. | ||
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). | ||
@@ -209,1 +216,27 @@ This is not coming from me, but [from Lerna's maintainer](https://github.com/lerna/lerna/issues/1243#issuecomment-401396850). | ||
``` | ||
### I have trouble with duplicated dependencies | ||
It can happen that when using `next-transpile-modules` with a local package and `npm`, you end up with duplicated dependencies in your final Next.js build. It is important to understand _why_ it happens. | ||
Let's take the following setup: one Next.js app ("Consumer"), and one Styleguide library. | ||
You will probably have `react` as a `peerDependencies` and as a `devDependecy` of the Styleguide. If you use `npm i`, it will create a symlink to your Styleguide package in your "Consumer" `node_modules`. | ||
The thing is in this shared package, you also have a `node_modules`. So when your shared modules requires, let's say `react`, Webpack will resolve it to the version in your Styleguide's `node_modules`, and not your Consumer's `node_modules`. Hence the duplicated `react` in your final bundles. | ||
You can tell Webpack how to resolve the `react` of your Styleguide to use the version in your Next.js app like that: | ||
```diff | ||
const withTM = require('next-transpile-modules')(['styleguide']); | ||
module.exports = withTM({ | ||
webpack: (config) => { | ||
+ config.resolve.alias['react'] = path.resolve(__dirname, '.', 'node_modules', 'react'); | ||
return config | ||
}, | ||
}); | ||
``` | ||
It is not a great solution, but it works. Any help to find a more future-proof solution is welcome. |
@@ -82,3 +82,3 @@ const path = require('path'); | ||
config.module.rules.push({ | ||
test: /\.+(js|jsx|ts|tsx)$/, | ||
test: /\.+(js|jsx|mjs|ts|tsx)$/, | ||
loader: options.defaultLoaders.babel, | ||
@@ -85,0 +85,0 @@ include: includes |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16658
237