Treat missing source map sources as non-fatal during SSR
See original GitHub issueClear and concise description of the problem
Some NPM packages include source maps that reference sources which were not included as part of the package. For example, the Material Components reference the original Typescript sources in their source maps. When loading such a module for SSR, the missing sources cause Vite to throw an error.
A simple repro (after installing vite
and @material/ripple
):
const {createServer} = require('vite');
async function run() {
const vite = await createServer();
vite.ssrLoadModule('@material/ripple');
}
run();
results in:
node:internal/process/promises:218
triggerUncaughtException(err, true /* fromPromise */);
^
[Error: ENOENT: no such file or directory, open '/home/repos/vite-issue/node_modules/@material/ripple/index.ts'] {
errno: -2,
code: 'ENOENT',
syscall: 'open',
path: '/home/repos/vite-issue/node_modules/@material/ripple/index.ts'
}
Suggested solution
Ignore missing sources in source maps.
Additional context
I ran into this issue when trying to set up SvelteKit with Material Components. I think it’s not uncommon for packages to not ship sources that are referenced in source maps so it would be nice for Vite to ignore such situations instead of having package authors fix their source maps.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:15
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Angular 12 source map is missing in browser - Stack Overflow
I am on Angular 13 and I'm struggling to get the sourceMaps in order to debug. Anyone has had the issue on the...
Read more >Devtool - webpack
devtool performance production quality
(none) build: fastest rebuild: fastest yes bundle
eval build: fast rebuild: fastest no generated
eval‑cheap‑source‑map build: ok rebuild: fast no transformed
Read more >Source-maps could be revealing your private project files
Source -maps could be revealing your private project files. You could be making your frontend application source code public by mistake with ...
Read more >emirates crash history - MetamorfosiWeb
Col Dr The crash forced Dubai International Airport, the world's busiest for international travel, to temporarily close, and remains the worst incident in...
Read more >Source maps in Node.js. Supporting the many flavors of…
ts file mapping to its compiled .js version, and for 1 to many mappings, e.g., many sources being minified into a single source...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I hope it would continue to warn, but I agree this should not be an error. It is helpful to know when source maps are broken so that they can be fixed. Supabase fixed their sourcemaps as a result of this being surfaced https://github.com/supabase/supabase-js/issues/153
This seems to be fixed now. Here’s a stackblitz link to reproduce it. The logs now show:
without crashing.