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

v3.2.0 missing output #10735

Closed
7 tasks done
DerYeger opened this issue Oct 31, 2022 · 13 comments · Fixed by rollup/rollup#4867, #12110 or #12786
Closed
7 tasks done

v3.2.0 missing output #10735

DerYeger opened this issue Oct 31, 2022 · 13 comments · Fixed by rollup/rollup#4867, #12110 or #12786

Comments

@DerYeger
Copy link

Describe the bug

After upgrading to v3.2.0 or later, vite build no longer outputs CSS files and is missing JS (except barebones IIFE).

Reproduction

https://github.com/DerYeger/vue-masonry-wall/tree/ae1b3b4586a8b0eba96e56997fce34ecd39dd0f2

Steps to reproduce

Run yarn install && yarn build && yarn demo:build

System Info

System:
    OS: macOS 13.1
    CPU: (8) arm64 Apple M1
    Memory: 444.34 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.18.0 - ~/.volta/tools/image/node/16.18.0/bin/node
    Yarn: 1.22.19 - ~/.volta/tools/image/yarn/1.22.19/bin/yarn
    npm: 8.19.2 - ~/.volta/tools/image/node/16.18.0/bin/npm
  Browsers:
    Chrome: 107.0.5304.87
    Firefox: 104.0
    Safari: 16.1
  npmPackages:
    @vitejs/plugin-vue: 3.2.0 => 3.2.0
    vite: 3.2.1 => 3.2.1

Used Package Manager

yarn

Logs

Expected

build:demo: vite v3.1.8 building for production...
build:demo: transforming...
build:demo: ✓ 24 modules transformed.
build:demo: rendering chunks...
build:demo: dist/index.html                  1.13 KiB
build:demo: dist/assets/index.306b3559.css   2.84 KiB / gzip: 0.99 KiB
build:demo: dist/assets/index.34650a52.js    63.97 KiB / gzip: 25.68 KiB

With v3.2.0

vite v3.2.1 building for production...
transforming...
✓ 24 modules transformed.
rendering chunks...
dist/index.html                 1.07 KiB
dist/assets/index.891d93e6.js   0.69 KiB / gzip: 0.39 KiB

Validations

@sapphi-red
Copy link
Member

It seems Vite is respecting the sideEffects field of the root package.json. I think this is a correct behavior.
Placing package.json including { "sideEffects": true } at demo directory worked.

@DerYeger
Copy link
Author

DerYeger commented Oct 31, 2022

It seems Vite is respecting the sideEffects field of the root package.json. I think this is a correct behavior.
Placing package.json including { "sideEffects": true } at demo directory worked.

That does indeed solve the issue, thanks!
I must have missed the changelog of Vite now picking up the sideEffects property.

Though it does work in dev mode.

@sapphi-red
Copy link
Member

It doesn't happen in dev mode because Vite doesn't do the tree shake in dev mode.

@bluwy
Copy link
Member

bluwy commented Nov 1, 2022

I didn't know Vite is now respecting the sideEffects field. Does this mean there's a solution for #4389 now? I'm also not sure if this counts as a regression as we don't support sideEffects before.

@sodatea
Copy link
Member

sodatea commented Nov 2, 2022

Vite has always respected sideEffects since 2.0 00c57fc

I think #4389 is something different

@tzimmermann
Copy link

tzimmermann commented Nov 11, 2022

@sodatea In react-stick's demo page, we also saw the behaviour described here only after upgrading from 3.1.8 to 3.2.0.
In case it helps

Removing sideEffects: false fixed the issue, but I wanted to mention it anyway, as there seems to have been some kind of change in 3.2.0 that surfaced this bug.

@guoyunhe
Copy link

I believe the change is from v3.2.0. And it is a regression. sideEffects: false causes empty output, which it shouldn't.

azu added a commit to textlint-rule/sentence-splitter that referenced this issue Feb 10, 2023
Use `import` instead of <script>
Ref vitejs/vite#10735
azu added a commit to textlint-rule/sentence-splitter that referenced this issue Feb 10, 2023
Use `import` instead of <script>
Ref vitejs/vite#10735
azu added a commit to textlint-rule/sentence-splitter that referenced this issue Feb 10, 2023
* refactor: update types and cleanup dependencies

- Update @textlint/ast-node-types
  - Export extends `TxtNode`
- Require Node.js 14+
  - Now, output ES2018+ codes
- Remove CLI
  - You can use a website

* CI: update node versions

* CI: Update Node versions

* docs: remove CLI

* CI: use Node 16

* CI: use Node 18

* refactor: use dual package

* fix: import .js

* fix: avoid vite `sideEffects` bug

Use `import` instead of <script>
Ref vitejs/vite#10735

* chore: add .js

* fix: work on ESM

* make ES2020

* fix types

* CI: add .github/release.yml

* fix: debug log

* chore: remove snowpack

* chore: remove unused pkg

* fix: use import type

* fix: cleanup unused functions

* update

* update

* update

* update

* Update

* Update
@fregante
Copy link

fregante commented Feb 13, 2023

@lukastaegert
Copy link

Likely fix at rollup/rollup#4867

@bluwy bluwy linked a pull request Feb 21, 2023 that will close this issue
9 tasks
@fregante
Copy link

I'm testing 4.2.0 beta, with rollup 3.17.2, and I'm still not seeing any output :(

Inlined log:


6:36:27 PM: Post processing - header rules
6:36:26 PM: vite v4.2.0-beta.0 building for production...
6:36:27 PM: transforming...
6:36:27 PM: ✓ 10 modules transformed.
6:36:27 PM: Post processing - redirect rules
6:36:27 PM: 10:36:27 AM [vite-plugin-svelte] dom compile done.
6:36:27 PM: package             	files	 time	  avg
6:36:27 PM: github-url-detection	    1	0.12s	0.12s
6:36:27 PM: rendering chunks...
6:36:28 PM: Post processing done
6:36:27 PM: computing gzip size...
6:36:27 PM: dist/index.html                 0.85 kB
6:36:27 PM: dist/assets/index-fbdb3af1.css  0.37 kB │ gzip: 0.27 kB
6:36:28 PM: Section completed: postprocessing
6:36:27 PM: dist/assets/index-3050aee0.js   0.71 kB │ gzip: 0.40 kB
6:36:27 PM: ✓ built in 420ms
6:36:27 PM: ​
6:36:27 PM: (build.command completed in 988ms)

Note that the version is 4.2.0 beta and the JS file is a measly 710 bytes (it should be 37KB)

@patak-dev
Copy link
Member

@fregante would you check with 4.3.0-beta.2? I tried to reproduce your issue in refined-github/github-url-detection but it is building correctly for me. I think it works after this PR:

@fregante
Copy link

fregante commented Apr 7, 2023

it is building correctly for me

The output is still sub 1KB:

❯ nr demo:build
vite v4.3.0-beta.2 building for production...
✓ 10 modules transformed.
dist/index.html                 0.85 kB │ gzip: 0.49 kB
dist/assets/index-fbdb3af1.css  0.37 kB │ gzip: 0.27 kB
dist/assets/index-3050aee0.js   0.71 kB │ gzip: 0.40 kB
✓ built in 558ms

@patak-dev
Copy link
Member

Sorry for the noise, just reproduced the issue locally too 👍🏼

@github-actions github-actions bot locked and limited conversation to collaborators Apr 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.