denoflare icon indicating copy to clipboard operation
denoflare copied to clipboard

TS0: error: unexpected argument '*.ts' found

Open marcoaleixo opened this issue 11 months ago • 3 comments

➜ deno --version
deno 2.1.9 (stable, release, aarch64-apple-darwin)
v8 13.0.245.12-rusty
typescript 5.6.2
➜ npx wrangler --version

 ⛅️ wrangler 3.107.3
--------------------

main.ts looks like

import { Hono } from "hono";
import { usersRoute } from "./src/api/features/user/routes/user-routes.ts";

const app = new Hono();

app.route("/users", usersRoute);

export default {
    fetch: app.fetch,
};

.denoflare

{
  "$schema": "https://raw.githubusercontent.com/skymethod/denoflare/v0.6.0/common/config.schema.json",
  "scripts": {
    "main": {
      "path": "main.ts",
      "localPort": 8000
    }
  },
  "profiles": {
    "myprofile": {
      "accountId": "key",
      "apiToken": "token"
    }
  }
}

deno.json

{
  "tasks": {
    "start": "deno serve -NRESW --env --watch main.ts",
    "generate": "deno task drizzle-kit generate",
    "migrate": "deno run -A --env ./src/index.ts migrate",
    "drizzle-kit": "deno run --env -A --node-modules-dir npm:drizzle-kit",
    "drizzle-studio": "deno run --env -A drizzle-kit studio"
  },
  "imports": {
    "@drizzle-team/brocli": "npm:@drizzle-team/brocli@^0.11.0",
    "@types/pg": "npm:@types/pg@^8.11.11",
    "drizzle-kit": "npm:drizzle-kit@^0.30.4",
    "drizzle-orm": "npm:drizzle-orm@^0.39.3",
    "hono": "jsr:@hono/hono@^4.6.20",
    "pg": "npm:pg@^8.13.1",
    "postgres": "npm:postgres@^3.4.5",
    "zod": "npm:zod@^3.24.1",
    "youtubei.js": "npm:youtubei.js"
  },
  "fmt": {
    "indentWidth": 2,
    "semiColons": true,
    "useTabs": false,
    "exclude": [
      "node_modules",
      "drizzle",
      "tsconfig.json",
      "README.md",
      ".devcontainer",
      ".vscode"
    ]
  },
  "compilerOptions": {
    "jsx": "precompile",
    "jsxImportSource": "hono/jsx"
  }
}

error

➜  backend-js git:(setup-cloudflare) ✗ denoflare serve main
✅ Granted all import access.
Compiling https://raw.githubusercontent.com/skymethod/denoflare/v0.6.0/cli-webworker/worker.ts into worker contents...
✅ Granted all write access.
TS0: error: unexpected argument '--config' found

Usage: deno bundle [OPTIONS]


  at undefined:
error: Uncaught (in promise) Error: bundle failed
        throw new Error('bundle failed');
              ^
    at bundle (https://raw.githubusercontent.com/skymethod/denoflare/v0.6.0/cli/bundle.ts:108:15)
    at eventLoopTick (ext:core/01_core.js:177:7)
    at async Function.start (https://raw.githubusercontent.com/skymethod/denoflare/v0.6.0/cli/worker_manager.ts:40:43)
    at async createLocalRequestServer (https://raw.githubusercontent.com/skymethod/denoflare/v0.6.0/cli/cli_serve.ts:161:35)
    at async Object.serve [as handler] (https://raw.githubusercontent.com/skymethod/denoflare/v0.6.0/cli/cli_serve.ts:194:32)
    at async CliCommand.routeSubcommand (https://raw.githubusercontent.com/skymethod/denoflare/v0.6.0/cli/cli_command.ts:104:13)
    at async https://raw.githubusercontent.com/skymethod/denoflare/v0.6.0/cli/cli.ts:41:5

Not sure how address this TS0: error: unexpected argument '--config' found or why it's happening

If you have some time can you setup an example of hono + deno + denoflare?

marcoaleixo avatar Feb 12 '25 02:02 marcoaleixo

0.6.0 is very out of date at this point. I should create a new tag soon, but honestly need to make sure the new esbuild-based bundler is ready, with all of the features that the old one had.

You could try installing denoflare from the latest commit, this should detect that you're using deno2 and use denoflare's esbuild-based bundler by default.

I just tried this and it worked for the default hono cf-worker project template, although if you're using denoflare, you could probably simply the deps further since you won't need any of the wrangler deps

Works locally (via deno serve)

Image

and on cloudflare (via deno push)

Image

and on deno deploy (via deno push-deploy)

Image

johnspurlock-skymethod avatar Feb 12 '25 16:02 johnspurlock-skymethod

thanks!

bumping to the latest denoflare version the error is gone.

I have a different one, probably not related to denoflare, but any idea why?

deno serve main.ts works fine

➜  backend-js git:(setup-cloudflare) ✗ denoflare serve main.ts

✅ Granted all import access.
Compiling https://raw.githubusercontent.com/skymethod/denoflare/f7f6c3f9f5d44bc1db7a239c2465f3a300ae2dc5/cli-webworker/worker.ts into worker contents...
✅ Granted all write access.
{ out: "", err: "", success: true }
Bundled https://raw.githubusercontent.com/skymethod/denoflare/f7f6c3f9f5d44bc1db7a239c2465f3a300ae2dc5/cli-webworker/worker.ts (esbuild) in 3217ms
runScript: main.ts
{ out: "", err: "", success: true }
✘ [ERROR] Could not resolve "postgres" [plugin deno-loader]

    ../../Library/Caches/deno/deno_esbuild/registry.npmjs.org/[email protected]/node_modules/drizzle-orm/postgres-js/driver.js:1:21:
      1 │ import pgClient from "postgres";
        ╵                      ~~~~~~~~~~

  You can mark the path "postgres" as external to exclude it from the bundle, which will remove this
  error and leave the unresolved path in the bundle.

error: Uncaught (in promise) Error: Build failed with 1 error:
../../Library/Caches/deno/deno_esbuild/registry.npmjs.org/[email protected]/node_modules/drizzle-orm/postgres-js/driver.js:1:21: ERROR: [plugin: deno-loader] Could not resolve "postgres"
➜  backend-js git:(setup-cloudflare) ✗ deno push         
error: Module not found "file:///Users/marcoaleixo/code/backend-js/push".
➜  backend-js git:(setup-cloudflare) ✗ 

marcoaleixo avatar Feb 12 '25 17:02 marcoaleixo

can you please share a .zip with your sample? i'm not able to make it work...

marcoaleixo avatar Feb 12 '25 20:02 marcoaleixo