Skip to content

Improve handling of ESM default exports

Choose a tag to compare

@thetutlage thetutlage released this 26 May 11:39

The IoC container now treats ESM exports as first class citizens and handles them in the following ways

ESM default export

export default class Foo {}
ioc.make('Path/To/Foo/Module') // Foo instance
export default class Foo {}
ioc.use('Path/To/Foo/Module') // Foo class
export default class Foo {}
ioc.useEsm('Path/To/Foo/Module') // { default: Foo }

Also, the fakes are limited to work with default exports. Named exports cannot be faked using ioc.fake

  • refactor: cleaning up handling of esm default exports 57bee2b

v6.0.1...v6.0.2