eta-dev / eta

Embedded JS template engine for Node, Deno, and the browser. Lighweight, fast, and pluggable. Written in TypeScript
https://eta.js.org
MIT License
1.35k stars 60 forks source link

support for cloudflare workers #263

Closed maxjoygit closed 8 months ago

maxjoygit commented 8 months ago

if possible :)

nebrelbug commented 8 months ago

@maxjoygit can you provide an example? I would think that it should already work.

maxjoygit commented 8 months ago

X [ERROR] Could not resolve "node:path"

node_modules/eta/dist/eta.module.mjs:1:22:
  1 │ import * as path from 'node:path';
    ╵                       ~~~~~~~~~~~

You can mark the path "node:path" as external to exclude it from the bundle, which will remove this error.

X [ERROR] Could not resolve "node:fs"

node_modules/eta/dist/eta.module.mjs:2:20:
  2 │ import * as fs from 'node:fs';
    ╵                     ~~~~~~~~~

You can mark the path "node:fs" as external to exclude it from the bundle, which will remove this error.

X [ERROR] Build failed with 2 errors:

node_modules/eta/dist/eta.module.mjs:1:22: ERROR: Could not resolve "node:path" node_modules/eta/dist/eta.module.mjs:2:20: ERROR: Could not resolve "node:fs"

nebrelbug commented 8 months ago

@maxjoygit from https://developers.cloudflare.com/workers/runtime-apis/nodejs/path/:

To use Node.js APIs in your Worker, add the nodejs_compat compatibility flag to your wrangler.toml file.

maxjoygit commented 8 months ago

I did, but not working Can I have working example app?

nebrelbug commented 8 months ago

@maxjoygit sorry, I don't have any working examples to share right now.