From 1542dd17162e8d260c09a59491fe51ccce11e1bc Mon Sep 17 00:00:00 2001 From: jealouscloud Date: Tue, 18 Nov 2025 18:54:17 -0500 Subject: [PATCH 1/3] Add import map before any preload links This was a failure of our import map placement previously browsers warned about it --- changelog.txt | 3 +++ pyproject.toml | 2 +- src/html_compose/resource/__init__.py | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/changelog.txt b/changelog.txt index 8aba157..2c9a411 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,6 @@ +# 0.11.2 +* resource module correctly places import map before preload links + # 0.11.1 * livereload fix: live server waits for daemon to terminate before restarting * livereload fix: Fix bug for ignore_glob not firing diff --git a/pyproject.toml b/pyproject.toml index d6baee2..214ec8d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "html-compose" -version = "0.11.1" +version = "0.11.2" description = "Composable HTML generation in python" authors = [ { name = "jealouscloud", email = "github@noaha.org" } diff --git a/src/html_compose/resource/__init__.py b/src/html_compose/resource/__init__.py index 49582ba..e9ffc81 100644 --- a/src/html_compose/resource/__init__.py +++ b/src/html_compose/resource/__init__.py @@ -128,7 +128,7 @@ def to_elements( import_map["scopes"] = scopes # dump to json; prevent escapes js_dump = json.dumps(import_map).replace("<", "\\u003c") - script_tags.insert( + preload_links.insert( 0, el.script(type="importmap")[unsafe_text(js_dump)] ) style_text: list[str] = [] From 23abb5bd0f263410285025787bb4b88468f1f39c Mon Sep 17 00:00:00 2001 From: jealouscloud Date: Wed, 19 Nov 2025 19:40:51 -0500 Subject: [PATCH 2/3] bugfix: only lstrip for path.join --- changelog.txt | 1 + src/html_compose/resource/util_funcs.py | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/changelog.txt b/changelog.txt index 2c9a411..7f1f49f 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,6 @@ # 0.11.2 * resource module correctly places import map before preload links +* bugfix: relative paths were stripped in cache_bust=true # 0.11.1 * livereload fix: live server waits for daemon to terminate before restarting diff --git a/src/html_compose/resource/util_funcs.py b/src/html_compose/resource/util_funcs.py index 2086efa..ef69c9f 100644 --- a/src/html_compose/resource/util_funcs.py +++ b/src/html_compose/resource/util_funcs.py @@ -32,8 +32,7 @@ def _cachebust_resource_uri(source: str): "does not exist" ) from exc - source = source.lstrip("/") - resource_path = path.join(base_dir, source) + resource_path = path.join(base_dir, source.lstrip("/")) now = time() ts = misc_stat_cache.get(path.join(base_dir, source), None) update_ts = ts is None or (now - ts) > settings.stat_poll_interval From bd917177c102766d9e893f8da183ccef76a5f52d Mon Sep 17 00:00:00 2001 From: jealouscloud Date: Wed, 19 Nov 2025 19:55:55 -0500 Subject: [PATCH 3/3] tests now correctly watch for import order --- tests/test_importer.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/test_importer.py b/tests/test_importer.py index 9f4a49f..24db837 100644 --- a/tests/test_importer.py +++ b/tests/test_importer.py @@ -194,11 +194,11 @@ def test_js_import(): ] expected = [ "", - '', - '', '", + '', + '', '", '", '', '', '', '', - '", '", '\n\n', + '\n\ndemo\n\n', "", "

", "Hello world",