Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: use require.resolve and remove resolve dependency #6752

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bluwy
Copy link
Contributor

@bluwy bluwy commented Sep 18, 2024

What this PR solves / how to test

Fixes N/A

It looks like we can simplify the resolve using require.resolve, similar to how other parts of the codebase that also does so:

return require.resolve(specifier, { paths: [referrer] });

// resolve with node resolution
path: require.resolve(aliasPath, {
// From the esbuild alias docs: "Note that when an import path is substituted using an alias, the resulting import path is resolved in the working directory instead of in the directory containing the source file with the import path."
// https://esbuild.github.io/api/#alias:~:text=Note%20that%20when%20an%20import%20path%20is%20substituted%20using%20an%20alias%2C%20the%20resulting%20import%20path%20is%20resolved%20in%20the%20working%20directory%20instead%20of%20in%20the%20directory%20containing%20the%20source%20file%20with%20the%20import%20path.
paths: [entry.directory],
}),

This allows the package to drop the resolve dependency, which isn't used anywhere else in the wrangler prod dependency graph.

Author has addressed the following

  • Tests
    • TODO (before merge)
    • Tests included
    • Tests not necessary because: refactors code
  • E2E Tests CI Job required? (Use "e2e" label or ask maintainer to run separately)
    • I don't know
    • Required
    • Not required because: refactors code
  • Changeset (Changeset guidelines)
    • TODO (before merge)
    • Changeset included
    • Changeset not necessary because:
  • Public documentation
    • TODO (before merge)
    • Cloudflare docs PR(s):
    • Documentation not necessary because: internal refactor

@bluwy bluwy requested a review from a team as a code owner September 18, 2024 18:00
Copy link

changeset-bot bot commented Sep 18, 2024

🦋 Changeset detected

Latest commit: 7d0b36c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
wrangler Patch
@cloudflare/vitest-pool-workers Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Untriaged
Development

Successfully merging this pull request may close these issues.

1 participant