Comments (8)
Yep, I'm good with this change.
I'm not sure if the built-in Skypack CDN behavior will work with Microsite's SSR setup... might be better to just support local
builds for now.
from microsite.
I’ve thought about ways it could work (also tying in with #99), but after so many boondoggles around tests I’m definitely happy to keep it as small and focused as possible for a first start. I doubt I’ll look at it tomorrow, I’m going to yeet myself out to space if I don’t have a meaningful commit on my own site tomorrow. But I’ll be back to this, I definitely want it.
from microsite.
One more note on this because it’s something I’m tracking on my site: I tried a bunch of stuff locally with the contexts used to gather head/hydration to preload as much as possible and it seems Skypack itself is a bottleneck here. Going local already felt like a good direction given cache partitioning, but to add more flavor here, the Skypack CDN has a pretty much fixed 200-300ms latency and their cache headers don’t do well with even non-force reloads.
from microsite.
@eyelidlessness Makes sense. I'm taking a look at this now and I'll see where I get.
from microsite.
OK, you warned me but this was much more involved than I expected. 😅
What the build script does right now is mark preact
as external for the SSG pass, which allows node
to resolve preact
to the same instance that microsite
is using from node_modules
. As a final pass Microsite transforms any references to bare preact
in the generated dist files to point at the CDN. This works smoothly because we're only dealing with a single instance of preact
, whereas if we include preact
in the bundle, we're dealing with a version local to the user's components and a version local to Microsite's wrapper components. Due to Preact's architecture, despite both instances being the same exact version of Preact, they can't be mixed.
There's definitely a way around this, but I think it requires some more thought. I have a feeling v1.2.0 is going to be focused on eliminating the differences between the dev/build scripts, so this should fit nicely into that set of refactoring.
from microsite.
I’m still in early caffeination stage but this feels like it might be an easy solve by making Preact a dev/peer dependency? That way for users there should only be one version and no mixing
from microsite.
Unfortunately not, Snowpack bundles Preact into <STAGING_DIR>/_snowpack/pkg/preact.js
, so userland components all pull that Preact instance while the Microsite SSG pass pulls from node_modules
. It shouldn't be too hard to solve, just want to prioritize getting v1.1.0
out the door finally.
from microsite.
Just cross-referencing the fact that in #125, I promised Preact on Skypack would opt-in behavior in v1.2.0.
@Siilwyn I agree with that! Local will always be better for performance.
- v1.1.0 will remain on Skypack, purely because there are too many unrelated fixes/features that have needed to go out for a while.
- v1.2.0 will load Preact from a local
vendor
chunk by default. I can start on the architectural changes ASAP. Would love your help @eyelidlessness!
from microsite.
Related Issues (20)
- Remove defer from inline scripts HOT 3
- Move `microsite-templates` into this repo HOT 1
- Doesn't do the thing 🙃 HOT 3
- Partial hydration causes Preact to be fetched twice HOT 10
- production build fails when CSS module is imported on multiple pages HOT 2
- getStaticProps + node builtins + dev server fails HOT 1
- Preact import regex matches too much HOT 2
- Preact CDN lookup fails for non-hardcoded submodules HOT 1
- Enhancement: Support SSR-able components as props for hydrated components HOT 7
- getStaticPaths uses module’s path when returning params object HOT 1
- [RFC] Built-in Markdown/MDX Support HOT 2
- Dynamic routes won't work in dev mode HOT 4
- Hydrated component isn't initialized in prod builds when it is exported/imported under a name different from the name of the component it decorates HOT 6
- Make withHydrate a no-op when nested rather than an error
- Hydration fails with nested props arrays/objects HOT 7
- Build fails with "Error: You must supply options.input to rollup"
- import.meta.env.SSR is true on the client HOT 1
- Preact modules are loaded with `modulepreload` even if they're not used
- dev server fails to load fetch HOT 1
- Add SCSS/SASS support?
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 microsite.