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
Vite 4 is removing import #11356
Comments
This was an upstream issue. I created an issue to rollup (rollup/rollup#4751). |
@johandalabacka , I did run your code, all u need to do is to add the base property to vite.config.js, it works on production as well |
@Foster0123 Thanks. I try it Update: I tried your fix but it didn't make any difference. api.greetings.hello() is still removed. I don't think base has anything to do with how treeshaking works. It set the base-url used for finding assets and etc |
did u run the build on a server ?? u need a local server to serve the build else the script will be blocked by CORS |
@Foster0123 I'm not sure what you mean. Running yarn build and then yarn preview starts a local server serving the built files. And I watched in the built code and the call is missing. I also tried
with |
yeah it seems to be a vite build issue, most likely a bug |
Closing as this is fixed in rollup 3.7.5. |
Describe the bug
If I have an import in App.vue which is a "double" import. The imported method is removed on build. While developing it works but it is gone on build. It works if I use vite@^3. I also works if I import is imported directly
App.vue
api/index.js
api/greetings.js
Reproduction
https://github.com/johandalabacka/vite4-build-error
Steps to reproduce
Download repo and install
Open http://localhost:5173/ and pressing the button and the output in the log is:
But if we build it:
Open http://localhost:4173/ and press the button and now output in the log is only:
System Info
Used Package Manager
yarn
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: