Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@weco/next-plugin-transpile-modules

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@weco/next-plugin-transpile-modules - npm Package Compare versions

Comparing version 2.0.2 to 2.2.0

33

index.js
const path = require('path');
const PATH_DELIMITER = '[\\\\/]'; // match 2 antislashes or one slash
/**
* Stolen from https://stackoverflow.com/questions/10776600/testing-for-equality-of-regular-expressions
*/
function regexEqual (x, y) {
const regexEqual = (x, y) => {
return (x instanceof RegExp) && (y instanceof RegExp) &&
(x.source === y.source) && (x.global === y.global) &&
(x.ignoreCase === y.ignoreCase) && (x.multiline === y.multiline);
}
};
const generateIncludes = (modules) => {
return modules.map(module => (new RegExp(`${safePath(module)}(?!.*node_modules)`)));
};
const generateExcludes = (modules) => {
return [new RegExp(`node_modules${PATH_DELIMITER}(?!(${modules.map(safePath).join('|')})(?!.*node_modules))`)];
};
/**
* On Windows, the Regex won't match as Webpack tries to resolve the
* paths of the modules. So we need to check for \\ and /
*/
const safePath = (module) => module.split('/').join(PATH_DELIMITER);
/**
* Actual Next.js plugin
*/
module.exports = (nextConfig = {}) => {
const withTm = (nextConfig = {}) => {
const { transpileModules = [] } = nextConfig;
const includes = transpileModules.map(module => (new RegExp(`${module}(?!.*node_modules)`)));
const excludes = [new RegExp(`node_modules(?!/(${transpileModules.join('|')})(?!.*node_modules))`)];
const includes = generateIncludes(transpileModules);
const excludes = generateExcludes(transpileModules);

@@ -70,2 +86,7 @@ return Object.assign({}, nextConfig, {

config.watchOptions.ignored = ignored;
if (typeof nextConfig.webpackDevMiddleware === 'function') {
return nextConfig.webpackDevMiddleware(config);
}
return config;

@@ -75,1 +96,3 @@ }

};
module.exports = withTm;

12

package.json
{
"name": "@weco/next-plugin-transpile-modules",
"version": "2.0.2",
"version": "2.2.0",
"main": "index.js",

@@ -9,3 +9,3 @@ "license": "MIT",

"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"test": "jest",
"lint": "eslint ."

@@ -34,10 +34,14 @@ },

"devDependencies": {
"anymatch": "2.0.0",
"eslint": "5.12.1",
"eslint-config-semistandard": "^13.0.0",
"eslint-config-semistandard": "13.0.0",
"eslint-config-standard": "12.0.0",
"eslint-plugin-import": "2.15.0",
"eslint-plugin-jest": "22.3.0",
"eslint-plugin-node": "8.0.1",
"eslint-plugin-promise": "4.0.1",
"eslint-plugin-standard": "4.0.0"
"eslint-plugin-standard": "4.0.0",
"jest": "24.1.0",
"rewire": "4.0.1"
}
}

@@ -77,4 +77,8 @@ # Next.js + Transpile `node_modules`

If you have a transpilation error when loading a page, check that your `.babelrc`/`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.
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.
### 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, when the latter works for relative paths only (and won't work as Yarn install dependencies in a parent directory).
### I have trouble with Yarn and hot reloading

@@ -81,0 +85,0 @@

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