Tesseract.js version 5.1.1
Describe the bug
Tesseract.js doesn't work on Cloudflare because it make it as browser env.
To Reproduce
Steps to reproduce the behavior:
- install Tesseract on cloudflare sample project and just run.
- the log is:
✘ [ERROR] ReferenceError: Worker is not defined
at module.exports
(file:///Users/xxx/Workspace/WebstormProjects/podcast-backend/node_modules/.pnpm/tesseract.js@5.1.1/node_modules/tesseract.js/src/worker/browser/spawnWorker.js:14:5)
at module.exports [as createWorker]
(file:///Users/xxx/Workspace/WebstormProjects/podcast-backend/node_modules/.pnpm/tesseract.js@5.1.1/node_modules/tesseract.js/src/createWorker.js:46:16)
at workerGen
(file:///Users/xxx/Workspace/WebstormProjects/podcast-backend/src/index.ts:33:34)
at Array.<anonymous>
(file:///Users/xxx/Workspace/WebstormProjects/podcast-backend/src/index.ts:16:15)
at Hono2.dispatch
(file:///Users/xxx/Workspace/WebstormProjects/podcast-backend/node_modules/.pnpm/hono@4.5.10/node_modules/hono/dist/hono-base.js:187:37)
at Hono2.fetch
(file:///Users/xxx/Workspace/WebstormProjects/podcast-backend/node_modules/.pnpm/hono@4.5.10/node_modules/hono/dist/hono-base.js:213:17)
at fetchDispatcher
(file:///Users/xxx/Workspace/WebstormProjects/podcast-backend/.wrangler/tmp/bundle-2Cuv2V/middleware-loader.entry.ts:54:17)
at __facade_invokeChain__
(file:///Users/xxx/Workspace/WebstormProjects/podcast-backend/node_modules/.pnpm/wrangler@3.73.0_@cloudflare+workers-types@4.20240821.1/node_modules/wrangler/templates/middleware/common.ts:53:9)
at Object.next
(file:///Users/xxx/Workspace/WebstormProjects/podcast-backend/node_modules/.pnpm/wrangler@3.73.0_@cloudflare+workers-types@4.20240821.1/node_modules/wrangler/templates/middleware/common.ts:50:11)
at jsonError
(file:///Users/xxx/Workspace/WebstormProjects/podcast-backend/node_modules/.pnpm/wrangler@3.73.0_@cloudflare+workers-types@4.20240821.1/node_modules/wrangler/templates/middleware/middleware-miniflare3-json-error.ts:22:30)
Please attach any input image required to replicate this behavior.
Expected behavior
It should be treat as node env but now is browser.
Device Version:
- OS + Version: macOS 14.6.1 (23G93)
Additional context
Add any other context about the problem here.
Tesseract.js version 5.1.1
Describe the bug
Tesseract.js doesn't work on Cloudflare because it make it as browser env.
To Reproduce
Steps to reproduce the behavior:
✘ [ERROR] ReferenceError: Worker is not defined at module.exports (file:///Users/xxx/Workspace/WebstormProjects/podcast-backend/node_modules/.pnpm/tesseract.js@5.1.1/node_modules/tesseract.js/src/worker/browser/spawnWorker.js:14:5) at module.exports [as createWorker] (file:///Users/xxx/Workspace/WebstormProjects/podcast-backend/node_modules/.pnpm/tesseract.js@5.1.1/node_modules/tesseract.js/src/createWorker.js:46:16) at workerGen (file:///Users/xxx/Workspace/WebstormProjects/podcast-backend/src/index.ts:33:34) at Array.<anonymous> (file:///Users/xxx/Workspace/WebstormProjects/podcast-backend/src/index.ts:16:15) at Hono2.dispatch (file:///Users/xxx/Workspace/WebstormProjects/podcast-backend/node_modules/.pnpm/hono@4.5.10/node_modules/hono/dist/hono-base.js:187:37) at Hono2.fetch (file:///Users/xxx/Workspace/WebstormProjects/podcast-backend/node_modules/.pnpm/hono@4.5.10/node_modules/hono/dist/hono-base.js:213:17) at fetchDispatcher (file:///Users/xxx/Workspace/WebstormProjects/podcast-backend/.wrangler/tmp/bundle-2Cuv2V/middleware-loader.entry.ts:54:17) at __facade_invokeChain__ (file:///Users/xxx/Workspace/WebstormProjects/podcast-backend/node_modules/.pnpm/wrangler@3.73.0_@cloudflare+workers-types@4.20240821.1/node_modules/wrangler/templates/middleware/common.ts:53:9) at Object.next (file:///Users/xxx/Workspace/WebstormProjects/podcast-backend/node_modules/.pnpm/wrangler@3.73.0_@cloudflare+workers-types@4.20240821.1/node_modules/wrangler/templates/middleware/common.ts:50:11) at jsonError (file:///Users/xxx/Workspace/WebstormProjects/podcast-backend/node_modules/.pnpm/wrangler@3.73.0_@cloudflare+workers-types@4.20240821.1/node_modules/wrangler/templates/middleware/middleware-miniflare3-json-error.ts:22:30)Please attach any input image required to replicate this behavior.
Expected behavior
It should be treat as node env but now is browser.
Device Version:
Additional context
Add any other context about the problem here.