Skip to content

Commit f28493e

Browse files
committed
Fix HyperApp sandboxes
1 parent e5bd388 commit f28493e

File tree

3 files changed

+9
-14
lines changed

3 files changed

+9
-14
lines changed

packages/app/src/sandbox/eval/transpilers/babel/worker/babel-worker.js

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ async function compile(code, customConfig, path, isV7) {
406406
try {
407407
self.importScripts(
408408
process.env.NODE_ENV === 'development'
409-
? `${process.env.CODESANDBOX_HOST || ''}/static/js/babel.7.3.4.min.js`
409+
? `${process.env.CODESANDBOX_HOST || ''}/static/js/babel.7.3.4.js`
410410
: `${process.env.CODESANDBOX_HOST || ''}/static/js/babel.7.3.4.min.js`
411411
);
412412
} catch (e) {
@@ -579,16 +579,6 @@ self.addEventListener('message', async event => {
579579
Babel.registerPlugin('transform-vue-jsx', vuePlugin);
580580
}
581581

582-
if (
583-
flattenedPlugins.indexOf('jsx-pragmatic') > -1 &&
584-
Object.keys(Babel.availablePlugins).indexOf('jsx-pragmatic') === -1
585-
) {
586-
const pragmaticPlugin = await import(
587-
/* webpackChunkName: 'babel-plugin-jsx-pragmatic' */ 'babel-plugin-jsx-pragmatic'
588-
);
589-
Babel.registerPlugin('jsx-pragmatic', pragmaticPlugin);
590-
}
591-
592582
if (
593583
flattenedPlugins.indexOf('babel-plugin-macros') > -1 &&
594584
Object.keys(Babel.availablePlugins).indexOf('babel-plugin-macros') === -1

packages/app/src/sandbox/eval/transpilers/babel/worker/evaluate.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,14 @@ export default function evaluate(
7373
availablePlugins[requirePath] ||
7474
availablePlugins[requirePath.replace('babel-plugin-', '')] ||
7575
availablePlugins[requirePath.replace('@babel/plugin-', '')];
76-
if (plugin && requirePath !== 'react') {
77-
return plugin;
76+
77+
// This is some weird behaviour, it seems like we have a mix of { __esModule: true, default ... } modules in
78+
// this list and some direct functions. If we return the plugin itself (not .default) one sandbox breaks,
79+
// if we return a .default the other sandbox breaks. The two sandboxes are: `utmms` and `sebn6`. I've decided
80+
// to only return plugins that have been pre-added to babel-standalone (the plugins with a .default), this
81+
// way both sandboxes work.
82+
if (plugin && requirePath !== 'react' && plugin.__esModule) {
83+
return plugin.default;
7884
}
7985

8086
const preset =

packages/sandbox-hooks/react-error-overlay/overlay.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,6 @@ let listenToRuntimeErrorsUnmounter;
279279

280280
function inject() {
281281
listenToRuntimeErrorsUnmounter = listenToRuntimeErrors(error => {
282-
console.log('what the matter', error);
283282
crash(error.error);
284283
});
285284
}

0 commit comments

Comments
 (0)