Skip to content

Commit 20ca39e

Browse files
committed
docs: record the CommonJS TypeScript import gap
The fix for it is an `exports` map, and that also seals the deep imports this project keeps working, so it belongs to 3.0.0 rather than to the documentation stack — which is exactly what the deferred-work ledger is for. Measured on the published tarball: TS1479 for a static import from a `.cts` file under node16/nodenext and TS1471 for `import ... = require(...)`, while dynamic `import()`, node10/bundler resolution and JavaScript `require()` all compile.
1 parent 8efd5fd commit 20ca39e

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

‎docs/plans/deferred-work.md‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ unaffected: `docs/` is not in the `files` allowlist.
139139

140140
## Workflow and packaging follow-ups
141141

142-
Noticed while auditing the stack before its first deployment. Neither is broken today — every run on the
143-
three pull requests is green — so both wait for a commit of their own.
142+
Noticed while auditing the stack before its first deployment. None of these is broken today — every run
143+
on the three pull requests is green — so each waits for a commit of its own.
144144

145145
- **The workflows pin action majors that are several releases behind.** `.github/workflows/docs.yml` uses
146146
`actions/checkout@v4`, `actions/setup-node@v4`, `actions/configure-pages@v5`,
@@ -160,3 +160,14 @@ three pull requests is green — so both wait for a commit of their own.
160160
repository instead, in which case there is nothing to fix. The file is also served by neither site:
161161
the old index only used it as an `<img>` in the README's heading, and that URL already 404s on the
162162
published TypeDoc site.
163+
- **A CommonJS TypeScript consumer cannot import the package under `node16`/`nodenext`.** Measured on the
164+
published tarball, in a `.cts` file compiled with `module`/`moduleResolution` `node16`:
165+
`import { MaxRectsPacker } from "maxrects-packer"` is TS1479 ("the referenced file is an ECMAScript
166+
module and cannot be imported with `require`") and `import pkg = require("maxrects-packer")` is TS1471,
167+
while `await import(...)`, `moduleResolution` `node10`/`bundler` and a JavaScript `require()` all work;
168+
neither `skipLibCheck` nor the compiler version changes anything (TS 6 and TS 7 both). No gate can see
169+
it: `verify:package` compiles its type fixture in an ESM consumer, which is exactly what makes
170+
`node16`/`nodenext` read it as ESM, and the runtime `require()` path it does cover is fine. The fix is
171+
an `exports` map with per-format conditions and declarations — which also seals off the deep imports
172+
`maxrects-packer/dist/...` that the entry-points section above keeps working, so it belongs to 3.0.0.
173+
Documented as a sharp edge in `docs/user/troubleshooting.md` meanwhile.

0 commit comments

Comments
 (0)