diff --git a/README.md b/README.md index 114b787..52b220e 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,10 @@ The UMD bundles externalize `rdflib` only. The ESM bundles externalize both `rdflib` and the auth library packages `@uvdsl/solid-oidc-client-browser` / `@uvdsl/solid-oidc-client-browser/core`. +The ESM and CommonJS builds bundle `@dokieli/web-access-control` and its +runtime dependencies so CommonJS consumers do not need to load its ESM-only +package entry directly. + ## Available Files | Format | File | Usage | Global Variable | diff --git a/vite.config.mts b/vite.config.mts index d670071..99d25ab 100644 --- a/vite.config.mts +++ b/vite.config.mts @@ -1,7 +1,25 @@ +import { isAbsolute } from 'node:path' import { buildConfig } from "solidos-toolkit/vite"; import { defineConfig } from "vitest/config"; -const build = buildConfig({ entry: "src/index.ts" }) ?? {}; +const bundledCjsDependencies = new Set([ + '@dokieli/web-access-control', + '@rdfjs/data-model', + '@rdfjs/types', + 'n3' +]) + +const build = buildConfig({ + entry: "src/index.ts", + overrides: { + rolldownOptions: { + external: (id: string) => { + if (bundledCjsDependencies.has(id)) return false + return !id.startsWith("~icons/") && !id.startsWith("@/") && !id.startsWith(".") && !isAbsolute(id) + } + } + } +}) ?? {}; export default defineConfig({ build,