Importing transpiled JS (imports with JS extensions) #19225
-
This is probably super basic, but I can't find it anywhere - but also don't know where to look because I'd think it spans a few different areas. Anyway, I prefer to import ESM modules with JS extensions in my Typescript project. One use case is in SPAs where I just want my JS side by side with my TS in my file structure. And second, for a library where I my JS files get transpiled to the root and I publish this file list to NPM at the root. How is this accomplished? It looks like ESBuild publishes to some sort of internal cache by default. So one step would be to change this behavior. But even then, if I'm importing JS files instead of TS, it looks like the TS files aren't watched, so making any changes doesn't trigger page reloading. I have a task working reasonably well where I just set up TSC to watch for transpile, and then once the JS files are generated Vite will reload the page. But this seems a bit indirect, and I'd assume I'm missing some configuration to get this working all with Vite (and ESBuild). Any hints? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Never mind! It looks like JS imports are fine, but not in the HTML entry point. There, if I import the .ts file, everything else woks fine |
Beta Was this translation helpful? Give feedback.
Never mind! It looks like JS imports are fine, but not in the HTML entry point. There, if I import the .ts file, everything else woks fine