It's been 2 days now that I am struggling with this issue of not being able to exclude @supabase/supabase-js and its dependancies from the final server.js file. I am using Cloudflare workers solid adapter. I've tried all possible combinations to mark the library as external with no luck. Here is my vite.ts file.
import solid from 'solid-start/vite'
import { defineConfig } from 'vite'
import cloudflare from 'solid-start-cloudflare-workers'
import createExternal from 'vite-plugin-external'
export default defineConfig({
plugins: [
solid({
ssr: false,
exclude: ['@supabase/supabase-js', 'node_modules'],
adapter: cloudflare({
wranglerConfigPath: true,
}),
}),
createExternal({
externals: {
supabase: '@supabase/supabase-js',
},
}),
],
envPrefix: 'PUBLIC_',
server: {
port: 8010,
},
build: {
rollupOptions: {
external: ['node_modules', '@supabase/supabase-js'],
output: {
globals: {
'@supabase/supabase-js': '@supabase/supabase-js',
},
},
},
},
optimizeDeps: {
disabled: true,
exclude: ['node_modules', '@supabase/supabase-js'],
},
ssr: {
external: ['node_modules', '@supabase/supabase-js'],
},
})
Resulting server.js
has traces of supabase being bundles into the file along with its dependencies.
import manifestJSON from '__STATIC_CONTENT_MANIFEST';
import Stream from 'stream';
import http from 'http';
import Url from 'url';
import require$$0$2 from 'punycode';
import https from 'https';
import zlib from 'zlib';
import require$$2 from 'events';
import require$$0$3 from 'tty';
import require$$1$1 from 'util';
import require$$3 from 'fs';
import require$$4 from 'net';
import require$$0$5 from 'crypto';
...
I need to end up with server simply having depencies imported as:
import {createServer} from '@supabase/supabase-js'
It's probably worth mentioning that I am using typescript and there is a tsconfig.json file with the following configs:
{
"extends": "tsconfig/solid.json",
"compilerOptions": {
"types": ["solid-start/env"],
"baseUrl": "./",
"paths": {
"~/*": ["./src/*"]
}
},
"include": ["src/**/*"],
"exclude": ["node_modules", "@supabase/supabase-js"]
}
Any help would be greatly appreciated.
I've tried to add externals into config file with the same result every time.