Closed cristobal closed 1 year ago
This looks to me like a dvlp issue. The first message is coming from lit and is standard when NODE_ENV=development
. It's a warning, but flagged here as an error by dvlp. There is only one version of lit-html.js
, and it works on both server/client.
The real problem here is that the lit
core packages need to be vendored due to Google's aggressive minification and missing API for modifying internal properties during hydration. I will continue to look for a better solution here.
From what i can see is that we require the following files:
@popeindustries+lit-html-server@6.0.1_@types+trusted-types@2.0.3/node_modules/@popeindustries/lit-html-server/lit-html-server.js
to make the server happy@popeindustries+lit-html@5.2.1_@types+trusted-types@2.0.3/node_modules/@popeindustries/lit-html/src/vendor/lit-html.js
the client code when run on the server tooBoth of them inline a bit of the same code it seems, however the server code is minified on the left, as depicted in the picture on the left below.
It may be that they don't inline the all the same code, however something is overlapping at least it seems.
I think i found out why this happens now, it seems that the bundled lit-html-server, includes the same lit-html since it's imports and exports from @popeindustries/lit-html
package from the lit-html-server.js file.
https://github.com/popeindustries/lit/blob/8b26dbce848997642c1d3ca45665e4c0eb43d630/packages/lit-html-server/src/lit-html-server.js#L3-L9
However the built file includes all the code that it imports and exports from @popeindustries/lit-html
, instead of using import and exports.
This is what is imported 👇🏽
So the package @popeindustries/lit-html
is not imported at all here ☝🏽, but rather bundled as part of the build instead. I guess we need to fix the build file here.
Will create an PR 👋🏽
Ok, I guess you just need to update L8 in packages/lit-html-server/scripts/build.js
to externalize @popeindustries/lit-html
instead of lit-html
Question
Should the
lit-html
andlit-html-server
include the batteries in other words bundle lit core themselves.Background
The problem that we see now is that we get the following message on the server.
With some debug we saw that it's the same version that we get the warning on:
Problem
It adds a bit of complexity in the code with ESM to handle server vs. client since it would require to have a custom file that handles dynamic import of the lit implementations depending whether we are on the client vs. server.
Solution
Some solution to this could be e.g.: