tslab icon indicating copy to clipboard operation
tslab copied to clipboard

Support for yarn2 + workspaces

Open the21st opened this issue 3 years ago • 2 comments

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!

the21st avatar Mar 15 '21 18:03 the21st

To be honest, I'm not very familiar with yarn 2.

I think we need to consider these 4 points to support yarn2 (pnp):

  1. How to install tslab and register it to Jupyter with yarn 2? Now, we install tslab with npm install -g tslab and register the globall-installed tslab to Jupyter. Do we still use npm install -g for the global installation of tslab?
  2. TypeScript resolve dependencies from node_modules. IIUC, we need to change the typescript configuration to resolve dependencies from other places in yarn2
  3. node runtime resolves dependencies (via requre) from node_modules. Actually, I don't understand how node runtime finds dependencies maintained by yarn 2.
  4. tslab finds the project-local tslab by finding node_modules/tslab/dist/main.js. We also need to update this logic so that we can find yarn2 project-local tslab binary. https://github.com/yunabe/tslab/blob/d37e7c7f094abf5a778ab4d8c39b01d6d8e82364/src/main.ts#L53

yunabe avatar Mar 17 '21 02:03 yunabe

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

the21st avatar Mar 27 '21 10:03 the21st