Make dev environment match production environment more closely
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 20.8k
- Forks
- 2.3k
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 156
Description
Describe the problem
I'm not sure if this is a bug so much as a discussion I'd like to have. One basic premise of sveltekit is that we have a local dev experience that matches closely to the production experience.
I find that one area where this promise is broken is when you try to render-on-demand rather than prerender, because it is very common for serverless environments (netlify, vercel et al) to separately bundle and run the serverless function. So, if I have a page that is only rendered on demand, its very easy for me to code a file read that works in dev, but then breaks when done in prod:
import { resolve } from 'path';
import { promises as fs } from 'fs';
const x = await fs.readFile(resolve('./podcasts.yml'), 'utf8')
this code works fine in dev, but then deploy it and...
{"errorType":"Runtime.UnhandledPromiseRejection","errorMessage":"Error: ENOENT: no such file or directory, open '/var/task/podcasts.yml'","trace":["Runtime.UnhandledPromiseRejection: Error: ENOENT: no such file or directory, open '/var/task/podcasts.yml'"," at process.<anonymous> (/var/runtime/index.js:35:15)"," at process.emit (events.js:400:28)"," at processPromiseRejections (internal/process/promises.js:245:33)"," at processTicksAndRejections (internal/process/task_queues.js:96:32)"]}
Describe the proposed solution
i think we should try to shift this problem left - if the page is serverless, actually compile the function and make it properly isolated as it would be in prod
Alternatives considered
do nothing, let people fumble around with this new serverless rendering paradigm :(
for what its worth i'm a veteran Netlify user, spent multiple hours trying to figure out how to get around this and still havent got anything i'm really happy with (apart from brute force copying the file postbuild into the built folder, which really feels super janky and not great)
Importance
would make my life easier
Additional Information
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the difference between local rendering and a separately bundled serverless deployment using the podcasts.yml file-read example. Investigate how serverless pages are built and isolated, then define done as development behavior exposing the same missing-file failures or asset handling as production.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- build-system, cloud
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100