diff --git a/django_vite/core/asset_loader.py b/django_vite/core/asset_loader.py index 2a8e96d..840db86 100644 --- a/django_vite/core/asset_loader.py +++ b/django_vite/core/asset_loader.py @@ -511,6 +511,7 @@ def generate_vite_asset_url(self, path: str) -> str: def generate_vite_legacy_polyfills( self, + nomodule: bool = True, **kwargs: Dict[str, str], ) -> str: """ @@ -542,7 +543,9 @@ def generate_vite_legacy_polyfills( f"at {self.manifest.manifest_path}" ) - scripts_attrs = {"nomodule": "", "crossorigin": "", **kwargs} + scripts_attrs = {"crossorigin": "", **kwargs} + if nomodule: + scripts_attrs["nomodule"] = "" url = self._get_production_server_url(polyfills_manifest_entry.file) return TagGenerator.script( @@ -820,10 +823,11 @@ def generate_vite_asset_url( def generate_vite_legacy_polyfills( self, app: str = DEFAULT_APP_NAME, + nomodule: bool = True, **kwargs: Dict[str, str], ) -> str: app_client = self._get_app_client(app) - return app_client.generate_vite_legacy_polyfills(**kwargs) + return app_client.generate_vite_legacy_polyfills(nomodule, **kwargs) def generate_vite_legacy_asset( self, diff --git a/django_vite/templatetags/django_vite.py b/django_vite/templatetags/django_vite.py index 33aab81..280e66d 100644 --- a/django_vite/templatetags/django_vite.py +++ b/django_vite/templatetags/django_vite.py @@ -114,7 +114,9 @@ def vite_asset_url(path: str, app: str = DEFAULT_APP_NAME) -> str: @register.simple_tag @mark_safe -def vite_legacy_polyfills(app: str = DEFAULT_APP_NAME, **kwargs: Dict[str, str]) -> str: +def vite_legacy_polyfills( + app: str = DEFAULT_APP_NAME, nomodule: bool = True, **kwargs: Dict[str, str] +) -> str: """ Generates a