Skip to content

Commit

Permalink
fix(ts): update ts lib default local module path
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdbradley committed Aug 15, 2020
1 parent 76bbac4 commit 16f30bc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions src/compiler/sys/typescript/tests/typescript-sys.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,23 @@ describe('getTypescriptPathFromUrl', () => {
};

it('not typescript, return url', () => {
const tsExecutingUrl = 'https://cdn.jsdelivr.net/npm/[email protected]/lib/typescript.js';
const tsExecutingUrl = 'https://cdn.jsdelivr.net/npm/@stencil/[email protected]/compiler/stencil.js';
const url = 'https://cdn.jsdelivr.net/npm/something/index.js';
const r = getTypescriptPathFromUrl(config, tsExecutingUrl, url);
expect(r).toBe('https://cdn.jsdelivr.net/npm/something/index.js');
});

it('ts path from url, version', () => {
const tsExecutingUrl = 'https://cdn.jsdelivr.net/npm/[email protected]/lib/typescript.js';
const url = 'https://cdn.jsdelivr.net/npm/[email protected]/lib/lib.es2015.proxy.d.ts';
const tsExecutingUrl = 'https://cdn.jsdelivr.net/npm/@stencil/[email protected]/compiler/stencil.js';
const url = 'https://cdn.jsdelivr.net/npm/@stencil/[email protected]/compiler/lib.es2015.proxy.d.ts';
const r = getTypescriptPathFromUrl(config, tsExecutingUrl, url);
expect(r).toBe('/some/path/node_modules/typescript/lib/lib.es2015.proxy.d.ts');
expect(r).toBe('/some/path/node_modules/@stencil/core/compiler/lib.es2015.proxy.d.ts');
});

it('ts path from url, no version', () => {
const tsExecutingUrl = 'https://cdn.jsdelivr.net/npm/typescript/lib/typescript.js';
const url = 'https://cdn.jsdelivr.net/npm/typescript/lib/lib.es2015.proxy.d.ts';
const tsExecutingUrl = 'https://cdn.jsdelivr.net/npm/@stencil/core/compiler/stencil.js';
const url = 'https://cdn.jsdelivr.net/npm/@stencil/core/compiler/lib.es2015.proxy.d.ts';
const r = getTypescriptPathFromUrl(config, tsExecutingUrl, url);
expect(r).toBe('/some/path/node_modules/typescript/lib/lib.es2015.proxy.d.ts');
expect(r).toBe('/some/path/node_modules/@stencil/core/compiler/lib.es2015.proxy.d.ts');
});
});
2 changes: 1 addition & 1 deletion src/compiler/sys/typescript/typescript-sys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ export const getTypescriptPathFromUrl = (config: d.Config, tsExecutingUrl: strin
const tsBaseUrl = new URL('..', tsExecutingUrl).href;
if (url.startsWith(tsBaseUrl)) {
const tsFilePath = url.replace(tsBaseUrl, '/');
const tsNodePath = config.sys.getLocalModulePath({ rootDir: config.rootDir, moduleId: 'typescript', path: tsFilePath });
const tsNodePath = config.sys.getLocalModulePath({ rootDir: config.rootDir, moduleId: '@stencil/core', path: tsFilePath });
return normalizePath(tsNodePath);
}
return url;
Expand Down

0 comments on commit 16f30bc

Please sign in to comment.