Skip to content

make auto definition optional#3

Merged
johnjenkins merged 3 commits intojohnjenkins:feat-custom-elements-import-dependenciesfrom
rwaskiewicz:johnjenkins-feat-custom-elements-import-dependencies-ryan-3
Sep 29, 2021
Merged

make auto definition optional#3
johnjenkins merged 3 commits intojohnjenkins:feat-custom-elements-import-dependenciesfrom
rwaskiewicz:johnjenkins-feat-custom-elements-import-dependencies-ryan-3

Conversation

@rwaskiewicz
Copy link
Copy Markdown

With this commit, we make auto definition of custom elements optional, by hiding them behind a configuration flag (autoDefineCustomElements)

A small design decision here: the BUILD.* global variable is not available to us in code that lives in src/compiler/*, which is why we use the config file directly (or rather, the parsed/validated version of the config file).

I also reverted the version change in package.json I made in the last PR/commit

Copy link
Copy Markdown
Owner

@johnjenkins johnjenkins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me know what you think re the comments :)

* functionality allows consumers to bypass the explicit call to define a component, its children, its children's
* children, etc. Users of this flag should be aware that enabling this functionality may increase bundle size.
*/
autoDefineCustomElements?: boolean;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, I wonder if it might make more sense for this to go into the OutputTargetDistCustomElements interface as opposed to config extras? (~L1900)

setupComponentDependencies(moduleFile, components, newStatements, caseStatements, tagNames);
addDefineCustomElementFunction(tagNames, newStatements, caseStatements);

if (config.extras?.autoDefineCustomElements) {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, I wonder if it might make more sense for this to go into the OutputTargetDistCustomElements interface as opposed to config extras?

Suggested change
if (config.extras?.autoDefineCustomElements) {
import { isOutputTargetDistCustomElements } from 'src/compiler/output-targets/output-utils';
...
if (config.outputTargets.find(isOutputTargetDistCustomElements).autoDefineCustomElements) {

OutputTargetDistCustomElements
@johnjenkins johnjenkins merged commit 8247a84 into johnjenkins:feat-custom-elements-import-dependencies Sep 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants