Skip to content

TypeScript should be a peerdependency #839

@arcanis

Description

@arcanis

Expected Behaviour

ts-loader shouldn't rely on undefined behaviors

Actual Behaviour

ts-loader currently relies on the hoisting in order to have access to the typescript package

The fix is pretty simple: typescript just has to be listed as a peerDependencies of ts-loader (rather than just a devDependencies). This will guarantee that it will then get the exact same instance than its parent. It can be listed as both if you want to also install it by default on dev environments.

Steps to Reproduce the Problem

It causes issues with package trees that do not support hoisting, such as Yarn Plug'n'Play.

Location of a Minimal Repository that Demonstrates the Issue.

Because Plug'n'Play has a fallback mechanism, hitting this case is a bit more difficult to reproduce - but basically, if you have a workspace that depends on both ts-loader and typescript, it won't work (because ts-loader won't be allowed to access typescript as it's not one of its dependencies, and because the fallback won't kick in since typescript will be in a workspace rather than the top-level module).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions