Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assets entries in the manifest do not preserve the original file extension #8764

Closed
7 tasks done
ElMassimo opened this issue Jun 24, 2022 · 6 comments · Fixed by #8768
Closed
7 tasks done

Assets entries in the manifest do not preserve the original file extension #8764

ElMassimo opened this issue Jun 24, 2022 · 6 comments · Fixed by #8768
Labels
p3-downstream-blocker Blocking the downstream ecosystem to work properly (priority)

Comments

@ElMassimo
Copy link
Contributor

ElMassimo commented Jun 24, 2022

Describe the bug

#6649 added assets to the manifest, but the entries are invalid for Sass/Less/Stylus stylesheets, as it's erasing the original extension from the manifest entry names and src.

For example, for style.scss the entry is:

  "style.css": {
    "file": "assets/style.a5c756ae.css",
    "src": "style.css"
  }

In contrast, Vite does preserve .ts extensions:

  "main.ts": {
    "file": "assets/main.ts.a1959a64.js",
    "src": "main.ts",

For any backend integration to map files correctly, it's desirable to preserve the extension for assets as well:

  "style.scss": {
    "file": "assets/style.a5c756ae.css",
    "src": "style.scss"
  }

Background 📜

This is the behavior that vite-plugin-ruby implements, but it no longer works with Vite 3.

I believe this change is currently preventing Vite Ruby from trying to recover the original extension, making #6649 a breaking change for many Vite Ruby projects.

If the manifest preserves the extensions, this would greatly simplify all backend integrations, including Vite Ruby.

Reproduction

Run npm run build or see the manifest, notice that both the entry name and the src are incorrect.

Additionally, this failing test run demonstrates the issue.

System Info

System:
    OS: macOS 12.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 109.84 MB / 16.00 GB
    Shell: 3.3.1 - /opt/homebrew/bin/fish
  Binaries:
    Node: 16.13.1 - /var/folders/j6/gyvfxjy50jqgy9lth08nd_f40000gn/T/fnm_multishells/3581_1656077025812/bin/node
    Yarn: 1.22.17 - /var/folders/j6/gyvfxjy50jqgy9lth08nd_f40000gn/T/fnm_multishells/3581_1656077025812/bin/yarn
    npm: 8.1.2 - /var/folders/j6/gyvfxjy50jqgy9lth08nd_f40000gn/T/fnm_multishells/3581_1656077025812/bin/npm
  Browsers:
    Chrome: 102.0.5005.115
    Firefox: 101.0
    Safari: 15.2

Used Package Manager

pnpm

Logs

No response

Validations

@patak-dev
Copy link
Member

@jessarcher @innocenzi @lubomirblazekcz ping for visibility. I imagine you are ok with this change. PR welcome if someone wants to take over, it would be good to launch v3 with this solved

@patak-dev patak-dev added the p3-downstream-blocker Blocking the downstream ecosystem to work properly (priority) label Jun 24, 2022
@ElMassimo
Copy link
Contributor Author

ElMassimo commented Jun 24, 2022

To clarify, I believe it's this change is currently preventing Vite Ruby from trying to recover the original extension, making #6649 a breaking change for many Vite Ruby projects.

@innocenzi
Copy link
Contributor

Yes, I also had issues with my current manifest generation, I had to change my implementation.

Additionally, is it possible to add an isEntry boolean to CSS files that are used in build.rollupOptions.input? This is needed for avoiding FOUCs - I didn't realize #6649 didn't do that, without it we still need to override the manifest in my integration and the official Laravel one

@jessarcher
Copy link
Contributor

Definitely okay with the change over here. I will try to find some time to dig into it. I'm hoping the original extension is still available in the chunk at this point so we can just change the hard-coding of .css.

@ElMassimo
Copy link
Contributor Author

ElMassimo commented Jun 24, 2022

I have a fix for the extension, currently looking into the isEntry piece.

@ElMassimo
Copy link
Contributor Author

ElMassimo commented Jun 24, 2022

Added a Map to preserve isEntry information accurately.

@github-actions github-actions bot locked and limited conversation to collaborators Jul 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
p3-downstream-blocker Blocking the downstream ecosystem to work properly (priority)
Projects
None yet
5 participants