stencil icon indicating copy to clipboard operation
stencil copied to clipboard

stencil build throws error if component.d.ts is not present

Open SebastianSchenk opened this issue 5 years ago • 22 comments

Stencil version:

 @stencil/[email protected]

I'm submitting a:

[x] bug report [ ] feature request [ ] support request => Please do not submit support requests here, use one of these channels: https://stencil-worldwide.herokuapp.com/ or https://forum.ionicframework.com/

Current behavior:

In our project we added src/components.d.ts to .gitignore, since we think that a auto generated file shouldn't be version controlled and could lead to unnecessary merge conflicts. Problem is that running the build script on a fresh checkout will throw the following error.

[ ERROR ]  Rollup: Unresolved Import
           Could not resolve './components' from src/index.js

After the error was thrown the src/components.d.ts file is generated anyway. So running the build script a second time will build the project correctly.

Expected behavior:

stencil build build should check for src/components.d.ts first. If not present, the file will be created. After creation the build should be executed.

Steps to reproduce:

  • Create a new stencil component project
  • Delete src/components.d.ts
  • Run npm build

SebastianSchenk avatar Aug 01 '19 08:08 SebastianSchenk

Creating component.d.ts is not that easy since it requires to transpile first everything. It's fixable, but a not trivial amount of work needs to be done. We might revisit it once we port to TS 3.6 (since we plan to use the new incremental apis). In the meantime, we recommend to commit that file.

manucorporat avatar Aug 01 '19 08:08 manucorporat

is this now fixed? If I delete src/components.d.ts and then run npm run build then the file is regenerated. I'm using "@stencil/core": "^1.8.1" which has TypeScript 3.7 as a dependency.

devinshoemaker avatar Dec 07 '19 19:12 devinshoemaker

@devinshoemaker I also observed this behaviour. But unfortunately the issue is still existing. It worked on my local machine but not on my CI pipeline. After some tests, I observed, that the build error appears if you

  1. delete the node_modules
  2. run an npm install following by a npm run-script build in a clean environment.

cremich avatar Jan 15 '20 13:01 cremich

Confirmed the scenario mentioned by @cremich. Emptying the components.d.ts file is another way to replicate this issue.

ghost avatar Mar 02 '20 00:03 ghost

Should not happen anymore since we released in the compiler update using latest TS!

manucorporat avatar May 06 '20 20:05 manucorporat

@manucorporat Still doesn't work for me and I am using "@stencil/core": "^1.13.0",

Steps to reproduce :

  • deleted the file, added to git ignore
  • re-clone repo without file there
  • run a build and it fails

image

stevenbriscoeca avatar May 19 '20 17:05 stevenbriscoeca

I found it had fixed in 1.14.0! @stephenbe

euxn23 avatar Jun 02 '20 09:06 euxn23

@euxn23 , I'm on 1.17.3 version right now and this issue is still reproducible for me (in the same way as described in initial comment). @manucorporat , maybe some updates after fix broke this flow again?

SilverTracer avatar Oct 08 '20 10:10 SilverTracer

@euxn23 , I'm on 1.17.3 version right now and this issue is still reproducible for me (in the same way as described in initial comment). @manucorporat , maybe some updates after fix broke this flow again?

Ditto - I've upgraded to stencil core v2.1.0 and can't get a clean build. Nothing listed in this thread seems to have fixed the issue for me. I have an external module, and this error happens when importing the external module.

lorenwest avatar Oct 24 '20 00:10 lorenwest

This still seems like an issue in v2.3.0. If I delete components.d.ts the first time I build it fails due the the error above. The second time it succeeds because the previous run generated components.d.ts.

kassemsandarusi avatar Nov 13 '20 22:11 kassemsandarusi

@manucorporat Could you please open this issue again. I can confirm the behavior in v2.5.2

janrembold avatar Apr 12 '21 12:04 janrembold

@manucorporat this issues is still present in version 2.6.0. I would appreciate a fix for this.

webdesign2be avatar Jun 04 '21 13:06 webdesign2be

I'm afraid I'm getting the same issue too on version 2.6.0

kevin-coyle-pfizer avatar Jun 22 '21 14:06 kevin-coyle-pfizer

Seems this is still an issue in version 2.7.1

tcarrio avatar Sep 20 '21 13:09 tcarrio

This still an issue in version 2.8.0 just FYI

adrianiy avatar Oct 20 '21 15:10 adrianiy

Hi all! Help us out. We need a reproduction case - specifically a GitHub repo that we can use to reproduce this behavior. If it is that you need to simply delete the definitions file in order to create this, that is good to know too. I'll reopen.

splitinfinities avatar Oct 20 '21 17:10 splitinfinities

The original comment includes steps to reproduce, is this sufficient?

Steps to reproduce:

Create a new stencil component project Delete src/components.d.ts Run npm build

littleninja avatar Oct 20 '21 17:10 littleninja

I have had success with the following workaround - add an empty index.ts file under src/components/. I'm using Stencil 1.12.7 and typescript 3.8.3.

gtranter avatar Nov 16 '21 20:11 gtranter

Any updates on this? None of the workarounds work for v 4.7.0

zovorap avatar Nov 15 '23 20:11 zovorap

Any updates on this? None of the workarounds work for v 4.7.0

I doubt this will ever be fixed since it was originally filed against Stencil v1. I would suggest you open a new issue against v4.7.0.

gtranter avatar Nov 22 '23 14:11 gtranter

Hey folks, please do not create a new issue in this case - this issue is tagged (with Bug Validated), ingested into our internal backlog, and has comments/additional information for the team there for when we get the chance to work on this. ATM, we still advise folks check this file into their source control, much like a package-lock.json file.

rwaskiewicz avatar Nov 28 '23 18:11 rwaskiewicz

While I'm personally ok with committing this file every time, But many devs around me always complain about it, since they often have to deal with merge conflicts. I think this is one of the things that retain people from starting using stencil on daily basis. I think it would be very beneficial for stencil if this can be fixed asap.

zovorap avatar Nov 28 '23 18:11 zovorap