single-spa / single-spa-react

Single-spa lifecycles helper for React applications
https://single-spa.js.org/docs/ecosystem-react.html
MIT License
227 stars 63 forks source link

package.json exports when using moduleResolution node16 #170

Closed webdeveric closed 11 months ago

webdeveric commented 1 year ago

When using moduleResolution: "node16" in tsconfig.json, the current package.json exports are not enough and TypeScript complains with:

Could not find a declaration file for module 'single-spa-react'. '.../node_modules/single-spa-react/lib/esm/single-spa-react.js' implicitly has an 'any' type. Try npm i --save-dev @types/single-spa-react if it exists or add a new declaration (.d.ts) file containing declare module 'single-spa-react';

I manually edited your package.json in the node_modules folder and this config makes the error go away.

{
  "exports": {
    ".": {
      "import": {
        "types": "./types/single-spa-react.d.ts",
        "default": "./lib/esm/single-spa-react.js"
      },
      "require": {
        "types": "./types/single-spa-react.d.ts",
        "default":"./lib/cjs/single-spa-react.cjs"
      }
    },
    "./parcel": {
      "import": {
        "types": "./types/single-spa-react.d.ts",
        "default": "./lib/esm/parcel.js"
      },
      "require": {
        "types": "./types/single-spa-react.d.ts",
        "default":"./lib/cjs/parcel.cjs"
      }
    },
    "./package.json": "./package.json"
  }
}
awx-josh-fu commented 1 year ago

Hi, what's the progress? I see there was a PR raised, but for what reason it's not yet merged?

MilanKovacic commented 1 year ago

Hi, thank you for reporting the issue. We are waiting for additional changes before merging the PR.

MilanKovacic commented 1 year ago

I have opened a pull request #197 that will solve the problems. Feel free to help with testing it.