Skip to content

Commit

Permalink
DRY
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich-Harris committed Jan 26, 2023
1 parent e5a2705 commit bec04b5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 13 deletions.
6 changes: 6 additions & 0 deletions packages/kit/src/core/sync/ts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/** @type {import('typescript')} */
// @ts-ignore
export let ts = undefined;
try {
ts = (await import('typescript')).default;
} catch {}
7 changes: 1 addition & 6 deletions packages/kit/src/core/sync/write_tsconfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@ import path from 'path';
import colors from 'kleur';
import { posixify } from '../../utils/filesystem.js';
import { write_if_changed } from './utils.js';

/** @type {import('typescript') | undefined} */
let ts = undefined;
try {
ts = (await import('typescript')).default;
} catch {}
import { ts } from './ts.js';

/**
* @param {string} cwd
Expand Down
8 changes: 1 addition & 7 deletions packages/kit/src/core/sync/write_types/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import path from 'path';
import MagicString from 'magic-string';
import { posixify, rimraf, walk } from '../../../utils/filesystem.js';
import { compact } from '../../../utils/array.js';
import { ts } from '../ts.js';

/**
* @typedef {{
Expand All @@ -20,13 +21,6 @@ import { compact } from '../../../utils/array.js';
* @typedef {Map<import('types').PageNode, {route: import('types').RouteData, proxies: Proxies}>} RoutesMap
*/

/** @type {import('typescript')} */
// @ts-ignore
let ts = undefined;
try {
ts = (await import('typescript')).default;
} catch {}

const cwd = process.cwd();

/**
Expand Down

0 comments on commit bec04b5

Please sign in to comment.