Skip to content

Conversation

@kdziamura
Copy link
Contributor

Closes #17403

@CLAassistant
Copy link

CLAassistant commented Jan 13, 2023

CLA assistant check
All committers have signed the CLA.

}
let invalid_segment_re =
Regex::new(r"(^|\|/)(..?|node_modules)(\|/|$)").expect("bad regex");
Regex::new(r"(^|\\|/)(\.\.?|node_modules)?(\\|/|$)").expect("bad regex");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The corresponding regex in the node codebase:

https://github.com/nodejs/node/blob/f5dc92cff34933fc4a4685765afbba085f081b36/lib/internal/modules/esm/resolve.js#L299

After cleanup I found that not only escaping symbols are missed but also the question mark

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I reverted the optional regex group change because I found that it was introduced in this PR (related to double slash deprecation), after the deno impelementation so I guess, it's enough to have the deprecated version for now

@kdziamura kdziamura force-pushed the node_resolution_regex branch from a193f5f to b46a8c7 Compare January 13, 2023 21:34
@bartlomieju
Copy link
Member

Cool, thanks for the fix! Any chance you could add some tests that exercise this changed regex? I believe they should be added to cli/tests/testdata/npm/conditional_exports/main.js and cli/tests/testdata/npm/registry/@denotest/conditional-exports/1.0.0/package.json. You can run the test by doing cargo test npm::conditional_exports

@kdziamura
Copy link
Contributor Author

Sure! Just wanted to ask about tests. Thanks for the quick comment!

@kdziamura kdziamura force-pushed the node_resolution_regex branch from 7920aad to 7149c7f Compare January 13, 2023 22:30
@kdziamura
Copy link
Contributor Author

Added a test case and reverted the optional regex group change, see #17404 (comment)

@kdziamura
Copy link
Contributor Author

The failed test seems to be unrelated. Can it be flaky?

@bartlomieju
Copy link
Member

The failed test seems to be unrelated. Can it be flaky?

That's possible, I restarted the CI

Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

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

LGTM! I confirmed the test fails on main but this PR fixes it. Very nice first contribution @wontem, thanks!

@bartlomieju bartlomieju merged commit 934ed8e into denoland:main Jan 13, 2023
bartlomieju pushed a commit that referenced this pull request Jan 16, 2023
Fixes regex for matching conditional exports in a package.
Updated to the same regex Node.js uses.
MierenManz added a commit to MierenManz/oned that referenced this pull request Jan 20, 2023
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.

Node modules resolution fails for a valid exports configuration

3 participants