Skip to content

feat: dont underscore numbers when formatting module names #710

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

c43721
Copy link

@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