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

build: add @esri/calcite-components-angular package #8084

Merged
merged 24 commits into from
Nov 2, 2023

Conversation

benelan
Copy link
Member

@benelan benelan commented Oct 30, 2023

Related Issue: #7860

Summary

Add a package of angular components that wrap the web component library following Stencil's documentation.

There were a lot of type related build errors and I ended up adding three patches:

  1. Rebuild the web component library if the CC types aren't generated correctly as a workaround for bug: re-open of issue #2769 / components.d.ts missing types ionic-team/stencil#3239
  2. Fix a couple type import paths for event details that were generated by @stencil/angular-output-target. Not sure if this one is an issue on our end or theirs.
  3. A JSDOM types error that other people also experienced when using stencil's angular output target.

All of the build/CI stuff is working correctly. It was a bit wonky at first because we need an angular workspace just to build a single component library.

I still need to do some testing in an example app, but I don't foresee any issues so the PR is ready for review. I'll add setup steps to the package's README after I walk through them while setting up the example.

@github-actions github-actions bot added the chore Issues with changes that don't modify src or test files. label Oct 30, 2023
Copy link
Member

@jcfranco jcfranco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking great, @benelan!

I was curious about the projects/component-library/ folders. Is this required for 👇?

All of the build/CI stuff is working correctly. The outputs of lerna version and npm --workspace @esri/calcite-components-angular pack are both correct. It was a bit wonky at first because we need an angular workspace just to build a single component library.

"clean": "rimraf dist node_modules .turbo .angular projects/component-library/dist"
},
"dependencies": {
"@angular/animations": "^16.2.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we pin these deps and have renovate handle them?

Applies to all package.json files in this PR.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work @benelan! What's your plan for updating Angular deps, e.g. each Calcite release? Mainly wondering how Calcite, Components and @arcgis/core can stay roughly in sync. For example, Angular 17 is being released next week.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jcfranco @benelan thoughts on this? Are you going with @latest, for each Calcite release? I don't know how 'renovate' is tied into the process.

Also, will there be a next release of this that I can test on?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @andygup! Yeah renovate will submit a PR to bump the angular dependencies when new versions come out.

And yes, a next release will be deployed automatically once there are "deployable" changes. I'll let you know when one goes out. Like the react wrapper, the angular wrapper's version will always match CC's to prevent confusion.

@benelan
Copy link
Member Author

benelan commented Oct 30, 2023

I was curious about the projects/component-library/ folders.

Yup, that's related to using an Angular workspace, which is how the Stencil doc says to do it and how the ArcGIS Web Components monorepo does it.

There may be a way to set this up without using an Angular workspace, but as someone who has never used Angular I wouldn't be the one to do it. I just followed the doc 🤷‍♂️

@benelan
Copy link
Member Author

benelan commented Oct 30, 2023

Here is Angular's doc about their workspace file structure: https://angular.io/guide/file-structure

It doesn't seem like there are any other options for developing "shareable libraries", which is what we are doing.

Angular also supports workspaces with multiple projects. This type of development environment is suitable for advanced users who are developing shareable libraries, and for enterprises that use a "monorepo" development style, with a single repository and global configuration for all Angular projects.

Here is the Angular doc about creating libraries: https://angular.io/guide/creating-libraries

And the doc about library file structure: https://angular.io/guide/file-structure#library-project-files

@benelan benelan force-pushed the benelan/7860-angular-wrapper branch from 406311b to aab1c68 Compare October 31, 2023 01:27
@andygup
Copy link
Member

andygup commented Oct 31, 2023

There may be a way to set this up without using an Angular workspace

Using an Angular workspace is the recommended, but non-intuitive, way to go.

…wrapper

* origin/main:
  test(input-time-zone): update screenshot tests to use time zones unaffected by DST (#8094)
  chore: release next
  fix(accordion-item): update expanded chevron color (#8087)
benelan added a commit to Esri/calcite-components-examples that referenced this pull request Oct 31, 2023
Copy link
Member

@jcfranco jcfranco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐📐📐📐📐📐📐📐📐📐📐📐📐📐📐📐📐📐📐📐📐📐📐📐📐📐📐📐
📐🎁📐📐📐🎁📐📐🎁🎁📐📐🎁🎁🎁📐📐🎁🎁🎁📐🎁🎁🎁🎁📐🎁📐
📐🎁🎁📐📐🎁📐🎁📐📐🎁📐📐🎁📐📐🎁📐📐📐📐🎁📐📐📐📐🎁📐
📐🎁📐🎁📐🎁📐🎁📐📐🎁📐📐🎁📐📐🎁📐📐📐📐🎁🎁🎁📐📐🎁📐
📐🎁📐📐🎁🎁📐🎁📐📐🎁📐📐🎁📐📐🎁📐📐📐📐🎁📐📐📐📐📐📐
📐🎁📐📐📐🎁📐📐🎁🎁📐📐🎁🎁🎁📐📐🎁🎁🎁📐🎁🎁🎁🎁📐🎁📐
📐📐📐📐📐📐📐📐📐📐📐📐📐📐📐📐📐📐📐📐📐📐📐📐📐📐📐📐

"@esri/calcite-components": "1.10.0"
},
"dependencies": {
"tslib": "2.3.0"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed by Angular or can we update the tsconfig.json target to avoid this dependency?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is added by the angular cli so I'm pretty sure it's required

anveshmekala and others added 4 commits November 1, 2023 18:26
…8077)

**Related Issue:** #7188

## Summary

- Prevents increasing/decreasing the value in `calcite-input-number`
when the pointer is moved away from the increment/decrement buttons .
- Emitting pointerUp event also prevents increasing/decreasing of the
value.
…wrapper

* origin/main:
  chore: release next
  fix(input-number): prevent mutating value when pointerUp is emitted. (#8077)
@benelan benelan added the skip visual snapshots Pull requests that do not need visual regression testing. label Nov 2, 2023
@benelan benelan merged commit 14518ac into main Nov 2, 2023
@benelan benelan deleted the benelan/7860-angular-wrapper branch November 2, 2023 08:06
@github-actions github-actions bot added this to the 2023 November Priorities milestone Nov 2, 2023
benelan added a commit to Esri/calcite-components-examples that referenced this pull request Nov 14, 2023
Change the angular example to use the new
`@esri/calcite-components-angular` package once it is installed in
Esri/calcite-design-system#8084 and published to
NPM.
benelan added a commit that referenced this pull request Nov 15, 2023
…m the entry point (#8177)

**Related Issue:** #8084

## Summary

I ran into build errors related to event detail types when adding the
Angular output target to the monorepo. Stencil's auto-generated Angular
code expected the types to be exported from the
`@esri/calcite-components` entry point, but they were not. Here is one
of the error messages:

```
angular-workspace:build: projects/component-library/src/lib/stencil-generated/components.ts:1014:15 - error TS2459: Module '"@esri/calcite-components"' declares 'HandleNudge' locally, but it is not exported.
angular-workspace:build:
angular-workspace:build: 1014 import type { HandleNudge as ICalciteHandleHandleNudge } from '@esri/calcite-components';
angular-workspace:build:                    ~~~~~~~~~~~
angular-workspace:build:
angular-workspace:build:   ../calcite-components/dist/types/components.d.ts:42:24
angular-workspace:build:     42 import { HandleChange, HandleNudge } from "./components/handle/interfaces";
angular-workspace:build:                               ~~~~~~~~~~~
angular-workspace:build:     'HandleNudge' is declared here.
```

To resolve the errors, I added a prebuild patch to the Angular output
target that fixed the import paths for the three event detail types. As
a result, a Calcite Components fix/feat that added a new event detail
would create an unrelated entry in the Angular changelog. This is
because the new event detail would need to be added to the patch, which
lived in the Angular package's directory. This came up in:
#8123 (comment)

This pull request exports the event detail types from the entry point,
so the patch can be removed. **When adding a new event detail, it must
be exported from
[`packages/calcite-components/src/index.ts`](https://github.com/Esri/calcite-design-system/blob/main/packages/calcite-components/src/index.ts)
to prevent build errors.**
benelan added a commit that referenced this pull request Nov 15, 2023
…m the entry point (#8177)

**Related Issue:** #8084

## Summary

I ran into build errors related to event detail types when adding the
Angular output target to the monorepo. Stencil's auto-generated Angular
code expected the types to be exported from the
`@esri/calcite-components` entry point, but they were not. Here is one
of the error messages:

```
angular-workspace:build: projects/component-library/src/lib/stencil-generated/components.ts:1014:15 - error TS2459: Module '"@esri/calcite-components"' declares 'HandleNudge' locally, but it is not exported.
angular-workspace:build:
angular-workspace:build: 1014 import type { HandleNudge as ICalciteHandleHandleNudge } from '@esri/calcite-components';
angular-workspace:build:                    ~~~~~~~~~~~
angular-workspace:build:
angular-workspace:build:   ../calcite-components/dist/types/components.d.ts:42:24
angular-workspace:build:     42 import { HandleChange, HandleNudge } from "./components/handle/interfaces";
angular-workspace:build:                               ~~~~~~~~~~~
angular-workspace:build:     'HandleNudge' is declared here.
```

To resolve the errors, I added a prebuild patch to the Angular output
target that fixed the import paths for the three event detail types. As
a result, a Calcite Components fix/feat that added a new event detail
would create an unrelated entry in the Angular changelog. This is
because the new event detail would need to be added to the patch, which
lived in the Angular package's directory. This came up in:
#8123 (comment)

This pull request exports the event detail types from the entry point,
so the patch can be removed. **When adding a new event detail, it must
be exported from
[`packages/calcite-components/src/index.ts`](https://github.com/Esri/calcite-design-system/blob/main/packages/calcite-components/src/index.ts)
to prevent build errors.**
benelan added a commit that referenced this pull request Nov 16, 2023
…m the entry point (#8177)

**Related Issue:** #8084

I ran into build errors related to event detail types when adding the
Angular output target to the monorepo. Stencil's auto-generated Angular
code expected the types to be exported from the
`@esri/calcite-components` entry point, but they were not. Here is one
of the error messages:

```
angular-workspace:build: projects/component-library/src/lib/stencil-generated/components.ts:1014:15 - error TS2459: Module '"@esri/calcite-components"' declares 'HandleNudge' locally, but it is not exported.
angular-workspace:build:
angular-workspace:build: 1014 import type { HandleNudge as ICalciteHandleHandleNudge } from '@esri/calcite-components';
angular-workspace:build:                    ~~~~~~~~~~~
angular-workspace:build:
angular-workspace:build:   ../calcite-components/dist/types/components.d.ts:42:24
angular-workspace:build:     42 import { HandleChange, HandleNudge } from "./components/handle/interfaces";
angular-workspace:build:                               ~~~~~~~~~~~
angular-workspace:build:     'HandleNudge' is declared here.
```

To resolve the errors, I added a prebuild patch to the Angular output
target that fixed the import paths for the three event detail types. As
a result, a Calcite Components fix/feat that added a new event detail
would create an unrelated entry in the Angular changelog. This is
because the new event detail would need to be added to the patch, which
lived in the Angular package's directory. This came up in:
#8123 (comment)

This pull request exports the event detail types from the entry point,
so the patch can be removed. **When adding a new event detail, it must
be exported from
[`packages/calcite-components/src/index.ts`](https://github.com/Esri/calcite-design-system/blob/main/packages/calcite-components/src/index.ts)
to prevent build errors.**
DitwanP pushed a commit that referenced this pull request Nov 16, 2023
…m the entry point (#8177)

**Related Issue:** #8084

I ran into build errors related to event detail types when adding the
Angular output target to the monorepo. Stencil's auto-generated Angular
code expected the types to be exported from the
`@esri/calcite-components` entry point, but they were not. Here is one
of the error messages:

```
angular-workspace:build: projects/component-library/src/lib/stencil-generated/components.ts:1014:15 - error TS2459: Module '"@esri/calcite-components"' declares 'HandleNudge' locally, but it is not exported.
angular-workspace:build:
angular-workspace:build: 1014 import type { HandleNudge as ICalciteHandleHandleNudge } from '@esri/calcite-components';
angular-workspace:build:                    ~~~~~~~~~~~
angular-workspace:build:
angular-workspace:build:   ../calcite-components/dist/types/components.d.ts:42:24
angular-workspace:build:     42 import { HandleChange, HandleNudge } from "./components/handle/interfaces";
angular-workspace:build:                               ~~~~~~~~~~~
angular-workspace:build:     'HandleNudge' is declared here.
```

To resolve the errors, I added a prebuild patch to the Angular output
target that fixed the import paths for the three event detail types. As
a result, a Calcite Components fix/feat that added a new event detail
would create an unrelated entry in the Angular changelog. This is
because the new event detail would need to be added to the patch, which
lived in the Angular package's directory. This came up in:
#8123 (comment)

This pull request exports the event detail types from the entry point,
so the patch can be removed. **When adding a new event detail, it must
be exported from
[`packages/calcite-components/src/index.ts`](https://github.com/Esri/calcite-design-system/blob/main/packages/calcite-components/src/index.ts)
to prevent build errors.**
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Issues with changes that don't modify src or test files. skip visual snapshots Pull requests that do not need visual regression testing.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants