Skip to content

Commit 5832634

Browse files
committed
🔧fix: exports in package.json
1 parent d3d8e67 commit 5832634

File tree

6 files changed

+44
-7
lines changed

6 files changed

+44
-7
lines changed

package.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
"url": "https://github.com/elysiajs/elysia-cors"
1313
},
1414
"exports": {
15+
"bun": "./dist/index.js",
16+
"node": "./dist/cjs/index.js",
1517
"require": "./dist/cjs/index.js",
1618
"import": "./dist/index.js",
17-
"node": "./dist/cjs/index.js",
18-
"default": "./dist/cjs/index.js",
19-
"bun": "./dist/index.js"
19+
"default": "./dist/cjs/index.js"
2020
},
2121
"types": "./src/index.ts",
2222
"homepage": "https://github.com/elysiajs/elysia-cors",
@@ -27,19 +27,20 @@
2727
"license": "MIT",
2828
"scripts": {
2929
"dev": "bun run --hot example/index.ts",
30-
"test": "bun wiptest",
30+
"test": "bun wiptest && npm run test:node",
31+
"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",
3132
"build": "rimraf dist && tsc --project tsconfig.esm.json && tsc --project tsconfig.cjs.json",
3233
"release": "npm run build && npm run test && npm publish --access public"
3334
},
3435
"devDependencies": {
3536
"@types/node": "^18.11.7",
3637
"bun-types": "^0.5.7",
37-
"elysia": "0.5.0",
38+
"elysia": "0.5.12",
3839
"eslint": "^8.26.0",
3940
"rimraf": "^3.0.2",
4041
"typescript": "^5.0.4"
4142
},
4243
"peerDependencies": {
43-
"elysia": ">= 0.5.0"
44+
"elysia": ">= 0.5.12"
4445
}
45-
}
46+
}

test/node/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules/
2+
package-lock.json

test/node/cjs/index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
if ('Bun' in globalThis) {
2+
throw new Error('❌ Use Node.js to run this test!');
3+
}
4+
5+
const { cors } = require('@elysiajs/cors');
6+
7+
if (typeof cors !== 'function') {
8+
throw new Error('❌ CommonJS Node.js failed');
9+
}
10+
11+
console.log('✅ CommonJS Node.js works!');

test/node/cjs/package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"type": "commonjs",
3+
"dependencies": {
4+
"@elysiajs/cors": "../../.."
5+
}
6+
}

test/node/esm/index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
if ('Bun' in globalThis) {
2+
throw new Error('❌ Use Node.js to run this test!');
3+
}
4+
5+
import { cors } from '@elysiajs/cors';
6+
7+
if (typeof cors !== 'function') {
8+
throw new Error('❌ ESM Node.js failed');
9+
}
10+
11+
console.log('✅ ESM Node.js works!');

test/node/esm/package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"type": "module",
3+
"dependencies": {
4+
"@elysiajs/cors": "../../.."
5+
}
6+
}

0 commit comments

Comments
 (0)