Thanks to visit codestin.com
Credit goes to github.com

Skip to content

bug: Build succeeds first time, but fails second time #6250

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

Open
3 tasks done
petercmuc opened this issue May 5, 2025 · 3 comments
Open
3 tasks done

bug: Build succeeds first time, but fails second time #6250

petercmuc opened this issue May 5, 2025 · 3 comments
Labels
ionitron: needs reproduction This PR or Issue does not have a reproduction case URL

Comments

@petercmuc
Copy link

Prerequisites

Stencil Version

4.*

Current Behavior

With an incorrect import path to a typescript interface the first build succeeds.
This happens when the import path is transpiled to the component.d.ts type definition.

Expected Behavior

All builds with incorrect import paths should fail

System Info

Steps to Reproduce

See the Git repo for reproduction...

In a component use an event emitter which uses an interface:

import { MyType } from "./../types/myType";

@Component({
  tag: "app-root",
  styleUrl: "app-root.css",
  shadow: true,
})
export class AppRoot {
  @Event({ eventName: "myTypeEvent" }) showMessage: EventEmitter<MyType>;

  render() {
    return <div> Build Error Test</div>;
  }
}
  1. build the app using "npm run build" - all fine.
  2. Change the import path to something incorrect and build again: the build succeeds.
  3. A second and subsequent builds fail, however.

Code Reproduction URL

https://github.com/petercmuc/build-error

Additional Information

No response

@christian-bromann
Copy link
Member

@petercmuc I can't reproduce this, it fails as expected on the first run:

❯ g clone https://github.com/petercmuc/build-error.git
Cloning into 'build-error'...
remote: Enumerating objects: 28, done.
remote: Counting objects: 100% (28/28), done.
remote: Compressing objects: 100% (20/20), done.
remote: Total 28 (delta 4), reused 21 (delta 4), pack-reused 0 (from 0)
Receiving objects: 100% (28/28), 6.95 KiB | 6.95 MiB/s, done.
Resolving deltas: 100% (4/4), done.
❯ cd build-error/
❯ cursor .
❯ npm i

added 2 packages, and audited 3 packages in 310ms

found 0 vulnerabilities
❯ npm run build

> [email protected] build
> stencil build

[38:22.3]  @stencil/core
[38:22.7]  v4.30.0 🌺
[38:23.1]  build, app, prod mode, started ...
[38:23.1]  transpile started ...
[38:23.4]  transpile finished in 317 ms

[ ERROR ]  TypeScript: src/components.d.ts:18:24
           Cannot find name 'MyType'.

     L17:  interface HTMLAppRootElementEventMap {
     L18:      "myTypeEvent": MyType;
     L19:  }

[ ERROR ]  TypeScript: src/components/app-root/app-root.tsx:6:24
           Cannot find module './../../types/myType' or its corresponding type
           declarations.

      L5:  /** Change the path of the import below to provoke an error */
      L6:  import { MyType } from "./../../types/myType";

[38:23.4]  build failed in 360 ms

@christian-bromann christian-bromann added the ionitron: needs reproduction This PR or Issue does not have a reproduction case URL label May 5, 2025
@petercmuc
Copy link
Author

@christian-bromann thanks for looking into it.
My bad: I had commited the repo with the incorrect path. I have pushed the changes now.
Initially the path should be

import { MyType } from "./../types/myType";

@christian-bromann
Copy link
Member

I still observe the same:

❯ g clone https://github.com/petercmuc/build-error.git
Cloning into 'build-error'...
git: 'credential-manager-core' is not a git command. See 'git --help'.
remote: Enumerating objects: 34, done.
remote: Counting objects: 100% (34/34), done.
remote: Compressing objects: 100% (23/23), done.
remote: Total 34 (delta 7), reused 27 (delta 7), pack-reused 0 (from 0)
Receiving objects: 100% (34/34), 7.39 KiB | 3.69 MiB/s, done.
Resolving deltas: 100% (7/7), done.
❯ cd build-error/
❯ npm i

added 2 packages, and audited 3 packages in 508ms

found 0 vulnerabilities
❯ npm run build

> [email protected] build
> stencil build

[11:05.3]  @stencil/core
[11:05.8]  v4.30.0 🌺
[11:06.2]  build, app, prod mode, started ...
[11:06.2]  transpile started ...
[11:06.4]  transpile finished in 194 ms
[11:06.4]  generate lazy + source maps started ...
[11:06.7]  generate lazy + source maps finished in 251 ms
[11:06.7]  copy started ...
[11:06.7]  copy finished (1 file) in 7 ms
[11:06.7]  build finished in 476 ms

🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ionitron: needs reproduction This PR or Issue does not have a reproduction case URL
Projects
None yet
Development

No branches or pull requests

2 participants