Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@node-core/doc-kit",
"type": "module",
"version": "1.0.1",
"version": "1.0.2",
"repository": {
"type": "git",
"url": "git+https://github.com/nodejs/doc-kit.git"
Expand Down
9 changes: 0 additions & 9 deletions src/generators/web/constants.mjs
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
import { findPackageJSON } from 'node:module';
import { resolve, dirname } from 'node:path';
import { fileURLToPath } from 'node:url';

export const ROOT = dirname(fileURLToPath(import.meta.url));

// Resolve node_modules relative to this package (doc-kit), not cwd.
// We do this by finding where one of our dependencies (preact) is stored,
// and using it's NODE_MODULES
export const NODE_MODULES = resolve(
findPackageJSON(new URL(import.meta.resolve('preact'))),
'../..'
);

/**
* @typedef {Object} JSXImportConfig
* @property {string} name - The name of the component to be imported.
Expand Down
18 changes: 16 additions & 2 deletions src/generators/web/utils/bundle.mjs
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
import { resolve } from 'node:path';

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

import cssLoader from './css.mjs';
import getStaticData from './data.mjs';
import getConfig from '../../../utils/configuration/index.mjs';
import { NODE_MODULES } from '../constants.mjs';
import { lazy } from '../../../utils/misc.mjs';

// Resolve node_modules relative to this package (doc-kit), not cwd.
Comment thread
avivkeller marked this conversation as resolved.
// We do this by finding where one of our dependencies (preact) is stored,
// and using it's NODE_MODULES
Comment thread
avivkeller marked this conversation as resolved.
const getNodeModules = lazy(async () => {
const { findPackageJSON } = await import('node:module');

return resolve(
findPackageJSON(new URL(import.meta.resolve('preact'))),
'../..'
);
});

/**
* Asynchronously bundles JavaScript source code (and its CSS imports),
Expand Down Expand Up @@ -92,7 +106,7 @@ export default async function bundleCode(codeMap, { server = false } = {}) {

// Tell the bundler where to find node_modules.
// We use our custom `NODE_MODULES`, and then the cwd's `node_modules`.
modules: [NODE_MODULES, 'node_modules'],
modules: [await getNodeModules(), 'node_modules'],
},

// Array of plugins to apply during the build.
Expand Down
Loading