Skip to content

Commit 96510b0

Browse files
committed
Add a warmup for the new packager
1 parent 1564be2 commit 96510b0

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

packages/app/src/sandbox/compile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ const BABEL_DEPENDENCIES = [
109109
// Dependencies that we actually don't need, we will replace this by a dynamic
110110
// system in the future
111111
const PREINSTALLED_DEPENDENCIES = [
112-
'node-lib-browser',
112+
'node-libs-browser',
113113
'react-scripts',
114114
'react-scripts-ts',
115115
'parcel-bundler',

packages/app/src/sandbox/npm/fetch-dependencies.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,27 @@ const host = process.env.CODESANDBOX_HOST;
1717

1818
const VERSION = 1;
1919

20+
/**
21+
* Warm the cache of our new API
22+
*/
23+
const warmNewPackagerAPI = (url: string, method: string = 'GET') => {
24+
try {
25+
fetch(url, { method })
26+
.then(() => {})
27+
.catch(() => {});
28+
} catch (e) {
29+
/* ignore */
30+
}
31+
};
32+
2033
const BUCKET_URL =
2134
process.env.NODE_ENV === 'production' || process.env.NODE_ENV === 'test'
2235
? 'https://d1jyvh0kxilfa7.cloudfront.net'
2336
: 'https://s3-eu-west-1.amazonaws.com/dev.packager.packages';
37+
38+
const NEW_PACKAGER_URL =
39+
'https://aiwi8rnkp5.execute-api.eu-west-1.amazonaws.com/prod/packages';
40+
2441
const PACKAGER_URL =
2542
process.env.NODE_ENV === 'production' || process.env.NODE_ENV === 'test'
2643
? 'https://drq28qbjmc.execute-api.eu-west-1.amazonaws.com/prod/packages'
@@ -145,6 +162,7 @@ async function getDependencies(dependencies: Object) {
145162

146163
setScreen({ type: 'loading', text: 'Downloading Dependencies...' });
147164
try {
165+
warmNewPackagerAPI(`${NEW_PACKAGER_URL}/${dependencyUrl}`, 'POST');
148166
const bucketManifest = await callApi(
149167
`${BUCKET_URL}/${bucketDependencyUrl}`
150168
);

0 commit comments

Comments
 (0)