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

Update svelte config to compile web components and svelte components #234

Conversation

heatlikeheatwave
Copy link
Contributor

@heatlikeheatwave heatlikeheatwave commented Nov 30, 2021

Code changes

  • Added different svelte configs for web components and svelte components per svelte issue comment

  • Removed custom element tags from svelte components, e.g. <svelte:options tag="...">

  • Renamed web components to lowercase kebab case

Readiness checklist

  • [] Cypress tests passing?
  • [] New cypress tests added?
  • [] Included before/after screenshots, if the change is visual

License

I confirm that this contribution is made under the terms of the MIT license and that I have the authority necessary to make this contribution on behalf of its copyright owner.

@shortcut-integration
Copy link

@vercel
Copy link

vercel bot commented Nov 30, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/nylas/components/Wd6LXumu2BMDNBQF7rgS9C9swrtU
✅ Preview: Failed

[Deployment for 3c952b0 failed]

Comment on lines +47 to +48
import NError from "./components/NError.svelte";
void NError;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

not sure if this is the right change to have made here

Copy link
Contributor

@krisgardiner krisgardiner left a comment

Choose a reason for hiding this comment

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

I ran yarn start to do a quick smoke test against the components and it seems like most are broken with this change (to be expected). The immediate ones are NError needing to be imported now since it's not available globally and things like get_current_component().shadowRoot in HTMLEditor` not working since svelte components no longer have a shadow DOM when imported.

Also, I noticed that some of the components didn't get renamed properly (I think renaming files has always been an issue with git) - ie. Availability, Mailbox
image

@@ -1313,7 +1313,7 @@
}
</style>

<nylas-error {id} />
<NError {id} />
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this needs to be imported in now. Caught an error when yarn start.
image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Imported NError to all the components, this should be resolved now. Thanks for catching this!

const style = document.createElement("style");
style.innerHTML = styleContent;
host.shadowRoot.appendChild(style);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

It would probably be helpful to leave a comment or link to the comment that suggested this workaround. It seems like in order to retain the functionality of svelte components, we have to lose the scoped component styles feature. Since this change seems to be more permanent (I don't see interest from svelte team to fix this in the near future) it'd be nice to hear thoughts from the rest of the team.

Essentially, I think this means:

  1. all child svelte component styles need to be in their own file
  2. child component styles can now conflict since they're not scoped by the compiler
  3. child components lose they're reusability since we have to inject styles into their specific parent shadow dom

cc: @philrenaud @pooja169usp @ozsivanov @AaronDDM

@heatlikeheatwave heatlikeheatwave removed the request for review from AaronDDM December 3, 2021 17:04
@heatlikeheatwave heatlikeheatwave marked this pull request as draft December 3, 2021 17:04
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