TypeStrong / TypeStrong/ts-loader

bug: fail with yarn 3 + pnp + workspaces + typescript references

Open
#1,440 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
3.5k
Forks
439
Avg merge
17h 17m
Merged PRs (30d)
2

Description

Expected Behaviour

ts-loader works with yarn 3 + pnp + workspaces + typescript references

Actual Behaviour

Link: https://github.com/TypeStrong/ts-loader/issues/1145#issuecomment-1067891664

Fail:
image

Location of a Minimal Repository that Demonstrates the Issue.

https://github.com/DiFuks/ts-references

yarn tsc - working
yarn ts-node - working
yarn webpack:babel-loader - working
yarn webpack:ts-loader - not working :(

Module not found: Error: Can't resolve './showLib' in '/Users/difuks/PhpstormProjects/ts-references/entries/submodule/dist'

At the same time, with such an edit, everything starts to work. But in this case main uses the uncompiled version of submodule

Information about various build variations is stored here: https://github.com/DiFuks/ts-references/blob/master/entries/main/src/showLib.ts#L7

This workaround also works fine

With nodeLinker: node-modules in .yarnrc.yml things get a little better, but relative imports still don't work (../../submodule)

With symlinks: true the situation returns to the one that was in the "master" branch

Contributor guide

Open the contributing guide

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 minimal repository and run yarn webpack:ts-loader, then compare it with the working yarn tsc, yarn ts-node, and yarn webpack:babel-loader commands. Review the referenced entries/main/src/showLib.ts example, the reported module-resolution error, and the linked workarounds; done means the TypeScript loader resolves the relative import with Yarn 3 PnP, workspaces, and TypeScript references without relying on the uncompiled submodule.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript, webpack
Domain
build-system, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.