Commit 99d542e
authored
fix(js): support private methods and static blocks in babel preset (#36218)
## Current Behavior
The `@nx/js/babel` preset loads
`@babel/plugin-transform-class-properties` on its own. That plugin runs
babel's shared class-features transform, which hard-errors on `#private`
methods and `static {}` blocks unless their companion transforms are
also loaded. When babel-jest transforms an ESM-only dependency that uses
this syntax (un-ignored through `transformIgnorePatterns`, the
documented way to consume ESM-only packages), the transform fails:
```
SyntaxError: Class private methods are not enabled. Please add `@babel/plugin-transform-private-methods` to your configuration.
```
## Expected Behavior
The preset transforms private methods, `#private in obj` checks, and
static blocks instead of erroring. It now loads the companion
class-features transforms next to `class-properties`: `private-methods`
and `private-property-in-object` with the same `loose` setting (babel
requires `loose` to match across the three), plus `class-static-block`.
This clears the whole family of "not enabled" hard-errors, not just
private methods. A regression test covering the affected syntax is
added.
## Related Issue(s)
Fixes #36205
<!-- polygraph-session-start -->
---
[View session information
↗](https://app.trypolygraph.com/orgs/6a061dcb561c062131116eca/sessions/gh-36205-21561609)
<!-- polygraph-session-end -->1 parent 9ba1c01 commit 99d542e
4 files changed
Lines changed: 59 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
73 | 84 | | |
74 | 85 | | |
75 | 86 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
126 | 129 | | |
127 | 130 | | |
128 | 131 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments