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

Dev(or serve) mode doesn't compatible with amd format. #16511

Closed
7 tasks done
FoxDaxian opened this issue Apr 23, 2024 · 2 comments
Closed
7 tasks done

Dev(or serve) mode doesn't compatible with amd format. #16511

FoxDaxian opened this issue Apr 23, 2024 · 2 comments

Comments

@FoxDaxian
Copy link

Describe the bug

Use system0.21.6 to load main.jsx instead use type:module to load, shown as below:
image
Then use @babel/plugin-transform-modules-amd to transform source files so that SystemJS.import can work, shown as below:
image
Inspect page, what main.jsx shows is:

image

You can see except React an React-DOM which we can inject into html manually or automatically, and use SystemJS.register to initialize them. we have another dependence, named ./App.jsx, that means if we have 5 dependencies. we need use SystemJS.register to register them one by one. that's not what I want.


So I think Vite should bundle all code of src folder into to one single file(maybe main.jsx) when serve mode.
image

Hope can get your responses as soon as possible.
Best regards.

Reproduction

https://stackblitz.com/edit/vitejs-vite-wzmngy?file=vite.config.js

Steps to reproduce

just open stackblitz, then inspect page, check the network.

System Info

System:
    OS: macOS 13.6.6
    CPU: (8) arm64 Apple M1 Pro
    Memory: 62.73 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.20.2 - ~/.nvm/versions/node/v18.20.2/bin/node
    npm: 10.5.0 - ~/.nvm/versions/node/v18.20.2/bin/npm
    pnpm: 8.10.3 - ~/.nvm/versions/node/v18.20.2/bin/pnpm
  Browsers:
    Chrome: 124.0.6367.62
    Safari: 16.6
  npmPackages:
    @vitejs/plugin-react: ^4.2.1 => 4.2.1 
    vite: ^5.2.0 => 5.2.9

Used Package Manager

npm

Logs

No response

Validations

Copy link

stackblitz bot commented Apr 23, 2024

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

@FoxDaxian FoxDaxian changed the title Dev(or serve) mode can not compatible with amd format. Dev(or serve) mode doesn't compatible with amd format. Apr 23, 2024
@sapphi-red
Copy link
Member

sapphi-red commented Apr 25, 2024

I think Vite should bundle all code of src folder into to one single file(maybe main.jsx) when serve mode.

This is in direct conflict with Vite's philosophy, so I don't think it will be implemented.
https://vitejs.dev/guide/why.html#slow-server-start

But probably you would be able to swap ESM with SystemJS modules when #16471 lands. Although it would require quite a effort.

@sapphi-red sapphi-red closed this as not planned Won't fix, can't repro, duplicate, stale Apr 25, 2024
@github-actions github-actions bot locked and limited conversation to collaborators May 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants