originjs / vite-plugin-federation

Module Federation for vite & rollup
Other
2.39k stars 241 forks source link

ERROR: Expression Expected - Unable to understand this error #566

Open ashish141199 opened 9 months ago

ashish141199 commented 9 months ago

Versions

Reproduction

  1. Nuxt host app with Vite + Plugin Federation
  2. Vue remote app with Vite + Plugin Federation

What is actually happening?

Throwing out this error

 ERROR  Expression expected                                          8:40:49 am  

  at error (/C:/Users/DELL/Desktop/dev/latest/elixir/node_modules/.pnpm/rollup@4.9.6/node_modules/rollup/dist/es/shared/parseAst.js:337:30)
  at parseError (/C:/Users/DELL/Desktop/dev/latest/elixir/node_modules/.pnpm/rollup@4.9.6/node_modules/rollup/dist/es/shared/parseAst.js:972:9)
  at convertNode (/C:/Users/DELL/Desktop/dev/latest/elixir/node_modules/.pnpm/rollup@4.9.6/node_modules/rollup/dist/es/shared/parseAst.js:2057:12)
  at convertProgram (/C:/Users/DELL/Desktop/dev/latest/elixir/node_modules/.pnpm/rollup@4.9.6/node_modules/rollup/dist/es/shared/parseAst.js:965:12)
  at parseAst (/C:/Users/DELL/Desktop/dev/latest/elixir/node_modules/.pnpm/rollup@4.9.6/node_modules/rollup/dist/es/shared/parseAst.js:2104:12)
  at TransformContext.parse (/C:/Users/DELL/Desktop/dev/latest/elixir/node_modules/.pnpm/vite@5.0.11_@types+node@18.19.8_sass@1.70.0/node_modules/vite/dist/node/chunks/dep-V3BH7oO1.js:63681:20)
  at TransformContext.transform (C:/Users/DELL/Desktop/dev/latest/elixir/node_modules/.pnpm/@originjs+vite-plugin-federation@1.3.4/node_modules/@originjs/vite-plugin-federation/dist/index.js:1234:20)
  at TransformContext.transform (C:/Users/DELL/Desktop/dev/latest/elixir/node_modules/.pnpm/@originjs+vite-plugin-federation@1.3.4/node_modules/@originjs/vite-plugin-federation/dist/index.js:1537:74)
  at /C:/Users/DELL/Desktop/dev/latest/elixir/node_modules/.pnpm/vite-plugin-inspect@0.8.1_@nuxt+kit@3.9.3_vite@5.0.11/node_modules/vite-plugin-inspect/dist/index.mjs:376:26
  at plugin.<computed> (/C:/Users/DELL/Desktop/dev/latest/elixir/node_modules/.pnpm/vite-plugin-inspect@0.8.1_@nuxt+kit@3.9.3_vite@5.0.11/node_modules/vite-plugin-inspect/dist/index.mjs:363:14)
  at /C:/Users/DELL/Desktop/dev/latest/elixir/node_modules/.pnpm/vite-plugin-inspect@0.8.1_@nuxt+kit@3.9.3_vite@5.0.11/node_modules/vite-plugin-inspect/dist/index.mjs:376:26
  at plugin.<computed> (/C:/Users/DELL/Desktop/dev/latest/elixir/node_modules/.pnpm/vite-plugin-inspect@0.8.1_@nuxt+kit@3.9.3_vite@5.0.11/node_modules/vite-plugin-inspect/dist/index.mjs:363:14)
  at Object.transform (/C:/Users/DELL/Desktop/dev/latest/elixir/node_modules/.pnpm/vite@5.0.11_@types+node@18.19.8_sass@1.70.0/node_modules/vite/dist/node/chunks/dep-V3BH7oO1.js:64060:62)
  at process.processTicksAndRejections (node:internal/process/task_queues:95:5)  
  at async loadAndTransform (/C:/Users/DELL/Desktop/dev/latest/elixir/node_modules/.pnpm/vite@5.0.11_@types+node@18.19.8_sass@1.70.0/node_modules/vite/dist/node/chunks/dep-V3BH7oO1.js:49741:29)
  at async viteTransformMiddleware (/C:/Users/DELL/Desktop/dev/latest/elixir/node_modules/.pnpm/vite@5.0.11_@types+node@18.19.8_sass@1.70.0/node_modules/vite/dist/node/chunks/dep-V3BH7oO1.js:59342:32)

 ERROR  Expression expected                                          8:40:49 am  

  at error (/C:/Users/DELL/Desktop/dev/latest/elixir/node_modules/.pnpm/rollup@4.9.6/node_modules/rollup/dist/es/shared/parseAst.js:337:30)
  at parseError (/C:/Users/DELL/Desktop/dev/latest/elixir/node_modules/.pnpm/rollup@4.9.6/node_modules/rollup/dist/es/shared/parseAst.js:972:9)
  at convertNode (/C:/Users/DELL/Desktop/dev/latest/elixir/node_modules/.pnpm/rollup@4.9.6/node_modules/rollup/dist/es/shared/parseAst.js:2057:12)
  at convertProgram (/C:/Users/DELL/Desktop/dev/latest/elixir/node_modules/.pnpm/rollup@4.9.6/node_modules/rollup/dist/es/shared/parseAst.js:965:12)
  at parseAst (/C:/Users/DELL/Desktop/dev/latest/elixir/node_modules/.pnpm/rollup@4.9.6/node_modules/rollup/dist/es/shared/parseAst.js:2104:12)
  at TransformContext.parse (/C:/Users/DELL/Desktop/dev/latest/elixir/node_modules/.pnpm/vite@5.0.11_@types+node@18.19.8_sass@1.70.0/node_modules/vite/dist/node/chunks/dep-V3BH7oO1.js:63681:20)
  at TransformContext.transform (C:/Users/DELL/Desktop/dev/latest/elixir/node_modules/.pnpm/@originjs+vite-plugin-federation@1.3.4/node_modules/@originjs/vite-plugin-federation/dist/index.js:1234:20)
  at TransformContext.transform (C:/Users/DELL/Desktop/dev/latest/elixir/node_modules/.pnpm/@originjs+vite-plugin-federation@1.3.4/node_modules/@originjs/vite-plugin-federation/dist/index.js:1537:74)
  at /C:/Users/DELL/Desktop/dev/latest/elixir/node_modules/.pnpm/vite-plugin-inspect@0.8.1_@nuxt+kit@3.9.3_vite@5.0.11/node_modules/vite-plugin-inspect/dist/index.mjs:376:26
  at plugin.<computed> (/C:/Users/DELL/Desktop/dev/latest/elixir/node_modules/.pnpm/vite-plugin-inspect@0.8.1_@nuxt+kit@3.9.3_vite@5.0.11/node_modules/vite-plugin-inspect/dist/index.mjs:363:14)
  at /C:/Users/DELL/Desktop/dev/latest/elixir/node_modules/.pnpm/vite-plugin-inspect@0.8.1_@nuxt+kit@3.9.3_vite@5.0.11/node_modules/vite-plugin-inspect/dist/index.mjs:376:26
  at plugin.<computed> (/C:/Users/DELL/Desktop/dev/latest/elixir/node_modules/.pnpm/vite-plugin-inspect@0.8.1_@nuxt+kit@3.9.3_vite@5.0.11/node_modules/vite-plugin-inspect/dist/index.mjs:363:14)
  at Object.transform (/C:/Users/DELL/Desktop/dev/latest/elixir/node_modules/.pnpm/vite@5.0.11_@types+node@18.19.8_sass@1.70.0/node_modules/vite/dist/node/chunks/dep-V3BH7oO1.js:64060:62)
  at process.processTicksAndRejections (node:internal/process/task_queues:95:5)  
  at async loadAndTransform (/C:/Users/DELL/Desktop/dev/latest/elixir/node_modules/.pnpm/vite@5.0.11_@types+node@18.19.8_sass@1.70.0/node_modules/vite/dist/node/chunks/dep-V3BH7oO1.js:49741:29)
  at async viteTransformMiddleware (/C:/Users/DELL/Desktop/dev/latest/elixir/node_modules/.pnpm/vite@5.0.11_@types+node@18.19.8_sass@1.70.0/node_modules/vite/dist/node/chunks/dep-V3BH7oO1.js:59342:32)

 ERROR  Expression expected                                          8:40:49 am  

  at error (/C:/Users/DELL/Desktop/dev/latest/elixir/node_modules/.pnpm/rollup@4.9.6/node_modules/rollup/dist/es/shared/parseAst.js:337:30)
  at parseError (/C:/Users/DELL/Desktop/dev/latest/elixir/node_modules/.pnpm/rollup@4.9.6/node_modules/rollup/dist/es/shared/parseAst.js:972:9)
  at convertNode (/C:/Users/DELL/Desktop/dev/latest/elixir/node_modules/.pnpm/rollup@4.9.6/node_modules/rollup/dist/es/shared/parseAst.js:2057:12)
  at convertProgram (/C:/Users/DELL/Desktop/dev/latest/elixir/node_modules/.pnpm/rollup@4.9.6/node_modules/rollup/dist/es/shared/parseAst.js:965:12)
  at parseAst (/C:/Users/DELL/Desktop/dev/latest/elixir/node_modules/.pnpm/rollup@4.9.6/node_modules/rollup/dist/es/shared/parseAst.js:2104:12)
  at TransformContext.parse (/C:/Users/DELL/Desktop/dev/latest/elixir/node_modules/.pnpm/vite@5.0.11_@types+node@18.19.8_sass@1.70.0/node_modules/vite/dist/node/chunks/dep-V3BH7oO1.js:63681:20)
  at TransformContext.transform (C:/Users/DELL/Desktop/dev/latest/elixir/node_modules/.pnpm/@originjs+vite-plugin-federation@1.3.4/node_modules/@originjs/vite-plugin-federation/dist/index.js:1234:20)
  at TransformContext.transform (C:/Users/DELL/Desktop/dev/latest/elixir/node_modules/.pnpm/@originjs+vite-plugin-federation@1.3.4/node_modules/@originjs/vite-plugin-federation/dist/index.js:1537:74)
  at /C:/Users/DELL/Desktop/dev/latest/elixir/node_modules/.pnpm/vite-plugin-inspect@0.8.1_@nuxt+kit@3.9.3_vite@5.0.11/node_modules/vite-plugin-inspect/dist/index.mjs:376:26
  at plugin.<computed> (/C:/Users/DELL/Desktop/dev/latest/elixir/node_modules/.pnpm/vite-plugin-inspect@0.8.1_@nuxt+kit@3.9.3_vite@5.0.11/node_modules/vite-plugin-inspect/dist/index.mjs:363:14)
  at /C:/Users/DELL/Desktop/dev/latest/elixir/node_modules/.pnpm/vite-plugin-inspect@0.8.1_@nuxt+kit@3.9.3_vite@5.0.11/node_modules/vite-plugin-inspect/dist/index.mjs:376:26
  at plugin.<computed> (/C:/Users/DELL/Desktop/dev/latest/elixir/node_modules/.pnpm/vite-plugin-inspect@0.8.1_@nuxt+kit@3.9.3_vite@5.0.11/node_modules/vite-plugin-inspect/dist/index.mjs:363:14)
  at Object.transform (/C:/Users/DELL/Desktop/dev/latest/elixir/node_modules/.pnpm/vite@5.0.11_@types+node@18.19.8_sass@1.70.0/node_modules/vite/dist/node/chunks/dep-V3BH7oO1.js:64060:62)
  at process.processTicksAndRejections (node:internal/process/task_queues:95:5)  
  at async loadAndTransform (/C:/Users/DELL/Desktop/dev/latest/elixir/node_modules/.pnpm/vite@5.0.11_@types+node@18.19.8_sass@1.70.0/node_modules/vite/dist/node/chunks/dep-V3BH7oO1.js:49741:29)
  at async viteTransformMiddleware (/C:/Users/DELL/Desktop/dev/latest/elixir/node_modules/.pnpm/vite@5.0.11_@types+node@18.19.8_sass@1.70.0/node_modules/vite/dist/node/chunks/dep-V3BH7oO1.js:59342:32)

Unable to understand the issue.

My configuration: Host nuxt 3 app:

export default defineNuxtConfig({
  vite: {
    plugins: [
      federation({
        name: 'host-app',
        remotes: {
          remote_app: "http://localhost:5173/assets/remoteEntry.js",
        },
      })
    ]
  },
  experimental: {
    asyncEntry: true
  },
})

Remote: Vue 3 App:

import { fileURLToPath, URL } from 'node:url'

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

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue({
      template: {
        compilerOptions: {
          // treat all tags with a dash as custom elements
          isCustomElement: (tag) => tag.includes('-')
        }
      }
    }),
    federation({
      name: 'remote-app',
      filename: 'remoteEntry.js',
      // Modules to expose
      exposes: {
        './Button': './src/Button.vue',
      },
    })

  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  }
})

remoteEntry.js file is also being generated at http://localhost:5173/assets/remoteEntry.js

Please help!

cheesypeperoni commented 5 months ago

Hello! Did you manage to fix this ? im currently facing this issue as well