TypeScript-friendly strategies for package.json subpath exports compatibility
I'd like to know if the examples from this repo are still up-to-date, and if it's still advisable to model the output of our own packages after it. My reasons to suspect they might be outdated: - most of the code has not changed since 1.5 or 2 years (not a problem per se) - there have been some changes in TypeScript since 4.8.3 (most notably `--moduleResolution bundler` and `--verbatimModuleSyntax`, I think) - can't just clone and build it (see below) - can't just pack it (see below) - does not pass `arethetypeswrong` checks (see below) Of course it could be that the examples are just fine and there is something wrong with my system and/or my assumptions. So, apart from the minor work that I had to do to make it build / start / pack, is it still advised to follow the principles of these example, or can it be done better / easier with the current version of TypeScript? --- I cloned the repo and in each of the directories `examples/node11-resolution` and `examples/node16-resolution` I tried to run the commands `npm run build` and `npm run start`. In all four cases I got the error: ``` main.[ts|cts|mts]:1:20 - error TS2307: Cannot find module 'assert' or its corresponding type declarations. 1 import assert from "assert"; ``` I know that I can solve this by running `npm install --save @types/node` in each directory, but I was wondering if this means these examples are wrong or outdated, or if something on my system (node version v21.1.0, npm version 10.8.0) is not working as expected. With the dependency added, I can `build` and `start`, and it looks successful. --- Then I tried to check the result with [`@arethetypeswrong/cli`](https://www.npmjs.com/package/@arethetypeswrong/cli), specifically with `attw --pack .` I needed to add a `name` and `version` to `package.json` for the pack to work, and then got this for both `examples/node11-resolution` and `examples/node16-resolution`: ``` ┌───────────────────┬─────────────────────────────────────┐ │ │ "example-subpath-exports-ts-compat" │ ├───────────────────┼─────────────────────────────────────┤ │ node10 │ Resolution failed │ ├───────────────────┼─────────────────────────────────────┤ │ node16 (from CJS) │ Resolution failed │ ├───────────────────┼─────────────────────────────────────┤ │ node16 (from ESM) │ Resolution failed │ ├───────────────────┼─────────────────────────────────────┤ │ bundler │ Resolution failed │ └───────────────────┴─────────────────────────────────────┘ ```
This issue appears to be discussing a feature request or bug report related to the repository. Based on the content, it seems to be resolved. The issue was opened by lenaschimmel and has received 1 comments.