You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Requests that fall through here cannot be matched by any other externals config ahead.
1031
-
// Treat all these requests as relative import of source code. Node.js won't add the
1032
-
// leading './' to the relative path resolved by `path.relative`. So add manually it here.
1033
-
if(resolvedRequest[0]!=='.'){
1034
-
resolvedRequest=`./${resolvedRequest}`;
1031
+
1032
+
// only handle the request that is not in node_modules
1033
+
if(!resolvedRequest.includes('node_modules')){
1034
+
resolvedRequest=normalizeSlash(
1035
+
path.relative(
1036
+
path.dirname(contextInfo.issuer),
1037
+
resolvedRequest,
1038
+
),
1039
+
);
1040
+
// Requests that fall through here cannot be matched by any other externals config ahead.
1041
+
// Treat all these requests as relative import of source code. Node.js won't add the
1042
+
// leading './' to the relative path resolved by `path.relative`. So add manually it here.
1043
+
if(resolvedRequest[0]!=='.'){
1044
+
resolvedRequest=`./${resolvedRequest}`;
1045
+
}
1046
+
}else{
1047
+
// NOTE: If request is a phantom dependency, which means it can be resolved but not specified in dependencies or peerDependencies in package.json, the output will be incorrect to use when the package is published
1048
+
// return the original request instead of the resolved request
1049
+
returncallback(undefined,request);
1035
1050
}
1036
1051
}catch(e){
1052
+
// catch error when request can not be resolved by resolver
1037
1053
// e.g. A react component library importing and using 'react' but while not defining
1038
1054
// it in devDependencies and peerDependencies. Preserve 'react' as-is if so.
1039
-
logger.warn(
1055
+
logger.debug(
1040
1056
`Failed to resolve module ${color.green(`"${resolvedRequest}"`)} from ${color.green(contextInfo.issuer)}. If it's an npm package, consider adding it to dependencies or peerDependencies in package.json to make it externalized.`,
1041
1057
);
1042
1058
}
@@ -1271,6 +1287,7 @@ async function composeLibRsbuildConfig(
0 commit comments