Skip to content

Commit 9a2532e

Browse files
committed
fix(rolldown): dynamic import
1 parent 32a824c commit 9a2532e

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/generators/web/utils/bundle.mjs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { join } from 'node:path';
22

33
import virtual from '@rollup/plugin-virtual';
4-
import { build } from 'rolldown';
54

65
import cssLoader from './css.mjs';
76
import getStaticData from './data.mjs';
87
import 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(
2530
export 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

Comments
 (0)