New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@wessberg/di-compiler

Package Overview
Dependencies
Maintainers
0
Versions
95
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wessberg/di-compiler - npm Package Compare versions

Comparing version 3.3.0 to 4.0.0-beta.1

dist/chunk-AICTSNDO.cjs

2

LICENSE.md
The MIT License (MIT)
Copyright © 2023 [Frederik Wessberg](mailto:frederikwessberg@hotmail.com) ([@FredWessberg](https://twitter.com/FredWessberg)) ([Website](https://github.com/wessberg))
Copyright © 2024 [Frederik Wessberg](mailto:frederikwessberg@hotmail.com) ([@FredWessberg](https://twitter.com/FredWessberg)) ([Website](https://github.com/wessberg))

@@ -5,0 +5,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy

{
"name": "@wessberg/di-compiler",
"version": "3.3.0",
"description": "A Custom Transformer for Typescript that enables compile-time Dependency Injection",
"scripts": {
"generate:sandhog": "sandhog all --yes",
"generate:changelog": "standard-changelog --first-release",
"generate:all": "pnpm run generate:sandhog && pnpm run generate:changelog",
"clean": "rimraf dist",
"lint": "tsc --noEmit && eslint \"src/**/*.ts\" --color",
"prettier": "prettier --write \"{src,test,documentation}/**/*.{js,ts,json,html,xml,css,md}\"",
"test": "cross-env NODE_NO_WARNINGS=1 FORCE_COLOR=3 NODE_OPTIONS=\"--loader=tsx --max_old_space_size=6144\" ava",
"prebuild": "pnpm run clean",
"build": "pnpm run prebuild && pnpm run rollup",
"prewatch": "pnpm run clean",
"watch": "pnpm run prewatch && pnpm run rollup:watch",
"rollup": "rollup -c rollup.config.mjs",
"rollup:watch": "rollup -c rollup.config.mjs --watch",
"preversion": "pnpm run lint && pnpm run build",
"version": "pnpm run preversion && pnpm run generate:all && git add .",
"release": "np --no-cleanup --no-yarn",
"update:check": "pnpx npm-check-updates -x typescript-* --dep dev,prod",
"update:commit": "pnpx npm-check-updates -u -x typescript-* --dep dev,prod && pnpm update && pnpm install"
},
"keywords": [
"DI",
"dependency injection",
"ioc",
"inversion",
"service",
"container",
"newable",
"reflection",
"singleton",
"transient",
"compiler"
],
"files": [
"dist/**/*.*",
"loader.*",
"ts-node-loader.*"
],
"contributors": [
{
"name": "Frederik Wessberg",
"email": "frederikwessberg@hotmail.com",
"url": "https://github.com/wessberg",
"imageUrl": "https://avatars2.githubusercontent.com/u/20454213?s=460&v=4",
"role": "Lead Developer",
"twitter": "FredWessberg",
"github": "wessberg"
}
],
"license": "MIT",
"devDependencies": {
"@types/node": "^20.4.7",
"@types/prettier": "^2.7.3",
"@types/semver": "^7.5.0",
"@typescript-eslint/eslint-plugin": "^6.2.1",
"@typescript-eslint/parser": "^6.2.1",
"eslint-plugin-deprecation": "1.5.0",
"@wessberg/ts-config": "^4.0.0",
"@wessberg/prettier-config": "^1.0.0",
"@prettier/sync": "0.3.0",
"rollup-plugin-ts": "^3.4.1",
"semver": "^7.5.4",
"ava": "^5.3.1",
"cross-env": "^7.0.3",
"eslint": "^8.46.0",
"eslint-config-prettier": "^8.10.0",
"eslint-plugin-import": "^2.28.0",
"eslint-plugin-jsdoc": "^46.4.5",
"husky": "^8.0.3",
"np": "^8.0.4",
"pnpm": "^8.6.11",
"prettier": "^3.0.1",
"pretty-quick": "^3.1.3",
"rimraf": "^5.0.1",
"rollup": "^3.27.1",
"sandhog": "^2.0.2",
"standard-changelog": "^3.0.0",
"tsx": "^3.12.7",
"npm-check-updates": "^16.10.17",
"@esbuild-kit/esm-loader": "^2.5.5",
"typescript": "^5.1.6",
"typescript-3-4-1": "npm:typescript@3.4.1",
"typescript-3-5-1": "npm:typescript@3.5.1",
"typescript-3-6-2": "npm:typescript@3.6.2",
"typescript-3-7-2": "npm:typescript@3.7.2",
"typescript-3-8-3": "npm:typescript@3.8.3",
"typescript-3-9-2": "npm:typescript@3.9.2",
"typescript-4-0-3": "npm:typescript@4.0.3",
"typescript-4-1-2": "npm:typescript@4.1.2",
"typescript-4-2-4": "npm:typescript@4.2.4",
"typescript-4-3-5": "npm:typescript@4.3.5",
"typescript-4-4-2": "npm:typescript@4.4.2",
"typescript-4-5-4": "npm:typescript@4.5.4",
"typescript-4-6-4": "npm:typescript@4.6.4",
"typescript-4-7-2": "npm:typescript@4.7.2",
"typescript-4-8-2": "npm:typescript@4.8.2",
"typescript-4-9-4": "npm:typescript@4.9.4",
"typescript-5-0-4": "npm:typescript@5.0.4"
},
"dependencies": {
"crosspath": "^2.0.0",
"helpertypes": "^0.0.19",
"pirates": "^4.0.6",
"get-tsconfig": "^4.6.2",
"ts-evaluator": "^1.1.0",
"compatfactory": "^3.0.0"
},
"peerDependencies": {
"typescript": ">=3.x || >= 4.x || >= 5.x"
},
"repository": {
"type": "git",
"url": "https://github.com/wessberg/di-compiler.git"
},
"bugs": {
"url": "https://github.com/wessberg/di-compiler/issues"
},
"exports": {
"./loader": {
"import": "./dist/esm/loader.js",
"require": "./dist/cjs/loader.cjs"
},
"./ts-node-loader": {
"require": "./ts-node-loader.cjs"
},
".": {
"import": "./dist/esm/index.js",
"require": "./dist/cjs/index.cjs",
"types": "./dist/esm/index.d.ts"
}
},
"type": "module",
"types": "./dist/esm/index.d.ts",
"main": "./dist/cjs/index.cjs",
"module": "./dist/esm/index.js",
"engines": {
"node": ">=16.15.1"
},
"prettier": "@wessberg/prettier-config",
"ava": {
"files": [
"test/**/*.test.ts"
],
"verbose": true,
"timeout": "400s",
"concurrency": 1,
"extensions": {
"ts": "module"
}
}
}
"name": "@wessberg/di-compiler",
"version": "4.0.0-beta.1",
"description": "A Custom Transformer for Typescript that enables compile-time Dependency Injection",
"keywords": [
"DI",
"dependency injection",
"ioc",
"inversion",
"service",
"container",
"newable",
"reflection",
"singleton",
"transient",
"compiler"
],
"files": [
"dist/**/*.*",
"loader.*"
],
"contributors": [
{
"name": "Frederik Wessberg",
"email": "frederikwessberg@hotmail.com",
"url": "https://github.com/wessberg",
"imageUrl": "https://avatars2.githubusercontent.com/u/20454213?s=460&v=4",
"role": "Lead Developer",
"twitter": "FredWessberg",
"github": "wessberg"
}
],
"license": "MIT",
"devDependencies": {
"@types/node": "^22.7.1",
"@types/prettier": "^3.0.0",
"@types/semver": "^7.5.8",
"@wessberg/ts-config": "^5.0.17",
"@wessberg/prettier-config": "^1.0.0",
"@prettier/sync": "0.5.2",
"eslint": "^9.11.1",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-jsdoc": "^50.2.4",
"eslint-plugin-prettier": "^5.2.1",
"typescript-eslint": "^8.7.0",
"semver": "^7.6.3",
"husky": "^9.1.6",
"np": "^10.0.7",
"pnpm": "^9.11.0",
"prettier": "^3.3.3",
"lint-staged": "^15.2.10",
"rimraf": "^6.0.1",
"sandhog": "^2.0.2",
"standard-changelog": "^6.0.0",
"tsx": "^4.19.1",
"npm-check-updates": "^17.1.3",
"tsup": "^8.3.0",
"typescript": "^5.6.2",
"typescript-3-4-1": "npm:typescript@3.4.1",
"typescript-3-5-1": "npm:typescript@3.5.1",
"typescript-3-6-2": "npm:typescript@3.6.2",
"typescript-3-7-2": "npm:typescript@3.7.2",
"typescript-3-8-3": "npm:typescript@3.8.3",
"typescript-3-9-2": "npm:typescript@3.9.2",
"typescript-4-0-3": "npm:typescript@4.0.3",
"typescript-4-1-2": "npm:typescript@4.1.2",
"typescript-4-2-4": "npm:typescript@4.2.4",
"typescript-4-3-5": "npm:typescript@4.3.5",
"typescript-4-4-2": "npm:typescript@4.4.2",
"typescript-4-5-4": "npm:typescript@4.5.4",
"typescript-4-6-4": "npm:typescript@4.6.4",
"typescript-4-7-2": "npm:typescript@4.7.2",
"typescript-4-8-2": "npm:typescript@4.8.2",
"typescript-4-9-4": "npm:typescript@4.9.4",
"typescript-5-0-4": "npm:typescript@5.0.4",
"typescript-5-1-6": "npm:typescript@5.1.6",
"typescript-5-2-2": "npm:typescript@5.2.2",
"typescript-5-3-3": "npm:typescript@5.3.3",
"typescript-5-4-5": "npm:typescript@5.4.5",
"typescript-5-5-4": "npm:typescript@5.5.4",
"typescript-5-6-2": "npm:typescript@5.6.2"
},
"dependencies": {
"crosspath": "^2.0.0",
"helpertypes": "^0.0.19",
"get-tsconfig": "^4.8.1",
"ts-evaluator": "^1.2.0",
"compatfactory": "^4.0.2"
},
"peerDependencies": {
"typescript": ">=3.x || >= 4.x || >= 5.x",
"pirates": ">=4.x"
},
"peerDependenciesMeta": {
"pirates": {
"optional": true
}
},
"repository": {
"type": "git",
"url": "https://github.com/wessberg/di-compiler.git"
},
"bugs": {
"url": "https://github.com/wessberg/di-compiler/issues"
},
"exports": {
"./loader": {
"import": "./dist/loader/esm/loader.js",
"require": "./dist/loader/cjs/loader.cjs"
},
".": {
"import": "./dist/index.js",
"require": "./dist/index.cjs"
}
},
"type": "module",
"types": "./dist/index.d.ts",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"engines": {
"node": ">=18.20.0"
},
"lint-staged": {
"*": "prettier --ignore-unknown --write"
},
"prettier": "@wessberg/prettier-config",
"scripts": {
"generate:sandhog": "sandhog all --yes",
"generate:changelog": "standard-changelog --first-release",
"generate:all": "pnpm run generate:sandhog && pnpm run generate:changelog",
"clean": "rimraf dist",
"lint": "tsc --noEmit && eslint \"src/**/*.ts\" --color",
"prettier": "prettier --write \"{src,test,documentation}/**/*.{js,ts,json,html,xml,css,md}\"",
"test": "node --import tsx --test \"./test/**/*.test.ts\"",
"prebuild": "pnpm run clean",
"build": "pnpm run clean && pnpm run build:esm && pnpm run build:cjs",
"build:cjs": "tsup --entry=\"src/index.ts\" --entry=\"src/loader/esm/loader.ts\" --entry=\"src/loader/esm/hooks/index.ts\" --sourcemap --dts --format esm",
"build:esm": "tsup --entry=\"src/index.ts\" --entry=\"src/loader/cjs/loader.ts\" --sourcemap --splitting --dts --format cjs",
"preversion": "pnpm run lint && pnpm run build",
"version": "pnpm run preversion && pnpm run generate:all && git add .",
"release": "np --no-cleanup --no-yarn",
"update:check": "pnpx npm-check-updates -x typescript-* --dep dev,prod",
"update:commit": "pnpx npm-check-updates -u -x typescript-* --dep dev,prod && pnpm update && pnpm install"
}
}

@@ -59,6 +59,2 @@ <!-- SHADOW_SECTION_LOGO_START -->

| <a href="https://changelog.me"><img alt="Trent Raymond" src="https://avatars.githubusercontent.com/u/1509616?v=4" height="70" /></a> | <a href="https://scrubtheweb.com/computers/programming/1"><img alt="scrubtheweb" src="https://avatars.githubusercontent.com/u/41668218?v=4" height="70" /></a> |
| -------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [Trent Raymond](https://changelog.me) | [scrubtheweb](https://scrubtheweb.com/computers/programming/1) |
### Patreon

@@ -93,10 +89,7 @@

- [Usage with ts-nodes programmatic API](#usage-with-ts-nodes-programmatic-api)
- [Usage with ttypescript](#usage-with-ttypescript)
- [Usage with Rollup](#usage-with-rollup)
- [Usage with rollup-plugin-ts](#usage-with-rollup-plugin-ts)
- [Usage with rollup-plugin-typescript2](#usage-with-rollup-plugin-typescript2)
- [Usage with @rollup/plugin-typescript](#usage-with-rollupplugin-typescript)
- [Usage with Webpack](#usage-with-webpack)
- [Usage with awesome-typescript-loader](#usage-with-awesome-typescript-loader)
- [Usage with ts-loader](#usage-with-ts-loader)
- [Usage with ava](#usage-with-ava)
- [Options](#options)

@@ -141,2 +134,4 @@ - [Optimization](#optimization)

You may also need to install `pirates` depending on the features you are going to use. Refer to the documentation for the specific cases where it may be relevant.
<!-- SHADOW_SECTION_INSTALL_END -->

@@ -225,3 +220,3 @@

```
node --loader @wessberg/di-compiler/loader
node --import @wessberg/di-compiler/loader
```

@@ -234,3 +229,3 @@

```
node --loader @wessberg/di-compiler/loader --loader ts-node/esm
node --import @wessberg/di-compiler/loader --import ts-node/esm
```

@@ -241,3 +236,3 @@

```
node --loader @wessberg/di-compiler/loader --loader tsx
node --import @wessberg/di-compiler/loader --import tsx
```

@@ -248,3 +243,3 @@

```
node --loader @wessberg/di-compiler/loader --loader @esbuild-kit/esm-loader
node --import @wessberg/di-compiler/loader --import @esbuild-kit/esm-loader
```

@@ -261,10 +256,2 @@

A convenience loader is exposed that combines `ts-node` and DI-Compiler in a single loader for CommonJS projects, which also exposes a TypeScript Program to DI-Compiler, which is the most robust way to use it as a loader, at the expense of slower performance:
```
node -r @wessberg/di-compiler/ts-node-loader
```
> Note: You must install ts-node yourself for this configuration to work, as it is not listed as a dependency of DI-Compiler.
### Loader SourceMaps

@@ -314,3 +301,2 @@

- [With ts-nodes programmatic API](#usage-with-ts-nodes-programmatic-api)
- [With ttypescript](#usage-with-ttypescript)
- [With Rollup](#usage-with-rollup)

@@ -348,38 +334,12 @@

### Usage with ttypescript
To use DI-compiler with [`ttypescript`](https://github.com/cevek/ttypescript), create a file that wraps the invocation of `di`:
```typescript:transformer.ts
import type { Program } from 'typescript'
import { di } from "@wessberg/di-compiler";
const transformer = (program: Program) => di({ program })
export default transformer
```
Then add a record to the `plugins` array of your `tsconfig.json` that maps a key named `transform` to the relative path to the file you just created:
```json
{
"compilerOptions": {
"plugins": [{"transform": "path/to/transformer.ts"}]
}
}
```
### Usage with Rollup
There are a few TypeScript plugins for Rollup that support Custom Transformers, and DI-Compiler can be easily integrated with them:
There are a few TypeScript plugins for Rollup that support Custom Transformers, and DI-Compiler can be easily integrated with them.
- [Usage with rollup-plugin-ts](#usage-with-rollup-plugin-ts)
- [Usage with rollup-plugin-typescript2](#usage-with-rollup-plugin-typescript2)
#### Usage with @rollup/plugin-typescript
#### Usage with rollup-plugin-ts
Here's how you may integrate DI-Compiler with [@rollup/plugin-typescript](https://www.npmjs.com/package/@rollup/plugin-typescript):
To use DI-Compiler with [rollup-plugin-ts](https://github.com/wessberg/rollup-plugin-ts), all you have to do is pass it to the list of transformers given as a plugin option:
```typescript
import ts from "rollup-plugin-ts";
import ts from "@rollup/plugin-typescript";
import {di} from "@wessberg/di-compiler";

@@ -394,3 +354,3 @@

ts({
transformers: [di]
transformers: program => di({program})
})

@@ -401,23 +361,2 @@ ]

#### Usage with rollup-plugin-typescript2
Here's how you may integrate DI-Compiler with [rollup-plugin-typescript2](https://github.com/ezolenko/rollup-plugin-typescript2):
```typescript
import ts from "rollup-plugin-typescript2";
import {di} from "@wessberg/di-compiler";
export default {
input: "...",
output: [
/* ... */
],
plugins: [
ts({
transformers: [service => di({program: service.getProgram()})]
})
]
};
```
### Usage with Webpack

@@ -480,43 +419,2 @@

### Usage with ava
You can also use DI-compiler with the [`ava`](https://github.com/avajs/ava) test runner by using DI-Compiler as a loader.
See [this section](#usage-as-a-nodejs-loader) for more details on how to configure it.
For a CommonJS project, you can use the `require` property in the `ava` configuration. For example:
```js
{
"ava": {
// Other options...
"extensions": ["ts"],
"require": [
"@wessberg/di-compiler/loader",
// For teaching Node.js about TypeScript specific syntax and extensions
"ts-node"
]
}
}
```
Whereas for an ESM project, the syntax is a little different:
```js
{
"ava": {
// Other options...
"extensions": {
"ts": "module"
},
"nodeArguments": [
"--loader=@wessberg/di-compiler/loader",
// For teaching Node.js about TypeScript specific syntax and extensions.
"--loader=ts-node/esm"
]
}
}
```
> Note, we use ts-node in this example, but we could have used other tools like tsx or esm-loader just as well.
## Options

@@ -523,0 +421,0 @@

Sorry, the diff of this file is not supported yet

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