Skip to content

Commit 485d4f4

Browse files
mariohmolclaude
andcommitted
docs: add troubleshooting section for js-brasil CommonJS compile error (fixes #77)
Angular 11+ treats CommonJS dependencies as warnings (or errors). Add a Troubleshooting section explaining the allowedCommonJsDependencies fix. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent f1a23ee commit 485d4f4

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,41 @@ const formatted = new NgBrDirectives.InscricaoEstadualPipe()
136136
.transform('625085487072', 'sp');
137137
```
138138

139+
## Troubleshooting
140+
141+
### `js-brasil` fails to compile / CommonJS warning in Angular 11+
142+
143+
Angular 11 introduced stricter handling of CommonJS dependencies. Because `js-brasil` ships
144+
a CommonJS build, Angular may print a warning or fail with an error like:
145+
146+
```
147+
WARNING in js-brasil (and its dependencies) should be converted to ES modules.
148+
CommonJS or AMD dependencies can cause optimization bailouts.
149+
```
150+
151+
**Fix:** add `js-brasil` to `allowedCommonJsDependencies` in your project's `angular.json`:
152+
153+
```json
154+
{
155+
"projects": {
156+
"<your-app>": {
157+
"architect": {
158+
"build": {
159+
"options": {
160+
"allowedCommonJsDependencies": ["js-brasil"]
161+
}
162+
}
163+
}
164+
}
165+
}
166+
}
167+
```
168+
169+
See the [Angular CommonJS dependencies guide](https://angular.io/guide/build#configuring-commonjs-dependencies)
170+
for more details.
171+
172+
---
173+
139174
## Collaborate
140175

141176
```bash

0 commit comments

Comments
 (0)