Skip to content

Commit

Permalink
chore(repository-tools): add sub-path exports
Browse files Browse the repository at this point in the history
Enable importing specific functions, e.g.

```ts
import { findRootSync } from "@altano/repository-tools/findRootSync";
```
  • Loading branch information
altano committed Aug 28, 2024
1 parent e8ee7a9 commit 8f876e2
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/wet-forks-look.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@altano/repository-tools": minor
---

Enable importing specific functions
15 changes: 11 additions & 4 deletions packages/repository-tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,14 @@
"main": "./dist/cjs/index.js",
"module": "./dist/esm/index.js",
"exports": {
"import": "./dist/esm/index.js",
"require": "./dist/cjs/index.js"
".": {
"import": "./dist/esm/index.js",
"require": "./dist/cjs/index.js"
},
"./*": {
"import": "./dist/esm/*.js",
"require": "./dist/cjs/*.js"
}
},
"type": "module",
"sideEffects": false,
Expand All @@ -26,11 +32,12 @@
"lint:fix": "TIMING=1 pnpm lint --fix",
"lint:timing": "TIMING=1 pnpm lint",
"test:build": "./tests/scripts/createRepositoryBundles.ts",
"test:unit": "run-s test:unit:run test:unit:benchmark",
"test:unit": "run-s test:unit:run",
"test:unit:benchmark": "vitest --run bench",
"test:unit:run": "vitest --run",
"test:unit:watch": "vitest",
"typecheck": "tsc --noEmit"
"typecheck:src": "tsc --noEmit",
"typecheck:test": "tsc --noEmit --project ./tests/tsconfig.json"
},
"repository": {
"type": "git",
Expand Down
1 change: 1 addition & 0 deletions packages/repository-tools/tests/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"include": ["."],
"compilerOptions": {
"types": ["@altano/vitest-plugins/matchers/types"],
"moduleResolution": "Bundler",
"target": "ESNext",
"module": "ESNext"
}
Expand Down
19 changes: 19 additions & 0 deletions packages/repository-tools/tests/unit/packaging.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import path from "node:path";
import { describe, expect, it } from "vitest";
import { findRoot } from "@altano/repository-tools/findRoot";
import { findRootSync } from "@altano/repository-tools/findRootSync";

// Test sub-path exports separately by importing using the package name. This
// has to be separate from other tests because vitest test coverage analysis
// doesn't understand what code this is testing.

describe("sub-path exports", function () {
it("find this repository's root asynchronously", async () => {
const repoRoot = path.resolve(import.meta.dirname, "..", "..", "..", "..");
expect(await findRoot(import.meta.dirname)).toEqual(repoRoot);
});
it("find this repository's root synchronously", () => {
const repoRoot = path.resolve(import.meta.dirname, "..", "..", "..", "..");
expect(findRootSync(import.meta.dirname)).toEqual(repoRoot);
});
});
2 changes: 1 addition & 1 deletion packages/satori-fit-text/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"test:e2e": "playwright test",
"test:e2e:server": "vite --strictPort --port 3717 ./tests/e2e",
"test:e2e:ui": "playwright test --ui",
"test:unit": "run-s test:unit:run test:unit:benchmark",
"test:unit": "run-s test:unit:run",
"test:unit:benchmark": "vitest --run bench",
"test:unit:run": "vitest --run",
"test:unit:watch": "vitest",
Expand Down

0 comments on commit 8f876e2

Please sign in to comment.