#35553: HashedFilesMixin for ES modules does not work with `import * as ...` 
syntax
-------------------------------------+-------------------------------------
     Reporter:  Michael              |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  contrib.staticfiles  |                  Version:  5.0
     Severity:  Normal               |               Resolution:
     Keywords:  Manifest  Static     |             Triage Stage:  Accepted
  Files Storage, javascript module   |
  scripts                            |
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce):

 * resolution:  invalid =>
 * stage:  Unreviewed => Accepted
 * status:  closed => new
 * type:  Uncategorized => Bug

Comment:

 Replying to [comment:2 Michael]:
 > Hi, no it is not invalid, that is the result of minification, removing
 any extra whitespace, most production system will serve minified files, so
 it's much more likely to not have the space.

 Ah, TIL 😁 confirmed that this is the output of many minifiers

 Confirmed that your suggested patch works for me, here is also a test:
 {{{#!diff
 diff --git a/tests/staticfiles_tests/project/documents/cached/module.js
 b/tests/staticfiles_tests/project/documents/cached/module.js
 index 7764e740d6..30ca25e9b6 100644
 --- a/tests/staticfiles_tests/project/documents/cached/module.js
 +++ b/tests/staticfiles_tests/project/documents/cached/module.js
 @@ -2,6 +2,7 @@
  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 { 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 469d5ec690..956341a858 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.d16a17156de1.js")
          tests = [
              # Relative imports.
              b'import testConst from "./module_test.477bbebe77f0.js";',
 @@ -686,6 +686,8 @@ 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";',
              # Aliases.
              b'import { testConst as alias } from
 "./module_test.477bbebe77f0.js";',
              b"import {\n"
 }}}

 Would you like to raise a PR?
-- 
Ticket URL: <https://code.djangoproject.com/ticket/35553#comment:3>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107019049d4c115-ee09e7a5-4cb2-4e55-abfc-9fc533436bb8-000000%40eu-central-1.amazonses.com.

Reply via email to