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(nodebox): consider new files from Sandpack #778

Merged
merged 3 commits into from
Feb 28, 2023
Merged
Show file tree
Hide file tree
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
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