preactjs / create-preact Goto Github PK
View Code? Open in Web Editor NEWCreate a Vite-powered Preact app in seconds
License: MIT License
Create a Vite-powered Preact app in seconds
License: MIT License
Hi Preact team, Aurélien from @vikejs here. We saw that create-preact
is scaffolding projects with Vike, which is really nice.
Instead of maintaining your own Vike hooks here in your templates, we recommend moving them to a Vike extension named vike-preact
. Your templates could then just scaffold projects having vike
and vike-preact
in their package.json
.
We (Preact and Vike) could then for example co-maintain together this new vike-preact
package shipping the hooks. And vike-preact
could be used in other scaffolders, like https://github.com/batijs/bati
Let us know if you're interested in this collaboration. This would mean less maintenance work for you and less chances of mistakes if we co-maintain these hooks.
Describe the bug
When using npm init preact
to set up a project, a conflict arises when multiple contexts are defined using the same variable name. Even if these contexts are created in separate files, if they are assigned to the same variable name, they seem to override each other. This only happens when running npm run dev
, not when running npm run build
or npm run preview
.
To Reproduce
I created a minimal example exhibiting this behavior: https://github.com/rjvdw/preact-context-bug. Foo.jsx, Bar.jsx and Baz.jsx all define their own context. Foo.jsx and Bar.jsx use const ctx = createContext
, whereas Baz.jsx uses const ctxBaz = createContext
.
Expected behavior
When running this app, you are presented with three buttons. I would expect each button to only increment the counter directly next to this button, but instead the counters for Foo.jsx and Bar.jsx are linked. I.e. when I increment Foo, Bar is also incremented and vice versa. The counter for Baz is working as intended.
Right now we only support adding a router to pure client-side apps but we should expand this to SSG as well. Just need to add a config/router-ssg
directory I think, mirroring what we've done w/ base
and config/router
more or less.
I'm wondering if there are plans to add the PWA configuration features of preact-cli. If so, what is the expected timeline? Thanks!
In future, the package.json
and references to vite-plugin-ssr
would need to change over to vike
https://vite-plugin-ssr.com/vike
Happy to raise a PR if it helps out.
Should document the commands needed to get up and running (we also list this in the CLI output upon completion, but duplication wouldn't hurt) and possibly duplicate the resources info as well?
Creating a template app and just changing the anchor to a paragraph breaks the classes.
thegamerx1/vike-even@d23d5eb
I used create-preact
to start a project. But when I ran yarn run
I got this:
VITE v4.4.9 ready in 487 ms
➜ Local: http://127.0.0.1:3000/
➜ Network: use --host to expose
➜ press h to show help
Error: Failed to scan for dependencies from entries:
/pages/index.page.tsx
/renderer/_default.page.client.tsx
✘ [ERROR] Expected ">" but found "value"
renderer/usePageContext.ts:13:27:
13 │ return <Context.Provider value={pageContext}>{children}</Context...
│ ~~~~~
╵ >
And when I tried to go to localhost I got this:
14:59:08 [vite-plugin-ssr][request(1)] HTTP request: /
14:59:09 [vite][request(1)] Failed to transpile /renderer/usePageContext.ts because:
Unexpected token, expected ","
11 |
12 | function PageContextProvider({ pageContext, children }) {
> 13 | return <Context.Provider value={pageContext}>{children}</Context.Provider>
| ^
14 | }
15 |
16 | function usePageContext() {
┌───────────────────────────────┐
│ Error isn't helpful? See https://vite-plugin-ssr.com/errors#verbose │
└───────────────────────────────┘
14:59:09 [vite-plugin-ssr][request(1)][Warning] No _error.page.js found, we recommend defining an error page, see https://vite-plugin-ssr.com/error-page
14:59:09 [vite-plugin-ssr][request(1)] HTTP response / ERR
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.