Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# v13.0.4

- Update packages and simplify build ([#428](https://github.com/jeffijoe/awilix/pull/428)))

# v13.0.3

- Fix CJS environments (e.g. Jest + esbuild) failing to `require()` the `.mjs` native loader by providing separate CJS and ESM versions of `load-module-native` ([#418](https://github.com/jeffijoe/awilix/issues/418), [#419](https://github.com/jeffijoe/awilix/pull/419))
Expand Down
5,568 changes: 2,607 additions & 2,961 deletions package-lock.json

Large diffs are not rendered by default.

37 changes: 18 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,31 +76,28 @@
},
"homepage": "https://github.com/jeffijoe/awilix#readme",
"devDependencies": {
"@babel/core": "^7.29.0",
"@babel/plugin-transform-runtime": "^7.29.0",
"@babel/preset-env": "^7.29.0",
"@babel/runtime": "^7.28.6",
"@rollup/plugin-commonjs": "^29.0.0",
"@rollup/plugin-node-resolve": "^16.0.3",
"@babel/core": "^7.29.7",
"@babel/plugin-transform-runtime": "^7.29.7",
"@babel/preset-env": "^7.29.7",
"@babel/runtime": "^7.29.7",
"@rollup/plugin-replace": "^6.0.3",
"@types/jest": "^30.0.0",
"@types/node": "^25.3.3",
"babel-jest": "^30.2.0",
"@types/node": "^25.9.3",
"babel-jest": "^30.4.1",
"eslint": "^9.22.0",
"husky": "^9.1.7",
"jest": "^30.2.0",
"jest": "^30.4.2",
"lint-staged": "^16.3.1",
"prettier": "^3.8.1",
"prettier": "^3.8.4",
"rimraf": "^6.1.3",
"rollup": "^4.59.0",
"rollup-plugin-copy": "^3.5.0",
"rollup-plugin-typescript2": "^0.36.0",
"rollup": "^4.61.1",
"rollup-plugin-typescript2": "^0.37.0",
"smid": "^0.1.1",
"tinybench": "^6.0.0",
"ts-jest": "^29.4.6",
"tinybench": "^6.0.2",
"ts-jest": "^29.4.11",
"tslib": "^2.8.1",
"typescript": "^5.9.3",
"typescript-eslint": "^8.56.1"
"typescript": "^6.0.3",
"typescript-eslint": "^8.61.0"
},
"dependencies": {
"fast-glob": "^3.3.3"
Expand Down Expand Up @@ -147,15 +144,17 @@
"/node_modules/",
"__tests__",
"lib",
"src/load-module-native.mjs",
"src/load-module-native.js",
"src/load-module-native.ts",
"src/awilix.ts"
],
"moduleFileExtensions": [
"ts",
"tsx",
"js"
],
"moduleNameMapper": {
"^(\\.{1,2}/.*)\\.js$": "$1"
},
"transform": {
"^.+\\.tsx?$": [
"ts-jest",
Expand Down
33 changes: 4 additions & 29 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import typescript from 'rollup-plugin-typescript2'
import typescriptCompiler from 'typescript'
import replace from '@rollup/plugin-replace'
import commonjs from '@rollup/plugin-commonjs'
import resolve from '@rollup/plugin-node-resolve'
import copy from 'rollup-plugin-copy'

const comment = '/* removed in browser build */'
const ignoredWarnings = ['UNUSED_EXTERNAL_IMPORT']
Expand All @@ -17,6 +14,7 @@ const tsOpts = {
// Don't emit declarations, that's done by the regular build.
declaration: false,
module: 'ESNext',
moduleResolution: 'bundler',
},
},
}
Expand All @@ -34,27 +32,7 @@ export default [
format: 'es',
},
],
plugins: [
// The source imports ./load-module-native.js (the CJS version) so that
// tsc emits require("./load-module-native.js") in the CJS build.
// For this ESM bundle we remap it to the .mjs version.
// Returning a relative id with external: true tells rollup to preserve
// the path as-is in the output (see https://rollupjs.org/plugin-development/#resolveid).
{
name: 'rewrite-native-loader',
resolveId(source) {
if (source === './load-module-native.js') {
return { id: './load-module-native.mjs', external: true }
}
return null
},
},
// Copy the native module loaders and their type declarations to lib/
copy({
targets: [{ src: 'src/load-module-native.*', dest: 'lib' }],
}),
typescript(tsOpts),
],
plugins: [typescript(tsOpts)],
},
// Build 2: ES modules for browser builds.
{
Expand Down Expand Up @@ -86,7 +64,7 @@ export default [
'[util.inspect.custom]: inspect,': comment,
'[util.inspect.custom]: toStringRepresentationFn,': comment,
'case util.inspect.custom:': '',
[`export {
[`export {
type GlobWithOptions,
type ListModulesOptions,
type ModuleDescriptor,
Expand All @@ -102,14 +80,11 @@ export default [
declaration: false,
noUnusedLocals: false,
module: 'ESNext',
moduleResolution: 'bundler',
},
},
}),
),
resolve({
preferBuiltins: true,
}),
commonjs(),
],
},
]
Expand Down
1 change: 0 additions & 1 deletion src/load-module-native.d.mts

This file was deleted.

1 change: 0 additions & 1 deletion src/load-module-native.d.ts

This file was deleted.

5 changes: 0 additions & 5 deletions src/load-module-native.js

This file was deleted.

4 changes: 0 additions & 4 deletions src/load-module-native.mjs

This file was deleted.

5 changes: 5 additions & 0 deletions src/load-module-native.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Kept in a separate module so it can be excluded from test coverage;
// jest cannot execute a native dynamic import.
export function importModule(path: string): Promise<any> {
return import(path)
}
5 changes: 4 additions & 1 deletion tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
"exclude": ["__tests__", "**/__tests__/*", "node_modules/*", "examples", "benchmarks"],
"compilerOptions": {
"forceConsistentCasingInFileNames": false,
"baseUrl": "src"
"rootDir": "src",
// The base config enables this for ts-jest, but the build keeps it off
// so `const enum` values (e.g. TokenizerFlags) are inlined in the output.
"isolatedModules": false
}
}
7 changes: 5 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"compileOnSave": false,
"compilerOptions": {
"outDir": "./lib",
"rootDir": ".",
"strict": true,
"strictNullChecks": true,
"experimentalDecorators": true,
Expand All @@ -11,8 +12,10 @@
"target": "ES2021",
"esModuleInterop": true,
"lib": ["ES2021"],
"module": "commonjs",
"moduleResolution": "node",
"types": ["node", "jest"],
"module": "nodenext",
"moduleResolution": "nodenext",
"isolatedModules": true,
"importHelpers": false,
"sourceMap": true,
"declaration": true,
Expand Down
Loading