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 Feb 1, 2023
1 parent 8632812 commit 4fa5c32
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 @@ -58,7 +60,9 @@ const transform = (
},
},
loaders: loadersWithOptions.map((loader) => ({
loader: require.resolve(loader.loader, { paths: [resourceDir] }),
loader: __turbopack_external_require__.resolve(loader.loader, {
paths: [resourceDir],
}),
options: loader.options,
})),
readResource: (_filename, callback) => {
Expand Down

0 comments on commit 4fa5c32

Please sign in to comment.