Skip to content

feat: dont underscore numbers when formatting module names#710

Open
c43721 wants to merge 1 commit into
denoland:mainfrom
c43721:dev/c43721/803-second
Open

feat: dont underscore numbers when formatting module names#710
c43721 wants to merge 1 commit into
denoland:mainfrom
c43721:dev/c43721/803-second

Conversation

@c43721
Copy link
Copy Markdown

@c43721 c43721 commented Apr 11, 2025

Redo of #655

Contributes to jsr-io/jsr#803

I eventually got here by looking at how the identifier for the file was created:
image

image

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 see import ... as bar123 from ...

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.

1 participant