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

fix(dts-plugin): use cwd to create Module Federation tsconfig #3381

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

nachoaldamav
Copy link
Contributor

Description

This PR changes the directory to generate the .federated/tsconfig.${hash}.json to use the user specified cwd. This fixes issues with Typescript not being able to find packages specified in the tsconfig types' property.

Related Issue

#3338

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have updated the documentation.

Copy link

changeset-bot bot commented Dec 19, 2024

🦋 Changeset detected

Latest commit: f93c4c3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 29 packages
Name Type
@module-federation/dts-plugin Patch
@module-federation/enhanced Patch
@module-federation/manifest Patch
@module-federation/rspack Patch
@module-federation/modern-js Patch
@module-federation/nextjs-mf Patch
@module-federation/node Patch
@module-federation/rsbuild-plugin Patch
@module-federation/storybook-addon Patch
@module-federation/modernjsapp Patch
@module-federation/runtime Patch
@module-federation/webpack-bundler-runtime Patch
@module-federation/sdk Patch
@module-federation/runtime-tools Patch
@module-federation/managers Patch
@module-federation/third-party-dts-extractor Patch
@module-federation/devtools Patch
@module-federation/bridge-react Patch
@module-federation/bridge-vue3 Patch
@module-federation/bridge-shared Patch
@module-federation/bridge-react-webpack-plugin Patch
@module-federation/retry-plugin Patch
@module-federation/data-prefetch Patch
@module-federation/error-codes Patch
@module-federation/inject-external-runtime-core-plugin Patch
@module-federation/esbuild Patch
@module-federation/runtime-core Patch
@module-federation/utilities Patch
website-new Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

netlify bot commented Dec 19, 2024

Deploy Preview for module-federation-docs ready!

Name Link
🔨 Latest commit f93c4c3
🔍 Latest deploy log https://app.netlify.com/sites/module-federation-docs/deploys/677485ff9e55540008d47cd3
😎 Deploy Preview https://deploy-preview-3381--module-federation-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@ScriptedAlchemy ScriptedAlchemy marked this pull request as ready for review December 19, 2024 22:26
@ScriptedAlchemy ScriptedAlchemy requested a review from 2heal1 January 1, 2025 00:02
@2heal1
Copy link
Member

2heal1 commented Jan 2, 2025

the context is passed from compiler.context , which value is equal the cwd . So i don't know which cases will be crashed .

Can you help provide the reproduce repo that i can check if this is something i miss.

@nachoaldamav
Copy link
Contributor Author

@2heal1 This issue happens when the CWD is not the same one the code is placed at.

- /home/nacho
     - /CWD
- /tmp
     - /my-code

This is the code that appears when running tsc manually from the CWD. If the Federation TSConfig is placed in the /tmp... directory, it works, as it's able to find the missing packages.

root@PC-Nacho ~/L/C/B/c/6/frontend.module-federation_react_producer@14781b4e0abfed997de62ad25272142930a4f71f# npx tsc --project /tmp/sign-modfed-webpack/node_modules/.federation/tsconfig.9db31af3488c5a510fca4aaf7547c4ce.json
error TS2688: Cannot find type definition file for '@testing-library/jest-dom'.
  The file is in the program because:
    Entry point of type library '@testing-library/jest-dom' specified in compilerOptions

  ../../../../../../../tmp/sign-modfed-webpack/node_modules/.federation/tsconfig.9db31af3488c5a510fca4aaf7547c4ce.json:22:7
    22       "@testing-library/jest-dom"
             ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    File is entry point of type library specified here.

error TS2688: Cannot find type definition file for 'vitest/globals'.
  The file is in the program because:
    Entry point of type library 'vitest/globals' specified in compilerOptions

  ../../../../../../../tmp/sign-modfed-webpack/node_modules/.federation/tsconfig.9db31af3488c5a510fca4aaf7547c4ce.json:21:7
    21       "vitest/globals",
             ~~~~~~~~~~~~~~~~
    File is entry point of type library specified here.


Found 2 errors.

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

Successfully merging this pull request may close these issues.

3 participants