From df835b45aac86cdaadf816b7244ac1907bc91fca Mon Sep 17 00:00:00 2001 From: bogeychan Date: Sun, 4 Jun 2023 16:27:33 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7fix:=20exports=20in=20package.json?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 11 ++++++----- test/node/.gitignore | 2 ++ test/node/cjs/index.js | 11 +++++++++++ test/node/cjs/package.json | 6 ++++++ test/node/esm/index.js | 11 +++++++++++ test/node/esm/package.json | 6 ++++++ 6 files changed, 42 insertions(+), 5 deletions(-) create mode 100644 test/node/.gitignore create mode 100644 test/node/cjs/index.js create mode 100644 test/node/cjs/package.json create mode 100644 test/node/esm/index.js create mode 100644 test/node/esm/package.json diff --git a/package.json b/package.json index 9c457e0..c2b9099 100644 --- a/package.json +++ b/package.json @@ -13,9 +13,9 @@ }, "main": "./dist/index.js", "exports": { + "node": "./dist/cjs/index.js", "require": "./dist/cjs/index.js", "import": "./dist/index.js", - "node": "./dist/index.js", "default": "./dist/index.js" }, "types": "./dist/index.d.ts", @@ -30,7 +30,8 @@ "license": "MIT", "scripts": { "dev": "bun run --hot example/index.ts", - "test": "bun wiptest", + "test": "bun wiptest && npm run test:node", + "test:node": "npm install --prefix ./test/node/cjs/ && npm install --prefix ./test/node/esm/ && node ./test/node/cjs/index.js && node ./test/node/esm/index.js", "build": "rimraf dist && tsc --project tsconfig.esm.json && tsc --project tsconfig.cjs.json", "release": "npm run build && npm run test && npm publish --access public" }, @@ -42,12 +43,12 @@ "@sinclair/typebox": "^0.28.10", "@types/node": "^20.1.4", "bun-types": "^0.5.8", - "elysia": "0.5.0", + "elysia": "0.5.12", "eslint": "^8.40.0", "rimraf": "4.3", "typescript": "^5.0.4" }, "peerDependencies": { - "elysia": ">= 0.5.0" + "elysia": ">= 0.5.12" } -} +} \ No newline at end of file diff --git a/test/node/.gitignore b/test/node/.gitignore new file mode 100644 index 0000000..3ea1bb5 --- /dev/null +++ b/test/node/.gitignore @@ -0,0 +1,2 @@ +node_modules/ +package-lock.json \ No newline at end of file diff --git a/test/node/cjs/index.js b/test/node/cjs/index.js new file mode 100644 index 0000000..0e3bb21 --- /dev/null +++ b/test/node/cjs/index.js @@ -0,0 +1,11 @@ +if ('Bun' in globalThis) { + throw new Error('❌ Use Node.js to run this test!'); +} + +const { jwt } = require('@elysiajs/jwt'); + +if (typeof jwt !== 'function') { + throw new Error('❌ CommonJS Node.js failed'); +} + +console.log('✅ CommonJS Node.js works!'); diff --git a/test/node/cjs/package.json b/test/node/cjs/package.json new file mode 100644 index 0000000..0d82dda --- /dev/null +++ b/test/node/cjs/package.json @@ -0,0 +1,6 @@ +{ + "type": "commonjs", + "dependencies": { + "@elysiajs/jwt": "../../.." + } +} \ No newline at end of file diff --git a/test/node/esm/index.js b/test/node/esm/index.js new file mode 100644 index 0000000..58d28b0 --- /dev/null +++ b/test/node/esm/index.js @@ -0,0 +1,11 @@ +if ('Bun' in globalThis) { + throw new Error('❌ Use Node.js to run this test!'); +} + +import { jwt } from '@elysiajs/jwt'; + +if (typeof jwt !== 'function') { + throw new Error('❌ ESM Node.js failed'); +} + +console.log('✅ ESM Node.js works!'); diff --git a/test/node/esm/package.json b/test/node/esm/package.json new file mode 100644 index 0000000..3bd12f1 --- /dev/null +++ b/test/node/esm/package.json @@ -0,0 +1,6 @@ +{ + "type": "module", + "dependencies": { + "@elysiajs/jwt": "../../.." + } +} \ No newline at end of file