Skip to content

Commit

Permalink
Use esbuild plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
nickbabcock committed Nov 27, 2024
1 parent 860da9d commit 1d89a0c
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions packages/wrangler/src/deployment-bundle/module-collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,10 @@ export function createModuleCollector(props: {
build.onResolve(
{ filter: globToRegExp(glob) },
async (args: esbuild.OnResolveArgs) => {
if (args.pluginData?.skip) {
return;
}

// take the file and massage it to a
// transportable/manageable format

Expand All @@ -264,9 +268,16 @@ export function createModuleCollector(props: {
// and if so, validate the import against the package.json exports
// and resolve the file path to the correct file.
try {
filePath = require.resolve(args.path, {
paths: [args.resolveDir],
const resolved = await build.resolve(args.path, {
kind: "import-statement",
resolveDir: args.resolveDir,
pluginData: {
skip: true,
},
});
if (resolved.path) {
filePath = resolved.path;
}
} catch (ex) {
// We tried, now it'll just fall-through to the previous behaviour
// and ENOENT if the absolute file path doesn't exist.
Expand Down

0 comments on commit 1d89a0c

Please sign in to comment.