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

cannot identified the prompts.js as a function?? #5692

Closed
3 tasks done
MaybeSomeone opened this issue Apr 23, 2024 · 17 comments · Fixed by #5693
Closed
3 tasks done

cannot identified the prompts.js as a function?? #5692

MaybeSomeone opened this issue Apr 23, 2024 · 17 comments · Fixed by #5693
Assignees
Labels
Bug: Validated This PR or Issue is verified to be a bug within Stencil

Comments

@MaybeSomeone
Copy link

Prerequisites

Stencil Version

4.7.0

Current Behavior

when i execute npm generate then report a error!! uncaught cli error: TypeError: prompt is not a function, that's why????

Expected Behavior

i hope it can be run as normal

System Info

No response

Steps to Reproduce

just execute npm generate

Code Reproduction URL

https://github.com/MaybeSomeone/weathercomponent

Additional Information

No response

@ionitron-bot ionitron-bot bot added the triage label Apr 23, 2024
@rwaskiewicz rwaskiewicz self-assigned this Apr 23, 2024
@rwaskiewicz
Copy link
Member

Hey @MaybeSomeone 👋

Thanks for the error report! Can you do me a favor and provide some additional details for us?

  • Can you make your reproduction URL public? I can't seem to access it
  • Can you tell us what Operating System you're using, version of Node, and the output of npx stencil info?

Thanks!

@rwaskiewicz rwaskiewicz added Awaiting Reply This PR or Issue needs a reply from the original reporter. and removed triage labels Apr 23, 2024
@MaybeSomeone
Copy link
Author

Hello i have provide the url, but i just init project by export web component use, and then i execute npm run generate.

@ionitron-bot ionitron-bot bot removed the Awaiting Reply This PR or Issue needs a reply from the original reporter. label Apr 23, 2024
@MaybeSomeone
Copy link
Author

System: node 21.7.1
Platform: darwin (21.6.0)
CPU Model: Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz (8 cpus)
Compiler: /Users/super/Desktop/WebComponents/weathercomponent/node_modules/@stencil/core/compiler/stencil.js
Build: 1713808785
Stencil: 4.17.0 ♨️
TypeScript: 5.4.5
Rollup: 2.56.3
Parse5: 7.1.2
jQuery: 4.0.0-pre
Terser: 5.30.3

@rwaskiewicz
Copy link
Member

Thanks! I wasn't able to quite replicate it, but I think I know what's happening here. I see npm run generate in the component starter just failing on my end (no error, no warning). I think I have a solution - could you try installing this dev build and let me know if it fixes it for you?

npm i @stencil/core@4.17.0-dev.1713882968.4a08d0e

@MaybeSomeone
Copy link
Author

Ok i'll try and i change for another macbook can replicate it.

@MaybeSomeone
Copy link
Author

Hello how can i generate target component? it need me input the Component tag name, but export no relative components.

@MaybeSomeone
Copy link
Author

I don't know how to choose the target component or export all exist components.

@rwaskiewicz
Copy link
Member

You can generate a component with

npm run generate new-component

and select any css/test files to be generated.

I'm not sure I understand this part:

export no relative components.

@MaybeSomeone
Copy link
Author

yes i have, but seems absolutely a new components different with that exist component.tsx file.

@rwaskiewicz
Copy link
Member

Can you let me know how they differ?

@rwaskiewicz rwaskiewicz added the Bug: Validated This PR or Issue is verified to be a bug within Stencil label Apr 23, 2024
@MaybeSomeone
Copy link
Author

MaybeSomeone commented Apr 23, 2024

generate code

import { Component, Host, h } from '@stencil/core';

@Component({
  tag: 'component-set',
  styleUrl: 'component-set.css',
  shadow: true,
})
export class ComponentSet {

  render() {
    return (
      <Host>
        <slot></slot>
      </Host>
    );
  }

}

origin

import { Component, Prop, h } from '@stencil/core';
import { format } from '../../utils/utils';

@Component({
  tag: 'my-component',
  styleUrl: 'my-component.css',
  shadow: true,
})
export class MyComponent {
  /**
   * The first name
   */
  @Prop() first: string;

  /**
   * The middle name
   */
  @Prop() middle: string;

  /**
   * The last name
   */
  @Prop() last: string;

  private getText(): string {
    return format(this.first, this.middle, this.last);
  }

  render() {
    return <div>Hello, World! I'm {this.getText()}</div>;
  }
}

@rwaskiewicz
Copy link
Member

That is the expected output for the generate command - were you expecting something different?

rwaskiewicz added a commit that referenced this issue Apr 23, 2024
this pr is motivated by a scneario where running `npx stencil generate`
would result in either an error or an early return:
```
npm run generate

> gen-test-1@0.0.1 generate
> stencil generate

[49:23.1]  @stencil/core
[49:23.2]  v4.17.0 ♨️
```

note: the reported error was never reproduced locally, only the early
return.

technically, this was introduced in v4.17.0, when we switched over to
using esbuild for production builds. however, this has been present in
any build that is esbuild-based since we migrated the cli submodule to
esbuild (where we had a mixed rollup-esbuild build during the migration
for dev builds).

removing this alias eliminates dynamic imports in the CJS output of the
cli submodule:
```
const {
    prompt: r
  } = await import('../sys/node/prompts.js')
```
which wouldn't run properly, causing the error/early return.

this change does cause an increase in bundle size, as we end up
importing more of prompts.js than we do. to mitigate this, we direct
the cli module to the export we actually use (leading to less getting
bundled in the cli module).

fixes: #5692

STENCIL-1294 cannot identified the prompts.js as a function? ?
@MaybeSomeone
Copy link
Author

i want generate a WebComponent can be use in html directly.

@MaybeSomeone
Copy link
Author

ok. i check the document i think i misunderstood...........

@rwaskiewicz
Copy link
Member

Okay, I understand now. Thanks! Stencil's generate command does not generate a web component to use in HTML directly - you have to run the build command (npm run build in the component starter, or npx stencil build) in order to compile the TSX file to JS

@MaybeSomeone
Copy link
Author

Yes. you are right!!! sincerely thanks!!!!

github-merge-queue bot pushed a commit that referenced this issue Apr 23, 2024
this pr is motivated by a scneario where running `npx stencil generate`
would result in either an error or an early return:
```
npm run generate

> gen-test-1@0.0.1 generate
> stencil generate

[49:23.1]  @stencil/core
[49:23.2]  v4.17.0 ♨️
```

note: the reported error was never reproduced locally, only the early
return.

technically, this was introduced in v4.17.0, when we switched over to
using esbuild for production builds. however, this has been present in
any build that is esbuild-based since we migrated the cli submodule to
esbuild (where we had a mixed rollup-esbuild build during the migration
for dev builds).

removing this alias eliminates dynamic imports in the CJS output of the
cli submodule:
```
const {
    prompt: r
  } = await import('../sys/node/prompts.js')
```
which wouldn't run properly, causing the error/early return.

this change does cause an increase in bundle size, as we end up
importing more of prompts.js than we do. to mitigate this, we direct
the cli module to the export we actually use (leading to less getting
bundled in the cli module).

fixes: #5692

STENCIL-1294 cannot identified the prompts.js as a function? ?
@rwaskiewicz
Copy link
Member

The fix for npm run generate not running properly was a part of today's v4.17.1 release. If you're experiencing this bug on v4.17.0, please upgrade to v4.17.1.

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

Successfully merging a pull request may close this issue.

2 participants