-
Notifications
You must be signed in to change notification settings - Fork 784
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: Support providing custom TypeScript transformers #5602
Comments
Hey @maxpatiiuk, thanks for writing up the feature request! I'm just curious, what is it that you're trying to do via your rollup plugin that you're unable to do? Just to get a sense of what the use-case for this is for your team. |
Sure. We have several use cases that would be much easier to resolve with a TypeScript transformer (until Stencil supports all of this natively):
In general, most things are motivated by:
|
Thanks for providing that breakdown! I know that code re-use and extensibility / composition is a pain point in Stencil at present and it is something that we want to address for sure. I'm going to circulate what you shared among the team and we'll noodle on it a bit! |
Prerequisites
Describe the Feature Request
We need an ability to provide a custom TypeScript transformer plugin to Stencil to modify the code BEFORE Stencil extracts data from the AST.
stencil/src/compiler/transpile/transpile-module.ts
Lines 114 to 122 in 962372f
Describe the Use Case
Stencil allows to define a rollup plugin that would transform the output code.
However, current implementation is very limited because rollup plugins are called after Stencil pulled the data from the AST for each component and transformed the code using TypeScript plugins.
This means:
@Watch
/@State
/@Prop
/@Method
/@Listen
either, as the component meta is extracted by Stencil at an earlier step, before the Rollup plugin is run.BUILD
object (that is used by Stencil for dead code elimination in minified production builds) is computed at an earlier step.Describe Preferred Solution
Ability to provide a custom TypeScript transformer in the
stencil.config.ts
file that would be called before Stencil extracts data from the AST and begins it's transformation.Describe Alternatives
Expose
buildCtx
andcompilerCtx
objects to Rollup plugins so that they could modify the Stencil's compiler meta or internal file system before Stencil outputs the built files.A partial solution may also be to expose the
cmpMeta
to the component at run-time to let it dynamically define watchers and to let it get a list of all the props/states available on the component (to integrate each prop with an external reactivity library)Without this, our "hacky" solution may be to use Stencil's Core Compiler API rather than the CLI directly (we would have to create our own CLI) to provide a custom file system object that would modify the source files before Stencil extracts component meta from the AST
Related Code
No response
Additional Information
Requested by: Esri
Related issues:
The text was updated successfully, but these errors were encountered: