Socket
Socket
Sign inDemoInstall

awilix

Package Overview
Dependencies
Maintainers
1
Versions
82
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

awilix - npm Package Versions

1
9

4.0.0

Diff

Changelog

Source

v4.0.0

  • [BREAKING CHANGE]: Scoped containers no longer use the parent's cache for Lifetime.SCOPED registrations (#92)
  • Change the "react-native" module path to use awilix.browser.js (#104)
  • Update packages

Awilix v4 corrects a misunderstanding in how the scoped caching should work. For full context, please see issue #92, but the TL:DR version is that prior v4, scoped registrations (Lifetime.SCOPED / .scoped()) would travel up the family tree and use a parent's cached resolution if there is any. If there is not, the resolving scope would cache it locally.

While this was by design, it was not very useful, and it was designed based on a misunderstanding of how Unity's HierarchicalLifetimeManager works. In v4, Lifetime.SCOPED now works the same way: the container performing the resolution also caches it, not looking outside itself for cached resolutions of Lifetime.SCOPED registrations.

A prime use case for this is having a scoped logger, as well as a root logger. This is actually what prompted this change.

// logger.js
export class Logger {
  constructor(loggerPrefix = 'root') {
    this.prefix = loggerPrefix
  }

  log(message) {
    console.log(`[${this.prefix}]: ${message}`)
  }
}
// app.js
import { Logger } from './logger'
import { createContainer, asClass, InjectionMode } from 'awilix'

const container = createContainer({
  injectionMode: InjectionMode.CLASSIC,
}).register({
  logger: asClass(Logger).scoped(),
})

const scope = container.createScope()
scope.register({
  loggerPrefix: asValue('dope scope'),
})

const rootLogger = container.resolve('logger')
const scopeLogger = scope.resolve('logger')

rootLogger.log('yo!') // [root]: yo!
scopeLogger.log('wassup!') // [dope scope]: wassup!

Prior to v4, the scopeLogger would have resolved to the same as rootLogger because it would ask it's ancestors if they had a logger cached. Now it works as you would probably expect it to: it keeps it's own cache.

jeffijoe
published 3.0.9 •

Changelog

Source

v3.0.9

  • Updated packages.
jeffijoe
published 3.0.8 •

Changelog

Source

v3.0.8

  • Add support for parsing async and generator functions; these no longer break the parser. (#90)
  • Update dependencies.
jeffijoe
published 3.0.7 •

Changelog

Source

v3.0.7

  • Skip code comments in parser (#87)
  • Make the parser smarter by including full member expression paths so we get less false positives when scanning for the constructor token.
jeffijoe
published 3.0.6 •

Changelog

Source

v3.0.6

  • Update container.cradle typing to be any (#83, Ackos95)
jeffijoe
published 3.0.5 •

Changelog

Source

v3.0.5

  • Updated dependencies
  • Fix TS 2.7 compilation issue
  • Fix the GlobWithOptions type to include LifetimeType
jeffijoe
published 3.0.4 •

Changelog

Source

v3.0.4

  • Fix #76: don't overwrite declarations when building with Rollup.
jeffijoe
published 3.0.3 •

Changelog

Source

v3.0.3

jeffijoe
published 3.0.2 •

Changelog

Source

v3.0.2

  • Updated packages, fix an internal typing issue as a result of updated typings.
jeffijoe
published 3.0.1 •

Changelog

Source

v3.0.1

  • Use Reflect.construct() instead of new internally; fixes TS transpilation issue.
  • Add note on browser support to README.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc