Skip to content

Commit 3521935

Browse files
committed
Use unpkg as fallback
1 parent 83eb13a commit 3521935

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

packages/app/src/sandbox/compile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ function getDependencies(parsedPackage, templateDefinition, configurations) {
273273
// packager will only include the package.json for it.
274274
if (isBabel7(d, devDependencies)) {
275275
returnedDependencies['@babel/runtime'] =
276-
returnedDependencies['@babel/runtime'] || '7.1.2';
276+
returnedDependencies['@babel/runtime'] || '7.3.1';
277277
} else {
278278
returnedDependencies['babel-runtime'] =
279279
returnedDependencies['babel-runtime'] || '6.26.0';

packages/app/src/sandbox/eval/npm/fetch-npm-module.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ function getUnpkgUrl(name: string, version: string, forceJsDelivr?: boolean) {
7777
const nameWithoutAlias = name.replace(ALIAS_REGEX, '');
7878

7979
return TEMP_USE_JSDELIVR || forceJsDelivr
80-
? `https://cdn.jsdelivr.net/npm/${nameWithoutAlias}@${version}`
81-
: `https://unpkg.com/${nameWithoutAlias}@${version}`;
80+
? `https://unpkg.com/${nameWithoutAlias}@${version}`
81+
: `https://cdn.jsdelivr.net/npm/${nameWithoutAlias}@${version}`;
8282
}
8383

8484
function getMeta(name: string, packageJSONPath: string, version: string) {
@@ -125,8 +125,11 @@ function downloadDependency(depName: string, depVersion: string, path: string) {
125125
return x.text();
126126
}
127127

128-
if (isGitHub) {
129-
// Fall back to jsdelivr
128+
throw new Error(`Could not find module ${path}`);
129+
})
130+
.catch(err => {
131+
if (!isGitHub) {
132+
// Fallback to jsdelivr
130133
return fetch(
131134
`${getUnpkgUrl(depName, depVersion, true)}${relativePath}`
132135
).then(x2 => {
@@ -138,7 +141,7 @@ function downloadDependency(depName: string, depVersion: string, path: string) {
138141
});
139142
}
140143

141-
throw new Error(`Could not find module ${path}`);
144+
throw err;
142145
})
143146
.then(x => ({
144147
path,

0 commit comments

Comments
 (0)