From aa417b78b3e92d16ccd2064e7aa89c8964c5b276 Mon Sep 17 00:00:00 2001 From: Mateusz Bocian Date: Fri, 3 May 2024 12:26:49 -0400 Subject: [PATCH] fix: path imports for typescript (#493) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🎉 Thanks for sending this pull request! 🎉 Please make sure the title is clear and descriptive. If you are fixing a typo or documentation, please skip these instructions. Otherwise please fill in the sections below. **Which problem is this pull request solving?** See https://github.com/netlify/functions/actions/runs/8939586357/job/24555907790 **Describe the solution you've chosen** Remove export block to support node 10 and allow internal to be imported **Describe alternatives you've considered** Linking `internal.ts` in `main.ts`, however we look to want to keep these seperate **Checklist** Please add a `x` inside each checkbox: - [x] I have read the [contribution guidelines](../blob/master/CONTRIBUTING.md). - [x] The status checks are successful (continuous integration). Those can be seen below. - [x] Passed `npm run test:publish` - [x] Tested change with `npm link @netlify/functions` --- internal.d.ts | 2 ++ package.json | 24 ++++++++++++++++++------ 2 files changed, 20 insertions(+), 6 deletions(-) create mode 100644 internal.d.ts diff --git a/internal.d.ts b/internal.d.ts new file mode 100644 index 00000000..d91dddf5 --- /dev/null +++ b/internal.d.ts @@ -0,0 +1,2 @@ +// eslint-disable-next-line import/extensions +export * from './dist/internal.js' diff --git a/package.json b/package.json index f0d9b75e..248da4c6 100644 --- a/package.json +++ b/package.json @@ -1,16 +1,27 @@ { "name": "@netlify/functions", "main": "./dist/main.js", - "types": "./dist/main.d.ts", "type": "commonjs", "exports": { ".": { - "import": "./dist/main.mjs", - "require": "./dist/main.js" + "require": { + "types": "./dist/main.d.ts", + "default": "./dist/main.js" + }, + "import": { + "types": "./dist/main.d.mts", + "default": "./dist/main.mjs" + } }, "./internal": { - "import": "./dist/internal.mjs", - "require": "./dist/internal.js" + "require": { + "types": "./dist/internal.d.ts", + "default": "./dist/internal.js" + }, + "import": { + "types": "./dist/internal.d.mts", + "default": "./dist/internal.mjs" + } } }, "version": "2.6.1", @@ -19,7 +30,8 @@ "dist/**/*.js", "dist/**/*.mjs", "dist/**/*.d.ts", - "dist/**/*.d.mts" + "dist/**/*.d.mts", + "internal.d.ts" ], "scripts": { "build": "tsup src --format esm,cjs --dts --clean",