Comments (4)
+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.
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.
Great, thanks! I will try to get a testable version ready sometime this week.
from meteor-svelte.
Released in version 1.64.1_1! 🙂
from meteor-svelte.
Related Issues (20)
- Can't get the basic SSR example repo running HOT 1
- Wrapping Svelte components to a package with Meteor HOT 1
- Error messages HOT 3
- svelte:compiler fails to compile svelte exports from js files HOT 1
- Target is a required option in new Meteor installation HOT 4
- Babel transforms not applying to .svelte files HOT 3
- Error updating Svelte > 3.6.10 with 4.0.0-beta.0 HOT 7
- Problems importing Svelte components from package HOT 5
- load method from npm module can't export HOT 2
- Error in web.browser.legacy build HOT 3
- Syntax error on IE11 HOT 5
- Question: Optional Chaining on Svelte components HOT 1
- Typescript for Svelte HOT 6
- TypeError: undefined is not a constructor ... HOT 2
- Cannot import component
- ios svelte requires 3.27.0 + blank screen HOT 1
- Compatibility with Meteor v2 HOT 1
- Upgrade to svelte 3.44.3? HOT 1
- Cannot read property 'sections' of null (v3.44.3) HOT 2
- Incompatible with Svelte 4? HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from meteor-svelte.