stencil
stencil copied to clipboard
bug: not all types are exported when using `dist-custom-elements`
Prerequisites
- [x] I have read the Contributing Guidelines.
- [x] I agree to follow the Code of Conduct.
- [x] I have searched for existing issues that already report this problem, without success.
Stencil Version
v4.38.3 or later
Current Behavior
When using the dist-custom-elements without customElementsExportBehavior: 'single-export-module', the generated ./dist/components/index.d.ts does not export all the types exported by the ./src/index.ts
Current file contents (removed comments):
export declare const getAssetPath: (path: string) => string;
export declare const setAssetPath: (path: string) => void;
export declare const setNonce: (nonce: string) => void
export interface SetPlatformOptions {
raf?: (c: FrameRequestCallback) => number;
ael?: (el: EventTarget, eventName: string, listener: EventListenerOrEventListenerObject, options: boolean | AddEventListenerOptions) => void;
rel?: (el: EventTarget, eventName: string, listener: EventListenerOrEventListenerObject, options: boolean | AddEventListenerOptions) => void;
}
export declare const setPlatformOptions: (opts: SetPlatformOptions) => void;
Expected Behavior
If you set customElementsExportBehavior: 'single-export-module', then you get the expected result
export { MyComponent as MyComponent } from '../types/components/my-component/my-component';
export { defineCustomElement as defineCustomElementMyComponent } from './my-component';
export declare const getAssetPath: (path: string) => string;
export declare const setAssetPath: (path: string) => void;
export declare const setNonce: (nonce: string) => void
export interface SetPlatformOptions {
raf?: (c: FrameRequestCallback) => number;
ael?: (el: EventTarget, eventName: string, listener: EventListenerOrEventListenerObject, options: boolean | AddEventListenerOptions) => void;
rel?: (el: EventTarget, eventName: string, listener: EventListenerOrEventListenerObject, options: boolean | AddEventListenerOptions) => void;
}
export declare const setPlatformOptions: (opts: SetPlatformOptions) => void;
export * from '../types'; // THIS LINE IN PARTICULAR
System Info
Steps to Reproduce
- Run
pnpm create stencilto init a new repo - Check to make sure you have an
dist-custom-elementsoutput target with acustomElementsExportBehaviorwith any value other thansingle-export-module
{
type: 'dist-custom-elements',
customElementsExportBehavior: 'auto-define-custom-elements',
}
- Make sure that
formatis exported inindex.ts
export { format } from './utils/utils';
- Run the build and look at
./dist/components/index.d.ts
Code Reproduction URL
https://github.com/theo-staizen/stencil-repro-custom-elements
Additional Information
- npm install
- npm run build
- check to see that
export * from '../types';is missing from the end of./dist/components/index.d.ts - uncomment
customElementsExportBehavior: 'single-export-module'instencil.config.ts - Run the build again and check to see the that
export * from '../types;is now included