Skip to content

feat: modules can be imported from a url#80

Merged
maartenbreddels merged 1 commit into
masterfrom
feat/url-modules
Jul 5, 2026
Merged

feat: modules can be imported from a url#80
maartenbreddels merged 1 commit into
masterfrom
feat/url-modules

Conversation

@maartenbreddels

@maartenbreddels maartenbreddels commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

define_module gains explicit sources: exactly one of module (a Path), code= or url=. A url-backed module is imported by the browser from that url instead of shipping the code over the widget model — e.g. a bundle served from the app's static dir, cacheable and preloadable (solara adds ?v=<content-hash> + immutable headers and a <link rel=modulepreload> in widgetti/solara#1169). The Module widget gets a url trait; change:url hot-swaps like change:code.

Backwards compatible: a plain str still works as module code (the released API) with a DeprecationWarning pointing at code=. Unit tests cover all forms plus the error cases; existing module UI tests pass unchanged.

Note: under solara server, define_module is patched by solara.server.esm — released solara keeps working via the deprecated form; the new keywords apply there once widgetti/solara#1169 ships.

🤖 Generated with Claude Code

@maartenbreddels maartenbreddels force-pushed the feat/url-modules branch 2 times, most recently from c49d37b to eba1a5f Compare July 5, 2026 10:32
@maartenbreddels maartenbreddels marked this pull request as ready for review July 5, 2026 10:52
define_module(name, url="/static/bundle.mjs") imports the module from
the url instead of shipping the code over the widget model (e.g. a
bundle served from the app's static dir, cacheable and preloadable).
Exactly one of module (a Path), code= or url= must be passed; a plain
str still works as module code for backwards compatibility, with a
DeprecationWarning.

Note: under solara server define_module is patched by solara.server.esm,
which needs the matching update (widgetti/solara#1169) for the new
signature to apply there.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@maartenbreddels maartenbreddels merged commit 564a726 into master Jul 5, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant