hawtio / hawtio-next

Next generation Hawtio UI console
https://hawt.io
Apache License 2.0
7 stars 20 forks source link

Vite-based plugin for Hawtio #729

Open iMashtak opened 6 months ago

iMashtak commented 6 months ago

Is anyone tried to use Vite to build plugin for Hawtio? I failed with an error:

Uncaught SyntaxError: Cannot use import statement outside a module

vite.config.js:

import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import federation from "@originjs/vite-plugin-federation";

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    react(),
    federation({
      name: "project",
      filename: "remoteEntry.js",
      exposes: {
        "./plugin": "./src/project-plugin",
      },
      shared: ["react"],
    }),
  ],
  build: {
    modulePreload: false,
    target: "esnext",
    minify: false,
    cssCodeSplit: false,
  },
})

I've found the exact line where error occures: core.ts. I thought that module federation do not depend on build tool, but i am certanly not sure:(


CRACO build lasts over 3 minutes on my machine compared to 30 sec with Vite, so i very interested in Vite:)

tadayosi commented 6 months ago

Hi @iMashtak,

Yes we've tried Vite before hawtio/hawtio-online/issues/147 but what we found hard was that the core depends on @module-federation/utilities which is tied to Webpack implementation of Module Federation, so it's hard to interoperate with Vite at this moment.

Btw, we'll soon throw away CRACO and use plain Webpack instead. In the future, when we can find a way to interoperate with both Webpack and Vite we'll support both.

tadayosi commented 6 months ago

For reference: https://github.com/module-federation/universe/issues/784