Skip to content

Commit

Permalink
Merge branch 'main' of github.com:codesandbox/sandpack into feat/rtl-…
Browse files Browse the repository at this point in the history
…option
  • Loading branch information
jerrywu001 committed Mar 1, 2023
2 parents 0faab5b + 93a5b2d commit b58909c
Show file tree
Hide file tree
Showing 31 changed files with 575 additions and 1,569 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"
}
45 changes: 45 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,51 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [2.0.21](https://github.com/codesandbox/sandpack/compare/v2.0.20...v2.0.21) (2023-02-28)


### Bug Fixes

* **nodebox:** consider new files from Sandpack ([#778](https://github.com/codesandbox/sandpack/issues/778)) ([877222e](https://github.com/codesandbox/sandpack/commit/877222ef649ed741534709c834053eeefce70948))
* **sandpack-tests:** introduce `hideTestsAndSupressLogs` prop ([#775](https://github.com/codesandbox/sandpack/issues/775)) ([373ab43](https://github.com/codesandbox/sandpack/commit/373ab4329692820d6cb6760c88a21b0222708cc9))





## [2.0.20](https://github.com/codesandbox/sandpack/compare/v2.0.19...v2.0.20) (2023-02-28)


### Bug Fixes

* **sandpack-client:** setup build with rollup ([#758](https://github.com/codesandbox/sandpack/issues/758)) ([f645119](https://github.com/codesandbox/sandpack/commit/f6451194a718a0679ce5fcb4d64d1f0d58f6c146))





## [2.0.19](https://github.com/codesandbox/sandpack/compare/v2.0.18...v2.0.19) (2023-02-28)


### Bug Fixes

* **use-files:** watch prop keys changes ([#776](https://github.com/codesandbox/sandpack/issues/776)) ([987814f](https://github.com/codesandbox/sandpack/commit/987814f9ec0f7e455a645e69c1b51bda6aec7521))





## [2.0.18](https://github.com/codesandbox/sandpack/compare/v2.0.17...v2.0.18) (2023-02-28)


### Bug Fixes

* **sandpack-react:** open sandbox button ([#761](https://github.com/codesandbox/sandpack/issues/761)) ([430a0f5](https://github.com/codesandbox/sandpack/commit/430a0f5d13acc6da11e4108c8c4c82b35a0c7978))





## [2.0.17](https://github.com/codesandbox/sandpack/compare/v2.0.16...v2.0.17) (2023-02-24)


Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@
"message": "chore: [skip ci] bump packages"
}
},
"version": "2.0.17"
"version": "2.0.21"
}
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,15 @@
"@babel/preset-react": "^7.16.5",
"@babel/preset-typescript": "^7.16.5",
"@rollup/plugin-commonjs": "^24.0.0",
"@rollup/plugin-node-resolve": "^15.0.1",
"@rollup/plugin-replace": "^5.0.2",
"@rollup/plugin-terser": "^0.4.0",
"@rollup/plugin-typescript": "^10.0.1",
"@types/jest": "^27.4.0",
"@typescript-eslint/eslint-plugin": "^4.0.0",
"@typescript-eslint/parser": "^4.0.0",
"babel-eslint": "^10.0.0",
"babel-jest": "^27.4.5",
"esbuild": "^0.17.9",
"eslint": "^7.5.0",
"eslint-config-prettier": "^8.1.0",
"eslint-config-react-app": "^6.0.0",
Expand All @@ -52,15 +54,14 @@
"eslint-plugin-jsx-a11y": "^6.3.1",
"eslint-plugin-react": "^7.20.3",
"eslint-plugin-react-hooks": "^4.0.8",
"@esbuild-plugins/node-globals-polyfill": "0.1.1",
"jest": "^27.4.5",
"lerna": "^4.0.0",
"lerna-changelog": "^2.1.0",
"lint-staged": "^10.5.4",
"prettier": "^2.2.1",
"react-test-renderer": "^18.1.0",
"rollup": "^3.9.1",
"rollup-plugin-replace": "^2.2.0",
"rollup-plugin-string": "^3.0.0",
"turbo": "^1.5.5"
},
"lint-staged": {
Expand Down
22 changes: 22 additions & 0 deletions sandpack-client/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,28 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [2.0.21](https://github.com/codesandbox/sandpack/compare/v2.0.20...v2.0.21) (2023-02-28)


### Bug Fixes

* **nodebox:** consider new files from Sandpack ([#778](https://github.com/codesandbox/sandpack/issues/778)) ([877222e](https://github.com/codesandbox/sandpack/commit/877222ef649ed741534709c834053eeefce70948))





## [2.0.20](https://github.com/codesandbox/sandpack/compare/v2.0.19...v2.0.20) (2023-02-28)


### Bug Fixes

* **sandpack-client:** setup build with rollup ([#758](https://github.com/codesandbox/sandpack/issues/758)) ([f645119](https://github.com/codesandbox/sandpack/commit/f6451194a718a0679ce5fcb4d64d1f0d58f6c146))





## [2.0.17](https://github.com/codesandbox/sandpack/compare/v2.0.16...v2.0.17) (2023-02-24)


Expand Down
80 changes: 0 additions & 80 deletions sandpack-client/build.js

This file was deleted.

10 changes: 7 additions & 3 deletions sandpack-client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@codesandbox/sandpack-client",
"version": "2.0.17",
"version": "2.0.21",
"description": "",
"keywords": [],
"repository": {
Expand All @@ -12,16 +12,20 @@
"sideEffects": false,
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"exports": {
"./clients/runtime": {
"types": "./dist/clients/runtime/index.d.ts",
"import": "./dist/clients/runtime/index.mjs",
"require": "./dist/clients/runtime/index.js"
},
"./clients/node": {
"types": "./dist/clients/node/index.d.ts",
"import": "./dist/clients/node/index.mjs",
"require": "./dist/clients/node/index.js"
},
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.mjs",
"require": "./dist/index.js"
}
Expand All @@ -31,8 +35,7 @@
"prebuild": "yarn run clean",
"test": "jest .",
"lint": "eslint '**/*.ts?(x)' --fix",
"build": "node build.js && yarn run build:types",
"build:types": "tsc -p tsconfig.json",
"build": "rollup -c --bundleConfigAsCjs",
"build:publish": "yarn build && gulp",
"build:bundler": "gulp",
"format": "prettier --write '**/*.{ts,tsx,js,jsx}'",
Expand All @@ -47,6 +50,7 @@
],
"dependencies": {
"@codesandbox/nodebox": "0.1.0",
"buffer": "^6.0.3",
"dequal": "^2.0.2",
"outvariant": "1.3.0"
},
Expand Down
93 changes: 61 additions & 32 deletions sandpack-client/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,68 @@
const commonjs = require("@rollup/plugin-commonjs");
const typescript = require("@rollup/plugin-typescript");
const replace = require("rollup-plugin-replace");
import commonjs from "@rollup/plugin-commonjs";
import { nodeResolve } from "@rollup/plugin-node-resolve";
import replace from "@rollup/plugin-replace";
import terser from "@rollup/plugin-terser";
import typescript from "@rollup/plugin-typescript";
import { string } from "rollup-plugin-string";

const pkg = require("./package.json");
import pkg from "./package.json";

const configBase = {
input: "src/index.ts",
output: [
{
file: pkg.main,
exports: "named",
format: "cjs",
inlineDynamicImports: true,
interop: "auto",
},
{
file: pkg.module,
exports: "named",
const configs = [
{
input: "src/clients/node/inject-scripts/consoleHook.ts",
output: {
file: "src/clients/node/inject-scripts/dist/consoleHook.js",
format: "es",
inlineDynamicImports: true,
},
],
plugins: [
typescript({
tsconfig: "./tsconfig.json",
compilerOptions: { declaration: false },
}),
commonjs(),
nodeResolve(),
terser({ compress: { passes: 2 } }),
],
external: [],
},

{
input: {
index: "src/index.ts",
"clients/node/index": "src/clients/node/index.ts",
"clients/runtime/index": "src/clients/runtime/index.ts",
},
output: [
{
dir: "dist",
format: "cjs",
},
{
dir: "dist",
chunkFileNames: "[name]-[hash].mjs",
entryFileNames: "[name].mjs",
format: "es",
},
],

plugins: [
typescript({ tsconfig: "./tsconfig.json" }),
replace({
"process.env.CODESANDBOX_ENV": `"${process.env.CODESANDBOX_ENV}"`,
"process.env.PACKAGE_VERSION": `"${pkg.version}"`,
plugins: [
typescript({ tsconfig: "./tsconfig.json" }),
string({ include: "**/dist/consoleHook.js" }),
replace({
preventAssignment: true,
values: {
global: "globalThis",
"process.env.CODESANDBOX_ENV": `"${process.env.CODESANDBOX_ENV}"`,
"process.env.PACKAGE_VERSION": `"${pkg.version}"`,
},
}),
],
external: Object.keys({
...(pkg.dependencies || {}),
...(pkg.devDependencies || {}),
...(pkg.peerDependencies || {}),
}),
commonjs({ requireReturnsDefault: "preferred" }),
],
external: [
...Object.keys(pkg.dependencies),
...Object.keys(pkg.devDependencies),
],
};
},
];

module.exports = configBase;
export default configs;
2 changes: 2 additions & 0 deletions sandpack-client/src/clients/node/client.utils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Buffer } from "buffer";

import type { ShellCommandOptions } from "@codesandbox/nodebox/build/modules/shell";
import { invariant } from "outvariant";

Expand Down
7 changes: 6 additions & 1 deletion sandpack-client/src/clients/node/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/* eslint-disable no-console,@typescript-eslint/no-explicit-any,prefer-rest-params,@typescript-eslint/explicit-module-boundary-types */

import { Buffer } from "buffer";

import { PREVIEW_LOADED_MESSAGE_TYPE, Nodebox } from "@codesandbox/nodebox";
import type {
FilesMap,
Expand Down Expand Up @@ -364,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
2 changes: 1 addition & 1 deletion sandpack-client/src/clients/node/inject-scripts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { INJECT_MESSAGE_TYPE } from "@codesandbox/nodebox";

// get the bundled file, which contains all dependencies
// @ts-ignore
import consoleHook from "./dist/consoleHook.txt";
import consoleHook from "./dist/consoleHook.js";
import { setupHistoryListeners } from "./historyListener";

const scripts = [
Expand Down
Loading

0 comments on commit b58909c

Please sign in to comment.