Skip to content

Commit

Permalink
feat: now it ship ESM and CJS
Browse files Browse the repository at this point in the history
  • Loading branch information
kravetsone committed Mar 27, 2024
1 parent 05f0b5a commit 09fdc0b
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 15 deletions.
30 changes: 19 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
{
"name": "elysia-autoload",
"version": "0.1.9",
"version": "0.2.0",
"author": "kravetsone",
"type": "commonjs",
"main": "dist/index.js",
"type": "module",
"exports": {
".": {
"types": "./dist/index.d.ts",
"main": "./dist/index.js",
"module": "./dist/index.mjs"
}
},
"description": "Plugin for Elysia which autoload all routes in directory and code-generate types for Eden",
"homepage": "https://github.com/kravetsone/elysia-autoload",
"keywords": [
Expand All @@ -20,7 +26,7 @@
"codegeneration"
],
"scripts": {
"prepublishOnly": "bun test && rm -rf dist && tsc",
"prepublishOnly": "bun test && bunx tsup && rm -f ./dist/index.d.mts",
"lint": "bunx @biomejs/biome check src",
"lint:fix": "bun lint --apply",
"prepare": "husky"
Expand All @@ -29,13 +35,15 @@
"dist"
],
"devDependencies": {
"@biomejs/biome": "1.6.1",
"@elysiajs/eden": "^1.0.4",
"@elysiajs/swagger": "^1.0.2",
"@types/bun": "^1.0.8",
"elysia": "^1.0.5",
"typescript": "^5.4.2",
"husky": "^9.0.11"
"@biomejs/biome": "1.6.3",
"@elysiajs/eden": "^1.0.7",
"@elysiajs/swagger": "^1.0.3",
"@microsoft/api-extractor": "^7.43.0",
"@types/bun": "^1.0.11",
"elysia": "^1.0.9",
"husky": "^9.0.11",
"tsup": "^8.0.2",
"typescript": "^5.4.3"
},
"peerDependencies": {
"elysia": "^1.0.0"
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ type TSchemaHandler = ({
""
>;

const a = {} as ReturnType<TSchemaHandler>;

export interface ITypesOptions {
output?: string | string[];
typeName?: string;
Expand Down Expand Up @@ -91,6 +89,8 @@ export function autoload(options: IAutoloadOptions = {}) {
const url = transformToUrl(path);

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

if (types) paths.push(fullPath.replace(directoryPath, ""));
Expand Down
4 changes: 2 additions & 2 deletions tests/types/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import type Route0 from "Z:/PROJECTS/node-ts/elysia-autoload/tests/routes/index"
import type Route1 from "Z:/PROJECTS/node-ts/elysia-autoload/tests/routes/users/[id]";

declare global {
export type Routes = ElysiaWithBaseUrl<"/", ReturnType<typeof Route0>>
& ElysiaWithBaseUrl<"/users/:id", ReturnType<typeof Route1>>
export type Routes = ElysiaWithBaseUrl<"/api", ReturnType<typeof Route0>>
& ElysiaWithBaseUrl<"/api/users/:id", ReturnType<typeof Route1>>
}
9 changes: 9 additions & 0 deletions tsup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { defineConfig } from "tsup";

export default defineConfig({
entry: ["src/index.ts"],
format: ["esm", "cjs"],
target: "node20",
outDir: "dist",
dts: true,
});

0 comments on commit 09fdc0b

Please sign in to comment.