Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jonchurch/exports-ts
Repro of TS issues consuming a package that uses package.json exports field
https://github.com/jonchurch/exports-ts
Last synced: 22 days ago
JSON representation
Repro of TS issues consuming a package that uses package.json exports field
- Host: GitHub
- URL: https://github.com/jonchurch/exports-ts
- Owner: jonchurch
- Created: 2022-09-12T15:04:26.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-09-14T03:05:36.000Z (over 2 years ago)
- Last Synced: 2024-10-06T14:40:53.307Z (3 months ago)
- Language: TypeScript
- Size: 11.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
# Typescript Public Exports Demo
The goal of this package is to create a reproduction of issues I was seeing getting typescript to understand `exports` field in a package.
The repo consists of a pacakge that declares public entrypoints using the `exports` field in package.json, and an app built with typescript that consumes the package.
# The Fix -- Typescript v4.7
I had to do a few things to get the submodule import working:
* Upgrade to `[email protected]`
* set `"moduleResolution": "nodenext"`Typescript v4.7 included official support for the `exports` field. Oddly enough, it was actually the `.` import (or said another way, `import {wait} from 'package'`) that wasn't working once I was on the proper TS version. The submodule worked once I got the right TS version.
To get the root import working, I had to update the consuming `app/tsconfig.json` with `"moduleResolution": "nodenext"`. I don't think the exports field is meant to be unique to ECMAScript Modules, but apparently typescript was not satisfied with the default `"moduleResolution": "node"` setting.