Skip to content

Commit da1f19a

Browse files
committed
fix: Correctly setup Typescript root to emit declarations
Previously no root was set, so types for `vite.config` were included and the library types were emitted to `dist/lib`. Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
1 parent a21c1bb commit da1f19a

6 files changed

Lines changed: 42 additions & 30 deletions

File tree

REUSE.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ SPDX-PackageSupplier = "Nextcloud GmbH <https://nextcloud.com/impressum/>"
66
SPDX-PackageDownloadLocation = "https://github.com/nextcloud-libraries/nextcloud-paths"
77

88
[[annotations]]
9-
path = ["package.json", "package-lock.json", "tsconfig.json"]
9+
path = ["package.json", "package-lock.json", "tsconfig.json", "test/tsconfig.json"]
1010
precedence = "aggregate"
1111
SPDX-FileCopyrightText = "2019 Nextcloud GmbH and Nextcloud contributors"
1212
SPDX-License-Identifier = "GPL-3.0-or-later"

package-lock.json

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

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"type": "git",
2929
"url": "https://github.com/nextcloud-libraries/nextcloud-paths"
3030
},
31-
"author": "Christoph Wurst",
31+
"author": "Nextcloud GmbH and Nextcloud contributors",
3232
"license": "GPL-3.0-or-later",
3333
"devDependencies": {
3434
"@nextcloud/browserslist-config": "^3.0.1",
@@ -44,10 +44,11 @@
4444
],
4545
"engines": {
4646
"node": "^20.0.0",
47-
"npm": "^9.0.0 || ^10.0.0"
47+
"npm": "^10.0.0"
4848
},
4949
"files": [
5050
"dist",
51+
"AUTHORS.md",
5152
"CHANGELOG.md",
5253
"README.md",
5354
"LICENSE"

test/tsconfig.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "..",
3+
"include": ["../*.ts", ".", "../lib"],
4+
"compilerOptions": {
5+
"rootDir": ".."
6+
}
7+
}

tsconfig.json

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
{
2-
"compilerOptions": {
3-
"target": "ESNext",
4-
"module": "ESNext",
5-
"moduleResolution": "Bundler",
6-
"declaration": true,
7-
"outDir": "./dist",
8-
"strict": true,
9-
"lib": [
10-
"es6",
11-
"dom"
12-
]
13-
}
2+
"include": ["lib"],
3+
"compilerOptions": {
4+
"target": "ESNext",
5+
"module": "ESNext",
6+
"moduleResolution": "Bundler",
7+
"declaration": true,
8+
"outDir": "./dist",
9+
"rootDir": "lib",
10+
"strict": true,
11+
"lib": [
12+
"es6",
13+
"dom"
14+
],
15+
"types": ["vitest"]
16+
}
1417
}

vitest.config.ts

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,24 @@
22
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
33
* SPDX-License-Identifier: GPL-3.0-or-later
44
*/
5+
import { defineConfig } from "vitest/config";
56
import viteConfig from "./vite.config";
67

78
export default async (env: Parameters<typeof viteConfig>[0]) => {
89
const config =
910
typeof viteConfig === "function" ? await viteConfig(env) : viteConfig;
1011

11-
// node-externals conflicts with vitest
12-
config.plugins = config.plugins!.filter(
13-
(plugin) =>
14-
plugin && (!("name" in plugin) || plugin?.name !== "node-externals")
15-
);
16-
17-
config.test = {
18-
coverage: {
19-
reporter: ["text", "lcov"],
20-
},
21-
};
22-
23-
return config;
24-
};
12+
return defineConfig({
13+
...config,
14+
// node-externals conflicts with vitest
15+
plugins: config.plugins!.filter(
16+
(plugin) =>
17+
plugin && (!("name" in plugin) || plugin?.name !== "node-externals")
18+
),
19+
test: {
20+
coverage: {
21+
reporter: ["text", "lcov"],
22+
},
23+
}
24+
})
25+
}

0 commit comments

Comments
 (0)