Files
artcraft/frontend/libs/shared-vite-config.ts
Brandon Thomas 0004726a36 ArtCraft Desktop (fresh start)
This is a fresh start for the `artcraft` repo.

The old monorepo, which included our web API gateway, job services, SRE
tools, various frontends, and more has moved to `artcraft-services`

You can find the full git history here:

https://github.com/storytold/artcraft-services

This change was motivated by the fact that the entire git history was
hundreds of gigabytes in size, which is unwieldy for anyone not in the
core team that doesn't care about support services outside of the core
artcraft app.

We wanted to keep this repo in its well-known place since we already
have users and activity here.

Please update your remotes to either `artcraft-services` or make a fresh
clone of this repo.

History can be found at the artcraft-services repo.
2026-09-11 14:19:51 -04:00

60 lines
1.4 KiB
TypeScript

/**
* Shared Vite configuration for library builds.
*
* This ensures that:
* 1. React is always externalized (peer dependency)
* 2. @preact/signals-* packages are externalized to prevent duplicate state
* 3. @storyteller/* workspace packages are externalized so libraries don't bundle each other
*
* Without this, stateful modules like signals get bundled multiple times,
* causing state isolation issues in production builds.
*/
/**
* Returns true if the given module ID should be externalized during library builds.
*/
export function isExternal(id: string): boolean {
// Always externalize React
if (
id === 'react' ||
id === 'react-dom' ||
id === 'react/jsx-runtime' ||
id.startsWith('react/') ||
id.startsWith('react-dom/')
) {
return true;
}
// Other react libraries
if (
id === 'react-hot-toast' ||
id === 'react-router-dom' ||
id.startsWith('react-')
) {
return true;
}
// Externalize @preact/signals to prevent duplicate signal state
if (id.startsWith('@preact/signals')) {
return true;
}
// Other important libraries
if (
id === 'konva' ||
id === 'three' ||
id === 'zustand' ||
id === 'wavesurfer.js' ||
id === 'lucide-react'
) {
return true;
}
// Externalize all workspace packages so libraries don't bundle each other
if (id.startsWith('@storyteller/') || id.startsWith('@frontend/')) {
return true;
}
return false;
}