Skip to content

Unsupported type in webpack 5 #105

@RomainGaillardLesEchos

Description

@RomainGaillardLesEchos

We are facing this issue (webpack 5):

export default function config(): Configuration {
  return {
    ...,
    externals: [
      nodeExternals({
        modulesDir: path.resolve(__dirname, 'node_modules'),
        allowlist: ['@services/shared'],
      }),
    ],
  };
}
Type 'ExternalsFunctionElement[]' is not assignable to type 'string | RegExp | (ExternalItemObjectKnown & ExternalItemObjectUnknown) | ExternalItem[] | ((data: ExternalItemFunctionData, callback: (err?: Error | undefined, result?: string | ... 3 more ... | undefined) => void) => void) | ((data: ExternalItemFunctionData) => Promise<...>) | undefined'.
  Type 'ExternalsFunctionElement[]' is not assignable to type 'ExternalItem[]'.
    Type 'ExternalsFunctionElement' is not assignable to type 'ExternalItem'.
      Type 'ExternalsFunctionElement' is not assignable to type '(data: ExternalItemFunctionData, callback: (err?: Error | undefined, result?: string | boolean | string[] | { [index: string]: any; } | undefined) => void) => void'.ts(2322)

types.d.ts(1977, 2): The expected type comes from property 'externals' which is declared here on type 'Configuration'

Type Configuration is provided by webpack version ^5.36.2 and webpack-node-externals version ^3.0.0

Any idea ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions