Skip to content

Commit 803c300

Browse files
author
Rich Harris
committed
make imports in .d.ts files relative
1 parent 0d43af4 commit 803c300

File tree

5 files changed

+31
-12
lines changed

5 files changed

+31
-12
lines changed

packages/kit/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
"sade": "^1.8.1",
2323
"set-cookie-parser": "^2.6.0",
2424
"sirv": "^2.0.2",
25-
"tiny-glob": "^0.2.9",
2625
"undici": "~5.22.0"
2726
},
2827
"devDependencies": {
@@ -37,6 +36,7 @@
3736
"rollup": "^3.7.0",
3837
"svelte": "^3.56.0",
3938
"svelte-preprocess": "^5.0.3",
39+
"tiny-glob": "^0.2.9",
4040
"typescript": "^5.0.4",
4141
"uvu": "^0.5.6",
4242
"vite": "^4.3.0"
@@ -68,7 +68,7 @@
6868
"test:cross-platform:build": "pnpm test:unit && pnpm -r --workspace-concurrency 1 --filter=\"./test/**\" test:cross-platform:build",
6969
"test:unit": "uvu src \"(spec\\.js|test[\\\\/]index\\.js)\"",
7070
"postinstall": "node postinstall.js",
71-
"prepublishOnly": "tsc -p tsconfig.build.json && node scripts/copy-declaration-files"
71+
"prepublishOnly": "tsc -p tsconfig.build.json && node scripts/process-declaration-files"
7272
},
7373
"exports": {
7474
"./package.json": "./package.json",

packages/kit/scripts/copy-declaration-files.js

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import fs from 'node:fs';
2+
import path from 'node:path';
3+
import { copy } from '../src/utils/filesystem.js';
4+
import glob from 'tiny-glob/sync.js';
5+
6+
glob('**/*.d.ts', { cwd: 'src' }).forEach((file) => {
7+
fs.copyFileSync(`src/${file}`, `types/${file}`);
8+
});
9+
10+
glob('types/**/*.d.ts').forEach((file) => {
11+
// we need to rewrite `import('types')` as `import('../../types')` for anyone
12+
// not using moduleResolution: 'bundler'
13+
14+
const dir = path.dirname(file);
15+
const path_to_types = path.relative(dir, 'types/exports/types');
16+
const path_to_public_types = path.relative(dir, 'types/types/public');
17+
18+
const contents = fs
19+
.readFileSync(file, 'utf-8')
20+
.replace(/import\('types'\)/g, `import('${path_to_types}')`)
21+
.replace(/import\('@sveltejs\/kit'\)/g, `import('${path_to_public_types}')`);
22+
23+
fs.writeFileSync(file, contents);
24+
});

packages/kit/src/exports/hooks/sequence.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@
6363
* first post-processing
6464
* ```
6565
*
66-
* @param {...import('@sveltejs/kit').Handle} handlers The chain of `handle` functions
67-
* @returns {import('@sveltejs/kit').Handle}
66+
* @param {...import('types').Handle} handlers The chain of `handle` functions
67+
* @returns {import('types').Handle}
6868
*/
6969
export function sequence(...handlers) {
7070
const length = handlers.length;

pnpm-lock.yaml

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)