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

Removal of empty chunks doesn't update all imports #8330

Closed
7 tasks done
matthewp opened this issue May 25, 2022 · 1 comment · Fixed by #8345
Closed
7 tasks done

Removal of empty chunks doesn't update all imports #8330

matthewp opened this issue May 25, 2022 · 1 comment · Fixed by #8345
Labels
feat: css p3-downstream-blocker Blocking the downstream ecosystem to work properly (priority)

Comments

@matthewp
Copy link
Contributor

matthewp commented May 25, 2022

Describe the bug

In Astro we are updating to use vite:css-post for bundling instead of doing it our own thanks to the new viteMetadata property.

One thing that this plugin does is when there is a CSS chunk that only contains CSS, the JS bundle gets removed and any imports of that bundle are removed.

It uses a regexp to find import statements to remove. That code is here. However the code assumes the import statement is using double quotes.

I'm not sure why, but in Astro these become double quotes. As far as I can tell this isn't something Rollup lets you control. I'm not sure why it is happening, perhaps because we bundle to ESM?

Updating this regex to work with either single or double quotes would fix the issue. I'm willing to submit a PR to fix.

Reproduction

https://github.com/withastro/astro/runs/6595302507?check_suite_focus=true

System Info

System:
    OS: macOS 12.0.1
    CPU: (10) x64 Apple M1 Pro
    Memory: 32.51 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 14.19.1 - ~/.volta/tools/image/node/14.19.1/bin/node
    Yarn: 1.22.18 - ~/.volta/bin/yarn
    npm: 6.14.16 - ~/.volta/tools/image/node/14.19.1/bin/npm
  Browsers:
    Chrome: 101.0.4951.64
    Safari: 15.1

Used Package Manager

pnpm

Logs

No response

Validations

@sapphi-red
Copy link
Member

It also happened when esbuild: false. https://stackblitz.com/edit/vitejs-vite-pcufvl?terminal=dev

@sapphi-red sapphi-red added p3-downstream-blocker Blocking the downstream ecosystem to work properly (priority) and removed p3-minor-bug An edge case that only affects very specific usage (priority) labels May 27, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Jun 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feat: css p3-downstream-blocker Blocking the downstream ecosystem to work properly (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants