Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: reload if included server.js files #356

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/lib/client/adapters/webcontainer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ export async function create(base, error, progress, logs) {

const force_delete = [];

let include_server_files = false;

for (const stub of stubs) {
if (stub.name.endsWith('/__delete')) {
force_delete.push(stub.name.slice(0, -9));
Expand All @@ -136,6 +138,10 @@ export async function create(base, error, progress, logs) {

if (current?.contents !== stub.contents) {
to_write.push(stub);

if (!include_server_files || stub.basename.endsWith('server.js')) {
include_server_files = true;
}
}
} else {
// always add directories, otherwise convert_stubs_to_tree will fail
Expand Down Expand Up @@ -189,7 +195,7 @@ export async function create(base, error, progress, logs) {

// Also trigger a reload of the iframe in case new files were added / old ones deleted,
// because that can result in a broken UI state
const should_reload = !launched || will_restart || to_delete.length > 0;
const should_reload = !launched || will_restart || to_delete.length > 0 || include_server_files;

await launch();

Expand Down