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

Relative path with "sideEffects": false silently breaks pages #655

Closed
2 tasks
filipw01 opened this issue Feb 24, 2023 · 6 comments
Closed
2 tasks

Relative path with "sideEffects": false silently breaks pages #655

filipw01 opened this issue Feb 24, 2023 · 6 comments

Comments

@filipw01
Copy link

filipw01 commented Feb 24, 2023

Build tool

Vite

Where do you see the problem?

  • In the browser
  • In the terminal

Describe the bug

There is a page declared in vite.config.js - page.html importing ./main.js

When there is "sideEffects": false declared in package.json
vite bundles only modulepreload polyfill ignoring main.js

When there is no "sideEffects": false declared in package.json
vite correctly bundles both modulepreload polyfill and main.js file into one file

When page.html imports /main.js instead (absolute path) it works as expected bundling both modulepreload polyfill and main.js file into one file

My fix is to use absolute paths, but I would expect either an error or relative paths working as expected

Reproduction

https://stackblitz.com/edit/stackblitz-webcontainer-api-starter-ukxxhl?file=package.json

Logs

No response

System Info

You can see everything in reproduction too, but for me it's

System:
    OS: macOS 13.2.1
    CPU: (10) arm64 Apple M1 Max
    Memory: 4.70 GB / 32.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.10.0 - ~/Library/Caches/fnm_multishells/2776_1676359517532/bin/node
    Yarn: 3.3.1 - /opt/homebrew/bin/yarn
    npm: 7.24.0 - ~/Library/Caches/fnm_multishells/2776_1676359517532/bin/npm
  Browsers:
    Chrome: 110.0.5481.100
    Firefox: 110.0
    Safari: 16.3

Severity

annoyance

@filipw01
Copy link
Author

Closing temporarily as I missed one thing in reproduction and after fixing it it seems to work. I need to provide a better one because I definitely see an issue locally

@filipw01 filipw01 changed the title Relative path in multipage setup silently breaks some pages Relative path with "sideEffects": false silently breaks pages Feb 24, 2023
@filipw01
Copy link
Author

Found the actual issue, renamed issue and edited description

@filipw01 filipw01 reopened this Feb 24, 2023
@filipw01 filipw01 changed the title Relative path with "sideEffects": false silently breaks pages Relative path with "sideEffects": false silently breaks pages Feb 24, 2023
@jacksteamdev
Copy link
Contributor

I was able to reproduce this with a vanilla Vite project, and it looks like Vite is tracking this bug in this issue.

Closing since it's a Vite issue.

@jacksteamdev
Copy link
Contributor

@filipw01 This is a truly perfect minimal reproduction. Thank you! 🤗

We should add a link to a CRXJS project on StackBlitz, it makes everything so easy.

@filipw01
Copy link
Author

I didn't think it might be an issue with Vite itself. Thank you for the link. I might find a moment to add a link to StackBlitz somewhere

@filipw01
Copy link
Author

filipw01 commented Mar 22, 2023

@jacksteamdev I created this vanilla js project which I think we could link in the issue template https://stackblitz.com/edit/stackblitz-webcontainer-api-starter-humgcr

Feel free to fork it with your account to be in full control of it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants