Skip to content

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

@mkucmus

Description

@mkucmus

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions