FeaturesTemplatesShowcaseTownie
AI
BlogDocsPricing
Log inSign up
stevekrouse
stevekrouseesmTownTranspileDemo
Public
Like
2
esmTownTranspileDemo
Home
Code
2
README.md
main.tsx
Branches
1
Pull requests
Remixes
3
History
Environment variables
Settings
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in miliseconds.
Sign up now
Code
/
Code
/
Search
README.md

Val Town's esm.town Transpiles TypeScript and JSX for browsers

When Val Town's code registry (esm.town) gets a request from a browser (which it can detect via the User Agent header), it transpiles that val's code to web-standard JavaScript be able to run in the browser.

It doesn't do as much as other transpilers (such as esm.sh, such as rewriting npm: imports, etc). We may add that capability in the future. For now, if you want your npm imports to run in the browser, use https://esm.sh/package instead of npm:package.

The below script demonstrates this transiplation behavior by fetching its own source code (import.meta.url) with the user agent of a browser. You can uncoment the line setting the browser agent if you want to see the difference in the output. Or you could just load this val's module URL in your browser to see the untranspiled TS.

As of July 23, 2024, this is the code that determines when esm.town transpiles or not:

image.png

Migrated from folder: Archive/esmTownTranspileDemo

Code
README.mdmain.tsx
Go to top
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Product
FeaturesPricing
Developers
DocsStatusAPI ExamplesNPM Package Examples
Explore
ShowcaseTemplatesNewest ValsTrending ValsNewsletter
Company
AboutBlogCareersBrandhi@val.town
Terms of usePrivacy policyAbuse contact
© 2025 Val Town, Inc.