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

module federation not loading properly #9304

Open
XRFate opened this issue Nov 14, 2024 · 3 comments
Open

module federation not loading properly #9304

XRFate opened this issue Nov 14, 2024 · 3 comments
Labels

Comments

@XRFate
Copy link

XRFate commented Nov 14, 2024

Describe the bug

I forked module-federation producer's code, i tried to run it. It shows error when i open the browser which leads futher to module-federation malfunctioning.

 Unable to compile federated types, Error: compile TS failed, the original command is 'npx tsc --project C:\Users\oxyge\Project\bit-test\node_modules\.federation\tsconfig.6672be0bbb0f849d6702396f5c138c39.json'
Error: ENOENT: no such file or directory, open 'C:\Users\oxyge\Project\bit-test\node_modules\.cache\dist\@mf-types.zip'

STEPS

  1. I have tried to track it down, it somehow related to tsconfig with bit installs
  2. first it reads from config from .federation/tsconfig.{hash}.json
 {
  "extends": "C:\\Users\\oxyge\\Project\\bit-test\\tsconfig.json",
  "compilerOptions": {
    "typeRoots": [
      "./node_modules/.cache/global-types",
      "./node_modules/@types"
    ],
    "rootDir": "C:/Users/oxyge/Project/bit-test",
    "emitDeclarationOnly": true,
    "noEmit": false,
    "declaration": true,
    "outDir": "C:\\Users\\oxyge\\Project\\bit-test\\node_modules\\.cache\\dist\\@mf-types\\compiled-types"
  },
  "compileOnSave": false,
  "include": [],
  "exclude": [],
  "files": [
    "C:\\Users\\oxyge\\Project\\bit-test\\node_modules\\.bit_roots\\remote-scope_react_producer\\node_modules\\@remote-scope\\react.producer\\dist\\button.js",
    "C:/Users/oxyge/Project/bit-test/node_modules/.cache/global-types/asset.567ee21978cbce56ebd1a166885c6d74665e7d8f.d.ts",
    "C:/Users/oxyge/Project/bit-test/node_modules/.cache/global-types/env.b1403ffa9ba63713e98251b169862054caeb48ec.d.ts",
    "C:/Users/oxyge/Project/bit-test/node_modules/.cache/global-types/style.b31200bf25de0be451df15ad5c78e4e81a227cae.d.ts"
  ]
} 
  1. then it links to tsconfig.json under root
// bit-generated-typescript-config
{
  "extends": "./node_modules/.cache/tsconfig.bit.754597940e9abfd8eacb085e29f60aeb341bb92f.json",
  "compilerOptions": {
    "typeRoots": [
      "./node_modules/.cache/global-types",
      "./node_modules/@types"
    ]
  }
}  
  1. the root config solves a cached config looks like
{
  "compilerOptions": {
    "lib": [
      "esnext",
      "dom",
      "dom.Iterable"
    ],
    "target": "es2020",
    "module": "NodeNext",
    "jsx": "react-jsx",
    "declaration": true,
    "sourceMap": true,
    "experimentalDecorators": true,
    "skipLibCheck": true,
    "moduleResolution": "NodeNext",
    "esModuleInterop": true,
    "resolveJsonModule": true,
    "allowJs": true,
    "outDir": "./dist",
    "types": [
      "C:\\Users\\oxyge\\Project\\bit-test\\node_modules\\vitest\\globals",
      "C:\\Users\\oxyge\\Project\\bit-test\\node_modules\\@testing-library\\jest-dom"
    ],
    "rootDir": "../.."
  },
  "exclude": [
    "..\\..\\react\\examples\\vite-app/**/*.cjs",
    "..\\..\\react\\examples\\vite-app/./dist",
    "..\\..\\react\\examples\\vite-app/artifacts",
    "..\\..\\react\\examples\\vite-app/dist",
    "..\\..\\react\\examples\\vite-app/node_modules",
    "..\\..\\react\\examples\\vite-app/package.json",
    "..\\..\\react\\examples\\vite-app/public",
    "..\\..\\remote-scope\\hell-world/**/*.cjs",
    "..\\..\\remote-scope\\hell-world/./dist",
    "..\\..\\remote-scope\\hell-world/artifacts",
    "..\\..\\remote-scope\\hell-world/dist",
    "..\\..\\remote-scope\\hell-world/node_modules",
    "..\\..\\remote-scope\\hell-world/package.json",
    "..\\..\\remote-scope\\hell-world/public",
    "..\\..\\remote-scope\\test-app/**/*.cjs",
    "..\\..\\remote-scope\\test-app/./dist",
    "..\\..\\remote-scope\\test-app/artifacts",
    "..\\..\\remote-scope\\test-app/dist",
    "..\\..\\remote-scope\\test-app/node_modules",
    "..\\..\\remote-scope\\test-app/package.json",
    "..\\..\\remote-scope\\test-app/public"
  ],
  "include": [
    "../../react/examples/vite-app/**/*",
    "../../react/examples/vite-app/**/*.json",
    "../../remote-scope/hell-world/**/*",
    "../../remote-scope/hell-world/**/*.json",
    "../../remote-scope/test-app/**/*",
    "../../remote-scope/test-app/**/*.json",
    "./global-types/**/*"
  ]
} 

And this is where the type error the resolves in the context

error TS5058: The specified path does not exist: 'C:\Users\oxyge\Project\bit-test\node_modules\.federation\tsconfig.329502d679b482abca3caf2e93d2a425.json'npx tsc --project C:\Users\oxyge\Project\bit-test\node_modules\.federation\tsconfig.6672be0bbb0f849d6702396f5c138c39.json
error TS2688: Cannot find type definition file for 'C:\Users\oxyge\Project\bit-test\node_modules\@testing-library\jest-dom'.
  The file is in the program because:
    Entry point of type library 'C:\Users\oxyge\Project\bit-test\node_modules\@testing-library\jest-dom' specified in compilerOptions

error TS2688: Cannot find type definition file for 'C:\Users\oxyge\Project\bit-test\node_modules\vitest\globals'.     
  The file is in the program because:
    Entry point of type library 'C:\Users\oxyge\Project\bit-test\node_modules\vitest\globals' specified in compilerOptions
@XRFate
Copy link
Author

XRFate commented Nov 14, 2024

Apparently, the corrupted dependencies was brought by example vite app after forking it.

@itaymendel
Copy link
Contributor

itaymendel commented Nov 14, 2024

hi, please provide with steps to reproduce the issue.

  1. which commands did you ran, as we need full steps to reproduce the error
  2. what version of bit you use

@XRFate
Copy link
Author

XRFate commented Nov 14, 2024

bit version is 1.8.68
i can't remember exactly, but should be similar

bit import bitdev.react/examples/vite-app
bit import frontend.module-federation/react/producer
bit fork examples/vite-app
bit fork react/producer
bit install 
bit run react/producer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants