Skip to content

Commit 607e54c

Browse files
authored
small fix for resize dispatch and moving the sandpack projects out (#5562)
* small fix for resize dispatch and moving the sandpack projects out * remove commented code
1 parent b45791d commit 607e54c

File tree

92 files changed

+7
-28068
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+7
-28068
lines changed

.prettierignore

-3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,3 @@ www/
1818
*.html
1919

2020
.drone.yml
21-
22-
!/standalone-packages/react-sandpack
23-
!/standalone-packages/sandpack

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
"build:components": "lerna run build:dev --scope @codesandbox/components --stream",
4444
"build:deps": "lerna run build:dev",
4545
"build:dynamic": "lerna run build --scope dynamic-pages --stream",
46+
"build:sandpack": "lerna run build:sandpack-sandbox --scope app --stream",
4647
"build:embed": "lerna run build:embed --scope app --stream && gulp",
4748
"build:prod": "cross-env NODE_OPTIONS=\"--max-old-space-size=4096\" lerna run build --scope homepage --stream && lerna run build --scope app --stream && lerna run copy-assets --scope app --stream",
4849
"commit": "concurrently \"yarn typecheck\" \"yarn lint\" && git commit -m",

packages/app/src/sandbox/compile.ts

+6-13
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ import setScreen, { resetScreen } from './status-screen';
3737
import { showRunOnClick } from './status-screen/run-on-click';
3838
import { SCRIPT_VERSION } from '.';
3939

40-
let initializedDOMMutationListener = false;
4140
let manager: Manager | null = null;
4241
let actionsEnabled = false;
4342

@@ -402,7 +401,7 @@ function initializeDOMMutationListener() {
402401
// When a change is found, the sendResize function will determine if a message is dispatched
403402
const observer = new MutationObserver(sendResize);
404403

405-
observer.observe(document.body, {
404+
observer.observe(document, {
406405
attributes: true,
407406
childList: true,
408407
subtree: true,
@@ -411,8 +410,6 @@ function initializeDOMMutationListener() {
411410
window.addEventListener('unload', () => {
412411
observer.disconnect();
413412
});
414-
415-
initializedDOMMutationListener = true;
416413
}
417414

418415
function overrideDocumentClose() {
@@ -760,10 +757,6 @@ async function compile({
760757

761758
await manager.preset.teardown(manager, updatedModules);
762759

763-
if (!initializedDOMMutationListener && !manager.preset.htmlDisabled) {
764-
initializeDOMMutationListener();
765-
}
766-
767760
if (firstLoad && showOpenInCodeSandbox) {
768761
createCodeSandboxOverlay(modules);
769762
}
@@ -863,16 +856,16 @@ async function compile({
863856
});
864857
}
865858
}
859+
860+
if (!hadError && firstLoad) {
861+
initializeDOMMutationListener();
862+
}
863+
866864
firstLoad = false;
867865

868866
dispatch({ type: 'status', status: 'idle' });
869867
dispatch({ type: 'done', compilatonError: hadError });
870868

871-
if (!hadError) {
872-
// If compile is successful, compute the size of the content after a small delay and dispatch that
873-
setTimeout(sendResize, 100);
874-
}
875-
876869
if (typeof (window as any).__puppeteer__ === 'function') {
877870
setTimeout(() => {
878871
// Give everything some time to evaluate

standalone-packages/react-sandpack/.env.example

-1
This file was deleted.

standalone-packages/react-sandpack/.gitignore

-7
This file was deleted.

standalone-packages/react-sandpack/.storybook/main.js

-8
This file was deleted.

standalone-packages/react-sandpack/.storybook/preview.js

-5
This file was deleted.

standalone-packages/react-sandpack/LICENSE.md

-164
This file was deleted.

0 commit comments

Comments
 (0)