Skip to content

Commit 27bd331

Browse files
authored
Merge c60c306 into 7b4cf1e
2 parents 7b4cf1e + c60c306 commit 27bd331

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

crates/turbopack-ecmascript/js/src/runtime.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,9 @@ function externalRequire(id, esm) {
197197
interopEsm(raw, ns, true);
198198
return ns;
199199
}
200+
externalRequire.resolve = (name, opt) => {
201+
return require.resolve(name, opt);
202+
};
200203

201204
/**
202205
* @param {ModuleId} from

crates/turbopack-node/js/src/transforms/webpack-loaders.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
declare const __turbopack_external_require__: (id: string) => any;
1+
declare const __turbopack_external_require__: {
2+
resolve: (name: string, opt: { paths: string[] }) => string;
3+
} & ((id: string) => any);
24

35
import type { Ipc } from "../ipc/evaluate";
46
import {
@@ -30,7 +32,9 @@ const transform = (ipc: Ipc, content: string, name: string, loaders: any[]) => {
3032
const resourceDir = dirname(resource);
3133
// TODO this should be handled in turbopack instead to ensure it's watched
3234
loaders = loaders.map((loader: any) => {
33-
return require.resolve(loader, { paths: [resourceDir] });
35+
return __turbopack_external_require__.resolve(loader, {
36+
paths: [resourceDir],
37+
});
3438
});
3539
runLoaders(
3640
{

0 commit comments

Comments
 (0)