Skip to content
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

bare imports #159

Open
terrablue opened this issue Aug 20, 2024 · 0 comments
Open

bare imports #159

terrablue opened this issue Aug 20, 2024 · 0 comments
Labels
core core code dx developer experience
Milestone

Comments

@terrablue
Copy link
Contributor

terrablue commented Aug 20, 2024

Global bare imports.

import target from "#app/target";

target; // "desktop" | "web"
import IndexPage from "#components/IndexPage.jsx";

export default {
  get() {
     // statically (TS), this needs to resolve to the correct component for live-bindings between server and client
     // in runtime (JS), this needs to resolve to `view("IndexPage", props);`
     return IndexPage({ posts: [{ id: 0, title: "Hello, world!" }] });
  },
};

(Relates to #122)

Other uses also possible, like importing stores from anywhere, provided we can make sure that operations are still transactionalised.

With export conditions, we should even make it possible to import stores from clientside components, translating the implementation to a fetch call to some canonical API route that accesses the database and returns the results. But this could quickly become a security nightmare unless done conservatively and in an extremely guarded way (only reads, and possibly hardcoding the queries on the server so it doesn't become a universal mechanism to access the database).

Considerations:

  • Needs to work both clientside (esbuild) and serverside (node/bun/deno); esbuild currently bundles from ., not from ./build, for hotreloading during dev
  • TS should be supported to the extent possible
  • It should be compatible with both dev (build&serve) and prod (build now, serve later) environments

Is currently only possible with Node, as introducing custom loaders isn't supported in Bun (oven-sh/bun#13415) or Deno (denoland/deno#23201). We can only mainline this once Bun and Deno support it.

@terrablue terrablue added dx developer experience core core code labels Aug 20, 2024
@terrablue terrablue added this to the 0.33.0 milestone Nov 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core core code dx developer experience
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

1 participant