module-federation / core

Module Federation is a concept that allows developers to share code and resources across multiple JavaScript applications
https://module-federation.io/
MIT License
1.27k stars 182 forks source link

dts for entries exposed with aliases are not emitting #2671

Open smelukov opened 6 days ago

smelukov commented 6 days ago

Describe the bug

DTS for exposed entries does not emit If we're using an alias in there entries

import * as path from "node:path";
import {ModuleFederationPlugin} from "@module-federation/enhanced";

export default {
    resolve: {
        alias: {
            foo: path.resolve(__dirname, 'src/sub/foo') // here is an alias for foo
        }
    },
    plugins: [
        new ModuleFederationPlugin({
            exposes: {
                './foo': 'foo', // ❌ not working (no dts created for src/sub/foo), even if it's an existing alias
                // './foo': './src/sub/foo', // ✅ works fine
                './bar': './src/bar'
            },
        })
    ]
}

Reproduction

https://github.com/smelukov/mf-dts-alias-bug/blob/main/webpack.config.ts#L16

Used Package Manager

npm

System Info

...

Validations

ScriptedAlchemy commented 2 days ago

Alias is not analyzed. DTS does not use webpack resolvers to extract types. Its just tsc, not actually part of the compile AFIK

@2heal1 is it possible to support resolve alias in dts extraction?