diff --git a/django/contrib/staticfiles/storage.py b/django/contrib/staticfiles/storage.py index 191fe3cbb5..04a5edbd30 100644 --- a/django/contrib/staticfiles/storage.py +++ b/django/contrib/staticfiles/storage.py @@ -53,7 +53,8 @@ class HashedFilesMixin: ( ( ( - r"""(?Pimport(?s:(?P[\s\{].*?))""" + r"""(?Pimport""" + r"""(?s:(?P[\s\{].*?|\*\s*as\s*\w+))""" r"""\s*from\s*['"](?P[./].*?)["']\s*;)""" ), """import%(import)s from "%(url)s";""", diff --git a/tests/staticfiles_tests/project/documents/cached/module.js b/tests/staticfiles_tests/project/documents/cached/module.js index 7764e740d6..c56530aea6 100644 --- a/tests/staticfiles_tests/project/documents/cached/module.js +++ b/tests/staticfiles_tests/project/documents/cached/module.js @@ -2,6 +2,10 @@ import rootConst from "/static/absolute_root.js"; import testConst from "./module_test.js"; import * as NewModule from "./module_test.js"; +import*as m from "./module_test.js"; +import *as m from "./module_test.js"; +import* as m from "./module_test.js"; +import* as m from "./module_test.js"; import { testConst as alias } from "./module_test.js"; import { firstConst, secondConst } from "./module_test.js"; import { diff --git a/tests/staticfiles_tests/test_storage.py b/tests/staticfiles_tests/test_storage.py index 030b7dc6db..d6ea03b744 100644 --- a/tests/staticfiles_tests/test_storage.py +++ b/tests/staticfiles_tests/test_storage.py @@ -674,7 +674,7 @@ class TestCollectionJSModuleImportAggregationManifestStorage(CollectionTestCase) def test_module_import(self): relpath = self.hashed_file_path("cached/module.js") - self.assertEqual(relpath, "cached/module.55fd6938fbc5.js") + self.assertEqual(relpath, "cached/module.4326210cf0bd.js") tests = [ # Relative imports. b'import testConst from "./module_test.477bbebe77f0.js";', @@ -686,6 +686,11 @@ class TestCollectionJSModuleImportAggregationManifestStorage(CollectionTestCase) b'const dynamicModule = import("./module_test.477bbebe77f0.js");', # Creating a module object. b'import * as NewModule from "./module_test.477bbebe77f0.js";', + # Creating a minified module object. + b'import*as m from "./module_test.477bbebe77f0.js";', + b'import* as m from "./module_test.477bbebe77f0.js";', + b'import *as m from "./module_test.477bbebe77f0.js";', + b'import* as m from "./module_test.477bbebe77f0.js";', # Aliases. b'import { testConst as alias } from "./module_test.477bbebe77f0.js";', b"import {\n" @@ -701,7 +706,7 @@ class TestCollectionJSModuleImportAggregationManifestStorage(CollectionTestCase) def test_aggregating_modules(self): relpath = self.hashed_file_path("cached/module.js") - self.assertEqual(relpath, "cached/module.55fd6938fbc5.js") + self.assertEqual(relpath, "cached/module.4326210cf0bd.js") tests = [ b'export * from "./module_test.477bbebe77f0.js";', b'export { testConst } from "./module_test.477bbebe77f0.js";',