Giter VIP home page Giter VIP logo

Comments (4)

faburem avatar faburem commented on June 21, 2024 1

+1 on avoiding useless code on the client, I have not thought about that part.

Maybe we can use the same approach as Meteor's babel-compiler package and detect for which architecture (client or server) a file is compiled.

I did not know that this is possible with a build plugin, this would definitely be the best approach!
Please let me know if there is anything I could help with (i.e. testing), I am starting a new project and I will use meteor-svelte for the UI layer.

from meteor-svelte.

klaussner avatar klaussner commented on June 21, 2024

Thank you for this detailed analysis! I haven't used Svelte with SSR myself yet but it's definitely a feature I would like to have in the build plugin. However, exporting both builds ("dom" and "ssr") probably won't work because components would have to know whether they are imported on the client or on the server. For example:

<!-- Component.html -->

<div>I'm a component!</div>
<!-- App.html -->

<Component />

<script>
// Which of the two `import`s should be used? It depends on where
// `App.html` is imported (client or server).
import Component from "./Component.html";
import { ssr as Component } from "./Component.html";

export default {
  components: {
    Component
  }
};
</script>

I'd also like to avoid adding the "ssr" component's render function to the generated class because it would add code to the JavaScript bundle that is never used on the client.

Maybe we can use the same approach as Meteor's babel-compiler package and detect for which architecture (client or server) a file is compiled. If it's compiled for the server, we generate an "ssr" component. This would be similar to Svelte's require("svelte/ssr/register"), except that components are generated at build time rather than at runtime. And it wouldn't require any configuration.

What do you think? 🙂

from meteor-svelte.

klaussner avatar klaussner commented on June 21, 2024

Great, thanks! I will try to get a testable version ready sometime this week.

from meteor-svelte.

klaussner avatar klaussner commented on June 21, 2024

Released in version 1.64.1_1! 🙂

from meteor-svelte.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.