Skip to content

Upgrade dependencies #3

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

Closed
stefanovualto opened this issue Jan 26, 2021 · 5 comments
Closed

Upgrade dependencies #3

stefanovualto opened this issue Jan 26, 2021 · 5 comments

Comments

@stefanovualto
Copy link

stefanovualto commented Jan 26, 2021

Hi guys,

First of all, I would like to congratulate you on what you achieved here with this template... It is almost exactly what I need. And after trying different unsuccessful approaches I found your template which gave me some hopes in using svelte through web components.

I was wondering if you think about updating the dependencies? Because I am trying to do it, but running into issues due to some breaking change in the compiler configuration 😞 and the way how you inject the generatedCss ...

Again, Kudos for your work! ❤️

MonkeyAndres added a commit that referenced this issue Jan 28, 2021
@MonkeyAndres
Copy link
Contributor

Thanks to you for choosing it, I'm afraid it's a little complex to update the template as this change in the rollup-plugin-svelte breaks all the hack.

Also, I was getting a weird error from rollup when updating it. Feel free to continue my research and open a pull request.

@stefanovualto
Copy link
Author

I am not convinced 100% about the DX though, I am trying to modify few things to test the real webcomponent (to avoid surprises in prod).
But as soon as I will have time to fix the upgrade I will put it in a PR...
Thanks again for your hacks! 😄

@MonkeyAndres
Copy link
Contributor

We're using this template in a semi-prod environment if it gives you some more confidence.

Thanks to you, I'll close the issue.

@stefanovualto
Copy link
Author

stefanovualto commented Feb 4, 2021

Just in case I find a way to make it works, but with the incremental build if the css is not modified it doesn't re-inject the css into the root shadowdom (but first build is fine)

here is part of my actual configuration:

       // other latest imports (from today)
       import css from "rollup-plugin-css-only";
       import replace from "@rollup/plugin-replace";

       ...

       svelte({
            preprocess: sveltePreprocess({ sourceMap: !production }),
            compilerOptions: {
                dev: !production,
                customElement: true,
            },
            emitCss: false,
            include: "./src/_index.svelte",
        }),

        svelte({
            preprocess: sveltePreprocess({ sourceMap: !production }),
            compilerOptions: {
                dev: !production,
            },
            emitCss: true,
            exclude: "./src/_index.svelte",
        }),

        // injects the svelte app css into the shadow dom root node (if you minify later you need only one replace)
        // no sure about the key `bundle.js` works for me I didn't check in your template
        css({
            output(styles, styleNodes, bundle) {
               const match = production
                    ? `.shadowRoot.innerHTML="`
                    : `.shadowRoot.innerHTML = "`;

                bundle["bundle.js"].code = bundle[`bundle.js`].code.replace(
                    match,
                    `${match}<style>${styles}</style>`
                );
            },
        }),

       // add transition into shadow dom
        replace({
            ".ownerDocument": ".getRootNode()",
            delimiters: ["", ""],
        }),
        replace({
            ".head.appendChild": ".appendChild",
            delimiters: ["", ""],
        }),

MonkeyAndres added a commit that referenced this issue Feb 10, 2021
Special thanks to @stefanovualto for the workaround at #3
@MonkeyAndres
Copy link
Contributor

Thanks a lot, it seems like a good solution, we will update the template to use it 🤘🏼

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

No branches or pull requests

2 participants