WJSoftware / vite-plugin-single-spa

Vite plugin to convert Vite-based projects to single-spa root or micro-frontend applications.
MIT License
61 stars 4 forks source link

Single-spa types not exported with plugin #80

Closed amalvivek closed 8 months ago

amalvivek commented 8 months ago

I am seeing the following issue when I integrate the plugin to my root app. I am not certain however I think this github issue on single-spa could be related to the problem I am seeing.

image

Vue: Could not find a declaration file for module single-spa. ./node_modules/single-spa/lib/es2015/esm/single-spa.min.js implicitly has an any type. There are types at ./node_modules/single-spa/typings/single-spa.d.ts , but this result could not be resolved when respecting package.json exports. The single-spa library may need to update its package.json or typings.

Project type: [x ] Root Config [ ] Micro-frontend/parcel Project Framework: [ ] React [ ] Svelte [ x] Vue [ ] Preact [ ] Other:

My vite config:

import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vitePluginSingleSpa from 'vite-plugin-single-spa';

export default defineConfig({
  plugins: [vue(), vitePluginSingleSpa({
    type: 'root',
    imo: '3.1.1'
  })],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  }
})
webJose commented 8 months ago

Hello, @amalvivek. Those are functions that are provided within the single-spa NPM package, not this package. This package doesn't ship single-spa and merely has it as a peer dependency.

amalvivek commented 8 months ago

Ah apologies!

webJose commented 8 months ago

No problem. FYI, single-spa v7 will be out with better typing. For now, you'll have to deal with the current types single-spa provides. If you get in trouble like this, you could use TS tricks like the @ts-expect-error comment.