From f3420fdc56f6eb161bb78a763152c2607e92ed99 Mon Sep 17 00:00:00 2001 From: Danilo Woznica Date: Thu, 6 Oct 2022 21:18:23 +0100 Subject: [PATCH] [beta] Sandpack: provide bare components and move styles (#5124) * Update 6 files * Update _document.tsx * Update _document.tsx * Update _document.tsx * Update .env.production * Update package.json and yarn.lock * editor style * file tab * loading * loading * tweaks * tweak * bump sandpack * remove test page * Remove stitches from the bundle * apply ios fix only for playground Co-authored-by: Dan Abramov --- beta/.env.development | 1 + beta/.env.production | 3 +- beta/next.config.js | 7 + beta/package.json | 2 +- beta/src/components/MDX/ConsoleBlock.tsx | 2 +- beta/src/components/MDX/Sandpack/Console.tsx | 4 +- .../components/MDX/Sandpack/CustomPreset.tsx | 2 +- .../components/MDX/Sandpack/NavigationBar.tsx | 2 +- .../MDX/Sandpack/OpenInCodeSandboxButton.tsx | 2 +- .../components/MDX/Sandpack/SandpackRoot.tsx | 2 +- beta/src/components/MDX/Sandpack/index.tsx | 2 +- beta/src/pages/_app.tsx | 36 -- beta/src/pages/_document.tsx | 118 ----- beta/src/styles/sandpack.css | 403 +++++++++++------- beta/src/utils/emptyShim.js | 6 + beta/yarn.lock | 18 +- 16 files changed, 281 insertions(+), 329 deletions(-) create mode 100644 beta/src/utils/emptyShim.js diff --git a/beta/.env.development b/beta/.env.development index e69de29b..a692f21c 100644 --- a/beta/.env.development +++ b/beta/.env.development @@ -0,0 +1 @@ +SANDPACK_BARE_COMPONENTS=true \ No newline at end of file diff --git a/beta/.env.production b/beta/.env.production index d25eb7dd..445c9c4d 100644 --- a/beta/.env.production +++ b/beta/.env.production @@ -1 +1,2 @@ -NEXT_PUBLIC_GA_TRACKING_ID = 'UA-41298772-4' \ No newline at end of file +NEXT_PUBLIC_GA_TRACKING_ID = 'UA-41298772-4' +SANDPACK_BARE_COMPONENTS=true \ No newline at end of file diff --git a/beta/next.config.js b/beta/next.config.js index 5ac6773e..208895f9 100644 --- a/beta/next.config.js +++ b/beta/next.config.js @@ -16,6 +16,9 @@ const nextConfig = { legacyBrowsers: false, browsersListForSwc: true, }, + env: { + SANDPACK_BARE_COMPONENTS: process.env.SANDPACK_BARE_COMPONENTS, + }, async redirects() { return redirects.redirects; }, @@ -47,6 +50,10 @@ const nextConfig = { const {IgnorePlugin, NormalModuleReplacementPlugin} = require('webpack'); config.plugins.push( + new NormalModuleReplacementPlugin( + /^@stitches\/core$/, + require.resolve('./src/utils/emptyShim.js') + ), new NormalModuleReplacementPlugin( /^raf$/, require.resolve('./src/utils/rafShim.js') diff --git a/beta/package.json b/beta/package.json index b728160c..995ad67b 100644 --- a/beta/package.json +++ b/beta/package.json @@ -22,7 +22,7 @@ "check-all": "npm-run-all prettier lint:fix tsc" }, "dependencies": { - "@codesandbox/sandpack-react": "1.11.0", + "@codesandbox/sandpack-react": "1.14.1", "@docsearch/css": "3.0.0-alpha.41", "@docsearch/react": "3.0.0-alpha.41", "@headlessui/react": "^1.7.0", diff --git a/beta/src/components/MDX/ConsoleBlock.tsx b/beta/src/components/MDX/ConsoleBlock.tsx index 8322468f..a5e68cea 100644 --- a/beta/src/components/MDX/ConsoleBlock.tsx +++ b/beta/src/components/MDX/ConsoleBlock.tsx @@ -38,7 +38,7 @@ function ConsoleBlock({level = 'error', children}: ConsoleBlockProps) { } return ( -
+
diff --git a/beta/src/components/MDX/Sandpack/Console.tsx b/beta/src/components/MDX/Sandpack/Console.tsx index 04eaa89f..375a92f0 100644 --- a/beta/src/components/MDX/Sandpack/Console.tsx +++ b/beta/src/components/MDX/Sandpack/Console.tsx @@ -181,14 +181,14 @@ export const SandpackConsole = ({visible}: {visible: boolean}) => {
{isExpanded && ( -
+
{logs.map(({data, id, method}) => { return (
diff --git a/beta/src/components/MDX/Sandpack/CustomPreset.tsx b/beta/src/components/MDX/Sandpack/CustomPreset.tsx index 97951ccb..7ef53657 100644 --- a/beta/src/components/MDX/Sandpack/CustomPreset.tsx +++ b/beta/src/components/MDX/Sandpack/CustomPreset.tsx @@ -111,7 +111,7 @@ const SandboxShell = memo(function SandboxShell({ } } }}> - + }) { // space that's taken by the (invisible) tab list.