forked from codesandbox/codesandbox-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstartup.js
More file actions
30 lines (27 loc) · 898 Bytes
/
startup.js
File metadata and controls
30 lines (27 loc) · 898 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/* eslint-disable import/default */
import BabelWorker from 'worker-loader?publicPath=/&name=babel-transpiler.[hash:8].worker.js!./eval/transpilers/babel/worker/index';
/* eslint-enable import/default */
import hookConsole from 'sandbox-hooks/console';
import setupHistoryListeners from 'sandbox-hooks/url-listeners';
import { listenForPreviewSecret } from 'sandbox-hooks/preview-secret';
import { isStandalone } from 'codesandbox-api';
window.babelworkers = [];
for (let i = 0; i < 3; i++) {
const worker = new BabelWorker();
window.babelworkers.push(worker);
// Warm up the babel worker
worker.postMessage({
type: 'compiler',
path: 'test.js',
code: 'const a = "b"',
config: { presets: ['env'] },
version: 7,
loaderOptions: {},
});
}
if (!isStandalone) {
// Means we're in the editor
setupHistoryListeners();
hookConsole();
listenForPreviewSecret();
}