Skip to content

Commit 41aab52

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 e2af5fc commit 41aab52

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
@@ -158,8 +158,8 @@ unaffected: `docs/` is not in the `files` allowlist.
158158

159159
## Workflow and packaging follow-ups
160160

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

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

0 commit comments

Comments
 (0)