-
Notifications
You must be signed in to change notification settings - Fork 135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Awilix v3 Release Candidate π #64
Comments
Will do ASAP! π |
I think I have an issue, it seems some files are not included. |
@Seldszar oh damn, forgot to update the publish script to include a build step haha, gimme a sec! |
@Seldszar |
Perfect! |
#67 has been moved to jeffijoe/awilix-koa#3 β thanks @ith! |
Awilix v3 is now on npm - thank you all for your input! π |
I've pushed
awilix@3.0.0-rc.6
to npm which has a few breaking changes for JS users and a few more for TS users (new, better typings as v3 is now written in TypeScript).Please try it out so I can ship it as stable ASAP!
β¨ New Features
With v3 comes a few new cool features.
Disposer support (#48)
This has been a very requested feature. The idea is you can tell Awilix how to dispose
of a dependencyβfor example, to close a database connectionβwhen calling
container.dispose()
.alias
resolver (#55)This new resolver lets you alias a registration. This is best illustrated with an example:
It's essentially the exact same as calling
container.resolve('laughingOutLoad')
, butlol
might be easier to type out in your constructors. πDefault values in constructors/functions (#46)
This is a pretty small feature but was the most difficult to land, mainly because I had to write a smarter parser and tokenizer, not to mention they are now way better at skipping over code. Check out the tests, it's pretty wild.
Official support for running in the browser (#69)
Awilix now ships with 4 module flavors: CommonJS (same old), ES Modules for Node, ES Modules for the Browser and UMD.
Please see the Universal Module section in the readme for details.
π¨ Known breaking changes
The following is a list of known breaking changes. If there's any I've missed feel free to let me know.
The entire library is now written in TypeScript! (#49)
This means a bunch of interfaces have been renamed and made more correct.
If you're a TypeScript user, this is great news for you. π
ResolutionMode
is nowInjectionMode
(#57)ResolutionMode.js
renamed toinjection-mode.ts
ResolutionMode
renamed toInjectionMode
"Registrations" are now "Resolvers" (#51)
The terminology is now "you register a resolver to a name".
REGISTRATION
symbol renamed toRESOLVER
registrations.js
renamed toresolvers.ts
registrationOptions
inloadModules
renamed toresolverOptions
registerClass
,registerFunction
andregisterValue
removed (#60)This was done to simplify the API surface, and also simplifies the implementation greatly (less overloads). You should be using
container.register
withasClass
,asFunction
andasValue
instead.Resolver configuration chaining API is now immutable (#62)
This simplifies the TypeScript types and is also considered a good practice. All configuration functions rely on
this
, meaning you should not do:However, this also means you can now "split" a resolver to configure it differently. For example:
Removed
AwilixNotAFunctionError
in favor of a genericAwilixTypeError
(#52)This should not have an impact on userland code but I thought I'd mention it.
There are a bunch of internal uses of this error, so I thought it made sense to consolidate them into one error type.
π Other cool changes
husky
+lint-staged
to lint, format and test every commit to ensure top code quality.Please give it whirl and let me know how it goes! I'll update the changelog once stable ships.
/cc @ddproxy @cjhoward92 @blove @cikasfm @Seldszar
The text was updated successfully, but these errors were encountered: