Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

whether to consider pnpm compatibility? #41

Open
AnaniZhu opened this issue Jul 11, 2022 · 3 comments
Open

whether to consider pnpm compatibility? #41

AnaniZhu opened this issue Jul 11, 2022 · 3 comments

Comments

@AnaniZhu
Copy link

AnaniZhu commented Jul 11, 2022

image

this code get .bin folder failed when use pnpm

@najens
Copy link

najens commented Dec 15, 2022

I was able to get this library to work with pnpm by updating the resolve path to the tsc executable.
Screen Shot 2022-12-15 at 7 27 29 AM
Looking into a cleaner solution that can be added as a pull request.

@FFdhorkin
Copy link

FFdhorkin commented Oct 3, 2023

tsc-files 1.1.4 does not appear to currently work with pnpm.

In node_modules/.bin/tsc-files, it has

if [ -z "$NODE_PATH" ]; then
  export NODE_PATH="/my/project/path/node_modules/.pnpm/[email protected][email protected]/node_modules/tsc-files/node_modules:/my/project/path/node_modules/.pnpm/[email protected][email protected]/node_modules:/my/project/path/node_modules/.pnpm/node_modules"
else
  export NODE_PATH="/my/project/path/node_modules/.pnpm/[email protected][email protected]/node_modules/tsc-files/node_modules:/my/project/path/node_modules/.pnpm/[email protected][email protected]/node_modules:/my/project/path/node_modules/.pnpm/node_modules:$NODE_PATH"
fi

At the end of node_modules/tsc-files/cli.js, it has

const { status } = result = spawnSync(
  // See: https://github.com/gustavopch/tsc-files/issues/44#issuecomment-1250783206
  process.versions.pnp
    ? 'tsc'
    : resolveFromModule(
      'typescript',
      `../node_modules/.bin/tsc${process.platform === 'win32' ? '.cmd' : ''}`,
    ),
  ['-p', tmpTsconfigPath, ...remainingArgsToForward],
  { stdio: 'inherit' },
)

pnp resolves to undefined, so it goes to the false case of the ternary. Then it resolves the path to /my/repo/path/node_modules/.pnpm/[email protected]/node_modules/node_modules/.bin/tsc... which doesn't exist

incidentally, you have to go up several levels to get to something that does exist: /my/repo/path/node_modules/.pnpm/[email protected]/node_modules/ and the only contents of that folder are a subfolder called typescript. There is no bin there!

This needs to resolve to /my/repo/path/node_modules/.pnpm/[email protected]/node_modules/typescript/bin/tsc to work with pnpm.

This seems to work with pnpm:

const { status } = result = spawnSync(
  // See: https://github.com/gustavopch/tsc-files/issues/44#issuecomment-1250783206
  process.versions.pnp
    ? 'tsc'
    : resolveFromRoot(
      `node_modules/.bin/tsc${process.platform === 'win32' ? '.cmd' : ''}`,
    ),
  ['-p', tmpTsconfigPath, ...remainingArgsToForward],
  { stdio: 'inherit' },
)

@jonasgeiler
Copy link

jonasgeiler commented Oct 22, 2023

My fork tried to implement this: https://github.com/skayo/tsc-files
It works for my PNPM projects, but I only tested it on Linux so there might still be problems.
Not sure if I should do a PR here, but for now I'll release it as my own package (@jonasgeiler/tsc-files).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants