feat: dont underscore numbers when formatting module names #710
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Redo of #655
Contributes to jsr-io/jsr#803
I eventually got here by looking at how the identifier for the file was created:

The identifier replacing all non-characters with underscores seems to be the source so adjusting the regex to allow numbers.
The regex accounts for leading numbers, as they're invalid identifiers. So as long as your moduel doesn't start with a number, you can have numbers or letters in your identifier name.
If need be, can make
e.ts
that can assert all of the following; leading numbers are replaced, numbers are allowed, and special characters are replaced. I'd be more than happy to expand the test suite to include this. Not sure what makes sense from a practical standpoint though.Testing strategy includes running the snapshot tests and asserting both the module name is
bar123
as well as locally inspecting the generated HTML to seeimport ... as bar123 from ...