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: re-open of issue #2769 / components.d.ts missing types #3239

Open
stanley85 opened this issue Feb 11, 2022 · 6 comments
Open

bug: re-open of issue #2769 / components.d.ts missing types #3239

stanley85 opened this issue Feb 11, 2022 · 6 comments
Labels
Bug: Validated This PR or Issue is verified to be a bug within Stencil

Comments

@stanley85
Copy link

stanley85 commented Feb 11, 2022

Stencil version:

 @stencil/core@2.13.0

Current behavior:
The behaviour is best documented in the closed ticket (by bot due to inactivity) the Issue remains un-solved - please have a look at #2769

Copycat:
If there is no src/components.d.ts file present, and one component (A) references another's type (B)...

On first build, the types are not generated for (A) in the output directory dist/types/components. If (A) exports any types, this can also result in broken imports in dist/types/components.d.ts. No error is reported during build.

On second build (where there is now a src/components.d.ts present as a result of the first build), the types are generated for (A) in the output directory dist/types/components.

I do not like committing auto-generated files to source control, as they result in needless churn, hence why i do not have src/components.d.ts (this was a fresh clone of my repo).

Expected behavior:
All Types are present in the first compile of components.d.ts, when no components.d.ts is present in the first place.

Copycat:
Ideally it should Just Work(tm), and not rely on committing auto-generated files to source control. On both the first (broken) build and the second (successful) build, the src/components.d.ts file is exactly the same, so it may be a timing/ordering issue?

An alternative would simply be to raise an error in this case.

Steps to reproduce:

  1. create new stencil project with npm init stencil
  2. rm src/components.d.ts
  3. add the components from the Related code section below
  4. npm run build
  5. open dist/types/components.d.ts and see a broken import
  6. ls dist/types/components/ and notice there are no types for my-other-component

Related code:
please have a look at #2769

@ionitron-bot ionitron-bot bot added the triage label Feb 11, 2022
@stanley85 stanley85 changed the title Re-Open of issue #2769 / Components.d.ts missing types bug: re-open of issue #2769 / components.d.ts missing types Feb 11, 2022
@stanley85
Copy link
Author

We face this during a gitlab-ci pipeline.

$ cd frontend
$ npm run build
project-name@0.0.1 build
stencil build --docs-readme
[08:24.8] @stencil/core
[08:25.0] v2.13.0 🍣
[08:27.6] transpile started ...
[08:32.3] copy started ...
[08:32.3] generate custom elements started ...
[08:32.3] generate lazy started ...
[08:38.7] generate lazy finished ...
[ ERROR ] Rollup: Missing Export: ./src/index.ts:1:9
'Components' is not exported by ./src/components.d.ts, imported by
./src/index.ts
L1: export { Components, JSX } from './components';
[08:38.7] build failed in 11.15 s
Cleaning up project directory and file based variables

@rwaskiewicz
Copy link
Contributor

Thanks! I'm going to label this to get ingested for the team to take a closer look.

I've also got a PR up to make sure that issues like #2769 that are labeled for the team to be looked at to not be accidentally closed by the bot. Sorry about that all!

@rwaskiewicz rwaskiewicz added Bug: Validated This PR or Issue is verified to be a bug within Stencil Feature: Compiler labels Feb 15, 2022
@ionitron-bot ionitron-bot bot removed the triage label Feb 15, 2022
@theo-staizen
Copy link

theo-staizen commented May 27, 2022

Oh I have been facing this issue for ages. I never understood why, so I am always just rebuilding until I can see my types.
It's become a habit to check types before publishing too. I thought the problem was with my build, glad to see I'm not alone.

@benelan
Copy link

benelan commented Aug 22, 2022

Although not ideal, adding a prebuild NPM script can work around this issue:

"prebuild": "if [ ! -f ./src/components.d.ts ]; then touch ./src/components.d.ts; npm run build; fi",

@FabioGimmillaro
Copy link

Although not ideal, adding a prebuild NPM script can work around this issue:

"prebuild": "if [ ! -f ./src/components.d.ts ]; then touch ./src/components.d.ts; npm run build; fi",

This solution doesn't seem to work anymore with StencilJS Version 4.6 (I didn't check earlier versions)

@FabioGimmillaro
Copy link

FabioGimmillaro commented Oct 27, 2023

Another solution:
Call npm run build twice with the first returning "true". This however does only work on linux (and maybe Mac) based OS:

"two-build-steps": "echo 'Stencil Build Pass #1' && (npm run build || true) && echo 'Stencil Build Pass #2' && npm run build"

The first step generates the components.d.ts AFTER compiling the sources. The second step uses the generated components.d.ts from the first one.

benelan added a commit to Esri/calcite-design-system that referenced this issue Nov 2, 2023
**Related Issue:** #7860

## Summary

Add a package of angular components that wrap the web component library
following [Stencil's
documentation](https://stenciljs.com/docs/v2/angular).

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
stenciljs/core#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](DefinitelyTyped/DefinitelyTyped#57467 (reply in thread)).

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.

---------

Co-authored-by: Anveshreddy mekala <anv11827@esri.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
jcfranco added a commit to Esri/calcite-design-system that referenced this issue Nov 3, 2023
jcfranco added a commit to Esri/calcite-design-system that referenced this issue Nov 3, 2023
benelan added a commit to Esri/calcite-design-system that referenced this issue Mar 30, 2024
**Related Issue:** #9008

## Summary

Commit changes to `components.d.ts` after building for release to
prevent lerna/npm publishing errors due to an unclean working tree. The
commit will be discarded once the workflow run's container is destroyed.

### Background

The `components.d.ts` file is tracked as a temporary workaround for
stenciljs/core#3239

To keep the types updated, `components.d.ts` is added to the index in a
pre-commit hook.


https://github.com/Esri/calcite-design-system/blob/2bb1ee24bb317c95e2bef8165c75583fe98ad714/.husky/pre-commit#L7-L13

However, the file can still be outdated if people make changes and don't
rebuild before creating another commit. This is mostly an issue with
small doc updates, like the PR linked above. If that happens, the
release will fail due to an unclean working tree.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug: Validated This PR or Issue is verified to be a bug within Stencil
Projects
None yet
Development

No branches or pull requests

5 participants