Skip to content

Commit 1574cde

Browse files
committed
Move typings to unpkg
1 parent 0f7bf47 commit 1574cde

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

standalone-packages/monaco-typescript/src/fetchDependencyTypings.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,9 @@ export function absolute(path: string) {
129129
return "/" + path;
130130
}
131131

132-
const ROOT_URL = `https://cdn.jsdelivr.net/`;
132+
const UNPKG = true;
133+
134+
const ROOT_URL = UNPKG ? `https://unpkg.com/` : `https://cdn.jsdelivr.net/npm/`;
133135
const loadedTypings = [];
134136

135137
/**
@@ -168,7 +170,7 @@ const doFetch = url => {
168170
};
169171

170172
const fetchFromDefinitelyTyped = (dependency, version, fetchedPaths) => {
171-
const depUrl = `${ROOT_URL}npm/@types/${dependency
173+
const depUrl = `${ROOT_URL}@types/${dependency
172174
.replace("@", "")
173175
.replace(/\//g, "__")}`;
174176

@@ -266,13 +268,21 @@ const transformFiles = dir =>
266268
}, {})
267269
: {};
268270

269-
const getFileMetaData = (dependency, version, depPath) =>
270-
doFetch(
271+
const getFileMetaData = (dependency, version, depPath) => {
272+
if (UNPKG) {
273+
return doFetch(
274+
`https://unpkg.com/${dependency}@${version}/${depPath}?meta`
275+
)
276+
.then(response => JSON.parse(response))
277+
}
278+
279+
return doFetch(
271280
`https://data.jsdelivr.com/v1/package/npm/${dependency}@${version}/flat`
272281
)
273282
.then(response => JSON.parse(response))
274283
.then(response => response.files.filter(f => f.name.startsWith(depPath)))
275284
.then(tempTransformFiles);
285+
}
276286

277287
const resolveAppropiateFile = (fileMetaData, relativePath) => {
278288
const absolutePath = `/${relativePath}`;
@@ -297,7 +307,7 @@ const getFileTypes = (
297307

298308
if (fetchedPaths[virtualPath]) return null;
299309

300-
return doFetch(`${depUrl}/${depPath}`).then(typings => {
310+
return doFetch(`${depUrl}${depPath}`).then(typings => {
301311
if (fetchedPaths[virtualPath]) return null;
302312

303313
addLib(virtualPath, typings, fetchedPaths);
@@ -378,7 +388,7 @@ function fetchFromMeta(dependency, version, fetchedPaths) {
378388
}
379389

380390
function fetchFromTypings(dependency, version, fetchedPaths) {
381-
const depUrl = `${ROOT_URL}npm/${dependency}@${version}`;
391+
const depUrl = `${ROOT_URL}${dependency}@${version}`;
382392
return doFetch(`${depUrl}/package.json`)
383393
.then(response => JSON.parse(response))
384394
.then(packageJSON => {

standalone-packages/vscode-editor/release/min/vs/language/typescript/tsWorker.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)