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>
This commit is contained in:
Ferdinand Thiessen 2024-07-19 23:18:24 +02:00
Родитель a21c1bb988
Коммит da1f19a98a
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 45FAE7268762B400
6 изменённых файлов: 42 добавлений и 30 удалений

Просмотреть файл

@ -6,7 +6,7 @@ SPDX-PackageSupplier = "Nextcloud GmbH <https://nextcloud.com/impressum/>"
SPDX-PackageDownloadLocation = "https://github.com/nextcloud-libraries/nextcloud-paths"
[[annotations]]
path = ["package.json", "package-lock.json", "tsconfig.json"]
path = ["package.json", "package-lock.json", "tsconfig.json", "test/tsconfig.json"]
precedence = "aggregate"
SPDX-FileCopyrightText = "2019 Nextcloud GmbH and Nextcloud contributors"
SPDX-License-Identifier = "GPL-3.0-or-later"

2
package-lock.json сгенерированный
Просмотреть файл

@ -19,7 +19,7 @@
},
"engines": {
"node": "^20.0.0",
"npm": "^9.0.0 || ^10.0.0"
"npm": "^10.0.0"
}
},
"node_modules/@ampproject/remapping": {

Просмотреть файл

@ -28,7 +28,7 @@
"type": "git",
"url": "https://github.com/nextcloud-libraries/nextcloud-paths"
},
"author": "Christoph Wurst",
"author": "Nextcloud GmbH and Nextcloud contributors",
"license": "GPL-3.0-or-later",
"devDependencies": {
"@nextcloud/browserslist-config": "^3.0.1",
@ -44,10 +44,11 @@
],
"engines": {
"node": "^20.0.0",
"npm": "^9.0.0 || ^10.0.0"
"npm": "^10.0.0"
},
"files": [
"dist",
"AUTHORS.md",
"CHANGELOG.md",
"README.md",
"LICENSE"

7
test/tsconfig.json Normal file
Просмотреть файл

@ -0,0 +1,7 @@
{
"extends": "..",
"include": ["../*.ts", ".", "../lib"],
"compilerOptions": {
"rootDir": ".."
}
}

Просмотреть файл

@ -1,14 +1,17 @@
{
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "Bundler",
"declaration": true,
"outDir": "./dist",
"strict": true,
"lib": [
"es6",
"dom"
]
}
"include": ["lib"],
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "Bundler",
"declaration": true,
"outDir": "./dist",
"rootDir": "lib",
"strict": true,
"lib": [
"es6",
"dom"
],
"types": ["vitest"]
}
}

Просмотреть файл

@ -2,23 +2,24 @@
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/
import { defineConfig } from "vitest/config";
import viteConfig from "./vite.config";
export default async (env: Parameters<typeof viteConfig>[0]) => {
const config =
typeof viteConfig === "function" ? await viteConfig(env) : viteConfig;
// node-externals conflicts with vitest
config.plugins = config.plugins!.filter(
(plugin) =>
plugin && (!("name" in plugin) || plugin?.name !== "node-externals")
);
config.test = {
coverage: {
reporter: ["text", "lcov"],
},
};
return config;
};
return defineConfig({
...config,
// node-externals conflicts with vitest
plugins: config.plugins!.filter(
(plugin) =>
plugin && (!("name" in plugin) || plugin?.name !== "node-externals")
),
test: {
coverage: {
reporter: ["text", "lcov"],
},
}
})
}