Skip to content

Conversation

jasnell
Copy link
Collaborator

@jasnell jasnell commented Sep 19, 2025

  • Disable new module registry for python workers. There are a number of nuances with how python workers are registered and I want to work with @dom96 and @hoodmane to get those worked through. Nothing in python workers would directly depend on or immediately benefit from the new module registry stuff so disabling for now makes the most sense.
  • Improve normalization of module names from the user bundle, with tests

Specifically on the second bullet point... All modules provided by the user bundle must remain subordinate to the bundle root (default file:///bundle/), which means if the worker bundle happens to use a name like ../foo, we don't want that module id to be file:///foo, we still want it to be file:///bundle/foo. The handling here to tolerant of silliness. If the name in the worker bundle is something like /.././/./..//.////../../foo, then it'll still be resolved to file:///bundle/foo. Leading whitespace, /s, single-dot, and double dot segments will be removed such that the resolution against the base file:///bundle/ works correctly.

The PR also fixes up handling of the case where the module name is using non-ASCII characters. These will be converted to UTF-8 both in the bundle and in the source and the original handling code was not interpreting those correctly. Tests are added to verify correct handling.

@jasnell jasnell requested review from a team as code owners September 19, 2025 23:16
@jasnell jasnell requested a review from guybedford September 19, 2025 23:24
@jasnell jasnell force-pushed the jasnell/start-enabling-nmr-internal branch from 9f0546e to 140fa60 Compare September 23, 2025 00:16
@jasnell jasnell requested a review from guybedford September 23, 2025 11:57
* Disable new module registry for python workers
* Improve normalization of module names from the
  user bundle, with tests
Ensure that module specifiers cannot escape the bundle base URL
using relative path leading dot segments.

Ignore leading whitespace in module specifiers.

Ensure correct handling of Unicode characters in module specifiers.
@jasnell jasnell force-pushed the jasnell/start-enabling-nmr-internal branch from 140fa60 to dd00a33 Compare September 23, 2025 21:14
@jasnell jasnell requested a review from guybedford September 23, 2025 21:18
Copy link
Contributor

@guybedford guybedford 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 taking on board the feedback and terminology discussion. Depending on how normalizeModuleName is used it might well be a specifier function after all - basically "module specifier" for any string that is at the very beginning of the pipeline and will yet go through every single step of module resolution rules (including possible package mappings / import mappings), while everything else gets named according to where it is in the pipeline helps a lot in ensuring consistent processing.

Because I saw this used for addSyntheticModule, etc. which I'd assumed would apply to at least path-like module names, that's the reason I was wondering if it's not a specifier but rather a path-like -input. Good to have the terminology discussion though anyway.

Just one remaining question otherwise great to land.

@jasnell
Copy link
Collaborator Author

jasnell commented Sep 23, 2025

normalizeModuleName is only used when we are building the module registry from the worker bundle. It is not used during module resolution.

@jasnell jasnell merged commit b3dd0fd into main Sep 23, 2025
21 of 24 checks passed
@jasnell jasnell deleted the jasnell/start-enabling-nmr-internal branch September 23, 2025 22:38
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