Skip to content

Commit

Permalink
[workspace] Set Jest transformIgnorePatterns to default (#3880)
Browse files Browse the repository at this point in the history
This PR makes the following changes:
- In `jest.config.base.js` explicitly set `transformIgnorePatterns` to
the default (`['/node_modules/', '\\.pnp\\.[^\\/]+$']`), which will skip
running transforms on node-modules or pnp files. We were overriding the
default with an empty array. Standard practice is to only transform
specific dependencies if there is a need.
- Remove patch for `unicorn-magic` dependency, as it is no longer being
broken by the jest transform.
- Add README to `./patches` explaining how to make a patch using
`patch-package`. This also prevents the `patches` directory from being
removed if there are no patches, breaking the docker build.

Ref: #3871, #3874
  • Loading branch information
busma13 authored Dec 16, 2024
1 parent d75756c commit d21aba3
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 15 deletions.
5 changes: 4 additions & 1 deletion jest.config.base.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ export default (projectDir) => {
`<rootDir>/${parentFolder}/*/dist`,
`<rootDir>/${parentFolder}/teraslice-cli/test/fixtures/`
],
transformIgnorePatterns: [],
// do not run transforms on node_modules or pnp files
transformIgnorePatterns: [
'/node_modules/',
'\\.pnp\\.[^\\/]+$'],
moduleNameMapper: {
'^(\\.{1,2}/.*)\\.js$': '$1',
},
Expand Down
25 changes: 25 additions & 0 deletions patches/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# README

The `patches` directory is used to store patches made using [patch-package](https://github.com/ds300/patch-package/blob/master/README.md).

## How to make a patch

### Making patches

First make changes to the files of a particular package in your node_modules folder, then run

```bash
yarn patch-package package-name
```

### Nested packages

If you are trying to patch a package at, e.g. node_modules/package/node_modules/another-package you can just put a / between the package names:

```bash
npx patch-package package/another-package
```

### Updating patches

Use exactly the same process as for making patches in the first place, i.e. make more changes, run patch-package, commit the changes to the patch file.
14 changes: 0 additions & 14 deletions patches/npm-run-path++unicorn-magic+0.3.0.patch

This file was deleted.

0 comments on commit d21aba3

Please sign in to comment.