Skip to content

Yarn2 support #1

@ghost

Description

Hey there, this is a neat project and could hopefully someday do away with needing ts-node for everything.

I want to open this as more of a TO-DO for when I or someone else finds time. Right now I'm using yarn2, which uses a virtual filesystem and doesn't have a node_modules folder. All packages are instead stored in .zip files and extracted when needed.

A few takeaways from my hour trying to get this to work with yarn2.0.0-rc.29 and node 13.9:

  • It looks like this package depends on there being a node_modules folder, so that'd need to be dealt with

  • Yarn2's virtual filesystem is accessible via a few different routes but the simplest is by starting node as node --require ./.pnp.js from the project root. Delving into exactly what happens when .pnp.js is hooked like this is a big TODO, but I believe it monkeypatches the fs module to automatically unzip packages whenever they're imported / required.

    The catch22 with using yarn2 + this neat package is:

    • When package.json has "type": "module", require is not defined at startup. Since the CLI flag --require ... seems to literally use require(...), this fails with an error.
    • Without --require ./.pnp.js, none of the workspace's packages are available, meaning --loader=@k-foss/ts-esnode results in Cannot find package '@k-foss/ts-esnode ...

So maybe sometime later this month I'll have some bandwidth to tackle this. But compliments again for finding a way to leverage these new node features to potentially make typescript less painful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions