Skip to content

Commit 911adf7

Browse files
test: more coverage and fixtures. (#21)
1 parent 39719a9 commit 911adf7

28 files changed

Lines changed: 585 additions & 3 deletions

docs/release-1.0.0.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# @knighted/module 1.0.0 release notes
2+
3+
## Status
4+
5+
- Current candidate: 1.0.0-rc.0 (tag `latest` until final 1.0.0).
6+
- Stability: API surface locked for 1.0.x; only bug fixes expected before GA.
7+
8+
## Requirements
9+
10+
- Node >= 22.21.1 (tested primarily on 22.x). Older LTS are not guaranteed; add matrix coverage if support is desired.
11+
12+
## Highlights
13+
14+
- Symmetric ESM↔CJS transforms with optioned behaviors:
15+
- `topLevelAwait`: `error` (default), `wrap`, `preserve` for CJS targets.
16+
- `importMetaMain`: `shim` (default), `warn`, `error` with Node version gate.
17+
- `liveBindings`: `strict` (default), `loose`, `off` for ESM→CJS.
18+
- `cjsDefault`: `auto` (default), `module-exports`, `none` for default import interop.
19+
- `rewriteSpecifier`: extension or callback-based specifier rewriting for both directions.
20+
- `requireSource`: `builtin` (default) or `create-require` fallback.
21+
- Defensive handling: reject `with` / unshadowed `eval` when raising to ESM; reject shadowed `module`/`exports` in CJS lowering.
22+
- Runtime coverage: fixtures and integration tests for **filename/**dirname/import.meta globals, `require.main` rewrites, TLA wrapping, namespace/default interop, export hoisting, and project-level conversions.
23+
24+
## Behavior guarantees
25+
26+
- Live bindings are strict by default for ESM→CJS; CJS→ESM rewrites avoid unsound cases by throwing on unsupported constructs.
27+
- `import.meta` properties shimmed when targeting CJS; `import.meta.main` guarded by version-aware warnings/errors.
28+
- Top-level await in CJS targets defaults to `error`; wrapping/preserve are opt-in and keep exports intact.
29+
30+
## Packaging and metadata
31+
32+
- Confirm `package.json` exports/fields (`main`, `exports`, `types`) match the build outputs.
33+
- Dependencies: `oxc-parser`, `@babel/parser/traverse`, `magic-string`, `@knighted/specifier`, `@knighted/walk`, `node-module-type`.
34+
- Consider source maps (not emitted today); document absence if deferring.
35+
36+
## Testing
37+
38+
- Lint: `npm run lint` (oxlint) — clean.
39+
- Tests: `npm test`~98% statements, ~93% branches; format.ts 100% line coverage, remaining branches are defensive/unreachable.
40+
- Add Node matrix if supporting additional runtimes before GA.
41+
42+
## Release steps to GA
43+
44+
1. Publish 1.0.0-rc.0 as `latest` (per plan); keep `next` if needed for future prereleases.
45+
2. Monitor for regressions; if none, tag 1.0.0 with the same artifacts.
46+
3. Update README and docs links to reference this release note; remove any “remaining gaps” language now that coverage is closed.
47+
4. Add changelog entry summarizing changes since 1.0.0-alpha.8/1.0.0-beta.5.
48+
49+
## Open questions
50+
51+
- Do we want official support for Node 20/18? If yes, run matrix and adjust shims accordingly.
52+
- CLI packaging: still library-only; document intentionally if not providing a CLI.

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@knighted/module",
3-
"version": "1.0.0-beta.5",
3+
"version": "1.0.0-rc.0",
44
"description": "Transforms differences between ES modules and CommonJS.",
55
"type": "module",
66
"main": "dist/module.js",

test/fixtures/arrayValue.cjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = [1, 2, 3]
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module.exports
2+
exports.foo = 1
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import foo from './values.cjs'
2+
3+
export const value = foo.foo

test/fixtures/evalOnly.cjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
eval('exports.ok = true')
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default function () {
2+
return 'anon'
3+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
await Promise.resolve('tla')
2+
3+
export default function () {
4+
return 'tla-anon'
5+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default function namedNoTla() {
2+
return 'named-no-tla'
3+
}

0 commit comments

Comments
 (0)