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

feat: add util function to generate module paths #763

Merged
merged 7 commits into from
Oct 11, 2024
Merged

Conversation

thiagobrez
Copy link
Contributor

Summary

This PR introduces the getModulePaths util function, to generate module path regexes for both classic (npm, yarn) and exotic (pnpm) paths, to be used in the bundler config file include rules.

This function will be available for both internal and public use.

Test plan

Tests to classic and exotic module paths are included, also taking in consideration nested packages and backslashes from Windows systems.

@thiagobrez thiagobrez requested a review from jbroma October 6, 2024 18:47
Copy link

changeset-bot bot commented Oct 6, 2024

🦋 Changeset detected

Latest commit: 6481f3b

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

This PR includes changesets to release 3 packages
Name Type
@callstack/repack Minor
@callstack/repack-dev-server Minor
@callstack/repack-init Minor

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

Copy link

vercel bot commented Oct 6, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
repack-website ⬜️ Ignored (Inspect) Visit Preview Oct 8, 2024 5:52pm

Copy link
Member

@jbroma jbroma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the PR! The logic is sound 🎉, we just need to work on the API and simplify the tests a little bit, see the comments below

packages/repack/src/utils/getModulePaths.test.ts Outdated Show resolved Hide resolved
packages/repack/src/utils/getModulePaths.test.ts Outdated Show resolved Hide resolved
packages/repack/src/utils/getModulePaths.ts Outdated Show resolved Hide resolved
packages/repack/src/utils/getModulePaths.test.ts Outdated Show resolved Hide resolved
packages/repack/src/utils/getModulePaths.test.ts Outdated Show resolved Hide resolved
@thiagobrez
Copy link
Contributor Author

@jbroma Pushed the requested changes!

Let me know what you think about the new test structure. I separated it into logical tests (classic, exotic, backslashes) and think it's much better.

Although I had to do some massaging in the regex array returned from the function to be able to have some more scalable tests.

Copy link
Member

@jbroma jbroma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🎉

@jbroma jbroma merged commit e433584 into main Oct 11, 2024
5 checks passed
@jbroma jbroma deleted the feat/get-module-paths branch October 11, 2024 10:18
@jbroma
Copy link
Member

jbroma commented Oct 11, 2024

Thank you for working on this @thiagobrez, very useful stuff 🔥

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

Successfully merging this pull request may close these issues.

2 participants