From ca5cd7a7c4ee6730a56714002fe84fe1c61181b9 Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Wed, 29 May 2024 21:56:41 +0200 Subject: [PATCH 1/2] feat: Add `Hook` named export --- index.js | 1 + test/hook/dynamic-import.js | 2 +- test/hook/static-import-default.mjs | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 50a8665..50aa04f 100644 --- a/index.js +++ b/index.js @@ -89,5 +89,6 @@ Hook.prototype.unhook = function () { } module.exports = Hook +module.exports.Hook = Hook module.exports.addHook = addHook module.exports.removeHook = removeHook diff --git a/test/hook/dynamic-import.js b/test/hook/dynamic-import.js index 1d012f1..a466a1d 100644 --- a/test/hook/dynamic-import.js +++ b/test/hook/dynamic-import.js @@ -2,7 +2,7 @@ // // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2021 Datadog, Inc. -const Hook = require('../../index.js') +const { Hook } = require('../../index.js') const { strictEqual } = require('assert') Hook((exports, name) => { diff --git a/test/hook/static-import-default.mjs b/test/hook/static-import-default.mjs index 304224b..2c6982a 100644 --- a/test/hook/static-import-default.mjs +++ b/test/hook/static-import-default.mjs @@ -2,7 +2,7 @@ // // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2021 Datadog, Inc. -import Hook from '../../index.js' +import { Hook } from '../../index.js' import barMjs from '../fixtures/something.mjs' import barJs from '../fixtures/something.js' import { strictEqual } from 'assert' From d833b1f354878b841df1e8635dbe5c5b3932fbe6 Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Wed, 29 May 2024 23:22:59 +0200 Subject: [PATCH 2/2] update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 14eae8f..50851f7 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ imported in ESM files, regardless of whether they're imported statically or dynamically. ```js -import Hook from 'import-in-the-middle' +import { Hook } from 'import-in-the-middle' import { foo } from 'package-i-want-to-modify' console.log(foo) // whatever that module exported