Skip to content

Commit 0922fc7

Browse files
committed
build: adopt TypeScript, Vitest and Oxc development tooling
Consolidates the original contiguous commits eaf4233..8bea5b7. Preserves the exact tree at the end of this group.
1 parent 6fbe511 commit 0922fc7

75 files changed

Lines changed: 5931 additions & 4591 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.config/build.config.mts‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Published paths are stable even though their sources are TypeScript.
2+
export const entries = [
3+
'src/nwsapi',
4+
'src/dom-selector',
5+
'src/modules/nwsapi-jquery',
6+
'src/modules/nwsapi-traversal',
7+
] as const
8+
9+
export const outputs = [
10+
...entries.map(entry => `${entry}.js`),
11+
'dist/nwsapi.min.js',
12+
]

‎.config/oxfmt.json‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"tabWidth": 2,
3+
"printWidth": 80,
4+
"singleQuote": true,
5+
"trailingComma": "all",
6+
"semi": false,
7+
"arrowParens": "avoid"
8+
}

‎.config/oxlint.json‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"plugins": ["oxc", "import"],
3+
"categories": {
4+
"correctness": "error"
5+
},
6+
"env": {
7+
"node": true,
8+
"browser": true,
9+
"amd": true
10+
},
11+
"globals": {
12+
"NW": "readonly"
13+
},
14+
"rules": {
15+
"no-console": "off"
16+
},
17+
"overrides": [
18+
{
19+
"files": ["**/src/**/*.mts"],
20+
"rules": {
21+
"no-unused-vars": "off",
22+
"no-unused-expressions": "off",
23+
"no-cond-assign": "off",
24+
"no-control-regex": "off",
25+
"no-useless-escape": "off",
26+
"no-redeclare": "off",
27+
"no-empty": "off",
28+
"default-case": "error",
29+
"no-duplicate-case": "error",
30+
"radix": "error",
31+
"no-with": "error"
32+
}
33+
}
34+
]
35+
}

‎.config/playwright.config.mts‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import process from 'node:process'
2+
import { fileURLToPath } from 'node:url'
3+
import { defineConfig } from '@playwright/test'
4+
5+
// Vitest runs Node tests; this configuration only runs WPT in Chromium.
6+
export default defineConfig({
7+
testDir: '../test/upstream',
8+
outputDir: '../test-results',
9+
testMatch: 'wpt.spec.mts',
10+
fullyParallel: true,
11+
workers: process.env.WPT_UPDATE_EXPECTATIONS ? 1 : 4,
12+
reporter: 'list',
13+
timeout: 90_000,
14+
use: { baseURL: 'http://127.0.0.1:8000', browserName: 'chromium' },
15+
webServer: {
16+
cwd: fileURLToPath(new URL('../', import.meta.url)),
17+
command: 'node scripts/serve.mts',
18+
url: 'http://127.0.0.1:8000/resources/testharness.js',
19+
reuseExistingServer: false,
20+
env: { ...process.env, PORT: '8000' },
21+
},
22+
})

‎.config/vitest.config.mts‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { defineConfig } from 'vitest/config'
2+
import { fileURLToPath } from 'node:url'
3+
4+
process.env.TZ ??= 'UTC'
5+
6+
export default defineConfig({
7+
server: { watch: { usePolling: process.env.CHOKIDAR_USEPOLLING === '1' } },
8+
test: {
9+
watch: process.argv.includes('--watch'),
10+
include: ['test/*.test.mts'],
11+
globalSetup: ['.config/vitest.setup.mts'],
12+
forceRerunTriggers: ['../src/**/*.mts', '../scripts/build.mts', './**'].map(
13+
path => fileURLToPath(new URL(path, import.meta.url)),
14+
),
15+
environment: 'node',
16+
pool: 'forks',
17+
isolate: true,
18+
maxWorkers: 4,
19+
restoreMocks: true,
20+
testTimeout: 10000,
21+
coverage: {
22+
provider: 'v8',
23+
include: ['src/*.js'],
24+
reporter: ['text', 'html', 'json-summary'],
25+
},
26+
},
27+
})

‎.config/vitest.setup.mts‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { execFileSync } from 'node:child_process'
2+
import { fileURLToPath } from 'node:url'
3+
import type { TestProject } from 'vitest/node'
4+
5+
export default function setup(project: TestProject) {
6+
const build = () => {
7+
execFileSync(process.execPath, ['scripts/build.mts'], {
8+
cwd: new URL('../', import.meta.url),
9+
stdio: 'inherit',
10+
})
11+
}
12+
build()
13+
// Tests import generated CommonJS files, so watch their sources explicitly.
14+
if (project.vitest.config.watch) {
15+
project.vite.watcher.add(fileURLToPath(new URL('../src', import.meta.url)))
16+
}
17+
project.onTestsRerun(build)
18+
}
File renamed without changes.

‎.github/workflows/node.js.yml‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@ jobs:
1515
with:
1616
node-version: '26'
1717
cache: npm
18+
- run: npm install --global [email protected]
1819
- run: npm ci
1920
- run: npm run lint
20-
- run: npm test
21-
- run: npm run min
21+
- run: npm run format:check
22+
- run: npm run test:coverage
23+
- run: npm run check:coverage
24+
- run: npm run test:package
2225
- run: npm run upstream:clone
2326
- run: npm run upstream:verify
2427
- run: npx playwright install --with-deps chromium

‎.gitignore‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
**/node_modules/
2+
/coverage/
23
/dist/nwsapi.min.js
34
/playwright-report/
5+
/src/**/*.js
46
/test-results/
57
/upstream/
68
yarn.lock

‎.npmignore‎

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)