Skip to content

Commit 09fdc0b

Browse files
committed
feat: now it ship ESM and CJS
1 parent 05f0b5a commit 09fdc0b

File tree

4 files changed

+32
-15
lines changed

4 files changed

+32
-15
lines changed

package.json

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
{
22
"name": "elysia-autoload",
3-
"version": "0.1.9",
3+
"version": "0.2.0",
44
"author": "kravetsone",
5-
"type": "commonjs",
6-
"main": "dist/index.js",
5+
"type": "module",
6+
"exports": {
7+
".": {
8+
"types": "./dist/index.d.ts",
9+
"main": "./dist/index.js",
10+
"module": "./dist/index.mjs"
11+
}
12+
},
713
"description": "Plugin for Elysia which autoload all routes in directory and code-generate types for Eden",
814
"homepage": "https://github.com/kravetsone/elysia-autoload",
915
"keywords": [
@@ -20,7 +26,7 @@
2026
"codegeneration"
2127
],
2228
"scripts": {
23-
"prepublishOnly": "bun test && rm -rf dist && tsc",
29+
"prepublishOnly": "bun test && bunx tsup && rm -f ./dist/index.d.mts",
2430
"lint": "bunx @biomejs/biome check src",
2531
"lint:fix": "bun lint --apply",
2632
"prepare": "husky"
@@ -29,13 +35,15 @@
2935
"dist"
3036
],
3137
"devDependencies": {
32-
"@biomejs/biome": "1.6.1",
33-
"@elysiajs/eden": "^1.0.4",
34-
"@elysiajs/swagger": "^1.0.2",
35-
"@types/bun": "^1.0.8",
36-
"elysia": "^1.0.5",
37-
"typescript": "^5.4.2",
38-
"husky": "^9.0.11"
38+
"@biomejs/biome": "1.6.3",
39+
"@elysiajs/eden": "^1.0.7",
40+
"@elysiajs/swagger": "^1.0.3",
41+
"@microsoft/api-extractor": "^7.43.0",
42+
"@types/bun": "^1.0.11",
43+
"elysia": "^1.0.9",
44+
"husky": "^9.0.11",
45+
"tsup": "^8.0.2",
46+
"typescript": "^5.4.3"
3947
},
4048
"peerDependencies": {
4149
"elysia": "^1.0.0"

src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ type TSchemaHandler = ({
3030
""
3131
>;
3232

33-
const a = {} as ReturnType<TSchemaHandler>;
34-
3533
export interface ITypesOptions {
3634
output?: string | string[];
3735
typeName?: string;
@@ -91,6 +89,8 @@ export function autoload(options: IAutoloadOptions = {}) {
9189
const url = transformToUrl(path);
9290

9391
const groupOptions = schema ? schema({ path, url }) : {};
92+
// TODO: fix later
93+
// @ts-expect-error
9494
plugin.group(url, groupOptions, file.default);
9595

9696
if (types) paths.push(fullPath.replace(directoryPath, ""));

tests/types/routes.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ import type Route0 from "Z:/PROJECTS/node-ts/elysia-autoload/tests/routes/index"
33
import type Route1 from "Z:/PROJECTS/node-ts/elysia-autoload/tests/routes/users/[id]";
44

55
declare global {
6-
export type Routes = ElysiaWithBaseUrl<"/", ReturnType<typeof Route0>>
7-
& ElysiaWithBaseUrl<"/users/:id", ReturnType<typeof Route1>>
6+
export type Routes = ElysiaWithBaseUrl<"/api", ReturnType<typeof Route0>>
7+
& ElysiaWithBaseUrl<"/api/users/:id", ReturnType<typeof Route1>>
88
}

tsup.config.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { defineConfig } from "tsup";
2+
3+
export default defineConfig({
4+
entry: ["src/index.ts"],
5+
format: ["esm", "cjs"],
6+
target: "node20",
7+
outDir: "dist",
8+
dts: true,
9+
});

0 commit comments

Comments
 (0)