stackblitz / stackblitz/sdk

Feature request: API method to restart project / reinstall dependencies after changing package.json

Open
#35 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
50
Forks
32
PR merge metrics
No merged PRs in 30d

Description

Description

Currently, when using the JavaScript SDK’s vm.applyFsDiff to modify package.json, the changes are written to the file system but do not trigger dependency installation or restart the dev server. This means:

  • Newly added dependencies are not installed until the entire embed is reloaded.
  • Changes to scripts, startCommand, or other config have no effect until reload.
  • The only workaround is to reload the iframe, which resets runtime state and is disruptive.

Live example

https://mkucmus.github.io/scoped-template-launcher/?branch=main

  • template launcher alters the package.json via vm.applyFsDiff method for corresponding project via embedGithubProject
  • stackblitz does not detect the change and the packages aren't installed

Proposed solution

Introduce an API method in the SDK that allows developers to programmatically re-run the initialization flow after changes to package.json, without destroying the VM session. For example:

await vm.installDependencies(); // installs based on current package.json
await vm.restart(); // restarts dev server with updated config

Benefits

  • Smoother UX for dynamic demos where dependencies or commands change on the fly
  • No need to reload iframe → preserves state
  • Consistent with how StackBlitz handles package.json on initial project load

Example use cases

  • Adding a dependency on user action (e.g., “Add Tailwind CSS” button in a tutorial)
  • Switching between example setups with different dependency sets
  • Editing startCommand or build config dynamically

References

Contributor guide

No contributing guide indexed for this repository

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 by tracing the JavaScript SDK's vm.applyFsDiff entry point and the initialization flow it currently does not trigger. Define how dependency installation and dev-server restart should work without destroying the VM session, then verify that package.json changes affect dependencies and configuration without an iframe reload.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
api
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.