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

fix(css): correctly set manifest source name and emit CSS file #14945

Merged
merged 7 commits into from Nov 11, 2023

Conversation

sapphi-red
Copy link
Member

@sapphi-red sapphi-red commented Nov 10, 2023

Description

319e985: just simplifies the logic, it should be equivalent
b16ed8e: separate the process of generating the filename and the process of getting the original filename
c2a750d: generate the filename based on the chunk name
f1b6f67: fixes the test because #11578 changed the original filename incorrectly and the test was relying that fact

close #8057
fixes #12009
fixes #12072
fixes #14943
close #12030

refs #6649
refs #11578

Additional context


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines, especially the Pull Request Guidelines.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Update the corresponding documentation if needed.
  • Ideally, include relevant tests that fail without this PR but pass with it.

@sapphi-red sapphi-red added feat: css p3-minor-bug An edge case that only affects very specific usage (priority) labels Nov 10, 2023
@sapphi-red
Copy link
Member Author

/ecosystem-ci run

@vite-ecosystem-ci

This comment was marked as outdated.

@bluwy
Copy link
Member

bluwy commented Nov 10, 2023

I don't think this is a bad change, but we're quite close to the release now to make this change. I also saw the similar issues like #11413 and figured it's better to wait till next major.

If we do favour in merging this, I'd be comfortable only releasing stable on next Friday. I'd be bumped that we have to delay but future me will probably appreciate present me making exceptions 😄

@vite-ecosystem-ci

This comment was marked as outdated.

@patak-dev
Copy link
Member

Nice work here @sapphi-red! I think it is worth trying to merge this in Vite 5 after reviewing why it is breaking SvelteKit. Delaying a few days the release would not only be good for this change, but to give a few more days to maintainers to squash the other reds, so I vote for that exception too @bluwy 🙏🏼

@sapphi-red
Copy link
Member Author

The reason why SvelteKit test in vite-plugin-svelte failed was because the CSS chunk entry overrode the JS chunk entry. .svelte files maps to both JS chunk and CSS chunk. Before this PR, the original source file name of Foo.svelte's CSS chunks was output as Foo.css which is wrong. This PR fixes that to be Foo.svelte. That caused the conflict with the JS chunk to happen.

I wasn't able to add a test for this, because this depends on the order of bundle which is difficult to control.

.svelte-kit\output\server\.vite content

Before this PR (contains src/routes/+page.css that doesn't exist)

{
  "../../../node_modules/.pnpm/@sveltejs+kit@1.27.3_svelte@4.2.1_vite@5.0.0-beta.17/node_modules/@sveltejs/kit/src/runtime/components/error.svelte": {
    "file": "entries/fallbacks/error.svelte.js",
    "imports": [
      "_ssr.js"
    ],
    "isEntry": true,
    "src": "../../../node_modules/.pnpm/@sveltejs+kit@1.27.3_svelte@4.2.1_vite@5.0.0-beta.17/node_modules/@sveltejs/kit/src/runtime/components/error.svelte"
  },
  "../../../node_modules/.pnpm/@sveltejs+kit@1.27.3_svelte@4.2.1_vite@5.0.0-beta.17/node_modules/@sveltejs/kit/src/runtime/components/layout.svelte": {
    "file": "entries/fallbacks/layout.svelte.js",
    "imports": [
      "_ssr.js"
    ],
    "isEntry": true,
    "src": "../../../node_modules/.pnpm/@sveltejs+kit@1.27.3_svelte@4.2.1_vite@5.0.0-beta.17/node_modules/@sveltejs/kit/src/runtime/components/layout.svelte"
  },
  "../../../node_modules/.pnpm/@sveltejs+kit@1.27.3_svelte@4.2.1_vite@5.0.0-beta.17/node_modules/@sveltejs/kit/src/runtime/server/index.js": {
    "file": "index.js",
    "imports": [
      "_internal.js",
      "_index.js"
    ],
    "isEntry": true,
    "src": "../../../node_modules/.pnpm/@sveltejs+kit@1.27.3_svelte@4.2.1_vite@5.0.0-beta.17/node_modules/@sveltejs/kit/src/runtime/server/index.js"
  },
  ".svelte-kit/generated/server/internal.js": {
    "file": "internal.js",
    "imports": [
      "_internal.js"
    ],
    "isEntry": true,
    "src": ".svelte-kit/generated/server/internal.js"
  },
  "_index.js": {
    "file": "chunks/index.js",
    "imports": [
      "_ssr.js"
    ]
  },
  "_internal.js": {
    "file": "chunks/internal.js",
    "imports": [
      "_ssr.js"
    ]
  },
  "_ssr.js": {
    "file": "chunks/ssr.js"
  },
  "src/routes/+page.css": {
    "file": "_app/immutable/assets/_page.1A-_w4me.css",
    "src": "src/routes/+page.css"
  },
  "src/routes/+page.js": {
    "file": "entries/pages/_page.js",
    "isEntry": true,
    "src": "src/routes/+page.js"
  },
  "src/routes/+page.svelte": {
    "css": [
      "_app/immutable/assets/_page.1A-_w4me.css"
    ],
    "file": "entries/pages/_page.svelte.js",
    "imports": [
      "_ssr.js",
      "_index.js"
    ],
    "isEntry": true,
    "src": "src/routes/+page.svelte"
  }
}

this PR without 1376a34 (src/routes/+page.svelte points the CSS file)

{
  "../../../node_modules/.pnpm/@sveltejs+kit@1.27.3_svelte@4.2.1_vite@5.0.0-beta.17/node_modules/@sveltejs/kit/src/runtime/components/error.svelte": {
    "file": "entries/fallbacks/error.svelte.js",
    "imports": [
      "_ssr.js"
    ],
    "isEntry": true,
    "src": "../../../node_modules/.pnpm/@sveltejs+kit@1.27.3_svelte@4.2.1_vite@5.0.0-beta.17/node_modules/@sveltejs/kit/src/runtime/components/error.svelte"
  },
  "../../../node_modules/.pnpm/@sveltejs+kit@1.27.3_svelte@4.2.1_vite@5.0.0-beta.17/node_modules/@sveltejs/kit/src/runtime/components/layout.svelte": {
    "file": "entries/fallbacks/layout.svelte.js",
    "imports": [
      "_ssr.js"
    ],
    "isEntry": true,
    "src": "../../../node_modules/.pnpm/@sveltejs+kit@1.27.3_svelte@4.2.1_vite@5.0.0-beta.17/node_modules/@sveltejs/kit/src/runtime/components/layout.svelte"
  },
  "../../../node_modules/.pnpm/@sveltejs+kit@1.27.3_svelte@4.2.1_vite@5.0.0-beta.17/node_modules/@sveltejs/kit/src/runtime/server/index.js": {
    "file": "index.js",
    "imports": [
      "_internal.js",
      "_index.js"
    ],
    "isEntry": true,
    "src": "../../../node_modules/.pnpm/@sveltejs+kit@1.27.3_svelte@4.2.1_vite@5.0.0-beta.17/node_modules/@sveltejs/kit/src/runtime/server/index.js"
  },
  ".svelte-kit/generated/server/internal.js": {
    "file": "internal.js",
    "imports": [
      "_internal.js"
    ],
    "isEntry": true,
    "src": ".svelte-kit/generated/server/internal.js"
  },
  "_index.js": {
    "file": "chunks/index.js",
    "imports": [
      "_ssr.js"
    ]
  },
  "_internal.js": {
    "file": "chunks/internal.js",
    "imports": [
      "_ssr.js"
    ]
  },
  "_ssr.js": {
    "file": "chunks/ssr.js"
  },
  "src/routes/+page.js": {
    "file": "entries/pages/_page.js",
    "isEntry": true,
    "src": "src/routes/+page.js"
  },
  "src/routes/+page.svelte": {
    "file": "_app/immutable/assets/entries/pages/_page.1A-_w4me.css",
    "src": "src/routes/+page.svelte"
  }
}

with 1376a34

{
  "../../../node_modules/.pnpm/@sveltejs+kit@1.27.3_svelte@4.2.1_vite@5.0.0-beta.17/node_modules/@sveltejs/kit/src/runtime/components/error.svelte": {
    "file": "entries/fallbacks/error.svelte.js",
    "imports": [
      "_ssr.js"
    ],
    "isEntry": true,
    "src": "../../../node_modules/.pnpm/@sveltejs+kit@1.27.3_svelte@4.2.1_vite@5.0.0-beta.17/node_modules/@sveltejs/kit/src/runtime/components/error.svelte"
  },
  "../../../node_modules/.pnpm/@sveltejs+kit@1.27.3_svelte@4.2.1_vite@5.0.0-beta.17/node_modules/@sveltejs/kit/src/runtime/components/layout.svelte": {
    "file": "entries/fallbacks/layout.svelte.js",
    "imports": [
      "_ssr.js"
    ],
    "isEntry": true,
    "src": "../../../node_modules/.pnpm/@sveltejs+kit@1.27.3_svelte@4.2.1_vite@5.0.0-beta.17/node_modules/@sveltejs/kit/src/runtime/components/layout.svelte"
  },
  "../../../node_modules/.pnpm/@sveltejs+kit@1.27.3_svelte@4.2.1_vite@5.0.0-beta.17/node_modules/@sveltejs/kit/src/runtime/server/index.js": {
    "file": "index.js",
    "imports": [
      "_internal.js",
      "_index.js"
    ],
    "isEntry": true,
    "src": "../../../node_modules/.pnpm/@sveltejs+kit@1.27.3_svelte@4.2.1_vite@5.0.0-beta.17/node_modules/@sveltejs/kit/src/runtime/server/index.js"
  },
  ".svelte-kit/generated/server/internal.js": {
    "file": "internal.js",
    "imports": [
      "_internal.js"
    ],
    "isEntry": true,
    "src": ".svelte-kit/generated/server/internal.js"
  },
  "_index.js": {
    "file": "chunks/index.js",
    "imports": [
      "_ssr.js"
    ]
  },
  "_internal.js": {
    "file": "chunks/internal.js",
    "imports": [
      "_ssr.js"
    ]
  },
  "_ssr.js": {
    "file": "chunks/ssr.js"
  },
  "src/routes/+page.js": {
    "file": "entries/pages/_page.js",
    "isEntry": true,
    "src": "src/routes/+page.js"
  },
  "src/routes/+page.svelte": {
    "css": [
      "_app/immutable/assets/entries/pages/_page.1A-_w4me.css"
    ],
    "file": "entries/pages/_page.svelte.js",
    "imports": [
      "_ssr.js",
      "_index.js"
    ],
    "isEntry": true,
    "src": "src/routes/+page.svelte"
  }
}

@sapphi-red
Copy link
Member Author

/ecosystem-ci run

@vite-ecosystem-ci
Copy link

📝 Ran ecosystem CI on 1376a34: Open

suite result latest scheduled
analogjs failure failure
astro success success
histoire failure failure
ladle success success
laravel failure failure
marko success failure
nuxt failure failure
nx failure failure
previewjs success success
qwik failure failure
rakkas success success
sveltekit failure failure
unocss success success
vike failure failure
vite-plugin-pwa success success
vite-plugin-react success success
vite-plugin-react-pages failure failure
vite-plugin-react-swc success success
vite-plugin-svelte success success
vite-plugin-vue success success
vite-setup-catalogue success success
vitepress success success
vitest success failure

Copy link
Member

@bluwy bluwy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanation for the v-p-s/SvelteKit fail. I was a bit concerned with the change, but the new manifest output does seem more correct 👍

@bluwy bluwy merged commit 28ccede into vitejs:main Nov 11, 2023
11 checks passed
@sapphi-red sapphi-red deleted the fix/css-manifest-source-name branch November 11, 2023 15:21
@dominikg dominikg mentioned this pull request Nov 26, 2023
7 tasks
helhum added a commit to helhum/vite that referenced this pull request Nov 27, 2023
sapphi-red added a commit to helhum/vite that referenced this pull request Nov 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat: css p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
None yet
3 participants