sveltejs / sveltejs/kit

(Better) Node.js builtin emulation for client-side JS

Open
#8,307 10 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

documentation
Dominant language
JavaScript
Stars
20.8k
Forks
2.3k
Avg merge
1d 16h
Merged PRs (30d)
156

Description

Describe the problem

I've found many NPM packages that almost work in SvelteKit client-side JS, but their access to node builtins like process and buffer results in errors. For example:

There is a work-around for these errors, but it's neither obvious nor simple:

Most average Svelte devs may just assume it's not possible (like I did at first).

Describe the proposed solution

Ideally SvelteKit would provide something similar to Parcel's Polyfilling & Excluding Builtin Node Modules

The SvelteKit DX would be greatly enhanced by integrating the work-arounds linked above as either default or optional configurations.

If the work-arounds are not included (by default), detecting this class of error and giving meaningful error messages pointing to the correct work-arounds would still be very helpful.

Alternatives considered
  • It is possible to use the work-arounds linked above.
  • Limiting use of the problem modules to server-side JS, and wrapping with internal endpoints.
Importance

would make my life easier

Additional Information

Simple repro demonstrating problem:

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked minimal reproduction and its node-builtins-bug branch, then review the reported process, buffer, and path failures alongside the linked Vite and Parcel guidance. Done would require an agreed SvelteKit approach for client-side Node builtin emulation, or actionable diagnostics that direct users to supported workarounds.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js, vite
Domain
build-system, frontend, web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.