Files
documenso/apps/remix/rolldown.config.mjs
T
Lucas Smith b3ef92feb9 perf: upgrade to vite 8, migrate rollup to rolldown, and optimise build pipeline
- Upgrade vite from v7 to v8 (Rolldown-based bundler)
- Migrate server build from rollup to rolldown, eliminating 5 plugins
  (rolldown handles TS, JSX, JSON, CJS, and node resolution natively)
- Replace vite-plugin-babel-macros with targeted lingui macro plugin
  that skips files without macro imports (~90% of files)
- Replace vite-tsconfig-paths with native resolve.tsconfigPaths
- Remove redundant lingui error-reporter plugin (51% of plugin time)
- Narrow optimizeDeps.entries from ~1060 to ~460 files
- Move typecheck out of build into separate CI job (43s -> 24s build)
- Fix card.tsx var() typo exposed by LightningCSS
- Remove 30 unused packages (rollup, babel presets, rollup plugins, etc.)
- Add vite override for peer dep compatibility
- Patch @lingui/vite-plugin with moduleType for Rolldown compat
2026-03-13 10:06:15 +11:00

58 lines
1.7 KiB
JavaScript

import { transformAsync } from '@babel/core';
import linguiMacroPlugin from '@lingui/babel-plugin-lingui-macro';
import { defineConfig } from 'rolldown';
const linguiMacroRE = /@lingui\/(core\/macro|react\/macro|macro)/;
/**
* Rolldown config for building the Hono server entry.
*
* Replaces the previous rollup.config.mjs. Rolldown provides built-in
* TypeScript, JSX (automatic runtime), JSON, CJS interop, and node
* resolution — so we only need a single plugin for lingui macro compilation.
*/
export default defineConfig({
input: 'server/router.ts',
output: {
dir: 'build/server/hono',
format: 'esm',
sourcemap: true,
preserveModules: true,
preserveModulesRoot: '.',
},
// Externalize all third-party deps from node_modules.
// Workspace packages (@documenso/*) resolve to their actual source paths
// (outside node_modules) via npm workspace symlinks, so they get bundled.
external: [/node_modules/],
platform: 'node',
resolve: {
extensions: ['.ts', '.tsx', '.js', '.jsx', '.json'],
tsconfigFilename: 'tsconfig.json',
},
plugins: [
{
name: 'lingui-macro',
async transform(code, id) {
if (!/\.(tsx?|jsx?)$/.test(id)) return;
if (!linguiMacroRE.test(code)) return;
const result = await transformAsync(code, {
babelrc: false,
configFile: false,
filename: id,
parserOpts: {
sourceType: 'module',
allowAwaitOutsideFunction: true,
plugins: ['typescript', 'jsx'],
},
plugins: [linguiMacroPlugin],
sourceMaps: true,
});
if (!result?.code) return;
return { code: result.code, map: result.map };
},
},
],
});