diff --git a/changelog.txt b/changelog.txt index 8aba157..7f1f49f 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,7 @@ +# 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 * 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] = [] 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 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",