Skip to content

Commit

Permalink
fix: compile not sending template on hot reload
Browse files Browse the repository at this point in the history
  • Loading branch information
DeMoorJasper committed Apr 21, 2022
1 parent c583ca2 commit f688c31
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
3 changes: 1 addition & 2 deletions sandpack-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
"build:types": "tsc -p tsconfig.json",
"lint": "tslint -t codeFrame 'src/**/*.ts' 'test/**/*.ts'",
"build:publish": "yarn build && gulp",
"build:bundler": "gulp",
"start": "tsc -p tsconfig.esm.json --watch"
"build:bundler": "gulp"
},
"files": [
"dist",
Expand Down
14 changes: 10 additions & 4 deletions sandpack-client/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,10 @@ export class SandpackClient {
sandboxInfo = this.sandboxInfo,
isInitializationCompile?: boolean
): void {
this.sandboxInfo = sandboxInfo;
this.sandboxInfo = {
...this.sandboxInfo,
...sandboxInfo,
};

const files = this.getFiles();

Expand Down Expand Up @@ -279,6 +282,11 @@ export class SandpackClient {
{}
);

const template =
this.sandboxInfo.template || getTemplate(packageJSON, normalizedModules);

console.log({ template, sandboxInfo: this.sandboxInfo });

this.dispatch({
type: "compile",
codesandbox: true,
Expand All @@ -290,9 +298,7 @@ export class SandpackClient {
hasFileResolver: Boolean(this.options.fileResolver),
disableDependencyPreprocessing:
this.sandboxInfo.disableDependencyPreprocessing,
template:
this.sandboxInfo.template ||
getTemplate(packageJSON, normalizedModules),
template,
showOpenInCodeSandbox: this.options.showOpenInCodeSandbox ?? true,
showErrorScreen: this.options.showErrorScreen ?? true,
showLoadingScreen: this.options.showLoadingScreen ?? true,
Expand Down

0 comments on commit f688c31

Please sign in to comment.