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

Vite 6.0 is not supported, and a compilation error is reported #201

Closed
gongph opened this issue Dec 1, 2024 · 8 comments · Fixed by #224
Closed

Vite 6.0 is not supported, and a compilation error is reported #201

gongph opened this issue Dec 1, 2024 · 8 comments · Fixed by #224

Comments

@gongph
Copy link

gongph commented Dec 1, 2024

env:

  • vite6.0
@zhangHongEn
Copy link
Contributor

I tried it and didn’t encounter any issues. Could you provide an example to reproduce the problem?

@zhangHongEn
Copy link
Contributor

I encountered an issue with top-level await in build mode. Let me take a look.

@gongph
Copy link
Author

gongph commented Dec 2, 2024

Right, that's the build issue: await isn't allowed in non-async

@ErickDevv
Copy link

Same problem with Vite 6.

I init a project with Vite 6 and Module Federation. When I run npm run build I get the following error message:

NOTE: It is important to mention that I tested with Bun and Nodejs.

error during build:
[commonjs] node_modules/__mf__virtual/remote__loadShare__react__loadShare__.js (14:31): await isn't allowed in non-async function
file: C:...//node_modules/react-dom/cjs/react-dom.production.min.js:14:31

12:       requiredVersion: "^18.3.1"
13:     }}}))
14:     const exportModule = await res.then(factory => factory())
                                   ^
15:     module.exports = exportModule

Replace ... with the path to the project.

My package.json file is:

{
  "name": "remote",
  "private": true,
  "version": "0.0.0",
  "type": "module",
  "scripts": {
    "dev": "vite --port 4174",
    "build": "tsc && vite build",
    "preview": "bun run build && vite preview --port 4174"
  },
  "dependencies": {
    "@module-federation/vite": "^1.1.7",
    "install": "^0.13.0",
    "react": "^18.3.1",
    "react-dom": "^18.3.1"
  },
  "devDependencies": {
    "@eslint/js": "^9.15.0",
    "@types/react": "^18.3.12",
    "@types/react-dom": "^18.3.1",
    "@vitejs/plugin-react": "^4.3.4",
    "eslint": "^9.15.0",
    "eslint-plugin-react-hooks": "^5.0.0",
    "eslint-plugin-react-refresh": "^0.4.14",
    "globals": "^15.12.0",
    "typescript": "~5.6.2",
    "typescript-eslint": "^8.15.0",
    "vite": "^6.0.1"
  }
}

@gongph
Copy link
Author

gongph commented Dec 2, 2024

Hi @ErickDevv
Drop the version. It's okay to build with vite@5.4.0
Look here: https://github.com/gongph/module-federation-vue/blob/main/remote-vue/package.json#L18

@RobinBomkamp
Copy link
Contributor

Shouldn't vite 5.4.0 then be included as a peerDependency?

@gioboa
Copy link
Collaborator

gioboa commented Dec 2, 2024

Yep @RobinBomkamp, we need a way to say "it's working with v5 at the moment". feel free to drop a PR for that please.

@ScriptedAlchemy
Copy link
Member

Right, that's the build issue: await isn't allowed in non-async

can it be set to async mode in vite 6?

zhangHongEn added a commit to zhangHongEn/vite that referenced this issue Dec 17, 2024
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

Successfully merging a pull request may close this issue.

6 participants