prashantpalikhe / nuxt-ssr-lit

SSR support for Lit elements in Nuxt3
Other
42 stars 7 forks source link

If no components are used in a Nuxt page, but component definitions are imported in a plugin, the dom-shim on Node does not get applied #36

Closed prashantpalikhe closed 1 year ago

prashantpalikhe commented 1 year ago

Describe the bug

If no components are used in the Nuxt app, but component definitions are imported in a plugin (mode: 'all'), the dom-shim does not get applied.

This happens because the imports from LitWrapperServer are removed in the final output generated by Nuxt for the server. (.nuxt/dist/server/server.mjs) if no Lit components are being used. But if those component definitions are being imported in a plugin e.g. import "@acme/button". This will fail because the dom shim has been removed by Nuxt.

To Reproduce

Steps to reproduce the behavior:

  1. Create a Nuxt application that uses the module
  2. Create a Lit component
  3. Import the Lit component definition in a universal Nuxt plugin
  4. Do not use the Lit component anywhere
  5. Start the Nuxt application

https://stackblitz.com/edit/nuxt-starter-jpzrrq?file=nuxt.config.ts

Expected behavior

Nuxt application should not break.

steveworkman commented 1 year ago

Fixed in 1.0.5