Giter Site home page Giter Site logo

ivandotv / pumpit Goto Github PK

View Code? Open in Web Editor NEW
23.0 2.0 2.0 732 KB

PumpIt is a small (~2KB) dependency injection container without the decorators, suitable for the browser.

License: MIT License

JavaScript 0.24% TypeScript 99.76%
dependency-injection dependency-injection-container dependency-inversion ioc ioc-container

pumpit's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Awaiting Schedule

These updates are awaiting their schedule. Click on a checkbox to get an update now.

  • Update pnpm/action-setup action to v4

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Ignored or Blocked

These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.

Detected dependencies

github-actions
.github/workflows/CI.yml
  • actions/checkout v4
  • actions/setup-node v4
  • pnpm/action-setup v3.0.0
  • actions/cache v3
  • changesets/action v1
npm
package.json
  • @biomejs/biome 1.5.3
  • @changesets/cli ^2.27.1
  • @vitest/coverage-v8 ^1.3.1
  • lefthook ^1.6.5
  • microbundle ^0.15.1
  • shx ^0.3.4
  • typedoc ^0.25.10
  • typedoc-plugin-markdown ^3.17.1
  • typescript ^5.3.3
  • vitest ^1.3.1

  • Check this box to trigger a request for Renovate to run again on this repository

Implement validate dependencies method

Implement a method that will validate all the dependencies in the container (confirm that all dependencies can be resolved and instantiated)
This will effectively prevent runtime resolve errors.

Dependency inversion principle in bindClass

Hi, I am not very good with english, but i will try to express me. I am using this library with qwik.js because It does not support with decorators (for example, qwik.js with inversify.js). It is a very good library for this use case. the problem is that i use the SOLID principe "Dependency inversion principle" https://en.wikipedia.org/wiki/Dependency_inversion_principle and i need to use the bindClass's generic with interfaces, but it is not working. I am using my solution for this problem:

import type { BindKey, ClassOptions } from "pumpit";
import { PumpIt } from "pumpit";
import { UserRepository } from "./domain"
import { UserMongolRepository } from "./repository"

type Instanciable<T> =
  | { new (...arg: any[]): T }
  | { new (...arg: any[]): T; inject?: Inject };

type BindOptions<T> = Omit<
  Partial<
    ClassOptions<
      Instanciable<T>,
      "SINGLETON" | "TRANSIENT" | "REQUEST" | "CONTAINER_SINGLETON"
    >
  >,
  "type"
>;

class IoC extends PumpIt {
  bind = <T>(
    key: BindKey,
    value: Instanciable<T>,
    options?: BindOptions<T>
  ) => {
    return super.bindClass(key, value, options);
  };
}

export const container = new IoC();
container.bind<UserRepository>("TOKEN_REPOSITORY", UserMongoRepository);

can you add this features in your library? thanks for reading this

Support --moduleResolution node16 in typescript

Hi! I'm really liking this library! Thank you for your work.
I use moduleResolution of node16 in my project, and can't import it without errors.
image

Then I edit package.json in node_modules

...

  "umd:main": "./dist/prod/index.umd.js",
  "exports": {
    "require": "./dist/prod/index.cjs",
    "default": "./dist/prod/index.modern.js",
+   "types": "./src/index.ts"
  },
  "types": "./dist/types/index.d.ts",
...

But the source files is containing imports without .js extension, so there's other error

image

And last thing I tried is providing url to .d.ts file in exports:

...

  "umd:main": "./dist/prod/index.umd.js",
  "exports": {
    "require": "./dist/prod/index.cjs",
    "default": "./dist/prod/index.modern.js",
-   "types": "./src/index.ts"
+   "types": "./dist/types/index.d.ts"
  },
  "types": "./dist/types/index.d.ts",
...

But it also didn't work.
image

Without extensions it just doesn't reexport types in index.d.ts

image

I think the best solution for this problem is providing extensions for import paths and providing type's path to index.d.ts file in exports. What do you think?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.