Skip to content

Commit

Permalink
fix(nodebox): consider new files from Sandpack (#778)
Browse files Browse the repository at this point in the history
  • Loading branch information
danilowoz authored Feb 28, 2023
1 parent 373ab43 commit 877222e
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .codesandbox/ci.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"packages": ["sandpack-client", "sandpack-react"],
"sandboxes": ["sowx8r", "909l3f"],
"sandboxes": ["sowx8r"],
"node": "16"
}
5 changes: 4 additions & 1 deletion sandpack-client/src/clients/node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,10 @@ export class SandpackNode extends SandpackClient {
*/
if (this.emulatorShellProcess?.state === "running") {
Object.entries(modules).forEach(([key, value]) => {
if (Buffer.compare(value, this._modulesCache.get(key)) !== 0) {
if (
!this._modulesCache.get(key) ||
Buffer.compare(value, this._modulesCache.get(key)) !== 0
) {
this.emulator.fs.writeFile(key, value);
}
});
Expand Down
3 changes: 2 additions & 1 deletion sandpack-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"prebuild": "yarn run clean",
"test": "TEST_ENV=true jest . --transformIgnorePatterns \"node_modules/(?!@codemirror)/\" --modulePathIgnorePatterns \"e2e\"",
"lint": "eslint '**/*.ts?(x)' --fix",
"build": "rollup -c",
"build": "rollup -c && yarn build:types",
"build:types": "tsc -p tsconfig.json",
"build:publish": "yarn build",
"start": "tsc -p tsconfig.esm.json --watch",
"dev": "start-storybook -p 6006 --quiet",
Expand Down
28 changes: 11 additions & 17 deletions sandpack-react/src/Playground.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,31 +1,25 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import * as themes from "@codesandbox/sandpack-themes";
import React from "react";

import { Sandpack } from "./presets";
import { SandpackProvider } from ".";
import {
SandpackCodeEditor,
SandpackFileExplorer,
SandpackPreview,
} from "./components";

export default {
title: "Intro/Playground",
};

export const Basic: React.FC = () => {
const [text, setText] = React.useState("world");
return (
<>
<input
defaultValue={text}
onChange={({ target }) => setText(target.value)}
/>
<Sandpack
files={{
"App.js": `export default function App() {
return <h1>Hello ${text}</h1>
}
`,
}}
template="react"
theme={themes.sandpackDark}
/>
<SandpackProvider template="nextjs" theme={themes.sandpackDark}>
<SandpackFileExplorer />
<SandpackCodeEditor />
<SandpackPreview />
</SandpackProvider>
</>
);
};
3 changes: 2 additions & 1 deletion sandpack-themes/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"scripts": {
"clean": "rm -rf dist",
"prebuild": "yarn run clean",
"build": "rollup -c",
"build": "rollup -c && yarn build:types",
"build:types": "tsc -p tsconfig.json",
"build:publish": "yarn build",
"typecheck": "tsc"
},
Expand Down

1 comment on commit 877222e

@vercel
Copy link

@vercel vercel bot commented on 877222e Feb 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

sandpack-docs – ./website/docs

sandpack.vercel.app
sandpack-docs-git-main-codesandbox1.vercel.app
sandpack-docs-codesandbox1.vercel.app

Please sign in to comment.