webpack-node-externals icon indicating copy to clipboard operation
webpack-node-externals copied to clipboard

importType option misses some type definitions.

Open mrdulin opened this issue 2 years ago • 2 comments

Try to pass 'module' to importType option

externals: [nodeExternals({ importType: 'module' })],

Got error:

Type '"module"' is not assignable to type '"var" | "this" | "commonjs" | "amd" | "umd" | ImportTypeCallback | undefined'.ts(2322)

Below is the TS type definition of importType option

/**
 * The method in which unbundled modules will be required in the code. Best to leave as
 * 'commonjs' for node modules.
 * @default 'commonjs'
 */
importType?: 'var' | 'this' | 'commonjs' | 'amd' | 'umd' | ImportTypeCallback | undefined;

Expected:

All external types should be supported.

The above configuration works at runtime.

Version information:

"webpack": "^5.80.0",
"@types/webpack": "^5.28.1",
"webpack-node-externals": "^3.0.0"

mrdulin avatar Jul 27 '23 09:07 mrdulin

Hello @mrdulin

The issue has been fixed in version ^3.0.1. Try do update @types/webpack-node-externals to the latest version and see if it works.

tobiaszpiwowarczyk avatar Sep 16 '23 10:09 tobiaszpiwowarczyk

@tobiaszpiwowarczyk Thanks.

mrdulin avatar Sep 19 '23 01:09 mrdulin