question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Typescript] Next.js Error fetching types - not exposed by remote app

See original GitHub issue

Migrating this issue over now that the typescript package is located in this repo: https://github.com/module-federation/typescript/issues/25

Essentially, @mf-typescript is being written to .next as that is the output path for Next.js apps, but .next is not being publicly served so any app which wants to download the types from /@mf-typescript/__types_index.json will get a 404.

My suggestion is to output the types to public instead but @pavandv suggests he knows why and has a fix in mind?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
Kinbaumcommented, Oct 5, 2022

@hongkiulam @pavandv I am working on a solution that will allow you to specify the location of the __types_index.json for each remote as you will have situations like described above when mixing various Next and non-Next applications.

For the time being, you can get around this issue by adding the following to your webpack configuration:

config.devServer = {
    static: {
        directory: path.resolve(__dirname, 'public')
    }
};
1reaction
hongkiulamcommented, Oct 14, 2022

After this got merged in https://github.com/module-federation/nextjs-mf/pull/302, types are now looked up at /_next/static/chunks/@mf-typescript/__types_index.json.

So the new workaround should be

config.devServer = {
    static: {
        directory: path.resolve(__dirname, '_next/static/chunks')
    }
};
Read more comments on GitHub >

github_iconTop Results From Across the Web

Ignoring TypeScript Errors - next.config.js
Next. js fails your production build ( next build ) when TypeScript errors are present in your project. If you'd like Next.
Read more >
Internal API fetch with getServerSideProps? (Next.js)
The reason I'm not doing the required calculations for home.js in the API route itself is that I need more generic data from...
Read more >
Fetching and hydrating a Next.JS app using ... - Medium
When your app needs to process data from an external source (as in a fetch for a remote JSON file) you have two...
Read more >
Creating a Project with Nest.js + Next.js - DEV Community ‍ ‍
Open localhost:3000 in your browser and you will see a 404. Which is unexpected since we have both a controller and a NEXT.js...
Read more >
How typesafe can a remote be with Typescript? #20 - GitHub
As the remote var does not have type, I don't see a way to ... Are your exposes objects exposed as standard javascript/typescript...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found