Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build fails #11

Closed
ThatOneCalculator opened this issue Jun 15, 2024 · 3 comments
Closed

Build fails #11

ThatOneCalculator opened this issue Jun 15, 2024 · 3 comments

Comments

@ThatOneCalculator
Copy link

Tested on 0.1.0 and 0.1.1

Dev works fine, but build errors.

build.ts:

import { autoload } from "esbuild-plugin-autoload";

await Bun.build({
	entrypoints: ["src/index.ts"],
	outdir: "dist",
	target: "bun",
	sourcemap: "inline",
	minify: true,
	plugins: [
		autoload({
			pattern: "**/*.{ts,tsx,js,jsx,mjs,cjs}",
			directory: "src/routes",
		}),
	],
}).then(console.log);

index.ts

const app = new Elysia({
	serve: { reusePort: true },
})
	.use(
		await autoload({
			types: {
				output: "./routes.ts",
				typeName: "Routes",
			},
		}),
	)

File structure:

.
├── build.ts
├── env.d.ts
├── package.json
├── spawn.ts
├── src
│   ├── index.ts
│   ├── routes
│   │   ├── market
│   │   │   └── create.ts
│   │   ├── signedIn.ts
│   │   ├── signer
│   │   │   ├── approve.ts
│   │   │   └── sessionKey.ts
│   │   ├── timeline
│   │   │   └── [...].ts
│   │   └── user
│   │       ├── follow.ts
│   │       └── [name]
│   │           ├── followers.ts
│   │           ├── following.ts
│   │           └── index.ts
│   └── routes.ts

bun run build.ts:

{
  path: "/home/REDACTED/node_modules/elysia-autoload/dist/index.js",
  namespace: "file",
  loader: "jsx",
}
[ "signedIn.ts", "market/create.ts", "user/follow.ts", "user/[name]/index.ts", "user/[name]/followers.ts",
  "user/[name]/following.ts", "signer/sessionKey.ts", "signer/approve.ts", "timeline/[...].ts"
]
{
  outputs: [],
  success: false,
  logs: [
    74 |                                 ,
                                     ^
error: Expected identifier but found ","
    at /home/REDACTED/node_modules/elysia-autoload/dist/index.js:74:33, 76 |                                 ,
                                     ^
error: Expected identifier but found ","
    at /home/REDACTED/node_modules/elysia-autoload/dist/index.js:76:33, 78 |                                 ,
                                     ^
error: Expected identifier but found ","
    at /home/REDACTED/node_modules/elysia-autoload/dist/index.js:78:33, 80 |                                 ,
                                     ^
error: Expected identifier but found ","
    at /home/REDACTED/node_modules/elysia-autoload/dist/index.js:80:33, 82 |                                 ,
                                     ^
error: Expected identifier but found ","
    at /home/REDACTED/node_modules/elysia-autoload/dist/index.js:82:33, 84 |                                 ,
                                     ^
error: Expected identifier but found ","
    at /home/REDACTED/node_modules/elysia-autoload/dist/index.js:84:33, 86 |                                 ,
                                     ^
error: Expected identifier but found ","
    at /home/REDACTED/node_modules/elysia-autoload/dist/index.js:86:33, 88 |                                 ,
                                     ^
error: Expected identifier but found ","
    at /home/REDACTED/node_modules/elysia-autoload/dist/index.js:88:33
  ],
}
kravetsone added a commit to kravetsone/esbuild-plugin-autoload that referenced this issue Jun 16, 2024
@kravetsone
Copy link
Owner

Please add Build issues to plugin)

@kravetsone
Copy link
Owner

Tested on 0.1.0 and 0.1.1

Dev works fine, but build errors.

build.ts:

import { autoload } from "esbuild-plugin-autoload";

await Bun.build({
	entrypoints: ["src/index.ts"],
	outdir: "dist",
	target: "bun",
	sourcemap: "inline",
	minify: true,
	plugins: [
		autoload({
			pattern: "**/*.{ts,tsx,js,jsx,mjs,cjs}",
			directory: "src/routes",
		}),
	],
}).then(console.log);

index.ts

const app = new Elysia({
	serve: { reusePort: true },
})
	.use(
		await autoload({
			types: {
				output: "./routes.ts",
				typeName: "Routes",
			},
		}),
	)

File structure:

.
├── build.ts
├── env.d.ts
├── package.json
├── spawn.ts
├── src
│   ├── index.ts
│   ├── routes
│   │   ├── market
│   │   │   └── create.ts
│   │   ├── signedIn.ts
│   │   ├── signer
│   │   │   ├── approve.ts
│   │   │   └── sessionKey.ts
│   │   ├── timeline
│   │   │   └── [...].ts
│   │   └── user
│   │       ├── follow.ts
│   │       └── [name]
│   │           ├── followers.ts
│   │           ├── following.ts
│   │           └── index.ts
│   └── routes.ts

bun run build.ts:

{
  path: "/home/REDACTED/node_modules/elysia-autoload/dist/index.js",
  namespace: "file",
  loader: "jsx",
}
[ "signedIn.ts", "market/create.ts", "user/follow.ts", "user/[name]/index.ts", "user/[name]/followers.ts",
  "user/[name]/following.ts", "signer/sessionKey.ts", "signer/approve.ts", "timeline/[...].ts"
]
{
  outputs: [],
  success: false,
  logs: [
    74 |                                 ,
                                     ^
error: Expected identifier but found ","
    at /home/REDACTED/node_modules/elysia-autoload/dist/index.js:74:33, 76 |                                 ,
                                     ^
error: Expected identifier but found ","
    at /home/REDACTED/node_modules/elysia-autoload/dist/index.js:76:33, 78 |                                 ,
                                     ^
error: Expected identifier but found ","
    at /home/REDACTED/node_modules/elysia-autoload/dist/index.js:78:33, 80 |                                 ,
                                     ^
error: Expected identifier but found ","
    at /home/REDACTED/node_modules/elysia-autoload/dist/index.js:80:33, 82 |                                 ,
                                     ^
error: Expected identifier but found ","
    at /home/REDACTED/node_modules/elysia-autoload/dist/index.js:82:33, 84 |                                 ,
                                     ^
error: Expected identifier but found ","
    at /home/REDACTED/node_modules/elysia-autoload/dist/index.js:84:33, 86 |                                 ,
                                     ^
error: Expected identifier but found ","
    at /home/REDACTED/node_modules/elysia-autoload/dist/index.js:86:33, 88 |                                 ,
                                     ^
error: Expected identifier but found ","
    at /home/REDACTED/node_modules/elysia-autoload/dist/index.js:88:33
  ],
}

fixed in esbuild-plugin-autoload@0.1.2

@kravetsone
Copy link
Owner

Reopen if you still get errors

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants