Skip to content

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

@FoxDaxian

Description

@FoxDaxian

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions