@sharadox/vitest-configuration-web-library 0.1.1 → 0.1.3

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.
package/README.md CHANGED
@@ -55,7 +55,7 @@ Run with `vitest run --coverage` so the thresholds are enforced.
55
55
  - `react`: boolean.
56
56
  - `coverage`: per-measure thresholds that override 100.
57
57
 
58
- The `sharadox-source` export condition is on for Vite and for Node, so a library importing itself by name always gets its TypeScript source in tests, built or not.
58
+ Only the package's own name resolves to its source; dependencies keep their published builds. Other `@sharadox` packages are processed by Vitest (not loaded by Node directly), because they use bundler-style imports such as `next/link`.
59
59
 
60
60
  ## Develop
61
61
 
@@ -1,7 +1,5 @@
1
1
  import type { ViteUserConfig } from "vitest/config";
2
2
  import type { TestOptions } from "@sharadox/vitest-configuration-web-library/library-test/type";
3
- /** The package export condition that points at TypeScript source instead of the build. */
4
- export declare const SOURCE_CONDITION = "sharadox-source";
5
3
  /**
6
4
  * Builds the Vitest configuration of a project whose code lives in `folder` (`source` for libraries, `src` for
7
5
  * Next.js applications): imports of the package by its own name resolve to that folder, `?(*-)unit-test.ts(x)` and
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/library-test/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAGpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8DAA8D,CAAC;AAEhG,0FAA0F;AAC1F,eAAO,MAAM,gBAAgB,oBAAoB,CAAC;AAIlD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,MAAM,EACd,EAAE,IAAI,EAAE,WAAoB,EAAE,KAAK,EAAE,SAAiB,EAAE,QAAQ,EAAE,EAAE,WAAW,GAC9E,cAAc,CA0BhB;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,WAAW,GAAG,cAAc,CAEtE"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/library-test/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAGpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8DAA8D,CAAC;AAIhG;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,MAAM,EACd,EAAE,IAAI,EAAE,WAAoB,EAAE,KAAK,EAAE,SAAiB,EAAE,QAAQ,EAAE,EAAE,WAAW,GAC9E,cAAc,CAyBhB;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,WAAW,GAAG,cAAc,CAEtE"}
@@ -2,8 +2,6 @@ import react from "@vitejs/plugin-react";
2
2
  import { fileURLToPath } from "node:url";
3
3
  import { FULL_COVERAGE, NOT_MEASURED } from "@sharadox/vitest-configuration-web-library/coverage";
4
4
  import { readPackageName } from "@sharadox/vitest-configuration-web-library/package-name";
5
- /** The package export condition that points at TypeScript source instead of the build. */
6
- export const SOURCE_CONDITION = "sharadox-source";
7
5
  const escape = (text) => text.replace(/[.*+?^${}()|[\]\\/]/g, "\\$&");
8
6
  /**
9
7
  * Builds the Vitest configuration of a project whose code lives in `folder` (`source` for libraries, `src` for
@@ -15,18 +13,17 @@ export function defineProjectTest(folder, { root, environment = "node", react: w
15
13
  const code = fileURLToPath(new URL(`${folder}/`, root));
16
14
  return {
17
15
  plugins: withReact ? [react()] : [],
18
- // Self-imports resolve to the source, also when Vitest leaves a file to Node (the `sharadox-source` condition).
19
- resolve: {
20
- conditions: [SOURCE_CONDITION],
21
- alias: [{ find: new RegExp(`^${escape(name)}/(.*)$`), replacement: `${code}$1` }],
22
- },
23
- ssr: { resolve: { conditions: [SOURCE_CONDITION], externalConditions: [SOURCE_CONDITION] } },
16
+ // Only the package's own imports resolve to its source; dependencies keep their published builds.
17
+ resolve: { alias: [{ find: new RegExp(`^${escape(name)}/(.*)$`), replacement: `${code}$1` }] },
24
18
  css: { preprocessorOptions: { scss: { loadPaths: [code] } } },
25
19
  test: {
26
20
  environment,
27
21
  ...(withReact ? { css: { modules: { classNameStrategy: "non-scoped" } } } : {}),
28
22
  include: [`${folder}/**/?(*-)unit-test.{ts,tsx}`],
29
23
  exclude: ["**/node_modules/**", "**/test-fixture/**"],
24
+ // Sharadox packages ship bundler-style ESM (for example `import Link from "next/link"`), so Vitest processes
25
+ // them like source instead of handing them to Node.
26
+ server: { deps: { inline: [/@sharadox\//] } },
30
27
  benchmark: { include: [`${folder}/**/?(*-)benchmark-test.{ts,tsx}`] },
31
28
  coverage: {
32
29
  provider: "v8",
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/library-test/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,sBAAsB,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,qDAAqD,CAAC;AAClG,OAAO,EAAE,eAAe,EAAE,MAAM,yDAAyD,CAAC;AAG1F,0FAA0F;AAC1F,MAAM,CAAC,MAAM,gBAAgB,GAAG,iBAAiB,CAAC;AAElD,MAAM,MAAM,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,sBAAsB,EAAE,MAAM,CAAC,CAAC;AAE9E;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAC/B,MAAc,EACd,EAAE,IAAI,EAAE,WAAW,GAAG,MAAM,EAAE,KAAK,EAAE,SAAS,GAAG,KAAK,EAAE,QAAQ,EAAe;IAE/E,MAAM,IAAI,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;IACnC,MAAM,IAAI,GAAG,aAAa,CAAC,IAAI,GAAG,CAAC,GAAG,MAAM,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;IACxD,OAAO;QACL,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,KAA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AAE,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACxF,OAAO,EAAE,CAAC,GAAG,MAAM,6BAA6B,CAAC;YACjD,OAAO,EAAE,CAAC,oBAAoB,EAAE,oBAAoB,CAAC;YACrD,6GAA6G;YAC7G,oDAAoD;YACpD,MAAM,EAAE,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,CAAC,aAAa,CAAC,EAAE,EAAE;YAC7C,SAAS,EAAE,EAAE,OAAO,EAAE,CAAC,GAAG,MAAM,kCAAkC,CAAC,EAAE;YACrE,QAAQ,EAAE;gBACR,QAAQ,EAAE,IAAI;gBACd,OAAO,EAAE,CAAC,GAAG,MAAM,gBAAgB,CAAC;gBACpC,OAAO,EAAE,CAAC,GAAG,YAAY,CAAC;gBAC1B,UAAU,EAAE,EAAE,GAAG,aAAa,EAAE,GAAG,QAAQ,EAAE;aAC9C;SACF;KACF,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAAoB;IACpD,OAAO,iBAAiB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AAC9C,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sharadox/vitest-configuration-web-library",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Shared Vitest configurations for Sharadox libraries and applications: self-imports by package name, test file patterns, React and Sass support, and 100% coverage thresholds.",
5
5
  "private": false,
6
6
  "license": "SEE LICENSE IN LICENCA.md",