Fix migrations & schematics commonjs type for latest package, adjust module output#17183
Fix migrations & schematics commonjs type for latest package, adjust module output#17183damyanpetev merged 2 commits intomasterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses ng update migration/schematics crashes when the published igniteui-angular package is treated as ESM ("type": "module"), by ensuring the migrations/ and schematics/ subdirectories are explicitly treated as CommonJS at runtime.
Changes:
- Add
projects/igniteui-angular/schematics/package.jsonwith{ "type": "commonjs" }. - Add
projects/igniteui-angular/migrations/package.jsonwith{ "type": "commonjs" }.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| projects/igniteui-angular/schematics/package.json | Adds a nested package boundary to force CommonJS semantics for schematics runtime loading. |
| projects/igniteui-angular/migrations/package.json | Adds a nested package boundary to force CommonJS semantics for migrations runtime loading. |
|
@copilot apply changes based on the comments in this thread |
Applied. I updated |
51d6bbe to
454d4e6
Compare
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
84a0109 to
69dda0b
Compare
Closes #
Additional information (check all that apply):
Fix:
ng updatemigrations crash with"type": "module"The latest ng-packagr@21.2.2 sets
"type": "module"in the published package.json, causing Node.js to treat all.jsfiles as ES modules.The migrations and schematics are CommonJS so their
exports = ...syntax throwsexports is not defined in ES module scope. The fix adds a{ "type": "commonjs" }package.json to both themigrations/andschematics/source directories, overriding the parent ESM setting for those subdirectories. These files are automatically copied to dist by the existing gulp tasks.Additionally, the specific
import-helper.jsis a pre-compiled file to avoid a TypeScript emit converting dynamic imports to require, which is no longer needed with more modern module output modes so that is removed and updated.