|
1 | | -import { join } from 'node:path'; |
2 | | - |
3 | 1 | import virtual from '@rollup/plugin-virtual'; |
4 | 2 | import { build } from 'rolldown'; |
5 | 3 |
|
6 | 4 | import cssLoader from './css.mjs'; |
7 | 5 | import getStaticData from './data.mjs'; |
8 | 6 | import getConfig from '../../../utils/configuration/index.mjs'; |
9 | | - |
10 | | -// Resolve node_modules relative to this package (doc-kit), not cwd. |
11 | | -// This ensures modules are found when running from external directories. |
12 | | -const DOC_KIT_NODE_MODULES = join( |
13 | | - import.meta.dirname, |
14 | | - '../../../../node_modules' |
15 | | -); |
| 7 | +import { NODE_MODULES } from '../constants.mjs'; |
16 | 8 |
|
17 | 9 | /** |
18 | 10 | * Asynchronously bundles JavaScript source code (and its CSS imports), |
@@ -99,9 +91,8 @@ export default async function bundleCode(codeMap, { server = false } = {}) { |
99 | 91 | }, |
100 | 92 |
|
101 | 93 | // Tell the bundler where to find node_modules. |
102 | | - // This ensures packages are found when running doc-kit from external directories |
103 | | - // (e.g., running from the node repository via tools/doc/node_modules/.bin/doc-kit). |
104 | | - modules: [DOC_KIT_NODE_MODULES, 'node_modules'], |
| 94 | + // We use our custom `NODE_MODULES`, and then the cwd's `node_modules`. |
| 95 | + modules: [NODE_MODULES, 'node_modules'], |
105 | 96 | }, |
106 | 97 |
|
107 | 98 | // Array of plugins to apply during the build. |
|
0 commit comments