rollup-plugin-commonjs
Advanced tools
Comparing version 10.0.2 to 10.1.0
# rollup-plugin-commonjs changelog | ||
## 10.1.0 | ||
*2019-08-27* | ||
* Normalize ids before looking up in named export map ([#406](https://github.com/rollup/rollup-plugin-commonjs/issues/406)) | ||
* Update README.md with note on symlinks ([#405](https://github.com/rollup/rollup-plugin-commonjs/issues/405)) | ||
## 10.0.2 | ||
@@ -4,0 +9,0 @@ *2019-08-03* |
@@ -735,4 +735,7 @@ 'use strict'; | ||
resolvedId = path.resolve(id); | ||
} | ||
} // Note: customNamedExport's keys must be normalized file paths. | ||
// resolve and nodeResolveSync both return normalized file paths | ||
// so no additional normalization is necessary. | ||
customNamedExports[resolvedId] = options.namedExports[id]; | ||
@@ -776,3 +779,4 @@ | ||
const transformed = transformCommonjs(this.parse, code, id, this.getModuleInfo(id).isEntry, ignoreGlobal, ignoreRequire, customNamedExports[id], sourceMap, allowDynamicRequire, ast); | ||
const normalizedId = path.normalize(id); | ||
const transformed = transformCommonjs(this.parse, code, id, this.getModuleInfo(id).isEntry, ignoreGlobal, ignoreRequire, customNamedExports[normalizedId], sourceMap, allowDynamicRequire, ast); | ||
@@ -779,0 +783,0 @@ if (!transformed) { |
import { statSync, existsSync, realpathSync } from 'fs'; | ||
import { resolve, dirname, sep, basename, extname } from 'path'; | ||
import { resolve, dirname, sep, basename, extname, normalize } from 'path'; | ||
import { isCore, sync } from 'resolve'; | ||
@@ -731,4 +731,7 @@ import { makeLegalIdentifier, attachScopes, extractAssignedNames, createFilter } from 'rollup-pluginutils'; | ||
resolvedId = resolve(id); | ||
} | ||
} // Note: customNamedExport's keys must be normalized file paths. | ||
// resolve and nodeResolveSync both return normalized file paths | ||
// so no additional normalization is necessary. | ||
customNamedExports[resolvedId] = options.namedExports[id]; | ||
@@ -772,3 +775,4 @@ | ||
const transformed = transformCommonjs(this.parse, code, id, this.getModuleInfo(id).isEntry, ignoreGlobal, ignoreRequire, customNamedExports[id], sourceMap, allowDynamicRequire, ast); | ||
const normalizedId = normalize(id); | ||
const transformed = transformCommonjs(this.parse, code, id, this.getModuleInfo(id).isEntry, ignoreGlobal, ignoreRequire, customNamedExports[normalizedId], sourceMap, allowDynamicRequire, ast); | ||
@@ -775,0 +779,0 @@ if (!transformed) { |
{ | ||
"name": "rollup-plugin-commonjs", | ||
"version": "10.0.2", | ||
"version": "10.1.0", | ||
"description": "Convert CommonJS modules to ES2015", | ||
@@ -5,0 +5,0 @@ "main": "dist/rollup-plugin-commonjs.cjs.js", |
@@ -57,3 +57,3 @@ # rollup-plugin-commonjs [![Build Status][travis-img]][travis] | ||
// (see below for more details) | ||
namedExports: { './module.js': ['foo', 'bar' ] }, // Default: undefined | ||
namedExports: { 'react': ['createElement', 'Component' ] }, // Default: undefined | ||
@@ -70,5 +70,5 @@ // sometimes you have to leave require statements | ||
### Usage in monorepo | ||
### Usage with symlinks | ||
In case you are using a monorepo, you may want to use a regular expression for `include` as the string 'node_modules' will not match if your `node_modules` is not in your current working directory (i.e. '../node_modules'). Try this: | ||
Symlinks are common in monorepos and are also created by the `npm link` command. Rollup with `rollup-plugin-node-resolve` resolves modules to their real paths by default. So `include` and `exclude` paths should handle real paths rather than symlinked paths (e.g. `../common/node_modules/**` instead of `node_modules/**`). You may also use a regular expression for `include` that works regardless of base path. Try this: | ||
@@ -81,2 +81,4 @@ ``` | ||
Whether symlinked module paths are [realpathed](http://man7.org/linux/man-pages/man3/realpath.3.html) or preserved depends on Rollup's `preserveSymlinks` setting, which is false by default, matching Node.js' default behavior. Setting `preserveSymlinks` to true in your Rollup config will cause `import` and `export` to match based on symlinked paths instead. | ||
### Custom named exports | ||
@@ -113,3 +115,3 @@ | ||
// of a module in node_modules | ||
'node_modules/my-lib/index.js': [ 'named' ] | ||
'my-lib': [ 'named' ] | ||
} | ||
@@ -116,0 +118,0 @@ }) |
import { realpathSync, existsSync } from 'fs'; | ||
import { extname, resolve } from 'path'; | ||
import { extname, resolve, normalize } from 'path'; | ||
import { sync as nodeResolveSync, isCore } from 'resolve'; | ||
@@ -43,2 +43,6 @@ import { createFilter } from 'rollup-pluginutils'; | ||
} | ||
// Note: customNamedExport's keys must be normalized file paths. | ||
// resolve and nodeResolveSync both return normalized file paths | ||
// so no additional normalization is necessary. | ||
customNamedExports[resolvedId] = options.namedExports[id]; | ||
@@ -84,2 +88,4 @@ | ||
const normalizedId = normalize(id); | ||
const transformed = transformCommonjs( | ||
@@ -92,3 +98,3 @@ this.parse, | ||
ignoreRequire, | ||
customNamedExports[id], | ||
customNamedExports[normalizedId], | ||
sourceMap, | ||
@@ -95,0 +101,0 @@ allowDynamicRequire, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
211806
2189
128