Skip to content

Commit

Permalink
avoid warning in webpack loader executor
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed Jan 31, 2023
1 parent 9eea531 commit c60c306
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 c60c306

Please sign in to comment.