@integr8-media/config 1.0.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3 @@
1
+ import { t as ConfigError } from "./configError-Cap5gwBB.mjs";
2
+ import { A as cssToText, B as renderMarkdown, C as readSiteSwitch, D as uiDocsUrlOf, E as resolveSiteConfig, F as normalizeSitePath, H as typeLabel, I as playgroundBase, L as escapeHtml, M as itemDocs, N as renderItemPage, O as RegistrySiteError, P as extractDocs, R as groupItems, S as readPackageAndSwitch, T as resolveRegistryUrl, V as renderShell, _ as renderSiteFiles, a as serveSite, b as readLadleStories, c as formatReport, d as packageOf, f as publicExports, g as loadSiteConfig, h as checkPlaygroundBase, i as resolveSiteFile, j as importLines, k as renderRegistryPage, l as formatSummary, m as buildRegistrySite, n as runCli, o as OWN_CODE, p as shortPath, r as createSiteServer, s as formatKb, t as USAGE, u as groupByPackage, v as defaultStoryOf, w as defineRegistrySite, x as storiesOf, y as previewStoryOf, z as inlineMarkdown } from "./cli-DIsoGTED.mjs";
3
+ export { ConfigError, OWN_CODE, RegistrySiteError, USAGE, buildRegistrySite, checkPlaygroundBase, createSiteServer, cssToText, defaultStoryOf, defineRegistrySite, escapeHtml, extractDocs, formatKb, formatReport, formatSummary, groupByPackage, groupItems, importLines, inlineMarkdown, itemDocs, loadSiteConfig, normalizeSitePath, packageOf, playgroundBase, previewStoryOf, publicExports, readLadleStories, readPackageAndSwitch, readSiteSwitch, renderItemPage, renderMarkdown, renderRegistryPage, renderShell, renderSiteFiles, resolveRegistryUrl, resolveSiteConfig, resolveSiteFile, runCli, serveSite, shortPath, storiesOf, typeLabel, uiDocsUrlOf };
@@ -0,0 +1 @@
1
+ export {}
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+ import { n as runCli } from "./cli-DIsoGTED.mjs";
3
+ // src/registrySite/bin.ts
4
+ process.exitCode = await runCli(process.argv.slice(2));
5
+ export {};
package/dist/tsdown.d.mts CHANGED
@@ -10,19 +10,32 @@ interface Integr8TsdownOptions {
10
10
  entry: Integr8TsdownEntry;
11
11
  /** Target platform. `node` builds for `node24`; the others build for `es2024`. */
12
12
  platform: Integr8TsdownPlatform;
13
+ /**
14
+ * Build every source file as its own output file instead of one bundle. Defaults to `false`.
15
+ *
16
+ * Use it for React libraries whose files start with `'use client'`: each file is built on its
17
+ * own, so the directive stays on it and a Next.js server component can import the
18
+ * non-client exports from the same package. The preset then hides rolldown's
19
+ * `MODULE_LEVEL_DIRECTIVE` warning, which is only noise in that mode. With `false` the
20
+ * warning stays on, because there it points at a directive that the bundle drops.
21
+ */
22
+ unbundle?: boolean;
13
23
  }
14
24
  /**
15
25
  * Builds the shared tsdown config: ESM only, `.d.ts` generation (fast path through
16
26
  * isolatedDeclarations), no source maps, a clean output folder and tree-shaking.
17
27
  *
28
+ * With `unbundle: true` each source file becomes its own output file (see
29
+ * {@link Integr8TsdownOptions.unbundle}).
30
+ *
18
31
  * Output files always use `.mjs` and `.d.mts`, whatever the platform, so a package's
19
32
  * `exports` map is the same everywhere. Dependencies and peer dependencies stay external
20
33
  * (tsdown's default).
21
34
  *
22
- * @param options - Entry points and target platform.
35
+ * @param options - Entry points, target platform and the optional `unbundle` switch.
23
36
  * @returns A tsdown config to default-export from `tsdown.config.ts`.
24
- * @throws {@link ConfigError} with code `INVALID_OPTION` for an empty entry or an unknown
25
- * platform.
37
+ * @throws {@link ConfigError} with code `INVALID_OPTION` for an empty entry, an unknown
38
+ * platform or an `unbundle` that is not a boolean.
26
39
  *
27
40
  * @example
28
41
  * ```ts
package/dist/tsdown.mjs CHANGED
@@ -9,14 +9,17 @@ const PLATFORMS = [
9
9
  * Builds the shared tsdown config: ESM only, `.d.ts` generation (fast path through
10
10
  * isolatedDeclarations), no source maps, a clean output folder and tree-shaking.
11
11
  *
12
+ * With `unbundle: true` each source file becomes its own output file (see
13
+ * {@link Integr8TsdownOptions.unbundle}).
14
+ *
12
15
  * Output files always use `.mjs` and `.d.mts`, whatever the platform, so a package's
13
16
  * `exports` map is the same everywhere. Dependencies and peer dependencies stay external
14
17
  * (tsdown's default).
15
18
  *
16
- * @param options - Entry points and target platform.
19
+ * @param options - Entry points, target platform and the optional `unbundle` switch.
17
20
  * @returns A tsdown config to default-export from `tsdown.config.ts`.
18
- * @throws {@link ConfigError} with code `INVALID_OPTION` for an empty entry or an unknown
19
- * platform.
21
+ * @throws {@link ConfigError} with code `INVALID_OPTION` for an empty entry, an unknown
22
+ * platform or an `unbundle` that is not a boolean.
20
23
  *
21
24
  * @example
22
25
  * ```ts
@@ -29,6 +32,8 @@ function integr8Tsdown(options) {
29
32
  if (typeof options !== "object" || options === null) throw new ConfigError("INVALID_OPTION", "integr8Tsdown: options are required.");
30
33
  const { platform } = options;
31
34
  if (!PLATFORMS.includes(platform)) throw new ConfigError("INVALID_OPTION", `integr8Tsdown: "platform" must be one of ${PLATFORMS.join(", ")}; got ${String(platform)}.`);
35
+ const { unbundle = false } = options;
36
+ if (typeof unbundle !== "boolean") throw new ConfigError("INVALID_OPTION", `integr8Tsdown: "unbundle" must be a boolean; got ${String(unbundle)}.`);
32
37
  return {
33
38
  entry: copyEntry(options.entry),
34
39
  platform,
@@ -38,9 +43,17 @@ function integr8Tsdown(options) {
38
43
  dts: true,
39
44
  sourcemap: false,
40
45
  clean: true,
41
- treeshake: true
46
+ treeshake: true,
47
+ ...unbundle ? {
48
+ unbundle: true,
49
+ inputOptions: { onLog: dropDirectiveWarning }
50
+ } : {}
42
51
  };
43
52
  }
53
+ function dropDirectiveWarning(...[level, log, defaultHandler]) {
54
+ if (log.code === "MODULE_LEVEL_DIRECTIVE") return;
55
+ defaultHandler(level, log);
56
+ }
44
57
  function copyEntry(entry) {
45
58
  if (typeof entry === "string") {
46
59
  if (entry.trim() === "") throw invalidEntry();
package/dist/vitest.d.mts CHANGED
@@ -8,15 +8,22 @@ interface Integr8VitestOptions {
8
8
  environment?: Integr8VitestEnvironment;
9
9
  /** Minimum line coverage in percent (0–100). Defaults to `80`. */
10
10
  coverageThreshold?: number;
11
+ /**
12
+ * Setup file(s) run before each test file, passed to `test.setupFiles` (for example
13
+ * `'./test/setup.ts'` for Testing Library). Non-empty strings only.
14
+ */
15
+ setupFiles?: string | string[];
11
16
  }
12
17
  /**
13
18
  * Builds the shared Vitest config: v8 coverage on `src/**` (tests, `src/index.ts` and
14
- * `playground/` excluded) that fails when line coverage is below the threshold.
19
+ * `playground/` excluded) that fails when line coverage is below the threshold. Test collection
20
+ * skips `playground/**` too, so Playwright specs there are not run by Vitest.
15
21
  *
16
- * @param options - Environment and coverage threshold.
22
+ * @param options - Environment, coverage threshold and setup files.
17
23
  * @returns A Vitest config to default-export from `vitest.config.ts`.
18
24
  * @throws {@link ConfigError} with code `INVALID_OPTION` for an unknown environment or a
19
- * threshold outside 0–100.
25
+ * threshold outside 0–100, or for `setupFiles` that is not a non-empty string or a non-empty
26
+ * list of non-empty strings.
20
27
  *
21
28
  * @example
22
29
  * ```ts
package/dist/vitest.mjs CHANGED
@@ -1,15 +1,18 @@
1
1
  import { t as ConfigError } from "./configError-Cap5gwBB.mjs";
2
+ import { configDefaults } from "vitest/config";
2
3
  // src/vitest/integr8Vitest.ts
3
4
  const ENVIRONMENTS = ["node", "jsdom"];
4
5
  const DEFAULT_COVERAGE_THRESHOLD = 80;
5
6
  /**
6
7
  * Builds the shared Vitest config: v8 coverage on `src/**` (tests, `src/index.ts` and
7
- * `playground/` excluded) that fails when line coverage is below the threshold.
8
+ * `playground/` excluded) that fails when line coverage is below the threshold. Test collection
9
+ * skips `playground/**` too, so Playwright specs there are not run by Vitest.
8
10
  *
9
- * @param options - Environment and coverage threshold.
11
+ * @param options - Environment, coverage threshold and setup files.
10
12
  * @returns A Vitest config to default-export from `vitest.config.ts`.
11
13
  * @throws {@link ConfigError} with code `INVALID_OPTION` for an unknown environment or a
12
- * threshold outside 0–100.
14
+ * threshold outside 0–100, or for `setupFiles` that is not a non-empty string or a non-empty
15
+ * list of non-empty strings.
13
16
  *
14
17
  * @example
15
18
  * ```ts
@@ -23,8 +26,11 @@ function integr8Vitest(options = {}) {
23
26
  const coverageThreshold = options.coverageThreshold ?? DEFAULT_COVERAGE_THRESHOLD;
24
27
  if (!ENVIRONMENTS.includes(environment)) throw new ConfigError("INVALID_OPTION", `integr8Vitest: "environment" must be one of ${ENVIRONMENTS.join(", ")}; got ${String(environment)}.`);
25
28
  if (typeof coverageThreshold !== "number" || !Number.isFinite(coverageThreshold) || coverageThreshold < 0 || coverageThreshold > 100) throw new ConfigError("INVALID_OPTION", `integr8Vitest: "coverageThreshold" must be a number from 0 to 100; got ${String(coverageThreshold)}.`);
29
+ const setupFiles = copySetupFiles(options.setupFiles);
26
30
  return { test: {
27
31
  environment,
32
+ exclude: [...configDefaults.exclude, "playground/**"],
33
+ ...setupFiles === void 0 ? {} : { setupFiles },
28
34
  coverage: {
29
35
  provider: "v8",
30
36
  include: ["src/**/*.{ts,tsx}"],
@@ -39,4 +45,13 @@ function integr8Vitest(options = {}) {
39
45
  }
40
46
  } };
41
47
  }
48
+ function copySetupFiles(setupFiles) {
49
+ if (setupFiles === void 0) return;
50
+ if (isNonEmptyString(setupFiles)) return setupFiles;
51
+ if (Array.isArray(setupFiles) && setupFiles.length > 0 && setupFiles.every(isNonEmptyString)) return [...setupFiles];
52
+ throw new ConfigError("INVALID_OPTION", "integr8Vitest: \"setupFiles\" must be a non-empty path or a non-empty list of non-empty paths.");
53
+ }
54
+ function isNonEmptyString(value) {
55
+ return typeof value === "string" && value.trim() !== "";
56
+ }
42
57
  export { ConfigError, integr8Vitest };
package/lefthook/base.yml CHANGED
@@ -23,6 +23,3 @@ pre-push:
23
23
  build:
24
24
  priority: 3
25
25
  run: npm run build
26
- playground-smoke:
27
- priority: 4
28
- run: npm run playground:smoke --if-present
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@integr8-media/config",
3
- "version": "1.0.0",
3
+ "version": "1.2.0",
4
4
  "description": "Shared tooling presets for every @integr8-media repo: TypeScript, Biome, Vitest, tsdown, Lefthook and size-limit.",
5
5
  "license": "MIT",
6
6
  "author": "Mina Louis Leon",
@@ -42,8 +42,15 @@
42
42
  "types": "./dist/sizeLimit.d.mts",
43
43
  "default": "./dist/sizeLimit.mjs"
44
44
  },
45
+ "./registry-site": {
46
+ "types": "./dist/registrySite.d.mts",
47
+ "default": "./dist/registrySite.mjs"
48
+ },
45
49
  "./package.json": "./package.json"
46
50
  },
51
+ "bin": {
52
+ "integr8-registry-site": "./dist/registrySiteBin.mjs"
53
+ },
47
54
  "publishConfig": {
48
55
  "access": "public"
49
56
  },
@@ -55,7 +62,7 @@
55
62
  "test:coverage": "vitest run --coverage",
56
63
  "build": "tsdown",
57
64
  "size": "size-limit",
58
- "check:exports": "publint && attw --pack --profile esm-only --entrypoints ./vitest ./tsdown ./size-limit",
65
+ "check:exports": "publint && attw --pack --profile esm-only --entrypoints ./vitest ./tsdown ./size-limit ./registry-site",
59
66
  "docs": "typedoc",
60
67
  "prepare": "lefthook install"
61
68
  },