Skip to content

fix(sandpack-template): use custom react sandpack template - #6484

Merged
mattcarrollcode merged 3 commits into
reactjs:mainfrom
danilowoz:draft/flamboyant-rain
Dec 13, 2023
Merged

fix(sandpack-template): use custom react sandpack template#6484
mattcarrollcode merged 3 commits into
reactjs:mainfrom
danilowoz:draft/flamboyant-rain

Conversation

@danilowoz

@danilowozdanilowoz commented Dec 12, 2023

Copy link
Copy Markdown
Contributor

This solves the issue that users can't download a runnable sandbox from CodeSandbox. Closes#6482

Since we introduced the new editor, we had to make some changes to make templates easier to maintain and make them compatible with our microVM solution. Consequently, we had to remove some custom rules applied to the sandbox files before downloading them. For example, in the react template, we used to include scripts, dependencies, missing files, and move all files to src.

With this PR, we move the responsibility of providing all files and a runnable sandbox to react.dev, instead of relying on hidden layers inside CodeSandbox download logic. As a result, react.dev can now easily upgrade/download react dependencies, provide the minimal amount of files to run a React.js project and keep it transparent, avoiding any future headache.

Preview

@github-actions

github-actionsBot commented Dec 12, 2023

Copy link
Copy Markdown

Size changes

Details

📦 Next.js Bundle Analysis for react-dev

This analysis was generated by the Next.js Bundle Analysis action. 🤖

Three Pages Changed Size

The following pages changed size from the code in this PR compared to its base branch:

PageSize (compressed)First Load
/40477.36 KB(🟡 +37 B)181.17 KB
/50077.35 KB(🟡 +37 B)181.17 KB
/[[...markdownPath]]78.95 KB(🟡 +37 B)182.76 KB
Details

Only the gzipped size is provided here based on an expert tip.

First Load is the size of the global bundle plus the bundle for the individual page. If a user were to show up to your website and land on a given page, the first load size represents the amount of javascript that user would need to download. If next/link is used, subsequent page loads would only need to download that page's bundle (the number in the "Size" column), since the global bundle has already been downloaded.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

Next to the size is how much the size has increased or decreased compared with the base branch of this PR. If this percentage has increased by 10% or more, there will be a red status indicator applied, indicating that special attention should be given to this.

Remove console.log(filePath); from createFileMap.ts
Comment threadsrc/components/MDX/Sandpack/SandpackRoot.tsx
Comment threadsrc/components/MDX/Sandpack/createFileMap.ts Outdated
Comment threadsrc/components/MDX/Sandpack/template.ts
Comment threadsrc/components/MDX/Sandpack/createFileMap.ts Outdated
Comment threadsrc/components/MDX/Sandpack/SandpackRoot.tsx
Update file paths in Sandpack components to use root folder and variables
@mattcarrollcode
mattcarrollcode merged commit e98c393 into reactjs:mainDec 13, 2023
@danilowoz
danilowoz deleted the draft/flamboyant-rain branch December 14, 2023 08:48
geeseyj added a commit to geeseyj/react.dev that referenced this pull request Dec 15, 2023
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Download codesandbox broken in Beta editor

4 participants

@danilowoz@mattcarrollcode@harish-sethuraman@facebook-github-bot