Skip to content

Commit 2596a09

Browse files
authored
fix(supabase): add esm wrapper to resolve module not found error in nuxt (#1914)
1 parent 8769da9 commit 2596a09

File tree

3 files changed

+115
-2
lines changed

3 files changed

+115
-2
lines changed

packages/core/supabase-js/package.json

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,28 @@
1616
"src"
1717
],
1818
"main": "dist/main/index.js",
19-
"module": "dist/module/index.js",
19+
"module": "dist/esm/wrapper.mjs",
2020
"types": "dist/module/index.d.ts",
21+
"exports": {
22+
".": {
23+
"types": "./dist/module/index.d.ts",
24+
"import": "./dist/esm/wrapper.mjs",
25+
"require": "./dist/main/index.js"
26+
},
27+
"./dist/module/*": "./dist/module/*",
28+
"./package.json": "./package.json"
29+
},
2130
"sideEffects": false,
2231
"repository": {
2332
"type": "git",
2433
"url": "https://github.com/supabase/supabase-js.git",
2534
"directory": "packages/core/supabase-js"
2635
},
2736
"scripts": {
28-
"build": "npm run build:main && npm run build:module && npm run build:umd",
37+
"build": "npm run build:main && npm run build:module && npm run build:esm && npm run build:umd",
2938
"build:main": "tsc -p tsconfig.json",
3039
"build:module": "tsc -p tsconfig.module.json",
40+
"build:esm": "node scripts/copy-wrapper.cjs",
3141
"build:umd": "webpack --env mode=production",
3242
"test": "npm run test:types && npm run test:run",
3343
"test:all": "npm run test:types && npm run test:run && npm run test:integration && npm run test:integration:browser",
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const fs = require('fs')
2+
const path = require('path')
3+
4+
const src = path.join(__dirname, '..', 'wrapper.mjs')
5+
const destDir = path.join(__dirname, '..', 'dist', 'esm')
6+
const dest = path.join(destDir, 'wrapper.mjs')
7+
8+
fs.mkdirSync(destDir, { recursive: true })
9+
fs.copyFileSync(src, dest)
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
import * as index from '../main/index.js'
2+
const {
3+
PostgrestError,
4+
FunctionsHttpError,
5+
FunctionsFetchError,
6+
FunctionsRelayError,
7+
FunctionsError,
8+
FunctionRegion,
9+
SupabaseClient,
10+
createClient,
11+
GoTrueAdminApi,
12+
GoTrueClient,
13+
AuthAdminApi,
14+
AuthClient,
15+
navigatorLock,
16+
NavigatorLockAcquireTimeoutError,
17+
lockInternals,
18+
processLock,
19+
SIGN_OUT_SCOPES,
20+
AuthError,
21+
AuthApiError,
22+
AuthUnknownError,
23+
CustomAuthError,
24+
AuthSessionMissingError,
25+
AuthInvalidTokenResponseError,
26+
AuthInvalidCredentialsError,
27+
AuthImplicitGrantRedirectError,
28+
AuthPKCEGrantCodeExchangeError,
29+
AuthRetryableFetchError,
30+
AuthWeakPasswordError,
31+
AuthInvalidJwtError,
32+
isAuthError,
33+
isAuthApiError,
34+
isAuthSessionMissingError,
35+
isAuthImplicitGrantRedirectError,
36+
isAuthRetryableFetchError,
37+
isAuthWeakPasswordError,
38+
RealtimePresence,
39+
RealtimeChannel,
40+
RealtimeClient,
41+
REALTIME_LISTEN_TYPES,
42+
REALTIME_POSTGRES_CHANGES_LISTEN_EVENT,
43+
REALTIME_PRESENCE_LISTEN_EVENTS,
44+
REALTIME_SUBSCRIBE_STATES,
45+
REALTIME_CHANNEL_STATES,
46+
} = index.default || index
47+
48+
export {
49+
PostgrestError,
50+
FunctionsHttpError,
51+
FunctionsFetchError,
52+
FunctionsRelayError,
53+
FunctionsError,
54+
FunctionRegion,
55+
SupabaseClient,
56+
createClient,
57+
GoTrueAdminApi,
58+
GoTrueClient,
59+
AuthAdminApi,
60+
AuthClient,
61+
navigatorLock,
62+
NavigatorLockAcquireTimeoutError,
63+
lockInternals,
64+
processLock,
65+
SIGN_OUT_SCOPES,
66+
AuthError,
67+
AuthApiError,
68+
AuthUnknownError,
69+
CustomAuthError,
70+
AuthSessionMissingError,
71+
AuthInvalidTokenResponseError,
72+
AuthInvalidCredentialsError,
73+
AuthImplicitGrantRedirectError,
74+
AuthPKCEGrantCodeExchangeError,
75+
AuthRetryableFetchError,
76+
AuthWeakPasswordError,
77+
AuthInvalidJwtError,
78+
isAuthError,
79+
isAuthApiError,
80+
isAuthSessionMissingError,
81+
isAuthImplicitGrantRedirectError,
82+
isAuthRetryableFetchError,
83+
isAuthWeakPasswordError,
84+
RealtimePresence,
85+
RealtimeChannel,
86+
RealtimeClient,
87+
REALTIME_LISTEN_TYPES,
88+
REALTIME_POSTGRES_CHANGES_LISTEN_EVENT,
89+
REALTIME_PRESENCE_LISTEN_EVENTS,
90+
REALTIME_SUBSCRIBE_STATES,
91+
REALTIME_CHANNEL_STATES,
92+
}
93+
94+
export default index.default || index

0 commit comments

Comments
 (0)