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

I can't publish to Cloudflare Workers #46

Closed
nulltask opened this issue Jun 8, 2022 · 4 comments · Fixed by #84
Closed

I can't publish to Cloudflare Workers #46

nulltask opened this issue Jun 8, 2022 · 4 comments · Fixed by #84
Labels
bug Something isn't working

Comments

@nulltask
Copy link

nulltask commented Jun 8, 2022

Version

node: 18.3.0
@nuxtjs/supabase: 0.1.16
nuxt: 3.0.0-rc.3

Reproduction Link

https://github.com/nulltask/supabase-module-repro

Steps to reproduce

% npm install
% npx wrangler publish

What is Expected?

Publish the website to Cloudflare Workers successfully.

What is actually happening?

The following error message was output.
Remove @nuxtjs/supabase from modules, then I can publish website successfully.

% npx wrangler publish      
 ⛅️ wrangler 2.0.7 (update available 2.0.8)
-----------------------------------------------------
Running custom build: NITRO_PRESET=cloudflare npm run build

> build
> nuxt build

Nuxt CLI v3.0.0-rc.3                                                                                          14:57:19

 ERROR  (node:64807) ExperimentalWarning: The Fetch API is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)

ℹ Vite client warmed up in 1170ms                                                                             14:57:22
ℹ Client built in 1212ms                                                                                      14:57:22
ℹ Building server...                                                                                          14:57:22
✔ Server built in 551ms                                                                                       14:57:23
✔ Generated public .output/public                                                                       nitro 14:57:23
start Building server...                                                                                nitro 14:57:23
start Writing server bundle...                                                                          nitro 14:57:24
✔ Server built                                                                                          nitro 14:57:26
  └─ .output/server/index.mjs (488 kB) (150 kB gzip)
Σ Total size: 488 kB (150 kB gzip)
✔ You can preview this build using npx miniflare .output/server/index.mjs --site .output/public         nitro 14:57:26
✔ You can deploy this build using cd .output/server && npx wrangler publish                             nitro 14:57:26
✘ [ERROR] [plugin checkForNodeBuiltins] Detected a Node builtin module import while Node compatibility is disabled.
Add node_compat = true to your wrangler.toml file to enable Node compatibility.

    node_modules/node-gyp-build/index.js:1:17:
      1 │ var fs = require('fs')
        ╵                  ~~~~

  This error came from the "onResolve" callback registered here:

    node_modules/wrangler/wrangler-dist/cli.js:121207:11:
      121207 │     build6.onResolve({
             ╵            ~~~~~~~~~

    at setup (/Users/nulltask/Documents/GitHub/supabase-module-repro/node_modules/wrangler/wrangler-dist/cli.js:121207:12)
    at handlePlugins (/Users/nulltask/Documents/GitHub/supabase-module-repro/node_modules/wrangler/node_modules/esbuild/lib/main.js:843:23)
    at Object.buildOrServe (/Users/nulltask/Documents/GitHub/supabase-module-repro/node_modules/wrangler/node_modules/esbuild/lib/main.js:1137:7)
    at /Users/nulltask/Documents/GitHub/supabase-module-repro/node_modules/wrangler/node_modules/esbuild/lib/main.js:2079:17
    at new Promise (<anonymous>)
    at Object.build (/Users/nulltask/Documents/GitHub/supabase-module-repro/node_modules/wrangler/node_modules/esbuild/lib/main.js:2078:14)
    at Object.build (/Users/nulltask/Documents/GitHub/supabase-module-repro/node_modules/wrangler/node_modules/esbuild/lib/main.js:1927:51)
    at bundleWorker (/Users/nulltask/Documents/GitHub/supabase-module-repro/node_modules/wrangler/wrangler-dist/cli.js:121235:33)
    at publish (/Users/nulltask/Documents/GitHub/supabase-module-repro/node_modules/wrangler/wrangler-dist/cli.js:124352:67)

✘ [ERROR] [plugin checkForNodeBuiltins] Detected a Node builtin module import while Node compatibility is disabled.
Add node_compat = true to your wrangler.toml file to enable Node compatibility.

    node_modules/node-gyp-build/index.js:2:19:
      2 │ var path = require('path')
        ╵                    ~~~~~~

  This error came from the "onResolve" callback registered here:

    node_modules/wrangler/wrangler-dist/cli.js:121207:11:
      121207 │     build6.onResolve({
             ╵            ~~~~~~~~~

    at setup (/Users/nulltask/Documents/GitHub/supabase-module-repro/node_modules/wrangler/wrangler-dist/cli.js:121207:12)
    at handlePlugins (/Users/nulltask/Documents/GitHub/supabase-module-repro/node_modules/wrangler/node_modules/esbuild/lib/main.js:843:23)
    at Object.buildOrServe (/Users/nulltask/Documents/GitHub/supabase-module-repro/node_modules/wrangler/node_modules/esbuild/lib/main.js:1137:7)
    at /Users/nulltask/Documents/GitHub/supabase-module-repro/node_modules/wrangler/node_modules/esbuild/lib/main.js:2079:17
    at new Promise (<anonymous>)
    at Object.build (/Users/nulltask/Documents/GitHub/supabase-module-repro/node_modules/wrangler/node_modules/esbuild/lib/main.js:2078:14)
    at Object.build (/Users/nulltask/Documents/GitHub/supabase-module-repro/node_modules/wrangler/node_modules/esbuild/lib/main.js:1927:51)
    at bundleWorker (/Users/nulltask/Documents/GitHub/supabase-module-repro/node_modules/wrangler/wrangler-dist/cli.js:121235:33)
    at publish (/Users/nulltask/Documents/GitHub/supabase-module-repro/node_modules/wrangler/wrangler-dist/cli.js:124352:67)

✘ [ERROR] [plugin checkForNodeBuiltins] Detected a Node builtin module import while Node compatibility is disabled.
Add node_compat = true to your wrangler.toml file to enable Node compatibility.

    node_modules/node-gyp-build/index.js:3:17:
      3 │ var os = require('os')
        ╵                  ~~~~

  This error came from the "onResolve" callback registered here:

    node_modules/wrangler/wrangler-dist/cli.js:121207:11:
      121207 │     build6.onResolve({
             ╵            ~~~~~~~~~

    at setup (/Users/nulltask/Documents/GitHub/supabase-module-repro/node_modules/wrangler/wrangler-dist/cli.js:121207:12)
    at handlePlugins (/Users/nulltask/Documents/GitHub/supabase-module-repro/node_modules/wrangler/node_modules/esbuild/lib/main.js:843:23)
    at Object.buildOrServe (/Users/nulltask/Documents/GitHub/supabase-module-repro/node_modules/wrangler/node_modules/esbuild/lib/main.js:1137:7)
    at /Users/nulltask/Documents/GitHub/supabase-module-repro/node_modules/wrangler/node_modules/esbuild/lib/main.js:2079:17
    at new Promise (<anonymous>)
    at Object.build (/Users/nulltask/Documents/GitHub/supabase-module-repro/node_modules/wrangler/node_modules/esbuild/lib/main.js:2078:14)
    at Object.build (/Users/nulltask/Documents/GitHub/supabase-module-repro/node_modules/wrangler/node_modules/esbuild/lib/main.js:1927:51)
    at bundleWorker (/Users/nulltask/Documents/GitHub/supabase-module-repro/node_modules/wrangler/wrangler-dist/cli.js:121235:33)
    at publish (/Users/nulltask/Documents/GitHub/supabase-module-repro/node_modules/wrangler/wrangler-dist/cli.js:124352:67)


✘ [ERROR] Build failed with 3 errors:

  node_modules/node-gyp-build/index.js:1:17: ERROR: [plugin: checkForNodeBuiltins] Detected a Node
  builtin module import while Node compatibility is disabled.
  Add node_compat = true to your wrangler.toml file to enable Node compatibility.
  node_modules/node-gyp-build/index.js:2:19: ERROR: [plugin: checkForNodeBuiltins] Detected a Node
  builtin module import while Node compatibility is disabled.
  Add node_compat = true to your wrangler.toml file to enable Node compatibility.
  node_modules/node-gyp-build/index.js:3:17: ERROR: [plugin: checkForNodeBuiltins] Detected a Node
  builtin module import while Node compatibility is disabled.
  Add node_compat = true to your wrangler.toml file to enable Node compatibility.


If you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new.
@nulltask nulltask added the bug Something isn't working label Jun 8, 2022
@kevinmarrec
Copy link
Contributor

Does anyone have an update on this ?

My error when using wrangler publish is different :

image

@kevinmarrec
Copy link
Contributor

kevinmarrec commented Oct 6, 2022

image

The culprit for me is this one, but I don't know which package use it yet, changing global to globalThis or removing the little global.btoa part works.

btoa is https://developer.mozilla.org/fr/docs/Web/API/btoa

I need to find out which depedency use it but it's for sure a dependency used by @supabase/supabase-js.

@kevinmarrec
Copy link
Contributor

I found the issue, this is caused by this line :
https://github.com/nuxt-modules/supabase/blob/main/src/module.ts#L177

I already found a fix, gonna submit a PR

@kevinmarrec
Copy link
Contributor

Submitted the PR, and here is a workaround until it gets merged & released :

export default defineNuxtConfig({
  modules: [
    '@nuxtjs/supabase',
    (_, { options: { build: { transpile } } }) => { transpile.splice(transpile.findIndex(x => x === 'websocket'), 1) }
  ]
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants