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

Module name mapper regex #751

Merged
merged 2 commits into from
Jul 16, 2021

Conversation

StenCalDabran
Copy link

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[x] Bugfix
[x] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Other... Please describe:

What is the current behavior?

Issue Number: #750

What is the new behavior?

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

The first commit fixes the problem addressed in the issue. The second commit makes the generated moduleNameMapper entries more clear by only adding one entry per library.
The fixed original generated entry would be:

"moduleNameMapper": {
  "^@app/my-lib$": "<rootDir>/libs/my-lib/src",
  "^@app/my-lib/(.*)$": "<rootDir>/libs/my-lib/src/$1",
}

The new generated entry instead is:

"moduleNameMapper": {
  "^@app/my-lib(|/.*)$": "<rootDir>/libs/my-lib/src/$1",
}

It matches either an empty string or everything starting with a slash to be inserted into $1.
The trailing slash should present no problem.
However, I would understand if you only want to merge the fix commit, in that case I can change the PR.

using an optimized regex which matches either an empty string or the subpath after the packageRoot
@kamilmysliwiec
Copy link
Member

LGTM, thanks!

@kamilmysliwiec kamilmysliwiec merged commit 976bd33 into nestjs:master Jul 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants