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

absolute-module-mapper-plugin

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

absolute-module-mapper-plugin - npm Package Compare versions

Comparing version 1.2.1 to 1.2.2

21

__tests__/main.test.js

@@ -48,2 +48,23 @@ /**

it('should mapper async', function (done) {
const resolver = ResolverFactory.createResolver({
...resolverOptions,
plugins: [new AbsoluteModuleMapperPlugin({
root: fixture(''),
silent: false,
mapper: (path, ctx, cb) => {
cb(null, path.replace(new RegExp('/module/(\\w+)'), '/to/$1'))
}
})]
})
resolver.resolve({
issuer: fixture('module/index.js')
}, fixture('module'), './a.js', {}, (err, result) => {
expect(result).toBe(fixture('to/a.js'))
done(err)
})
});
it('should requestMapper', function () {

@@ -50,0 +71,0 @@ const resolver = ResolverFactory.createResolver({

4

CHANGELOG.md

@@ -0,1 +1,5 @@

## [1.2.2](https://github.com/imcuttle/absolute-module-mapper-plugin/compare/v1.2.1...v1.2.2) (2020-02-13)
## [1.2.1](https://github.com/imcuttle/absolute-module-mapper-plugin/compare/v1.2.0...v1.2.1) (2019-11-14)

@@ -2,0 +6,0 @@

48

index.js

@@ -42,3 +42,3 @@ /**

}
return filename => {
mapper = filename => {
for (let [regStr, replacer] of Object.entries(map)) {

@@ -54,2 +54,13 @@ if (new RegExp(regStr).test(filename)) {

if (typeof mapper === 'function') {
return (input, req, cb) => {
// without callback
if (mapper.length < 3) {
return cb(null, mapper(input, req))
}
return mapper(input, req, cb)
}
}
return mapper

@@ -98,11 +109,15 @@ }

const old = request.request
request.request = replaceRoot(requestMapper(old, request), root)
requestMapper(old, request, (error, result) => {
if (error) callback(error)
else {
request.request = replaceRoot(result || old, root)
!silent &&
old !== request.request &&
console.log('AbsoluteModuleMapperPlugin resolveRequest: in %s\n %s => %s', from, old, request.request)
!silent &&
old !== request.request &&
console.log('AbsoluteModuleMapperPlugin resolveRequest: in %s\n %s => %s', from, old, request.request)
callback()
}
})
}
callback()
// resolver.doResolve(requestTarget, request, null, resolveContext, callback)
})

@@ -117,11 +132,14 @@ }

const old = request.path
request.path = replaceRoot(mapper(old, request), root)
!silent &&
old !== request.path &&
console.log('AbsoluteModuleMapperPlugin path: in %s\n %s => %s', from, old, request.path)
mapper(old, request, (error, result) => {
if (error) callback(error)
else {
request.path = replaceRoot(result || old, root)
!silent &&
old !== request.path &&
console.log('AbsoluteModuleMapperPlugin path: in %s\n %s => %s', from, old, request.path)
callback()
}
})
}
callback()
// resolver.doResolve(target, request, null, resolveContext, callback)
})

@@ -128,0 +146,0 @@ }

{
"name": "absolute-module-mapper-plugin",
"version": "1.2.1",
"version": "1.2.2",
"main": "index.js",

@@ -5,0 +5,0 @@ "description": "The plugin on enhanced-resolver to map module path",

@@ -88,3 +88,3 @@ # absolute-module-mapper-plugin

- Type: `(filename, ctx) => string | {}`
- Type: `(filename, ctx) => string | (filename, ctx, callback) => void | {}`
- Example

@@ -101,3 +101,3 @@ ```javascript

- Type: `(request, ctx) => string | {}`
- Type: `(request, ctx) => string | (request, ctx, callback) => void | {}`
- Example

@@ -104,0 +104,0 @@ ```javascript

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