Skip to content
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

bug: proxyInputs errors when called multiple times #397

Closed
3 tasks done
liamdebeasi opened this issue Oct 26, 2023 · 1 comment · Fixed by #398
Closed
3 tasks done

bug: proxyInputs errors when called multiple times #397

liamdebeasi opened this issue Oct 26, 2023 · 1 comment · Fixed by #398
Labels

Comments

@liamdebeasi
Copy link
Contributor

Prerequisites

Stencil Version

4.6.0

Stencil Framework Output Target

Angular

Stencil Framework Output Target Version

0.8.2

Current Behavior

When calling proxyInputs multiple times an Cannot redefine property error is thrown in Chromium-based browsers. (Other browsers still throw an error, but the exact error message is slightly different). This is happening due to our usage of Object.defineProperty:

These properties are non-configurable by default, so attempting to change them will result in an error: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty

This is not a problem when using the ProxyCmp decorator since proxyInputs will be called at most once. However, calling proxyInputs in ngOnInit will result in the error if that component is used more than once on a page.


Ionic Framework needs to call proxyInputs in ngOnInit instead of using the ProxyCmp decorator to work around an ng-packagr/Webpack bug. Using a provider that references the Angular class in addition to two or more decorators causes the compiled component to be re-assigned. This re-assignment breaks treeshaking and causes components to be bundled even if they are not being used in the app.

See ionic-team/ionic-framework#28359 for more information.

Expected Behavior

I expect proxyInputs to be idempotent. Calling it multiple times should not have a different effect than calling it once.

Steps to Reproduce

  1. Clone repo.
  2. Run npm install.
  3. Run npm run start and open application in browser (typically served on port 4200). You can reproduce this on a non-Chromium browser but just be aware that the exact error message may be worded slightly different.
  4. Observe that noted error is thrown.

Code Reproduction URL

https://github.com/dtarnawsky/cs-752

Additional Information

No response

@ionitron-bot ionitron-bot bot added the triage label Oct 26, 2023
github-merge-queue bot pushed a commit to ionic-team/ionic-framework that referenced this issue Oct 27, 2023
…re used (#28423)

Issue number: resolves #28418

---------

<!-- Please do not submit updates to dependencies unless it fixes an
issue. -->

<!-- Please try to limit your pull request to one type (bugfix, feature,
etc). Submit multiple pull requests if needed. -->

## What is the current behavior?
<!-- Please describe the current behavior that you are modifying. -->

Due to
ionic-team/stencil-ds-output-targets#397,
calling `proxyInputs` for the form controls caused an error to be logged
in developer applications.

## What is the new behavior?
<!-- Please describe the behavior or changes that are being added by
this PR. -->

- Updated to a version of the Angular output targets with a patch for
this error
- I also excluded the `utils.ts` from all `angular-component-lib`
directories from prettier since it was causing a diff. These changes are
autogenerated so we should not be linting them anyways.

## Does this introduce a breaking change?

- [ ] Yes
- [x] No

<!-- If this introduces a breaking change, please describe the impact
and migration path for existing applications below. -->


## Other information

<!-- Any other information that is important to this PR such as
screenshots of how the component looks before and after the change. -->

Dev build: `7.5.3-dev.11698340692.18daff2f`
Copy link

ionitron-bot bot commented Nov 25, 2023

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of the output targets, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Nov 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
1 participant