Skip to content

Breaking API change (improved imports).

Choose a tag to compare

@pcafstockf pcafstockf released this 07 Aug 00:00
· 40 commits to master since this release

This release aims to shorten and simplify imports from async-injection.

A design goal of this project has always been to provide a minimal API surface of the most commonly used classes from index.ts, but still allow you to import less frequently used functionality from submodules.
However, due to the way the dual module cjs/esm support was done, submodule imports looked ugly, and while they worked, they could also be somewhat misleading.

import {INJECTABLE_METADATA_KEY} from 'async-injection/lib/cjs/constants';
// The above works even in an esm project!

This release moves the TypeScript typedefs up from inside lib/cjs/* and lib/esm/* to just lib/*.d.ts (and adds a ./* export in package.json).

Put simply in code, you can now just write:

import {INJECTABLE_METADATA_KEY} from 'async-injection/constants';

The interfaces in binder.ts turned out to be rarely used, so that submodule export has been dropped from index.ts. You can of course still import any of them using a submodule reference (e.g. 'async-injection/binder').

Ultimately the underlying JavaScript code is unchanged, but hopefully these typing changes will make things a little easier and more intuitive.