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

Rollup cannot do tree shaking on components generated via react-output-target. #222

Closed
LabEG opened this issue Feb 7, 2022 · 2 comments
Closed
Labels
needs: reply The issue needs a response from the reporter. package: react @stencil/react-output-target package

Comments

@LabEG
Copy link

LabEG commented Feb 7, 2022

Rollup does not support /@PURE/ annotation for function right now.
As a result, tree shaking does not work on such a file.

But if the generated components are divided into files, 1 component per 1 file, then tree shaking works properly.

You can change the generator so that there is only one function in one file /@PURE/createReactComponent?

@sean-perkins
Copy link
Collaborator

Hello @LabEG thanks for bringing this issue to our attention.

So that I understand your request accurately, you would like an option on the react output target, so that when generating the react components, it would output a separate file for each component that it is defining?

i.e.:

src/components/button.ts

import { createReactComponent } from './react-component-lib';

import type { JSX } from '@myorg/package/components';

import { defineCustomElement } from '@myorg/package/components/button.js';

export const MyButton = /*@__PURE__*/createReactComponent<JSX.MyButton, HTMLMyButtonElement>('my-button', undefined, undefined, defineCustomElement);

src/components/label.ts

import { createReactComponent } from './react-component-lib';

import type { JSX } from '@myorg/package/components';

import { defineCustomElement } from '@myorg/package/components/label.js';

export const MyLabel = /*@__PURE__*/createReactComponent<JSX.MyLabel, HTMLMyLabelElement>('my-label', undefined, undefined, defineCustomElement);

If this is true, would you additionally need a global barrel file that exports each of the generated component files from a single entry point or would that be managed independently in your package?

@sean-perkins sean-perkins added needs: reply The issue needs a response from the reporter. package: react @stencil/react-output-target package labels Feb 22, 2022
@ionitron-bot
Copy link

ionitron-bot bot commented Mar 24, 2022

Thanks for the issue! This issue is being closed due to the lack of a reply. If this is still an issue with the latest version of the output targets, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot closed this as completed Mar 24, 2022
@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Mar 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs: reply The issue needs a response from the reporter. package: react @stencil/react-output-target package
Projects
None yet
Development

No branches or pull requests

2 participants