question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Treat missing source map sources as non-fatal during SSR

See original GitHub issue

Clear 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:closed
  • Created 2 years ago
  • Reactions:15
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
benmccanncommented, Apr 21, 2021

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

0reactions
bluwycommented, Mar 6, 2022

This seems to be fixed now. Here’s a stackblitz link to reproduce it. The logs now show:

Sourcemap for "/home/projects/node-zfq2wn/node_modules/@material/ripple/index.js" points to missing source files
Sourcemap for "/home/projects/node-zfq2wn/node_modules/@material/ripple/util.js" points to missing source files
Sourcemap for "/home/projects/node-zfq2wn/node_modules/@material/ripple/adapter.js" points to missing source files
Sourcemap for "/home/projects/node-zfq2wn/node_modules/@material/ripple/constants.js" points to missing source files
Sourcemap for "/home/projects/node-zfq2wn/node_modules/@material/ripple/types.js" points to missing source files
Sourcemap for "/home/projects/node-zfq2wn/node_modules/@material/ripple/foundation.js" points to missing source files
Sourcemap for "/home/projects/node-zfq2wn/node_modules/@material/ripple/component.js" points to missing source files
Sourcemap for "/home/projects/node-zfq2wn/node_modules/@material/base/foundation.js" points to missing source files
Sourcemap for "/home/projects/node-zfq2wn/node_modules/@material/dom/events.js" points to missing source files
Sourcemap for "/home/projects/node-zfq2wn/node_modules/@material/dom/ponyfill.js" points to missing source files
Sourcemap for "/home/projects/node-zfq2wn/node_modules/@material/base/component.js" points to missing source files

without crashing.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found