diff --git a/packages/core/supabase-js/package.json b/packages/core/supabase-js/package.json index 1114d30c1..1be4be34a 100644 --- a/packages/core/supabase-js/package.json +++ b/packages/core/supabase-js/package.json @@ -16,8 +16,17 @@ "src" ], "main": "dist/main/index.js", - "module": "dist/module/index.js", + "module": "dist/esm/wrapper.mjs", "types": "dist/module/index.d.ts", + "exports": { + ".": { + "types": "./dist/module/index.d.ts", + "import": "./dist/esm/wrapper.mjs", + "require": "./dist/main/index.js" + }, + "./dist/module/*": "./dist/module/*", + "./package.json": "./package.json" + }, "sideEffects": false, "repository": { "type": "git", @@ -25,9 +34,10 @@ "directory": "packages/core/supabase-js" }, "scripts": { - "build": "npm run build:main && npm run build:module && npm run build:umd", + "build": "npm run build:main && npm run build:module && npm run build:esm && npm run build:umd", "build:main": "tsc -p tsconfig.json", "build:module": "tsc -p tsconfig.module.json", + "build:esm": "node scripts/copy-wrapper.cjs", "build:umd": "webpack --env mode=production", "test": "npm run test:types && npm run test:run", "test:all": "npm run test:types && npm run test:run && npm run test:integration && npm run test:integration:browser", diff --git a/packages/core/supabase-js/scripts/copy-wrapper.cjs b/packages/core/supabase-js/scripts/copy-wrapper.cjs new file mode 100644 index 000000000..9c4939081 --- /dev/null +++ b/packages/core/supabase-js/scripts/copy-wrapper.cjs @@ -0,0 +1,9 @@ +const fs = require('fs') +const path = require('path') + +const src = path.join(__dirname, '..', 'wrapper.mjs') +const destDir = path.join(__dirname, '..', 'dist', 'esm') +const dest = path.join(destDir, 'wrapper.mjs') + +fs.mkdirSync(destDir, { recursive: true }) +fs.copyFileSync(src, dest) diff --git a/packages/core/supabase-js/wrapper.mjs b/packages/core/supabase-js/wrapper.mjs new file mode 100644 index 000000000..794120464 --- /dev/null +++ b/packages/core/supabase-js/wrapper.mjs @@ -0,0 +1,94 @@ +import * as index from '../main/index.js' +const { + PostgrestError, + FunctionsHttpError, + FunctionsFetchError, + FunctionsRelayError, + FunctionsError, + FunctionRegion, + SupabaseClient, + createClient, + GoTrueAdminApi, + GoTrueClient, + AuthAdminApi, + AuthClient, + navigatorLock, + NavigatorLockAcquireTimeoutError, + lockInternals, + processLock, + SIGN_OUT_SCOPES, + AuthError, + AuthApiError, + AuthUnknownError, + CustomAuthError, + AuthSessionMissingError, + AuthInvalidTokenResponseError, + AuthInvalidCredentialsError, + AuthImplicitGrantRedirectError, + AuthPKCEGrantCodeExchangeError, + AuthRetryableFetchError, + AuthWeakPasswordError, + AuthInvalidJwtError, + isAuthError, + isAuthApiError, + isAuthSessionMissingError, + isAuthImplicitGrantRedirectError, + isAuthRetryableFetchError, + isAuthWeakPasswordError, + RealtimePresence, + RealtimeChannel, + RealtimeClient, + REALTIME_LISTEN_TYPES, + REALTIME_POSTGRES_CHANGES_LISTEN_EVENT, + REALTIME_PRESENCE_LISTEN_EVENTS, + REALTIME_SUBSCRIBE_STATES, + REALTIME_CHANNEL_STATES, +} = index.default || index + +export { + PostgrestError, + FunctionsHttpError, + FunctionsFetchError, + FunctionsRelayError, + FunctionsError, + FunctionRegion, + SupabaseClient, + createClient, + GoTrueAdminApi, + GoTrueClient, + AuthAdminApi, + AuthClient, + navigatorLock, + NavigatorLockAcquireTimeoutError, + lockInternals, + processLock, + SIGN_OUT_SCOPES, + AuthError, + AuthApiError, + AuthUnknownError, + CustomAuthError, + AuthSessionMissingError, + AuthInvalidTokenResponseError, + AuthInvalidCredentialsError, + AuthImplicitGrantRedirectError, + AuthPKCEGrantCodeExchangeError, + AuthRetryableFetchError, + AuthWeakPasswordError, + AuthInvalidJwtError, + isAuthError, + isAuthApiError, + isAuthSessionMissingError, + isAuthImplicitGrantRedirectError, + isAuthRetryableFetchError, + isAuthWeakPasswordError, + RealtimePresence, + RealtimeChannel, + RealtimeClient, + REALTIME_LISTEN_TYPES, + REALTIME_POSTGRES_CHANGES_LISTEN_EVENT, + REALTIME_PRESENCE_LISTEN_EVENTS, + REALTIME_SUBSCRIBE_STATES, + REALTIME_CHANNEL_STATES, +} + +export default index.default || index