-
Notifications
You must be signed in to change notification settings - Fork 318
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
[object Object] rendered when using rollup and html template exported from symlinked project #390
Comments
Thanks for pointing this out. Marked it for inclusion in the docs. |
Also worth noting, if anyone is experiencing this issue or the related one where the JS code for a directive is being rendered instead of its results, it's usually caused by having more than one copy of lit-html being bundled. One way to check is to look at the sourcemap to see if there are multiple entries for lit-html and it will also indicate where they are coming from, e.g. "sources: [
"../../node_modules/lit-html/lit-html.js",
"../../../some-included-elements/node_modules/lit-html/lit-html.js",
...
] |
Ran into this issue today using webpack. Here was my solution: resolve: {
alias: {
"lit-element": path.resolve("./node_modules/lit-element")
}
} |
We have lit-html issues opened for this. |
When consuming typed mixins that rely on lit-element (https://github.com/anoblet/mixins/blob/master/src/BeforeRender.ts) I've encountered similar errors (lit-element !=== lit-element). The solution for the consuming package with typescript was:
|
@justinfagnani - Which issue ? This is closed and can't find anything similar |
Description
Not really a bug, just something that someone may come across and the solution (where "someone" will probably be me in 6+ months time ...)
A template exported from a project that is symlinked doesn't render properly bundled using rollup.
Live Demo
Not appropriate
Steps to Reproduce
Suppose you have an "elements" project where you work on UI components independently. Inside it, you export a template, maybe a
sharedStyles
template that you also want to re-use in application view elements. Something like:While developing, you don't want to keep publishing to npm just to use them in the consuming app project so you use a symlink or
npm link
to reference the elements project from the app.Inside the app, you import the exported template and use it in an element:
...
You bundle the app using rollup
Expected Results
sharedStyles
renders HTML output on the pageActual Results
sharedStyles
renders as [object Object] because rollup includes some parts of lit-html twice, even if you de-dupe things (todo with path resolution).Solution
If you come across this, the solution is to set the
preserveSymlinks
option in rollup to true, this can be set as a command line option (rollup -c --preserveSymlinks
) or added torollup.config.js
:The text was updated successfully, but these errors were encountered: