Skip to content

Commit

Permalink
Merge c60c306 into 7b4cf1e
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed Jan 31, 2023
2 parents 7b4cf1e + c60c306 commit 27bd331
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions crates/turbopack-ecmascript/js/src/runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,9 @@ function externalRequire(id, esm) {
interopEsm(raw, ns, true);
return ns;
}
externalRequire.resolve = (name, opt) => {
return require.resolve(name, opt);
};

/**
* @param {ModuleId} from
Expand Down
8 changes: 6 additions & 2 deletions crates/turbopack-node/js/src/transforms/webpack-loaders.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
declare const __turbopack_external_require__: (id: string) => any;
declare const __turbopack_external_require__: {
resolve: (name: string, opt: { paths: string[] }) => string;
} & ((id: string) => any);

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

0 comments on commit 27bd331

Please sign in to comment.