将Vaadin与Astro一起使用

发布于 2025-02-02 11:32:13 字数 1066 浏览 2 评论 0 原文

我试图在Astro Powered应用中使用Vaadin组件。不幸的是,我遇到了这个错误。

  Named export 'dedupingMixin' not found. The requested module '@polymer/polymer/lib/utils/mixin.js' is a CommonJS module, which may not support all module.exports as named exports.
  CommonJS modules can always be imported via the default export, for example using:
  
  import pkg from '@polymer/polymer/lib/utils/mixin.js';
  const { dedupingMixin } = pkg;

这是Stackblitz的链接;

但总的来说,它足以设置新的Astro App( https://docs.astro.build/en/install/auto/ )安装vaadin组件; npm i @vaadin/button 并将其导入索引Astro; 导入'@vaadin/button'

您不必使用它,导入就足够了。我也尝试在Svelte组件中使用它,这是相同的错误。有什么想法吗?

I tried to use vaadin component in Astro powered app. Unfortunately I get this error;

  Named export 'dedupingMixin' not found. The requested module '@polymer/polymer/lib/utils/mixin.js' is a CommonJS module, which may not support all module.exports as named exports.
  CommonJS modules can always be imported via the default export, for example using:
  
  import pkg from '@polymer/polymer/lib/utils/mixin.js';
  const { dedupingMixin } = pkg;

Here is a link to stackblitz;
https://stackblitz.com/edit/github-veapdc?file=src%2Fpages%2Findex.astro&on=stackblitz

but in general it is enough to setup new astro app (https://docs.astro.build/en/install/auto/) install vaadin component;
npm i @vaadin/button
and import it in index astro;
import '@vaadin/button'

You don't have to use it, import is enough. I tried to use it in svelte component as well, same errors. Any ideas??

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

⊕婉儿 2025-02-09 11:32:13

对于那些遇到此问题的人,您可以如何处理它。由于Vaadin组件是Web组件,因此它们可能不会在Astro SSR开箱即用而使用。与其使用导入量子'@vaadin/button',不如在确认您在浏览器上运行后选择动态导入。

if (typeof window !== "undefined") {
  import("@vaadin/button");
}

要减轻未风格的内容(FOUC)的闪光,请在您的应用程序中添加以下CSS:

vaadin-button:not(:defined) {
  visibility: hidden;
}

For those encountering this issue, here's how you can work around it. Since Vaadin components are web components, they may not function smoothly with Astro SSR out of the box. Instead of statically importing with import '@vaadin/button', opt for dynamic import after confirming you're running on the browser.

if (typeof window !== "undefined") {
  import("@vaadin/button");
}

To mitigate the Flash of Unstyled Content (FOUC), add the following CSS to your application:

vaadin-button:not(:defined) {
  visibility: hidden;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文