-
Notifications
You must be signed in to change notification settings - Fork 309
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
feat: support Angular 13 in CJS mode #1122
Conversation
@ahnpnl hi, is there an ETA on when this will be completed and a release cut? |
Hi, currently I think it’s ok to have a release under |
@ahnpnl Thanks for letting me know! From our testing, the resolver looks good and the tests in a test workspace were passing. Thank you for adding the support! |
BREAKING CHANGE * **NodeJs** range version support now is `^12.20.0 || ^14.15.0 || >=16.10.0` * Due to the introduction of **ESM package format** for Angular packages, several things are added to the **default preset** to handle `.mjs` files from **Angular ESM packages**: + `ng-jest-resolver` is introduced as a custom Jest resolver to resolve `.mjs` files. + `transformIgnorePatterns` is added to inform Jest to transform `.mjs` files. + `transform` is updated to include `.mjs` extension to transform to `CommonJS` codes. If one has custom Jest config, please make sure to adjust Jest config as following: ``` // jest.config.js module.exports = { // other config resolver: 'jest-preset-angular/build/resolvers/ng-jest-resolver.js', transformIgnorePatterns: ['node_modules/(?!@angular)'], transform: { '^.+\\.(ts|js|mjs|html|svg)$': 'jest-preset-angular', }, } ```
Congratulations on this @ahnpnl - it was not easy and I know you had to do a lot of work to get it right. |
@ahnpnl 🎉 🔥 🚀 Thank you!! |
thanks for the suggestion!. I will definitely update the documentation |
Hey @ahnpnl. Trying to figure out how to fix my build after upgrading the Jest Builder to Angular 13. |
I haven't put a release for Since it's a breaking change so imo maybe you can also publish a |
I've published 11.0.0-rc.0 under |
I get a not very clear error with 11.0.0-rc.0. Any idea what this might be?
I can give more details about my setup later. |
@ahnpnl @magnusbakken I should have raised this last night! When doing my testing I noticed the When doing local testing, I had to manually copy that folder ( I'm not sure why it's no longer being included in the published bundle, but that is the cause of the error, and it'll likely cause problems for any consumer of the package. |
I have the same problem, I wrote an issue #1133 |
I have the same problem too |
should be fixed in 11.0.0-rc.1 which was already out |
I just tried with 11.0.0-rc.1 and have an issue with local paths. |
@b-johnse that isn’t an issue with jest-preset-angular. I’m working on supporting Angular 13 in Nx currently. This won’t work for Nx until we ship that support in and 13.2. You can keep an eye on progress here nrwl/nx#7161 |
Sounds good. I had changed the preset and transformer to match the docs here, so makes sense that custom tsconfig paths might not be picked up by the new transformer |
@b-johnse it’s actually the resolver, not the transformer. It’s the resolver that finds the correct path to the libs 🙂 |
FYI the default resolver of this preset doesn’t break native Jest resolver regarding TypeScript Probably I will also update Angular 13 guide regarding to the default resolver so it’s clearer. Currently change log already mentioned it. |
Summary
Closes #1090
Test plan
Green CI
Does this PR introduce a breaking change?
^12.20.0 || ^14.15.0 || >=16.10.0
.mjs
files from Angular ESM packages:ng-jest-resolver
is introduced as a custom Jest resolver to resolve.mjs
files.transformIgnorePatterns
is added to inform Jest to transform.mjs
files.transform
is updated to include.mjs
extension to transform toCommonJS
codes.If one has custom Jest config, please make sure to adjust Jest config as following:
Other information
N.A.