absolute-module-mapper-plugin
Advanced tools
Comparing version 1.2.2 to 1.2.3
@@ -48,3 +48,28 @@ /** | ||
it('should mapper exclude node_modules', function () { | ||
const resolver = ResolverFactory.createResolver({ | ||
...resolverOptions, | ||
plugins: [new AbsoluteModuleMapperPlugin({ | ||
root: fixture(''), | ||
silent: false, | ||
// include: [ | ||
// '**{,/}!node_modules{,/}**' | ||
// ], | ||
exclude: [ | ||
'**/node_modules/**' | ||
], | ||
mapper: { | ||
'^<root>/module/(\\w+)': '<root>/to/$1' | ||
} | ||
})] | ||
}) | ||
const path = resolver.resolveSync({ | ||
issuer: fixture('node_modules/index.js') | ||
}, fixture('module'), './a.js') | ||
expect(path).toBe(fixture('module/a.js')) | ||
}); | ||
it('should mapper async', function (done) { | ||
@@ -51,0 +76,0 @@ const resolver = ResolverFactory.createResolver({ |
@@ -0,1 +1,10 @@ | ||
## [1.2.3](https://github.com/imcuttle/absolute-module-mapper-plugin/compare/v1.2.2...v1.2.3) (2020-02-13) | ||
### Features | ||
* add exclude ([8882f5b](https://github.com/imcuttle/absolute-module-mapper-plugin/commit/8882f5bcf06637b8a0a23d188fd5368c1dc962b8)) | ||
## [1.2.2](https://github.com/imcuttle/absolute-module-mapper-plugin/compare/v1.2.1...v1.2.2) (2020-02-13) | ||
@@ -2,0 +11,0 @@ |
14
index.js
@@ -72,2 +72,3 @@ /** | ||
include: [], | ||
exclude: [], | ||
silent: true, | ||
@@ -86,2 +87,3 @@ mapper: null, | ||
opts.include = opts.include.map(replace) | ||
opts.exclude = opts.exclude.map(replace) | ||
} | ||
@@ -101,3 +103,3 @@ | ||
apply(resolver) { | ||
const { mapper, requestMapper, include, root, silent } = this.options | ||
const { mapper, requestMapper, include, exclude, root, silent } = this.options | ||
@@ -108,3 +110,3 @@ if (requestMapper) { | ||
const from = request.context.issuer | ||
if (from && isMatch(include, from)) { | ||
if (from && isMatch(include, from) && !isMatch(exclude, from)) { | ||
const old = request.request | ||
@@ -124,2 +126,5 @@ requestMapper(old, request, (error, result) => { | ||
} | ||
else { | ||
callback() | ||
} | ||
}) | ||
@@ -132,3 +137,3 @@ } | ||
const from = request.context.issuer | ||
if (from && isMatch(include, from)) { | ||
if (from && isMatch(include, from) && !isMatch(exclude, from)) { | ||
const old = request.path | ||
@@ -147,2 +152,5 @@ | ||
} | ||
else { | ||
callback() | ||
} | ||
}) | ||
@@ -149,0 +157,0 @@ } |
{ | ||
"name": "absolute-module-mapper-plugin", | ||
"version": "1.2.2", | ||
"version": "1.2.3", | ||
"main": "index.js", | ||
@@ -5,0 +5,0 @@ "description": "The plugin on enhanced-resolver to map module path", |
@@ -84,2 +84,8 @@ # absolute-module-mapper-plugin | ||
### `exclude` | ||
The excluded paths for mapping | ||
- Type: `Array<string|Function|RegExp>` | ||
- Default: `[]` | ||
### `mapper` | ||
@@ -86,0 +92,0 @@ |
16518
279
133