hanami / assets-js

esbuild plugin for Hanami Assets
3 stars 5 forks source link

Minimal repro of cross-slice name collisions #17

Closed timriley closed 6 months ago

timriley commented 10 months ago

This fails like so:

  ● hanami-assets › Full app

    expect(received).toEqual(expected) // deep equality

    - Expected  - 1
    + Received  + 1

    @@ -25,11 +25,11 @@
        },
        "background.jpg": Object {
          "sri": Array [
            "sha384-M7QyKTUfzyVWNC4FoMYq0ypu7LDifAYWEtXRT5d6M3Prpau9t5wavW1216HhvCJc",
          ],
    -     "url": "/assets/background-UU2XY655.jpg",
    +     "url": "/assets/background-83509E65.jpg",
        },
        "font.otf": Object {
          "sri": Array [
            "sha384-Lpm/oUsCQkOg41WyENyyB1zjaX/FB522VWlU44JKakwzwBxvu11le0ILkiPsR73K",
          ],

      118 |
      119 |     // Check if the manifest contains the correct file paths
    > 120 |     expect(manifest).toEqual({
          |                      ^
      121 |       "app.js": {
      122 |         url: "/assets/app-YRYN3NGE.js",
      123 |         sri: ["sha384-WAsFKE/RcOorRHTXmdRD8gxW+IxxfzKHbRgzcCuhFDC5StKi+6T+AawxcUmuv8Z5"],

      at Object.<anonymous> (test/hanami-assets.test.ts:120:22)

We get differing URLs for "background.jpg" since both the app and the admin slice import it via their entry points (via their respective CSS files that both include a same-named file). esbuild will override the first "background.jpg" entry with the second "background.jpg" entry as soon as it encounters it.