feat!: switch to native ESM with NodeNext module resolution and .js import paths

BREAKING CHANGE: Consumers must use ESM-compatible environments.
All import paths now include .js extensions.
CommonJS (require) is no longer supported.
This commit is contained in:
2025-04-02 21:05:56 +02:00
committed by 20Max01
parent 9bd899581f
commit c6e9fbd2a3
16 changed files with 62 additions and 59 deletions

View File

@@ -1,9 +1,9 @@
/* istanbul ignore file */ /* istanbul ignore file */
/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-explicit-any */
import { Inject } from 'src/decorators/Inject'; import { Inject } from 'src/decorators/Inject.js';
import { DependencyResolutionError } from 'src/interfaces/Exceptions'; import { DependencyResolutionError } from 'src/interfaces/Exceptions.js';
import { ForceConstructor } from 'src/types/GenericContructor'; import { ForceConstructor } from 'src/types/GenericContructor.js';
import { ITSinjex_, ITSinjex } from '../interfaces/ITSinjex'; import { ITSinjex_, ITSinjex } from '../interfaces/ITSinjex.js';
/** /**
* Test the Inject decorator. * Test the Inject decorator.

View File

@@ -1,13 +1,13 @@
/* eslint-disable deprecation/deprecation */ /* eslint-disable deprecation/deprecation */
import { TSinjex } from 'src/classes/TSinjex'; import { TSinjex } from 'src/classes/TSinjex.js';
import { Inject } from 'src/decorators/Inject'; import { Inject } from 'src/decorators/Inject.js';
import { Register } from 'src/decorators/Register'; import { Register } from 'src/decorators/Register.js';
import { RegisterInstance } from 'src/decorators/RegisterInstance'; import { RegisterInstance } from 'src/decorators/RegisterInstance.js';
import { import {
test_InjectDecorator, test_InjectDecorator,
test_RegisterDecorator, test_RegisterDecorator,
test_RegisterInstanceDecorator, test_RegisterInstanceDecorator,
} from './Decorators.spec'; } from './Decorators.spec.js';
test_InjectDecorator(TSinjex, Inject); test_InjectDecorator(TSinjex, Inject);

View File

@@ -1,6 +1,6 @@
/* istanbul ignore file */ /* istanbul ignore file */
/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-explicit-any */
import { ITSinjex, ITSinjex_ } from 'src/interfaces/ITSinjex'; import { ITSinjex, ITSinjex_ } from 'src/interfaces/ITSinjex.js';
export function test_RegisterFunction( export function test_RegisterFunction(
Container: ITSinjex_, Container: ITSinjex_,

View File

@@ -1,7 +1,10 @@
import { TSinjex } from 'src/classes/TSinjex'; import { TSinjex } from 'src/classes/TSinjex.js';
import { register } from 'src/functions/register'; import { register } from 'src/functions/register.js';
import { resolve } from 'src/functions/resolve'; import { resolve } from 'src/functions/resolve.js';
import { test_RegisterFunction, test_ResolveFunction } from './Functions.spec'; import {
test_RegisterFunction,
test_ResolveFunction,
} from './Functions.spec.js';
test_RegisterFunction(TSinjex, register); test_RegisterFunction(TSinjex, register);
test_ResolveFunction(TSinjex, resolve); test_ResolveFunction(TSinjex, resolve);

View File

@@ -1,5 +1,5 @@
/* istanbul ignore file */ /* istanbul ignore file */
import { ITSinjex_, ITSinjex } from '../interfaces/ITSinjex'; import { ITSinjex_, ITSinjex } from '../interfaces/ITSinjex.js';
/** /**
* Test the implementation of the `ITSinjex` interface. * Test the implementation of the `ITSinjex` interface.

View File

@@ -1,4 +1,4 @@
import { test_ITSinjex } from './ITSinjex.spec'; import { test_ITSinjex } from './ITSinjex.spec.js';
import { TSinjex } from '../classes/TSinjex'; import { TSinjex } from '../classes/TSinjex.js';
test_ITSinjex(TSinjex); test_ITSinjex(TSinjex);

View File

@@ -1,13 +1,13 @@
import type { Inject } from '../decorators/Inject'; import type { Inject } from '../decorators/Inject.js';
import type { Register } from '../decorators/Register'; import type { Register } from '../decorators/Register.js';
import type { RegisterInstance } from '../decorators/RegisterInstance'; import type { RegisterInstance } from '../decorators/RegisterInstance.js';
import type { register } from '../functions/register'; import type { register } from '../functions/register.js';
import type { resolve } from '../functions/resolve'; import type { resolve } from '../functions/resolve.js';
import { ImplementsStatic } from '../helper/ImplementsStatic'; import { ImplementsStatic } from '../helper/ImplementsStatic.js';
import { DependencyResolutionError } from '../interfaces/Exceptions'; import { DependencyResolutionError } from '../interfaces/Exceptions.js';
import { IDependency } from '../interfaces/IDependency'; import { IDependency } from '../interfaces/IDependency.js';
import { ITSinjex, ITSinjex_ } from '../interfaces/ITSinjex'; import { ITSinjex, ITSinjex_ } from '../interfaces/ITSinjex.js';
import { Identifier } from '../types/Identifier'; import { Identifier } from '../types/Identifier.js';
/** /**
* # TSinjex * # TSinjex

View File

@@ -1,12 +1,12 @@
import { TSinjex } from '../classes/TSinjex.js';
import { import {
DependencyResolutionError, DependencyResolutionError,
InitializationError, InitializationError,
InjectorError, InjectorError,
NoInstantiationMethodError, NoInstantiationMethodError,
} from 'src/interfaces/Exceptions'; } from '../interfaces/Exceptions.js';
import { TSinjex } from '../classes/TSinjex'; import { Identifier } from '../types/Identifier.js';
import { Identifier } from '../types/Identifier'; import { InitDelegate } from '../types/InitDelegate.js';
import { InitDelegate } from '../types/InitDelegate';
/** /**
* A decorator to inject a dependency from a DI (Dependency Injection) container into a class property. * A decorator to inject a dependency from a DI (Dependency Injection) container into a class property.

View File

@@ -1,6 +1,6 @@
import { InitDelegate } from 'src/types/InitDelegate'; import { InitDelegate } from 'src/types/InitDelegate.js';
import { TSinjex } from '../classes/TSinjex'; import { TSinjex } from '../classes/TSinjex.js';
import { Identifier } from '../types/Identifier'; import { Identifier } from '../types/Identifier.js';
//#region Overloads //#region Overloads

View File

@@ -1,6 +1,6 @@
import { Register } from './Register'; import { Register } from './Register.js';
import { Identifier } from '../types/Identifier'; import { Identifier } from '../types/Identifier.js';
import { InitDelegate } from '../types/InitDelegate'; import { InitDelegate } from '../types/InitDelegate.js';
/** /**
* A decorator to register an instance of a class in the DI (Dependency Injection) container. * A decorator to register an instance of a class in the DI (Dependency Injection) container.

View File

@@ -1,5 +1,5 @@
import { TSinjex } from '../classes/TSinjex'; import { TSinjex } from '../classes/TSinjex.js';
import { Identifier } from '../types/Identifier'; import { Identifier } from '../types/Identifier.js';
/** /**
* Register a dependency. * Register a dependency.

View File

@@ -1,6 +1,6 @@
import { TSinjex } from '../classes/TSinjex'; import { TSinjex } from '../classes/TSinjex.js';
import { DependencyResolutionError } from '../interfaces/Exceptions'; import { DependencyResolutionError } from '../interfaces/Exceptions.js';
import { Identifier } from '../types/Identifier'; import { Identifier } from '../types/Identifier.js';
/** /**
* Resolve a dependency. * Resolve a dependency.

View File

@@ -1,21 +1,21 @@
/* istanbul ignore file */ /* istanbul ignore file */
// Main // Main
export * from './classes/TSinjex'; export * from './classes/TSinjex.js';
// Decorators // Decorators
export * from './decorators/Inject'; export * from './decorators/Inject.js';
export * from './decorators/Register'; export * from './decorators/Register.js';
export * from './decorators/RegisterInstance'; export * from './decorators/RegisterInstance.js';
// Helper // Helper
export * from './helper/ImplementsStatic'; export * from './helper/ImplementsStatic.js';
// Functions // Functions
export * from './functions/resolve'; export * from './functions/resolve.js';
export * from './functions/register'; export * from './functions/register.js';
// Interfaces & Types // Interfaces & Types
export type * from './interfaces/ITSinjex'; export type * from './interfaces/ITSinjex.js';
export type * from './types/InitDelegate'; export type * from './types/InitDelegate.js';
export type * from './types/GenericContructor'; export type * from './types/GenericContructor.js';

View File

@@ -1,5 +1,5 @@
import { Identifier } from 'src/types/Identifier'; import { Identifier } from 'src/types/Identifier.js';
import { ITSinjex } from './ITSinjex'; import { ITSinjex } from './ITSinjex.js';
/** /**
* General error class for {@link ITSinjex} interface. * General error class for {@link ITSinjex} interface.

View File

@@ -1,5 +1,5 @@
import { DependencyResolutionError } from './Exceptions'; import { DependencyResolutionError } from './Exceptions.js';
import { Identifier } from '../types/Identifier'; import { Identifier } from '../types/Identifier.js';
/** /**
* Static TSInjex Interface * Static TSInjex Interface

View File

@@ -7,13 +7,13 @@
"declaration": true, "declaration": true,
"declarationMap": true, "declarationMap": true,
"outDir": "./dist", "outDir": "./dist",
"module": "ESNext", "module": "NodeNext",
"target": "ES6", "target": "ES2020",
"allowJs": true, "allowJs": true,
"noUnusedLocals": false, "noUnusedLocals": false,
"noUnusedParameters": false, "noUnusedParameters": false,
"noImplicitAny": true, "noImplicitAny": true,
"moduleResolution": "node", "moduleResolution": "NodeNext",
"allowSyntheticDefaultImports": true, "allowSyntheticDefaultImports": true,
"importHelpers": true, "importHelpers": true,
"isolatedModules": true, "isolatedModules": true,