Skip to content

Commit

Permalink
fix: Correctly setup Typescript root to emit declarations
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
susnux committed Jul 25, 2024
1 parent a21c1bb commit da1f19a
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 30 deletions.
2 changes: 1 addition & 1 deletion REUSE.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
Expand Down
7 changes: 7 additions & 0 deletions test/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "..",
"include": ["../*.ts", ".", "../lib"],
"compilerOptions": {
"rootDir": ".."
}
}
27 changes: 15 additions & 12 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -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"]
}
}
29 changes: 15 additions & 14 deletions vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
},
}
})
}

0 comments on commit da1f19a

Please sign in to comment.