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

feat: Allow to specify in CustomOuputTarget if the output have to be re-executed on each build #5514

Open
3 tasks done
Sukaato opened this issue Mar 18, 2024 · 4 comments
Open
3 tasks done
Labels
Bug: Validated This PR or Issue is verified to be a bug within Stencil

Comments

@Sukaato
Copy link
Contributor

Sukaato commented Mar 18, 2024

Prerequisites

Describe the Feature Request

I'd like to have a parameter that lets you choose whether the custom output target can be called at every change or only during the "final" build.

Describe the Use Case

I've created a little plugin to retrieve all @config docsTags in a component-config.d.ts so it's easyer to customise the default state of a component.

stencil.config.ts

export const config: Config = {
  ... // Config
  outputTargets: [
    {
      type: 'custom',
      name: 'component-option',
     execType: 'run', // new prop in CustomOutputTarget
     async generator(config, compilerCtx: any, buildCtx, docs): Promise<void> {
       // Logique to create a .d.ts file
     }
    },
  ]
}

component-config.d.ts

export interface ComponentOptions {
  "pop-drawer"?: {
    triggerAction?: "click" | "context-menu" | "hover";
    side?: "end" | "start";
    open?: boolean;
  }
}

These options are extracted from the component, but if a modification is made to this component, the output target is not updated.

Describe Preferred Solution

export const config: Config = {
  ... // Config
  outputTargets: [
    {
      type: 'custom',
      name: 'component-option',
     execType: 'run' | 'build', // new prop in CustomOutputTarget
     async generator(config, compilerCtx: any, buildCtx, docs): Promise<void> { }
    },
  ]
}

// 'run' : run on every change
// 'build' : run only on "final" build

Describe Alternatives

No response

Related Code

https://github.com/Sukaato/stencil-custom-target-example

Additional Information

No response

@ionitron-bot ionitron-bot bot added the triage label Mar 18, 2024
@christian-bromann christian-bromann self-assigned this Mar 18, 2024
@christian-bromann
Copy link
Member

I'd like to have a parameter that lets you choose whether the custom output target can be called at every change or only during the "final" build.

Can you elaborate on this? When you say "at every change" are you talking about having the output target run during watch mode? Because this works for me given your example project. I guess, could you explain in detail what the current behavior is and your expected/desired behavior?

@christian-bromann christian-bromann added Awaiting Reply This PR or Issue needs a reply from the original reporter. and removed triage labels Mar 18, 2024
@Sukaato
Copy link
Contributor Author

Sukaato commented Mar 19, 2024

Yes when a mean at every change, i mean in dev mode.

Like i said, when i add or remove a @config in JSdoc, the component-config.d.ts is not updated (not the components.d.ts that stencil provide),

I add some console.log in my component-config.target.ts but there only called on final build, not in dev mode.

@ionitron-bot ionitron-bot bot removed the Awaiting Reply This PR or Issue needs a reply from the original reporter. label Mar 19, 2024
@christian-bromann
Copy link
Member

Gotcha, what I can observe is that the src/components.d.ts is changing after every save:

drawer

However it seems that VSCode is not picking this up:
Screenshot 2024-03-19 at 2 56 44 PM

I will ingest this into our backlog for the team to take a closer look at. Any contributions are welcome!

@christian-bromann christian-bromann added the Bug: Validated This PR or Issue is verified to be a bug within Stencil label Mar 19, 2024
@Sukaato
Copy link
Contributor Author

Sukaato commented Mar 20, 2024

After running a few tests, I realized that the custom output target is never called when the --dev flag is set in the CLI, when it is cleared, the output target is called on first compilation, and on rebuild.

Based on this result, I think the bug is related to the dev flag.

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

2 participants