本文整理汇总了TypeScript中enhanced-resolve/lib/getInnerRequest.default函数的典型用法代码示例。如果您正苦于以下问题:TypeScript default函数的具体用法?TypeScript default怎么用?TypeScript default使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了default函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: callback
return (request, callback) => {
let innerRequest = getInnerRequest(resolver, request);
if (!innerRequest) {
return callback();
}
let match = innerRequest.match(mapping.aliasPattern);
if (!match) {
return callback();
}
let newRequestStr = mapping.target;
if (!mapping.onlyModule) {
newRequestStr = newRequestStr.replace('*', match[1]);
}
if (newRequestStr[0] === '.') {
newRequestStr = path.resolve(this.absoluteBaseUrl, newRequestStr);
}
let newRequest = _.extend({}, request, {
request: newRequestStr
}) as Request;
return resolver.doResolve(
this.target,
newRequest,
"aliased with mapping '" + innerRequest + "': '" + mapping.alias + "' to '" + newRequestStr + "'",
createInnerCallback(
function(err, result) {
if (arguments.length > 0) {
return callback(err, result);
}
// don't allow other aliasing or raw request
callback(null, null);
},
callback
)
);
};
示例2: async
async (request: NormalModuleFactoryRequest, resolveContext: {}) => {
if (!request || request.typescriptPathMapped) {
return;
}
const originalRequest = getInnerRequest(resolver, request);
if (!originalRequest) {
return;
}
// Only work on Javascript/TypeScript issuers.
if (!request.context.issuer || !request.context.issuer.match(/\.[jt]sx?$/)) {
return;
}
// Relative or absolute requests are not mapped
if (originalRequest.startsWith('.') || originalRequest.startsWith('/')) {
return;
}
// Amd requests are not mapped
if (originalRequest.startsWith('!!webpack amd')) {
return;
}
const replacements = findReplacements(originalRequest, this._options.paths || {});
for (const potential of replacements) {
const potentialRequest = {
...request,
request: path.resolve(this._options.baseUrl || '', potential),
typescriptPathMapped: true,
};
const result = await resolveAsync(potentialRequest, resolveContext);
if (result) {
return result;
}
}
},