tslab
tslab copied to clipboard
Support for yarn2 + workspaces
Hi! I'd love to use this with our project but we're using yarn2 (berry) with pnp mode and I cannot import any local modules. Is that supported?
Thanks!
To be honest, I'm not very familiar with yarn 2
.
I think we need to consider these 4 points to support yarn2 (pnp
):
- How to install
tslab
and register it to Jupyter withyarn 2
? Now, we installtslab
withnpm install -g tslab
and register the globall-installed tslab to Jupyter. Do we still usenpm install -g
for the global installation oftslab
? - TypeScript resolve dependencies from
node_modules
. IIUC, we need to change the typescript configuration to resolve dependencies from other places in yarn2 -
node
runtime resolves dependencies (viarequre
) fromnode_modules
. Actually, I don't understand hownode
runtime finds dependencies maintained byyarn 2
. -
tslab
finds the project-localtslab
by findingnode_modules/tslab/dist/main.js
. We also need to update this logic so that we can findyarn2
project-localtslab
binary. https://github.com/yunabe/tslab/blob/d37e7c7f094abf5a778ab4d8c39b01d6d8e82364/src/main.ts#L53
Hi @yunabe , thanks for the answer!
Just to provide some info, mainly for your point 3, yarn's pnp runtime patches node's fs
module directly, so that it resolves and loads dependencies from its zip archives instead of from node_modules
. Here's more information: https://yarnpkg.com/features/pnp#packages-are-stored-inside-zip-archives-how-can-i-access-their-files