microsoft / microsoft/TypeScript-Website

ATA: Unable to resolve sub module path for dual published ESM/CJS package

Open
#3,008 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
2.6k
Forks
1.5k
Avg merge
2d 2h
Merged PRs (30d)
7

Description

Page URL:

TypeScript Link Here

Example Code:

Code above

import { Type } from '@sinclair/typebox'        // ok
import { Value } from '@sinclair/typebox/value' // not found

Issue:

I'm not sure if this is a critical issue, but following a recent update to support dual published ESM / CJS in TypeBox. I have noticed that the TSP is no longer able to locate the /value sub module (or any other sub module), however the top level module import continues to work fine. I have checked to ensure TS resolution of sub module paths are valid for the package via the link below, I believe everything is setup correctly.

https://arethetypeswrong.github.io/?p=%40sinclair%2Ftypebox%400.32.4

I should note that this package uses a somewhat non-typical package redirection setup to support dual publishing. The technique it uses is described at the following link / project.

https://github.com/andrewbranch/example-subpath-exports-ts-compat/tree/main/examples/node_modules/package-json-redirects

Would be amazing if this could be looked at as I use the TSP almost daily to help users who have submitting issues to the TypeBox project. It would be a shame to lose the sub module imports as many type inference features exists for these sub modules, and it would be difficult to demonstrate functionality and share code via other means.

Many Thanks

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked TypeScript Playground reproduction and confirm that @sinclair/typebox resolves while @sinclair/typebox/value does not. Compare the package setup described in the arethetypeswrong report with the package-json-redirects example, and consider the issue complete when valid dual ESM/CJS subpath imports resolve in the Playground.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
developer-experience, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.