Title: fix(webpack): downlevel NativeClass classes in files updated by earlier transformers by edusperoni · Pull Request #11314 · NativeScript/NativeScript · GitHub
Open Graph Title: fix(webpack): downlevel NativeClass classes in files updated by earlier transformers by edusperoni · Pull Request #11314 · NativeScript/NativeScript
X Title: fix(webpack): downlevel NativeClass classes in files updated by earlier transformers by edusperoni · Pull Request #11314 · NativeScript/NativeScript
Description: PR Checklist The PR title follows our guidelines: https://github.com/NativeScript/NativeScript/blob/master/tools/notes/CONTRIBUTING.md#commit-messages. There is an issue for the bug/feature this PR is for. To avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it. You have signed the CLA. All existing tests are passing: https://github.com/NativeScript/NativeScript/blob/master/tools/notes/DevelopmentWorkflow.md#running-unit-tests-application. Tests for the changes are included - https://github.com/NativeScript/NativeScript/blob/master/tools/notes/WritingUnitTests.md. What is the current behavior? In Angular projects, any file that contains both an Angular-decorated class (@Injectable, @Directive, @Component, ...) and a @NativeClass class is silently skipped by the NativeClass transformer. The @NativeClass decorator survives into the emitted bundle as __decorate([NativeClass()], ...) and the app crashes at runtime with: ReferenceError: NativeClass is not defined Root cause: in the Angular webpack flavor the NativeClass transformer runs after Angular's Ivy transform. On files containing Angular-decorated classes, Ivy rebuilds the file via factory.updateSourceFile(), so the resulting SourceFile node itself carries ts.NodeFlags.Synthesized. The transformer's visitNode bails out on any Synthesized node before reaching its isSourceFile branch, so the whole file is returned untouched. Files without Angular decorators pass through Ivy unchanged (original SourceFile, no flag), which is why only this mixed-content case breaks. What is the new behavior? visitNode handles the SourceFile before the Synthesized bail-out, so files rebuilt by earlier transformers are still processed. The per-statement Synthesized check in transformStatements continues to protect statements generated by earlier transformers (e.g. Ivy's added imports and rewritten Angular classes) as well as the transformer's own helper output. Includes a regression test that runs the transformer after a preceding transformer which rebuilds the source file (simulating Ivy) — it fails without the fix and passes with it.
Open Graph Description: PR Checklist The PR title follows our guidelines: https://github.com/NativeScript/NativeScript/blob/master/tools/notes/CONTRIBUTING.md#commit-messages. There is an issue for the bug/feature this...
X Description: PR Checklist The PR title follows our guidelines: https://github.com/NativeScript/NativeScript/blob/master/tools/notes/CONTRIBUTING.md#commit-messages. There is an issue for the bug/feature this...
Opengraph URL: https://github.com/NativeScript/NativeScript/pull/11314
X: @github
Domain: Github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:f8112f5d-01eb-b7ac-cb68-2b9b8b8e1884 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 9B90:1CE2AE:4F4453:6E5510:6A639C4A |
| html-safe-nonce | 1b419617dc87cb3d823d8b083dbf1a25440684259885dbccfc1863b36af18a0a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QjkwOjFDRTJBRTo0RjQ0NTM6NkU1NTEwOjZBNjM5QzRBIiwidmlzaXRvcl9pZCI6IjQ0NjIwMDA4NjgzMjMyMzY1OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 133af59d132bb7e37b668a306b50f7e5866dca70221b42f6b1fedf8852acb3c5 |
| hovercard-subject-tag | pull_request:4118785935 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/NativeScript/NativeScript/pull/11314/files |
| twitter:image | https://avatars.githubusercontent.com/u/4061767?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/4061767?s=400&v=4 |
| og:image:alt | PR Checklist The PR title follows our guidelines: https://github.com/NativeScript/NativeScript/blob/master/tools/notes/CONTRIBUTING.md#commit-messages. There is an issue for the bug/feature this... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4ca676e17c4da4532dc68541e9fc874034ae840c26b5f34da7f1c42d9a600659 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/NativeScript/NativeScript git https://github.com/NativeScript/NativeScript.git |
| octolytics-dimension-user_id | 7392261 |
| octolytics-dimension-user_login | NativeScript |
| octolytics-dimension-repository_id | 31492490 |
| octolytics-dimension-repository_nwo | NativeScript/NativeScript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 31492490 |
| octolytics-dimension-repository_network_root_nwo | NativeScript/NativeScript |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 3a0a9f049e072eb8e5795dfddcefdba9e277501d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width