1
0
mirror of https://github.com/django/django.git synced 2024-12-22 17:16:24 +00:00

Fixed #35553 -- Handled import*as in HashedFilesMixin.

This commit is contained in:
Farhan 2024-08-03 15:45:39 +05:00 committed by Sarah Boyce
parent fdc638bf4a
commit 6993c9d8c9
3 changed files with 13 additions and 3 deletions

View File

@ -53,7 +53,8 @@ class HashedFilesMixin:
(
(
(
r"""(?P<matched>import(?s:(?P<import>[\s\{].*?))"""
r"""(?P<matched>import"""
r"""(?s:(?P<import>[\s\{].*?|\*\s*as\s*\w+))"""
r"""\s*from\s*['"](?P<url>[./].*?)["']\s*;)"""
),
"""import%(import)s from "%(url)s";""",

View File

@ -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 {

View File

@ -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";',