Skip to content

Commit 06e600c

Browse files
committed
chore: simplify package entry + test path construction
- restore `main`, drop the `exports` map and `prepare`/tsc build step - comment the value-parser `word` re-tag in transformValue - use `new URL(...)` for corpus paths instead of dirname/join chains
1 parent 172e0af commit 06e600c

5 files changed

Lines changed: 7 additions & 26 deletions

File tree

package.json

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,14 @@
1414
"type": "git",
1515
"url": "https://github.com/postcss/postcss-calc.git"
1616
},
17+
"main": "src/index.js",
1718
"types": "types/index.d.ts",
18-
"exports": {
19-
".": {
20-
"types": "./types/index.d.ts",
21-
"default": "./src/index.js"
22-
},
23-
"./package.json": "./package.json"
24-
},
2519
"files": [
2620
"src",
2721
"types",
2822
"LICENSE"
2923
],
3024
"scripts": {
31-
"prepare": "tsc",
3225
"lint": "eslint . && tsc",
3326
"test": "node --test",
3427
"test:mutation": "stryker run",

src/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ function transformValue(value, options, result, item) {
6767
});
6868
}
6969

70+
// Re-tag as `word` so value-parser emits `str` verbatim instead of
71+
// re-wrapping it as `name(...)`. Cast widens the `'function'` literal.
7072
/** @type {{type: string}} */ (node).type = 'word';
7173
node.value = str;
7274
} catch (error) {

test/conformance/corpus.test.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
// assert they agree. Any divergence is either a real bug or a known
1111
// design choice documented in `KNOWN_DIVERGENCES`.
1212
import { readdirSync, readFileSync } from 'node:fs';
13-
import { dirname, join } from 'node:path';
13+
import { join } from 'node:path';
1414
import { fileURLToPath } from 'node:url';
1515
import { test } from 'node:test';
1616
import assert from 'node:assert/strict';
1717
import { calc as csstoolsCalc } from '@csstools/css-calc';
1818
import { out } from '../helpers/out.mjs';
19-
const CORPUS_DIR = join(dirname(fileURLToPath(import.meta.url)), '../corpus');
19+
const CORPUS_DIR = fileURLToPath(new URL('../corpus/', import.meta.url));
2020
const COMPARE_PRECISION = 10;
2121
function ourOut(input) {
2222
try {

test/conformance/invalid-corpus.test.mjs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,12 @@
1010
//
1111
// Goal: every input must throw a real synchronous `Error`. No hangs, no
1212
// non-Error throws.
13-
import { dirname, join } from 'node:path';
1413
import { fileURLToPath } from 'node:url';
1514
import { test } from 'node:test';
1615
import assert from 'node:assert/strict';
1716
import { runCorpus, assertResilience } from '../helpers/resilience.mjs';
1817
const r = runCorpus(
19-
join(
20-
dirname(fileURLToPath(import.meta.url)),
21-
'..',
22-
'corpus',
23-
'github',
24-
'invalid.txt'
25-
)
18+
fileURLToPath(new URL('../corpus/github/invalid.txt', import.meta.url))
2619
);
2720
test(`invalid corpus: ${r.total} expressions parse-or-throw cleanly`, () => {
2821
assertResilience(r, 'invalid', assert);

test/conformance/preprocessor-corpus.test.mjs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
11
// Parser-only resilience test against real-world preprocessor (SCSS/Less)
22
// `calc(...)` expressions harvested from public GitHub repos. Asserts every
33
// input parses or throws cleanly — no hangs, no non-Error throws.
4-
import { dirname, join } from 'node:path';
54
import { fileURLToPath } from 'node:url';
65
import { test } from 'node:test';
76
import assert from 'node:assert/strict';
87
import { runCorpus, assertResilience } from '../helpers/resilience.mjs';
98
const r = runCorpus(
10-
join(
11-
dirname(fileURLToPath(import.meta.url)),
12-
'..',
13-
'corpus',
14-
'github',
15-
'preprocessor.txt'
16-
)
9+
fileURLToPath(new URL('../corpus/github/preprocessor.txt', import.meta.url))
1710
);
1811
test(`preprocessor corpus: ${r.total} expressions parse-or-throw cleanly`, () => {
1912
assertResilience(r, 'preprocessor', assert);

0 commit comments

Comments
 (0)