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

support pnpm #459

Open
1 task done
qballer opened this issue Oct 5, 2024 · 6 comments
Open
1 task done

support pnpm #459

qballer opened this issue Oct 5, 2024 · 6 comments
Assignees
Labels
enhancement New feature or request

Comments

@qballer
Copy link
Collaborator

qballer commented Oct 5, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe it

The project's current post-install scripts to get augmentation to work assume a hoisted node_modules system like in yarn and npm. This breaks when using PNPM install

Describe the solution you'd like

To get support for PNPM, the post-install script will need to support both hoisted and nested packages.
Specifically, lines like:
https://github.com/suites-dev/suites/blob/master/packages/di/nestjs/postinstall.js#L4
https://github.com/suites-dev/suites/blob/master/packages/di/inversify/postinstall.js#L4
And:
https://github.com/suites-dev/suites/blob/master/packages/doubles/jest/postinstall.js#L4-L7
https://github.com/suites-dev/suites/blob/master/packages/doubles/sinon/postinstall.js#L4-L7
https://github.com/suites-dev/suites/blob/master/packages/doubles/vitest/postinstall.mjs#L8-L11

Those post-install scripts will need to change in a way that allows them to detect dist folders (in suites repo), hoisted packages(Yarn and NPM), and nested packages (PNPM).

What is the motivation / use case for changing the behavior?

support PNPM

@qballer qballer added enhancement New feature or request hacktoberfest Hacktoberfest labels Oct 5, 2024
@omermorad omermorad changed the title support pnpm in suites support pnpm Oct 9, 2024
@qballer
Copy link
Collaborator Author

qballer commented Oct 11, 2024

Digging more into this, pnpm installs all the nested node_modules in .pnpm and resolves modules a bit differently. I will have to understand it better to support the type of augmentation done here.

@omermorad
Copy link
Collaborator

@qballer any news?

@qballer
Copy link
Collaborator Author

qballer commented Oct 18, 2024

I thought about maybe reusing the global.d.ts method and changing how the post-install script works. This means that instead of editing files, I would like to add a file called global.d.ts at the root of the dependency, which does what is right.
This would reduce the dependency on the internal structure of node_modules, which differs for each package manager.

@kyrregjerstad
Copy link

Hi, I'm using pnpm and i'm not able to import Mocked from @suites/unit, I have to import it from @suites/doubles.vitest. Any fix for this?

import type { Mocked } from '@suites/doubles.vitest';
import { TestBed } from '@suites/unit';

@omermorad
Copy link
Collaborator

Hi @kyrregjerstad, please see this: https://suites.dev/docs/overview/installation/#for-yarn-v1x-users

Realtes #473 (reply in thread)

Let me know if it worked :)

@kyrregjerstad
Copy link

kyrregjerstad commented Dec 26, 2024

Hi @omermorad, thanks for the quick reply!

I tried following the yarn install guide without any luck.

I discovered that the issue stems from using TypeScript's newer "moduleResolution": "bundler" setting. The library currently requires "moduleResolution": "node" to work properly.

Here's the working tsconfig.json configuration:

{
  "compilerOptions": {
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "moduleResolution": "node"
  },
  "include": ["src/**/*", "./global.d.ts"]
}

Would it be possible to add support for the bundler moduleResolution in a future release?

This would help developers using modern bundlers like Vite/webpack and align with TypeScript's recommended settings for newer projects.

Let me know if you'd like me to create a separate feature request issue for this enhancement.

@omermorad omermorad reopened this Mar 9, 2025
@omermorad omermorad removed the hacktoberfest Hacktoberfest label Mar 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants