typescript icon indicating copy to clipboard operation
typescript copied to clipboard

Failed to fetch types when types are published to a nested folder

Open joeheyming opened this issue 3 years ago • 1 comments
trafficstars

In my project, I am publishing my remoteEntry.js and types to a subfolder: e.g. https://mysite/common/remoteEntry.js and https://mysite/common/@mf-typescript/

But the code here https://github.com/module-federation/typescript/blob/main/src/index.js#L53 assumes we only want the origin of the remote. But we kind of need the origin and any base path. Is it possible to introduce a config for this plugin to add a basepath to all type fetching?

joeheyming avatar Sep 01 '22 18:09 joeheyming

I was able to get around this by setting devServer.static.directory, i.e. https://github.com/module-federation/typescript/blob/main/src/index.js#L22, in webpack.client.js to the root output, this would move it out of the normal sub-directory it would output it to. For example, the normal output for my build would be ./dist/client/ where all my client side MF code would exist. When I set devServer.static.directory to ./dist it would output @mf-typescript to ./dist/ instead of ./dist/client/. However it doesn't change actually wanting the host to request from the sub-directory, it just makes it available to be consumed correctly from the remote

arecvlohe avatar Oct 03 '22 17:10 arecvlohe