11import { join } from 'node:path' ;
22
33import virtual from '@rollup/plugin-virtual' ;
4- import { build } from 'rolldown' ;
54
65import cssLoader from './css.mjs' ;
76import getStaticData from './data.mjs' ;
87import getConfig from '../../../utils/configuration/index.mjs' ;
8+ import { lazy } from '../../../utils/misc.mjs' ;
99
1010// Resolve node_modules relative to this package (doc-kit), not cwd.
1111// This ensures modules are found when running from external directories.
@@ -14,6 +14,11 @@ const DOC_KIT_NODE_MODULES = join(
1414 '../../../../node_modules'
1515) ;
1616
17+ // TODO(@avivkeller): Untill we can use Rolldown's bindings in node-core,
18+ // we have to dynamically import it, as to not have it imported in core
19+ // at all.
20+ const rolldown = lazy ( ( ) => import ( 'rolldown' ) ) ;
21+
1722/**
1823 * Asynchronously bundles JavaScript source code (and its CSS imports),
1924 * targeting either browser (client) or server (Node.js) environments.
@@ -25,6 +30,8 @@ const DOC_KIT_NODE_MODULES = join(
2530export default async function bundleCode ( codeMap , { server = false } = { } ) {
2631 const config = getConfig ( 'web' ) ;
2732
33+ const { build } = await rolldown ( ) ;
34+
2835 const result = await build ( {
2936 // Entry points: array of virtual module names that the virtual plugin provides
3037 input : Array . from ( codeMap . keys ( ) ) ,
0 commit comments