pnp-webpack-plugin
Advanced tools
Comparing version 1.2.1 to 1.3.0
30
index.js
@@ -29,2 +29,9 @@ const path = require(`path`); | ||
function getDependencyLocator(sourceLocator, name) { | ||
const {packageDependencies} = pnp.getPackageInformation(sourceLocator); | ||
const reference = packageDependencies.get(name); | ||
return {name, reference}; | ||
} | ||
function getSourceLocation(sourceLocator) { | ||
@@ -45,7 +52,7 @@ if (!sourceLocator) | ||
function makeResolver(sourceLocator) { | ||
function makeResolver(sourceLocator, filter) { | ||
const sourceLocation = getSourceLocation(sourceLocator); | ||
return resolver => { | ||
const MAYBE_BUILTIN = /^[^\/]$/; | ||
const BACKWARD_PATH = /^\.\.([\\\/]|$)/; | ||
@@ -66,3 +73,3 @@ const resolvedHook = resolver.ensureHook(`resolve`); | ||
let request = requestContext.request; | ||
let issuer = sourceLocation || requestContext.context.issuer; | ||
let issuer = requestContext.context.issuer; | ||
@@ -77,6 +84,15 @@ // When using require.context, issuer seems to be false (cf https://github.com/webpack/webpack-dev-server/blob/d0725c98fb752d8c0b1e8c9067e526e22b5f5134/client-src/default/index.js#L94) | ||
console.log([request, issuer, filter]); | ||
if (filter) { | ||
const relative = path.relative(filter, issuer); | ||
if (path.isAbsolute(relative) || BACKWARD_PATH.test(relative)) { | ||
return callback(null); | ||
} | ||
} | ||
let resolutionIssuer = sourceLocation || issuer; | ||
let resolution; | ||
try { | ||
resolution = pnp.resolveToUnqualified(request, issuer, {considerBuiltins: false}); | ||
resolution = pnp.resolveToUnqualified(request, resolutionIssuer, {considerBuiltins: false}); | ||
} catch (error) { | ||
@@ -117,4 +133,10 @@ return callback(error); | ||
module.exports.bind = (filter, module, dependency) => pnp ? { | ||
apply: makeResolver(getDependencyLocator(getModuleLocator(module), dependency), filter), | ||
} : { | ||
apply: nothing, | ||
}; | ||
module.exports.tsLoaderOptions = (options = {}) => pnp ? Object.assign({}, options, { | ||
resolveModuleName: require('ts-pnp').resolveModuleName, | ||
}) : options; |
{ | ||
"name": "pnp-webpack-plugin", | ||
"version": "1.2.1", | ||
"version": "1.3.0", | ||
"description": "plug'n'play resolver for Webpack", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
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
10734
161