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

docs: Update Configuration.md for added special notes on usage scenarios for pnpm. #13115

Merged
merged 7 commits into from Aug 22, 2022

Conversation

dev-itsheng
Copy link
Contributor

Added special notes on usage scenarios for pnpm.

Summary

see #12984.

I use Jest to test a tool library packaged with Rollup, which uses the two ES Module packages lodash-es and dayjs/esm, since my Node.js does not support direct execution of ES Module (I There is no corresponding configuration), so I need to do conversion, and I checked the documentation, installed babel-jest and configured babel.config.js and jest.config.js:

// jest.config.js
module.exports = {
    transformIgnorePatterns: ['<rootDir>/node_modules/(?!(lodash-es|dayjs))']
};
// babel.config.js
module.exports = {
    presets: [
        ['@babel/preset-env', { targets: { node: 'current' } }],
        '@babel/preset-typescript',
    ]
};

It works fine.

When I replaced yarn with pnpm and executed Jest for unit testing, an error occurred. Then I spent a lot of time investigating, and finally I found this Issue, which matched my scenario. I made a slight modification according to the comments below. :

// jest.config.js
module.exports = {
    // Since pnpm uses symlinks, you need to add a .pnpm path
    transformIgnorePatterns: ['<rootDir>/node_modules/.pnpm/(?!(lodash-es|dayjs)@)']
};

It passed.

As more and more people use pnpm, I'm sure that many people will encounter this problem in the future, and an update to the documentation here is necessary to prevent more people like me from spending as much time on this problem.

So I updated the documentation.

Test plan

First, it worked on my device.

But this seems to be difficult to test. In order to design test cases, we need to use pnpm as the package manager, and construct an actual node_modules directory structure, and then set the corresponding structure of transformIgnorePatterns in jest.config.js , and then check if the package has been converted by babel.

I think this seems unnecessary, so I didn't do the corresponding processing.

Added special notes on usage scenarios for pnpm.
Copy link
Member

@SimenB SimenB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks! can you update all versions of this doc?

image

@@ -1651,6 +1651,20 @@ Example:
}
```

:::tip

If you use pnpm and need to convert some packages under `node_modules`, you need to note that the packages in this folder (eg `node_modules/package-a/`) have been symlinked to the path under `.pnpm` (eg ` node_modules/.pnpm/package-a@x.x.x/node_modules/pakcage-a/`), so using `<rootdir>/node_modules/(?!(package-a|package-b)/)` directly will not be recognized, while is to use:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
If you use pnpm and need to convert some packages under `node_modules`, you need to note that the packages in this folder (eg `node_modules/package-a/`) have been symlinked to the path under `.pnpm` (eg ` node_modules/.pnpm/package-a@x.x.x/node_modules/pakcage-a/`), so using `<rootdir>/node_modules/(?!(package-a|package-b)/)` directly will not be recognized, while is to use:
If you use `pnpm` and need to convert some packages under `node_modules`, you need to note that the packages in this folder (e.g. `node_modules/package-a/`) have been symlinked to the path under `.pnpm` (e.g. `node_modules/.pnpm/package-a@x.x.x/node_modules/pakcage-a/`), so using `<rootdir>/node_modules/(?!(package-a|package-b)/)` directly will not be recognized, while is to use:

@dev-itsheng
Copy link
Contributor Author

thanks! can you update all versions of this doc?

image

Due to being busy recently, it took me a while to finish this PR. I have added the corresponding documentation for each release and revised some details.

Copy link
Member

@SimenB SimenB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants