Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

feat: support single-file WASM exports (#10878)

Péter Gyarmati9eb4fa44c55e
diff --git a/docs/guides/exporting/webassembly_html.md b/docs/guides/exporting/webassembly_html.md
index c17bdde207..f781492e8f 100644
--- a/docs/guides/exporting/webassembly_html.md
+++ b/docs/guides/exporting/webassembly_html.md
@@ -1,6 +1,8 @@
# WebAssembly HTML
-Export your notebook to a self-contained HTML file that runs using [WebAssembly](../wasm.md).
+Export your notebook to HTML that runs in the browser using [WebAssembly](../wasm.md).
+Internet access is required to load Pyodide and Python packages. Single-file
+exports also load marimo's frontend assets from a CDN.
/// tip | Easiest way to share interactive notebooks
For the simplest way to share interactive notebooks online, including WebAssembly notebooks, use [molab](../molab.md).
@@ -22,12 +24,13 @@ view is not available in WebAssembly HTML exports.
Speaker notes are embedded in the HTML file and readable by anyone who receives it.
-The exported HTML file will run your notebook using WebAssembly, making it completely self-contained and executable in the browser. This means users can interact with your notebook without needing Python or marimo installed.
+Users can interact with the exported notebook without needing Python or marimo installed.
Options:
- `--mode`: Choose between `run` (read-only) or `edit` (allows editing)
- `--output`: Directory to save the HTML and required assets
+- `--single-file`: Write one HTML file that loads assets from a CDN and opens directly in a browser
- `--show-code/--no-show-code`: Whether to initially show or hide the code in the notebook
- `--watch/--no-watch`: Watch the notebook for changes and automatically export
- `--include-cloudflare`: Write configuration files necessary for deploying to Cloudflare
@@ -48,13 +51,32 @@ incompatibilities early:
!!! note "Note"
- The exported file must be served over HTTP to function correctly - it
+ By default, the exported file must be served over HTTP to function correctly. It
cannot be opened directly from the filesystem (`file://`). Your server must
also serve the assets in the `assets` directory, next to the HTML file. For
a simpler publishing experience, use [molab](../molab.md), publish to [GitHub
Pages](../publishing/github.md#publish-to-github-pages), [Cloudflare](../publishing/cloudflare.md), or
[self-host](../publishing/self_host_wasm.md).
+## Sharing a single file
+
+Export a notebook to share as an HTML attachment:
+
+```bash
+marimo export html-wasm notebook.py --single-file -o notebook.html
+```
+
+Recipients can open `notebook.html` directly in their browser. Internet access
+is required to load marimo, Pyodide, and Python packages. The notebook code is
+embedded in the HTML and runs in the recipient's browser. Use `--mode edit` to
+let recipients edit the code.
+
+Keep data in the notebook or load it from URLs that allow cross-origin access.
+Single-file exports do not bundle the `public/` directory, local modules,
+local wheels, or execution caches. Use the default directory export for these
+resources. `--execute` embeds a preview of outputs, but cells run again in the
+browser. `--include-cloudflare` requires a directory export.
+
??? note "Deploying to Cloudflare"
You can include `--include-cloudflare` for deploying to Cloudflare. For example:
diff --git a/frontend/src/core/islands/worker-factory.ts b/frontend/src/core/islands/worker-factory.ts
index 08279f07e8..9541542747 100644
--- a/frontend/src/core/islands/worker-factory.ts
+++ b/frontend/src/core/islands/worker-factory.ts
@@ -1,5 +1,6 @@
/* Copyright 2026 Marimo. All rights reserved. */
+import { createModuleWorker } from "@/utils/worker";
import { getMarimoVersion } from "../meta/globals";
import workerUrl from "./worker/worker.tsx?worker&url";
@@ -47,20 +48,9 @@ export class DefaultWorkerFactory implements WorkerFactory {
* Creates a new Pyodide worker
*/
create(): Worker {
- const js = `import ${JSON.stringify(new URL(this.url, import.meta.url))}`;
- const blob = new Blob([js], { type: "application/javascript" });
- const objURL = URL.createObjectURL(blob);
-
- const worker = new Worker(objURL, {
- type: "module",
- /* @vite-ignore */
+ return createModuleWorker(new URL(this.url, import.meta.url), {
name: this.name,
});
-
- // Blob URL can be revoked once the worker has loaded the script
- URL.revokeObjectURL(objURL);
-
- return worker;
}
/**
diff --git a/frontend/src/core/wasm/__tests__/fs.test.ts b/frontend/src/core/wasm/__tests__/fs.test.ts
new file mode 100644
index 0000000000..65aa8354fa
--- /dev/null
+++ b/frontend/src/core/wasm/__tests__/fs.test.ts
@@ -0,0 +1,22 @@
+/* Copyright 2026 Marimo. All rights reserved. */
+import type { PyodideInterface } from "pyodide";
+import { afterEach, expect, it, vi } from "vitest";
+import { WasmFileSystem } from "../worker/fs";
+
+afterEach(() => vi.unstubAllGlobals());
+
+it.each(["https://notebook.example", "null"])(
+ "mounts persistent storage only for a non-opaque origin: %s",
+ (origin) => {
+ vi.stubGlobal("origin", origin);
+ const mount = vi.fn();
+ const IDBFS = {};
+ const pyodide = {
+ FS: { mount, filesystems: { IDBFS } },
+ } as unknown as PyodideInterface;
+ WasmFileSystem.mountFS(pyodide);
+ expect(mount.mock.calls).toEqual(
+ origin === "null" ? [] : [[IDBFS, { root: "." }, "/marimo"]],
+ );
+ },
+);
diff --git a/frontend/src/core/wasm/bridge.ts b/frontend/src/core/wasm/bridge.ts
index d272006c55..80fb961adc 100644
--- a/frontend/src/core/wasm/bridge.ts
+++ b/frontend/src/core/wasm/bridge.ts
@@ -9,6 +9,7 @@ import { throwNotImplemented } from "@/utils/functions";
import { Logger } from "@/utils/Logger";
import { reloadSafe } from "@/utils/reload-safe";
import { generateUUID } from "@/utils/uuid";
+import { createModuleWorker } from "@/utils/worker";
import { notebookIsRunningAtom } from "../cells/cells";
import type { CommandMessage } from "../kernel/messages";
import { getMarimoVersion } from "../meta/globals";
@@ -45,6 +46,8 @@ import { createShareableLink } from "./share";
import { wasmInitStateAtom } from "./state";
import { fallbackFileStore, notebookFileStore } from "./store";
import { isWasm } from "./utils";
+import saveWorkerUrl from "./worker/save-worker.ts?worker&url";
+import workerUrl from "./worker/worker.ts?worker&url";
import type { SaveWorkerSchema } from "./worker/save-worker";
import type { WorkerSchema } from "./worker/worker";
@@ -82,13 +85,10 @@ export class PyodideBridge implements RunRequests, EditRequests {
}
// Create save worker
- const saveWorker = new Worker(
- // oxlint-disable-next-line unicorn/relative-url-style
- new URL("./worker/save-worker.ts", import.meta.url),
+ const saveWorker = createModuleWorker(
+ new URL(saveWorkerUrl, import.meta.url),
{
- type: "module",
// Pass the version (and optional capability suffix) to the worker
- /* @vite-ignore */
name: getWasmWorkerName(),
},
);
@@ -102,16 +102,10 @@ export class PyodideBridge implements RunRequests, EditRequests {
}
// Create a worker
- const worker = new Worker(
- // oxlint-disable-next-line unicorn/relative-url-style
- new URL("./worker/worker.ts", import.meta.url),
- {
- type: "module",
- // Pass the version (and optional capability suffix) to the worker
- /* @vite-ignore */
- name: getWasmWorkerName(),
- },
- );
+ const worker = createModuleWorker(new URL(workerUrl, import.meta.url), {
+ // Pass the version (and optional capability suffix) to the worker
+ name: getWasmWorkerName(),
+ });
// Create the RPC
this.rpc = getWorkerRPC<WorkerSchema>(worker);
diff --git a/frontend/src/core/wasm/worker/fs.ts b/frontend/src/core/wasm/worker/fs.ts
index c031a2e0ec..bfafd35cc8 100644
--- a/frontend/src/core/wasm/worker/fs.ts
+++ b/frontend/src/core/wasm/worker/fs.ts
@@ -20,6 +20,10 @@ export const WasmFileSystem = {
FS.chdir(HOME_DIR);
},
mountFS: (pyodide: PyodideInterface) => {
+ // Opaque origins (single-file exports) use the in-memory filesystem.
+ if (globalThis.origin === "null") {
+ return;
+ }
const FS = getFS(pyodide);
// Mount the filesystem
FS.mount(pyodide.FS.filesystems.IDBFS, { root: "." }, HOME_DIR);
diff --git a/frontend/src/utils/__tests__/worker.test.ts b/frontend/src/utils/__tests__/worker.test.ts
new file mode 100644
index 0000000000..c69fcf5d69
--- /dev/null
+++ b/frontend/src/utils/__tests__/worker.test.ts
@@ -0,0 +1,81 @@
+/* Copyright 2026 Marimo. All rights reserved. */
+import { afterEach, describe, expect, it, vi } from "vitest";
+import { createModuleWorker } from "../worker";
+
+afterEach(() => {
+ vi.unstubAllGlobals();
+ vi.restoreAllMocks();
+});
+
+describe("createModuleWorker", () => {
+ it.each(["http", "blob"])(
+ "preserves caller-owned %s worker URLs",
+ (scheme) => {
+ const Worker = vi.fn(function (
+ _url: string | URL,
+ _options: WorkerOptions,
+ ) {
+ return {};
+ });
+ vi.stubGlobal("Worker", Worker);
+ const url = new URL(
+ scheme === "blob"
+ ? `blob:${location.origin}/worker`
+ : new URL("/worker.js", location.href),
+ );
+ const revoke = vi.spyOn(URL, "revokeObjectURL");
+ createModuleWorker(url, { name: "marimo" });
+ expect(Worker).toHaveBeenCalledWith(url.href, {
+ type: "module",
+ name: "marimo",
+ });
+ expect(revoke).not.toHaveBeenCalled();
+ },
+ );
+
+ it("preserves the page origin for hosted CDN workers", () => {
+ const Worker = vi.fn(function (
+ _url: string | URL,
+ _options: WorkerOptions,
+ ) {
+ return {};
+ });
+ vi.stubGlobal("Worker", Worker);
+ const create = vi
+ .spyOn(URL, "createObjectURL")
+ .mockReturnValue("blob:worker");
+ const revoke = vi
+ .spyOn(URL, "revokeObjectURL")
+ .mockImplementation(() => undefined);
+ createModuleWorker(new URL("https://cdn.example.com/worker.js"), {
+ name: "islands",
+ });
+ expect(create).toHaveBeenCalledWith(expect.any(Blob));
+ expect(Worker).toHaveBeenCalledWith("blob:worker", {
+ type: "module",
+ name: "islands",
+ });
+ expect(revoke).toHaveBeenCalledWith("blob:worker");
+ });
+
+ it("imports a CDN worker from an opaque origin", () => {
+ const Worker = vi.fn(function (
+ _url: string | URL,
+ _options: WorkerOptions,
+ ) {
+ return {};
+ });
+ vi.stubGlobal("Worker", Worker);
+ vi.stubGlobal("origin", "null");
+ const url = new URL("https://cdn.example.com/worker.js");
+ createModuleWorker(url, { name: "0.24.2::controller" });
+ const [source, options] = Worker.mock.calls[0];
+ expect(decodeURIComponent(String(source))).toBe(
+ 'data:application/javascript,import "https://cdn.example.com/worker.js"',
+ );
+ expect(options).toEqual({
+ type: "module",
+ name: "0.24.2::controller",
+ });
+ });
+});
diff --git a/frontend/src/utils/worker.ts b/frontend/src/utils/worker.ts
new file mode 100644
index 0000000000..0e3285e791
--- /dev/null
+++ b/frontend/src/utils/worker.ts
@@ -0,0 +1,22 @@
+/* Copyright 2026 Marimo. All rights reserved. */
+
+/** Load a module worker across origins, including from file:// pages. */
+export function createModuleWorker(url: URL, options: WorkerOptions): Worker {
+ if (url.origin === globalThis.origin) {
+ return new Worker(url.href, { ...options, type: "module" });
+ }
+ const js = `import ${JSON.stringify(url.href)}`;
+ // Blob workers preserve the page origin, but file:// needs a data URL.
+ const source =
+ globalThis.origin === "null"
+ ? `data:application/javascript,${encodeURIComponent(js)}`
+ : URL.createObjectURL(new Blob([js], { type: "application/javascript" }));
+ try {
+ return new Worker(source, { ...options, type: "module" });
+ } finally {
+ if (source.startsWith("blob:")) {
+ // Worker() captures the Blob before returning, even while imports load.
+ URL.revokeObjectURL(source);
+ }
+ }
+}
diff --git a/marimo/_cli/export/commands.py b/marimo/_cli/export/commands.py
index 487eb93871..8e96997082 100644
--- a/marimo/_cli/export/commands.py
+++ b/marimo/_cli/export/commands.py
@@ -79,6 +79,7 @@ from marimo._schemas.export_options import (
WASMMode,
)
from marimo._server.utils import asyncio_run
+from marimo._templates import get_default_asset_url
from marimo._utils.file_watcher import FileWatcher
from marimo._utils.marimo_path import MarimoPath
from marimo._utils.paths import maybe_make_dirs
@@ -896,8 +897,8 @@ Example:
marimo export html-wasm notebook.py -o notebook.wasm.html
-The exported HTML file will run the notebook using WebAssembly, making it
-completely self-contained and executable in the browser. This lets you
+The exported HTML file runs the notebook using WebAssembly, without a local
+Python or marimo installation. This lets you
share interactive notebooks on the web without setting up
infrastructure to run Python code.
@@ -905,8 +906,8 @@ The exported notebook runs using Pyodide, which supports most
but not all Python packages. To learn more, see the Pyodide
documentation.
-In order for this file to be able to run, it must be served over HTTP,
-and cannot be opened directly from the file system (e.g. file://).
+By default, the export must be served over HTTP. Use --single-file to load
+assets from a CDN and open the HTML file directly. Internet access is required.
""",
)
@click.option(
@@ -914,7 +915,12 @@ and cannot be opened directly from the file system (e.g. file://).
"--output",
type=click.Path(path_type=Path),
required=True,
- help="Output directory to save the HTML to.",
+ help="Output directory or HTML file.",
+)
+ "--single-file",
+ is_flag=True,
+ help="Export one HTML file with CDN assets that can be opened directly.",
)
@click.option(
"--mode",
@@ -976,6 +982,7 @@ and cannot be opened directly from the file system (e.g. file://).
def html_wasm(
name: str,
output: Path,
+ single_file: bool,
mode: WASMMode,
watch: bool,
show_code: bool,
@@ -986,6 +993,10 @@ def html_wasm(
args: tuple[str, ...],
) -> None:
"""Export a notebook as a WASM-powered standalone HTML file."""
+ if single_file and include_cloudflare:
+ raise click.UsageError(
+ "--single-file and --include-cloudflare cannot be used together."
+ )
if execute and watch:
raise click.UsageError(
"--execute and --watch cannot be used together."
@@ -1059,6 +1070,12 @@ def html_wasm(
),
) from error
+ if single_file and (modules or metadata_wheels):
+ raise click.UsageError(
+ "Local modules and wheels require a directory export. "
+ "Omit --single-file."
+ )
+
try:
with build_local_module_wheels(modules) as local_wheels:
wheel_dependencies = (
@@ -1071,18 +1088,25 @@ def html_wasm(
wheel_dependencies=wheel_dependencies,
)
)
- copy_local_wheels(
- out_dir,
- tuple(
- dependency.path for dependency in wheel_dependencies
- ),
- source_wheel_dir=file_path.path.parent / WASM_WHEEL_DIR,
- )
+ if not single_file:
+ copy_local_wheels(
+ out_dir,
+ tuple(
+ dependency.path
+ for dependency in wheel_dependencies
+ ),
+ source_wheel_dir=file_path.path.parent
+ / WASM_WHEEL_DIR,
+ )
return result
except LocalWheelError as error:
raise click.UsageError(str(error)) from error
- wasm_options = WASMExportOptions(mode=mode, show_code=show_code)
+ wasm_options = WASMExportOptions(
+ mode=mode,
+ show_code=show_code,
+ asset_url=get_default_asset_url() if single_file else None,
+ )
if execute:
cli_args = parse_args(args)
@@ -1112,7 +1136,7 @@ def html_wasm(
argv=list(args),
stderr=STDERR,
),
- cache_export_dir=out_dir,
+ cache_export_dir=None if single_file else out_dir,
code_transform=code_transform,
stdout=STDOUT,
)
@@ -1150,6 +1174,14 @@ def html_wasm(
partial(export_unexecuted_wasm, file_path),
)
+ if single_file:
+ echo(
+ "Open the exported HTML file in a browser. Internet access is required."
+ )
+ return watch_and_export(
+ marimo_file, out_dir / filename, watch, export_callback, force
+ )
+
# Export assets first
Exporter().export_assets(out_dir)
diff --git a/marimo/_templates.py b/marimo/_templates.py
index c5c7e4d3ec..d85774b280 100644
--- a/marimo/_templates.py
+++ b/marimo/_templates.py
@@ -406,6 +406,11 @@ def notebook_page_template(
return html
+def get_default_asset_url() -> str:
+ version = str(__version__).replace(".dev", "-dev")
+ return f"https://cdn.jsdelivr.net/npm/@marimo-team/frontend@{version}/dist"
+
+
def static_notebook_template(
html: str,
user_config: MarimoConfig,
@@ -423,8 +428,7 @@ def static_notebook_template(
layout: LayoutConfig | None = None,
) -> str:
if asset_url is None:
- version = str(__version__).replace(".dev", "-dev")
- asset_url = f"https://cdn.jsdelivr.net/npm/@marimo-team/frontend@{version}/dist"
+ asset_url = get_default_asset_url()
html = html.replace("{{ base_url }}", "")
filename = os.path.basename(filepath or "")
@@ -539,12 +543,7 @@ def wasm_notebook_template(
notebook_snapshot: NotebookV1 | None = None,
) -> str:
"""Template for WASM notebooks."""
- import re
-
- body = html
-
- if asset_url is not None:
- body = re.sub(r'="./assets/', f'="{asset_url}/assets/', body)
+ body = _replace_asset_urls(html, asset_url)
body = body.replace("{{ base_url }}", "")
body = body.replace(
@@ -587,7 +586,8 @@ def wasm_notebook_template(
}
</script>
"""
- body = body.replace("</head>", f"{warning_script}</head>")
+ if asset_url is None:
+ body = body.replace("</head>", f"{warning_script}</head>")
# Hide save button in WASM mode
wasm_styles = """
@@ -719,9 +719,31 @@ def _replace_asset_urls(html: str, asset_url: str | None) -> str:
if "{version}" in asset_url:
asset_url = asset_url.replace("{version}", __version__)
- return (
- html.replace("href='./", f"crossorigin='anonymous' href='{asset_url}/")
- .replace("src='./", f"crossorigin='anonymous' src='{asset_url}/")
- .replace('href="./', f'crossorigin="anonymous" href="{asset_url}/')
- .replace('src="./', f'crossorigin="anonymous" src="{asset_url}/')
+ def replace_tag(match: re.Match[str]) -> str:
+ tag = match.group()
+ relative_url = re.search(r"\s(?:href|src)=([\"'])\./", tag)
+ if relative_url is None:
+ return tag
+ # Ignore attribute values when checking for an existing attribute.
+ attributes = re.sub(r"([\"']).*?\1", "", tag, flags=re.DOTALL)
+ if not re.search(
+ r"\scrossorigin(?=\s|=|/?>)", attributes, re.IGNORECASE
+ ):
+ quote = relative_url[1]
+ start = relative_url.start()
+ tag = (
+ tag[:start]
+ + f" crossorigin={quote}anonymous{quote}"
+ + tag[start:]
+ )
+ return re.sub(
+ r"(\s(?:href|src)=[\"'])\./",
+ lambda url: f"{url[1]}{asset_url}/",
+ tag,
+ )
+
+ return re.sub(
+ r"""<[a-zA-Z](?:[^>"']|"[^"]*"|'[^']*')*>""",
+ replace_tag,
+ html,
)
diff --git a/tests/_cli/test_cli_export.py b/tests/_cli/test_cli_export.py
index 2d18c2c277..291d25dfe0 100644
--- a/tests/_cli/test_cli_export.py
+++ b/tests/_cli/test_cli_export.py
@@ -243,7 +243,11 @@ class TestExportHTML:
assert '<marimo-code hidden=""></marimo-code>' in html
@staticmethod
- def test_cli_export_html_wasm(tmp_path: Path) -> None:
+ @pytest.mark.parametrize("single_file", [False, True])
+ @pytest.mark.parametrize("mode", ["run", "edit"])
+ def test_cli_export_html_wasm(
+ tmp_path: Path, single_file: bool, mode: str
+ ) -> None:
notebook = tmp_path / "notebook.py"
_write_minimal_wasm_notebook(
notebook,
@@ -258,22 +262,104 @@ class TestExportHTML:
"html-wasm",
str(notebook),
"--mode",
- "edit",
+ mode,
"--output",
str(out_dir),
+ *(["--single-file"] if single_file else []),
)
_assert_success(p)
html = Path(out_dir / "index.html").read_text()
assert "{ filename }" not in html
- assert '"mode": "edit"' in html
assert '<marimo-code hidden=""></marimo-code>' not in html
assert "<marimo-wasm" in html
assert '"showAppCode": false' in html
- assert Path(out_dir / ".nojekyll").exists()
+ if single_file:
+ assert list(out_dir.iterdir()) == [out_dir / "index.html"]
+ assert "cdn.jsdelivr.net/npm/@marimo-team/frontend@" in html
+ assert 'src="./' not in html
+ assert 'href="./' not in html
+ assert "This file must be served" not in html
+ else:
+ assert Path(out_dir / ".nojekyll").exists()
+ assert "This file must be served" in html
mount_config = parse_mount_config((out_dir / "index.html").read_text())
- assert mount_config["mode"] == "edit"
+ assert mount_config["mode"] == ("edit" if mode == "edit" else "read")
assert mount_config["layout"] == {"type": "slides", "data": {}}
+ @staticmethod
+ def test_cli_export_html_wasm_single_file_dev_version(
+ tmp_path: Path,
+ ) -> None:
+ notebook = tmp_path / "notebook.py"
+ _write_minimal_wasm_notebook(notebook, ' "hello"\n return\n')
+ output = tmp_path / "notebook.html"
+ with mock.patch("marimo._templates.__version__", "0.24.2.dev123"):
+ result = _run_export(
+ "html-wasm",
+ str(notebook),
+ "--single-file",
+ "--no-sandbox",
+ "-o",
+ str(output),
+ )
+ _assert_success(result)
+ html = output.read_text()
+ assert (
+ "https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/"
+ in html
+ )
+ assert "[email protected]" not in html
+
+ @staticmethod
+ @pytest.mark.parametrize("resource", ["module", "wheel", "cloudflare"])
+ def test_cli_export_html_wasm_single_file_requires_directory(
+ tmp_path: Path, resource: str
+ ) -> None:
+ notebook = tmp_path / "notebook.py"
+ _write_minimal_wasm_notebook(
+ notebook, " import helper\n return\n"
+ )
+ if resource == "module":
+ (tmp_path / "helper.py").write_text("value = 1\n")
+ elif resource == "wheel":
+ wheel = tmp_path / "helper-1.0.0-py3-none-any.whl"
+ wheel.touch()
+ notebook.write_text(
+ '# /// script\n# dependencies = ["helper @ ./helper-1.0.0-py3-none-any.whl"]\n# ///\n'
+ + notebook.read_text()
+ )
+ output = tmp_path / "out" / "notebook.html"
+ result = _run_export(
+ "html-wasm",
+ str(notebook),
+ "--single-file",
+ "--no-sandbox",
+ "-o",
+ str(output),
+ *(["--include-cloudflare"] if resource == "cloudflare" else []),
+ )
+ assert result.exit_code == 2
+ assert "--single-file" in result.output
+ assert not output.parent.exists()
+
+ @staticmethod
+ def test_cli_export_html_wasm_single_file_execute(tmp_path: Path) -> None:
+ notebook = tmp_path / "notebook.py"
+ _write_minimal_wasm_notebook(notebook, ' "hello"\n return\n')
+ output = tmp_path / "out" / "notebook.html"
+ result = _run_export(
+ "html-wasm",
+ str(notebook),
+ "--single-file",
+ "--execute",
+ "--no-sandbox",
+ "-o",
+ str(output),
+ )
+ _assert_success(result)
+ assert list(output.parent.iterdir()) == [output]
+ assert parse_mount_config(output.read_text())["session"] is not None
+
@staticmethod
def test_cli_export_html_wasm_packages_local_modules(
tmp_path: Path,
diff --git a/tests/_server/templates/snapshots/export1.txt b/tests/_server/templates/snapshots/export1.txt
index 4ce31a2994..16f855e96f 100644
--- a/tests/_server/templates/snapshots/export1.txt
+++ b/tests/_server/templates/snapshots/export1.txt
@@ -8,12 +8,12 @@
<link rel="preload" crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/gradient.png"" as="image" />
<link rel="preload" crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/noise.png"" as="image" />
<!-- Preload the fonts -->
- <link rel="preload" crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/Lora-VariableFont_wght.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
- <link rel="preload" crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/PTSans-Regular.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
- <link rel="preload" crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/PTSans-Bold.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
- <link rel="preload" crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/FiraMono-Regular.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
- <link rel="preload" crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/FiraMono-Medium.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
- <link rel="preload" crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/FiraMono-Bold.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
+ <link rel="preload" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/Lora-VariableFont_wght.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
+ <link rel="preload" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/PTSans-Regular.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
+ <link rel="preload" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/PTSans-Bold.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
+ <link rel="preload" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/FiraMono-Regular.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
+ <link rel="preload" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/FiraMono-Medium.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
+ <link rel="preload" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/FiraMono-Bold.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
@@ -61,11 +61,11 @@
</script>
<marimo-filename hidden>notebook.py</marimo-filename>
<title>notebook</title>
- <script type="module" crossorigin crossorigin="anonymous" src="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/index.js""></script>
- <link rel="stylesheet" crossorigin crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/cells.css"">
- <link rel="stylesheet" crossorigin crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/markdown-renderer.css"">
- <link rel="stylesheet" crossorigin crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/JsonOutput.css"">
- <link rel="stylesheet" crossorigin crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/index.css"">
+ <script type="module" crossorigin src="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/index.js""></script>
+ <link rel="stylesheet" crossorigin href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/cells.css"">
+ <link rel="stylesheet" crossorigin href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/markdown-renderer.css"">
+ <link rel="stylesheet" crossorigin href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/JsonOutput.css"">
+ <link rel="stylesheet" crossorigin href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/index.css"">
<script data-marimo="true">
Object.defineProperty(window, "__MARIMO_STATIC__", {
diff --git a/tests/_server/templates/snapshots/export2.txt b/tests/_server/templates/snapshots/export2.txt
index 250a51c0a3..f1b5949d2e 100644
--- a/tests/_server/templates/snapshots/export2.txt
+++ b/tests/_server/templates/snapshots/export2.txt
@@ -8,12 +8,12 @@
<link rel="preload" crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/gradient.png"" as="image" />
<link rel="preload" crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/noise.png"" as="image" />
<!-- Preload the fonts -->
- <link rel="preload" crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/Lora-VariableFont_wght.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
- <link rel="preload" crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/PTSans-Regular.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
- <link rel="preload" crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/PTSans-Bold.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
- <link rel="preload" crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/FiraMono-Regular.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
- <link rel="preload" crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/FiraMono-Medium.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
- <link rel="preload" crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/FiraMono-Bold.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
+ <link rel="preload" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/Lora-VariableFont_wght.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
+ <link rel="preload" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/PTSans-Regular.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
+ <link rel="preload" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/PTSans-Bold.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
+ <link rel="preload" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/FiraMono-Regular.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
+ <link rel="preload" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/FiraMono-Medium.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
+ <link rel="preload" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/FiraMono-Bold.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
@@ -61,11 +61,11 @@
</script>
<marimo-filename hidden></marimo-filename>
<title>marimo</title>
- <script type="module" crossorigin crossorigin="anonymous" src="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/index.js""></script>
- <link rel="stylesheet" crossorigin crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/cells.css"">
- <link rel="stylesheet" crossorigin crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/markdown-renderer.css"">
- <link rel="stylesheet" crossorigin crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/JsonOutput.css"">
- <link rel="stylesheet" crossorigin crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/index.css"">
+ <script type="module" crossorigin src="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/index.js""></script>
+ <link rel="stylesheet" crossorigin href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/cells.css"">
+ <link rel="stylesheet" crossorigin href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/markdown-renderer.css"">
+ <link rel="stylesheet" crossorigin href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/JsonOutput.css"">
+ <link rel="stylesheet" crossorigin href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/index.css"">
<script data-marimo="true">
Object.defineProperty(window, "__MARIMO_STATIC__", {
diff --git a/tests/_server/templates/snapshots/export3.txt b/tests/_server/templates/snapshots/export3.txt
index 85c60fc738..bb9509b0ec 100644
--- a/tests/_server/templates/snapshots/export3.txt
+++ b/tests/_server/templates/snapshots/export3.txt
@@ -8,12 +8,12 @@
<link rel="preload" crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/gradient.png"" as="image" />
<link rel="preload" crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/noise.png"" as="image" />
<!-- Preload the fonts -->
- <link rel="preload" crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/Lora-VariableFont_wght.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
- <link rel="preload" crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/PTSans-Regular.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
- <link rel="preload" crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/PTSans-Bold.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
- <link rel="preload" crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/FiraMono-Regular.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
- <link rel="preload" crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/FiraMono-Medium.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
- <link rel="preload" crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/FiraMono-Bold.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
+ <link rel="preload" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/Lora-VariableFont_wght.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
+ <link rel="preload" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/PTSans-Regular.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
+ <link rel="preload" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/PTSans-Bold.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
+ <link rel="preload" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/FiraMono-Regular.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
+ <link rel="preload" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/FiraMono-Medium.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
+ <link rel="preload" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/FiraMono-Bold.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
@@ -61,11 +61,11 @@
</script>
<marimo-filename hidden>notebook.py</marimo-filename>
<title>notebook</title>
- <script type="module" crossorigin crossorigin="anonymous" src="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/index.js""></script>
- <link rel="stylesheet" crossorigin crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/cells.css"">
- <link rel="stylesheet" crossorigin crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/markdown-renderer.css"">
- <link rel="stylesheet" crossorigin crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/JsonOutput.css"">
- <link rel="stylesheet" crossorigin crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/index.css"">
+ <script type="module" crossorigin src="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/index.js""></script>
+ <link rel="stylesheet" crossorigin href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/cells.css"">
+ <link rel="stylesheet" crossorigin href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/markdown-renderer.css"">
+ <link rel="stylesheet" crossorigin href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/JsonOutput.css"">
+ <link rel="stylesheet" crossorigin href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/index.css"">
<script data-marimo="true">
Object.defineProperty(window, "__MARIMO_STATIC__", {
diff --git a/tests/_server/templates/snapshots/export4.txt b/tests/_server/templates/snapshots/export4.txt
index 57ea4bd320..76ffc89063 100644
--- a/tests/_server/templates/snapshots/export4.txt
+++ b/tests/_server/templates/snapshots/export4.txt
@@ -8,12 +8,12 @@
<link rel="preload" crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/gradient.png"" as="image" />
<link rel="preload" crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/noise.png"" as="image" />
<!-- Preload the fonts -->
- <link rel="preload" crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/Lora-VariableFont_wght.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
- <link rel="preload" crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/PTSans-Regular.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
- <link rel="preload" crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/PTSans-Bold.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
- <link rel="preload" crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/FiraMono-Regular.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
- <link rel="preload" crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/FiraMono-Medium.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
- <link rel="preload" crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/FiraMono-Bold.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
+ <link rel="preload" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/Lora-VariableFont_wght.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
+ <link rel="preload" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/PTSans-Regular.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
+ <link rel="preload" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/PTSans-Bold.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
+ <link rel="preload" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/FiraMono-Regular.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
+ <link rel="preload" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/FiraMono-Medium.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
+ <link rel="preload" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/FiraMono-Bold.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
@@ -61,11 +61,11 @@
</script>
<marimo-filename hidden>notebook.py</marimo-filename>
<title>notebook</title>
- <script type="module" crossorigin crossorigin="anonymous" src="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/index.js""></script>
- <link rel="stylesheet" crossorigin crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/cells.css"">
- <link rel="stylesheet" crossorigin crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/markdown-renderer.css"">
- <link rel="stylesheet" crossorigin crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/JsonOutput.css"">
- <link rel="stylesheet" crossorigin crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/index.css"">
+ <script type="module" crossorigin src="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/index.js""></script>
+ <link rel="stylesheet" crossorigin href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/cells.css"">
+ <link rel="stylesheet" crossorigin href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/markdown-renderer.css"">
+ <link rel="stylesheet" crossorigin href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/JsonOutput.css"">
+ <link rel="stylesheet" crossorigin href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/index.css"">
<script data-marimo="true">
Object.defineProperty(window, "__MARIMO_STATIC__", {
diff --git a/tests/_server/templates/snapshots/export5.txt b/tests/_server/templates/snapshots/export5.txt
index 8639bed716..d8ff9ad911 100644
--- a/tests/_server/templates/snapshots/export5.txt
+++ b/tests/_server/templates/snapshots/export5.txt
@@ -8,12 +8,12 @@
<link rel="preload" crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/gradient.png"" as="image" />
<link rel="preload" crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/noise.png"" as="image" />
<!-- Preload the fonts -->
- <link rel="preload" crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/Lora-VariableFont_wght.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
- <link rel="preload" crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/PTSans-Regular.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
- <link rel="preload" crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/PTSans-Bold.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
- <link rel="preload" crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/FiraMono-Regular.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
- <link rel="preload" crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/FiraMono-Medium.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
- <link rel="preload" crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/FiraMono-Bold.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
+ <link rel="preload" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/Lora-VariableFont_wght.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
+ <link rel="preload" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/PTSans-Regular.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
+ <link rel="preload" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/PTSans-Bold.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
+ <link rel="preload" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/FiraMono-Regular.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
+ <link rel="preload" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/FiraMono-Medium.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
+ <link rel="preload" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/FiraMono-Bold.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
@@ -61,11 +61,11 @@
</script>
<marimo-filename hidden>notebook.py</marimo-filename>
<title>My App</title>
- <script type="module" crossorigin crossorigin="anonymous" src="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/index.js""></script>
- <link rel="stylesheet" crossorigin crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/cells.css"">
- <link rel="stylesheet" crossorigin crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/markdown-renderer.css"">
- <link rel="stylesheet" crossorigin crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/JsonOutput.css"">
- <link rel="stylesheet" crossorigin crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/index.css"">
+ <script type="module" crossorigin src="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/index.js""></script>
+ <link rel="stylesheet" crossorigin href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/cells.css"">
+ <link rel="stylesheet" crossorigin href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/markdown-renderer.css"">
+ <link rel="stylesheet" crossorigin href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/JsonOutput.css"">
+ <link rel="stylesheet" crossorigin href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/index.css"">
<script data-marimo="true">
Object.defineProperty(window, "__MARIMO_STATIC__", {
diff --git a/tests/_server/templates/snapshots/export6.txt b/tests/_server/templates/snapshots/export6.txt
index 80113423e1..502aee0d15 100644
--- a/tests/_server/templates/snapshots/export6.txt
+++ b/tests/_server/templates/snapshots/export6.txt
@@ -8,12 +8,12 @@
<link rel="preload" crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/gradient.png"" as="image" />
<link rel="preload" crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/noise.png"" as="image" />
<!-- Preload the fonts -->
- <link rel="preload" crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/Lora-VariableFont_wght.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
- <link rel="preload" crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/PTSans-Regular.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
- <link rel="preload" crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/PTSans-Bold.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
- <link rel="preload" crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/FiraMono-Regular.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
- <link rel="preload" crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/FiraMono-Medium.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
- <link rel="preload" crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/FiraMono-Bold.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
+ <link rel="preload" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/Lora-VariableFont_wght.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
+ <link rel="preload" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/PTSans-Regular.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
+ <link rel="preload" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/PTSans-Bold.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
+ <link rel="preload" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/FiraMono-Regular.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
+ <link rel="preload" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/FiraMono-Medium.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
+ <link rel="preload" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/FiraMono-Bold.woff2"" as="font" type="font/woff2" crossorigin="anonymous" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
@@ -61,11 +61,11 @@
</script>
<marimo-filename hidden>notebook.py</marimo-filename>
<title>notebook</title>
- <script type="module" crossorigin crossorigin="anonymous" src="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/index.js""></script>
- <link rel="stylesheet" crossorigin crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/cells.css"">
- <link rel="stylesheet" crossorigin crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/markdown-renderer.css"">
- <link rel="stylesheet" crossorigin crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/JsonOutput.css"">
- <link rel="stylesheet" crossorigin crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/index.css"">
+ <script type="module" crossorigin src="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/index.js""></script>
+ <link rel="stylesheet" crossorigin href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/cells.css"">
+ <link rel="stylesheet" crossorigin href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/markdown-renderer.css"">
+ <link rel="stylesheet" crossorigin href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/JsonOutput.css"">
+ <link rel="stylesheet" crossorigin href="https://cdn.jsdelivr.net/npm/@marimo-team/[email protected]/dist/assets/index.css"">
<script data-marimo="true">
Object.defineProperty(window, "__MARIMO_STATIC__", {
diff --git a/tests/_server/templates/test_templates.py b/tests/_server/templates/test_templates.py
index 84c81a49e1..2dd7f140c2 100644
--- a/tests/_server/templates/test_templates.py
+++ b/tests/_server/templates/test_templates.py
@@ -1308,6 +1308,27 @@ class TestReplaceAssetUrls(unittest.TestCase):
expected = f"""<link crossorigin="anonymous" href="https://cdn.example.com/v{__version__}/assets/style.css" rel="stylesheet">"""
assert result == expected
+ def test_replace_asset_urls_preserves_crossorigin(self) -> None:
+ html = """<script type="module" crossorigin src="./assets/app.js"></script>
+<link href='./assets/style.css' rel='stylesheet' crossorigin='use-credentials'>
+<script src="./assets/other.js" CROSSORIGIN="anonymous"></script>"""
+
+ result = templates._replace_asset_urls(html, "https://cdn.example.com")
+
+ assert result == html.replace(
+ "./assets/", "https://cdn.example.com/assets/"
+ )
+
+ def test_replace_asset_urls_crossorigin_in_attribute_value(self) -> None:
+ html = """<link title="preload > crossorigin='use-credentials'" href='./assets/style.css'>"""
+
+ result = templates._replace_asset_urls(html, "https://cdn.example.com")
+
+ assert (
+ result
+ == """<link title="preload > crossorigin='use-credentials'" crossorigin='anonymous' href='https://cdn.example.com/assets/style.css'>"""
+ )
+
def test_replace_asset_urls_double_quotes(self) -> None:
"""Test asset URL replacement with double quotes."""
html = '<link href="./assets/style.css" rel="stylesheet">'