Skip to content

Conversation

@JounQin
Copy link
Member

@JounQin JounQin commented Aug 26, 2025

close #10

Summary by CodeRabbit

  • New Features

    • Introduced a new package for PDF export features, accessible via a single entry point.
    • Simplified imports for HTML-to-PDF utilities and core APIs.
  • Chores

    • Migrated the project to a monorepo with workspaces; updated build scripts and TypeScript configs.
  • CI

    • Publishing workflow now targets only workspace packages.
  • Maintenance

    • Broadened ignore patterns for formatting and linting.
  • Notes

    • Consumers should import PDF export APIs from the new package going forward.

@changeset-bot
Copy link

changeset-bot bot commented Aug 26, 2025

🦋 Changeset detected

Latest commit: 4f9517b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@alauda/doom-export Minor
@alauda/doom Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link

coderabbitai bot commented Aug 26, 2025

Walkthrough

Converts the repo to a Yarn workspaces monorepo. Introduces two packages: @alauda/doom (core) and @alauda/doom-export (PDF export). Updates build configs (tsconfig, ESLint, Prettier), CI publish workflow, and rewires imports/exports to the new package boundaries while removing legacy barrel exports under src/.

Changes

Cohort / File(s) Summary
Monorepo setup & root configs
package.json, tsconfig.base.json, tsconfig.json, .prettierignore, eslint.config.js, src/tsconfig.json
Root becomes private workspace with packages/*; adds base TS config and references; broadens ignore patterns; removes root exports/bin/deps; updates scripts; deletes old src tsconfig.
CI workflow
.github/workflows/pkg-pr-new.yml
Publish step targets ./packages/*; comments out --compact; keeps Yarn package manager.
Changeset
.changeset/dull-jeans-stare.md
Adds changeset marking minor bumps for @alauda/doom-export and @alauda/doom with note "migrate to mono repo".
Doom package (core)
packages/doom/package.json, packages/doom/tsconfig.json, packages/doom/src/cli/export.ts
Adds core package with bin and exports; project tsconfig; CLI now imports PDF export types/functions from @alauda/doom-export.
Export package (PDF)
packages/export/package.json, packages/export/tsconfig.json, packages/export/src/index.ts, packages/export/src/helpers.ts, packages/export/src/export-pdf-core/*, packages/export/src/html-export-pdf/*, packages/export/src/merge-pdfs/index.ts
Adds new PDF export package; establishes barrels for core/utils; adjusts import extensions/paths; adds helpers and HTML export barrels; sets package exports/files/deps.
Legacy barrels removed
src/cli/export-pdf-core/index.ts, src/cli/export-pdf-core/utils/index.ts, src/cli/html-export-pdf/core/index.ts, src/cli/html-export-pdf/index.ts, src/cli/html-export-pdf/utils/index.ts
Removes re-export barrels under old src/cli/**, aligning with moved code into packages/export.

Sequence Diagram(s)

sequenceDiagram
  actor User
  participant CLI as @alauda/doom CLI
  participant Export as @alauda/doom-export
  participant Playwright as Playwright/browser
  participant PDF as PDF tools

  User->>CLI: run doom export ...
  CLI->>Export: generatePdf(options)
  Export->>Playwright: render pages
  Export->>PDF: merge/post-process
  Export-->>CLI: PDF path/result
  CLI-->>User: output success/error
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Assessment against linked issues

Objective Addressed Explanation
Migrate repository to monorepo (#10)
Create/split Doom core package (#10)
Split into Rspress plugins (#10) No Rspress plugin packages or plugin-related code added.

Assessment against linked issues: Out-of-scope changes

(No out-of-scope functional changes detected.)

Possibly related PRs

Suggested labels

feature, breaking, internal

Poem

I hopped from root to verdant rows,
Two burrows now where codegrass grows.
One for Doom, one exports bright—
PDFs by moonlit night.
Workspaces weave a carrot trail,
Ship with a thump of cotton tail.
Monorepo dreams, we set sail! 🥕✨

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/monorepo

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@JounQin JounQin force-pushed the feat/monorepo branch 3 times, most recently from 56e9b0f to a8e55f7 Compare August 26, 2025 09:47
@pkg-pr-new
Copy link

pkg-pr-new bot commented Aug 26, 2025

Open in StackBlitz

yarn add https://pkg.pr.new/alauda/doom/@alauda/doom@159.tgz
yarn add https://pkg.pr.new/alauda/doom/@alauda/doom-export@159.tgz

commit: 4f9517b

@JounQin JounQin marked this pull request as ready for review August 26, 2025 09:56
Copilot AI review requested due to automatic review settings August 26, 2025 09:56
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR migrates the codebase from a single package structure to a monorepo setup with separate packages for the main functionality and export capabilities.

  • Restructures the codebase into packages/doom and packages/export with shared TypeScript configuration
  • Moves export-related functionality into a separate @alauda/doom-export package
  • Updates import paths from .js to .ts extensions throughout the codebase

Reviewed Changes

Copilot reviewed 29 out of 186 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
tsconfig.base.json Adds shared TypeScript configuration for the monorepo
packages/export/* Creates new export package with moved PDF generation functionality
packages/doom/* Creates main doom package with updated imports to use the new export package
package.json Converts root to monorepo workspace with updated scripts and dependencies
Various config files Updates ignore patterns and paths for monorepo structure

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 11

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (4)
packages/export/src/export-pdf-core/generatePdf.ts (1)

113-114: HTTP header name typo: use Referer

Playwright/Node expect the historical misspelling “referer”. The current “refer” header will be ignored.

-              refer: parsedUrlString,
+              referer: parsedUrlString,
packages/export/src/html-export-pdf/core/printer.ts (3)

121-128: Misuse of Playwright connect options; args/headless/pipe are ignored.

chromium.connect() does not accept launch options like args, headless, or pipe. These options are only used by chromium.launch(). As written, connecting to a remote browser won’t apply the intended settings; worse, it suggests a false sense of configuration parity.

Minimal fix: use separate option sets for connect vs launch.

-    if (this.browserWSEndpoint) {
-      this.browser = await chromium.connect(
-        this.browserWSEndpoint,
-        browserOptions,
-      )
-    } else {
-      this.browser = await chromium.launch(browserOptions)
-    }
+    if (this.browserWSEndpoint) {
+      // Only pass supported ConnectOptions here (e.g., timeout, headers)
+      const { timeout } = (launchOptions ?? {}) as { timeout?: number }
+      this.browser = await chromium.connect(this.browserWSEndpoint, { timeout })
+    } else {
+      this.browser = await chromium.launch(browserOptions)
+    }

If you intend to connect to an existing Chromium via CDP, consider chromium.connectOverCDP({ wsEndpoint, timeout }).


147-171: Access control routing not installed unless allowed lists are non-empty.

route('**/*', ...) is only registered when needsAllowedRules() is truthy. That function currently checks only allowedPaths/allowedDomains. As a result, allowLocal/allowRemote are not enforced unless you also provide allowed lists.

Fix by treating the booleans as gating conditions too:

-    if (this.needsAllowedRules()) {
+    if (this.needsAllowedRules()) {
       await page.route('**/*', (route) => {
-        const uri = new URL(route.request().url())
-        const { host, protocol, pathname } = uri
+        const uri = new URL(route.request().url())
+        const { host, protocol } = uri
         const local = protocol === 'file:'
 
-        if (local && !this.withinAllowedPath(pathname)) {
+        // Convert file URL to OS path for reliable checks on all platforms
+        const pathname = local ? toFsPath(uri) : undefined
+
+        if (local && pathname && !this.withinAllowedPath(pathname)) {
           return route.abort()
         }
 
         if (local && !this.allowLocal) {
           return route.abort()
         }
 
         if (host && !this.isAllowedDomain(host)) {
           return route.abort()
         }
 
         if (host && !this.allowRemote) {
           return route.abort()
         }
 
         return route.continue()
       })
     }

And update needsAllowedRules() accordingly (see next comment).
Outside this hunk, add:

// near imports
import { fileURLToPath } from 'node:url'

// near class methods (helper)
function toFsPath(u: URL) {
  return fileURLToPath(u) // handles Windows and percent-encoding correctly
}

297-299: Return a boolean and include allowLocal/allowRemote in the condition.

This currently returns a number and ignores the boolean gates; make it explicit.

-  needsAllowedRules() {
-    return this.allowedPaths.length || this.allowedDomains.length
-  }
+  needsAllowedRules() {
+    return (
+      this.allowedPaths.length > 0 ||
+      this.allowedDomains.length > 0 ||
+      this.allowLocal === false ||
+      this.allowRemote === false
+    )
+  }
🧹 Nitpick comments (22)
.prettierignore (1)

2-2: Broadened pyodide ignore looks good; consider aligning Prettier/Eslint ignores.

The **/pyodide pattern is appropriate for a monorepo. To avoid Prettier touching build artifacts across packages (and to stay consistent with eslint ignores), consider also ignoring dist and lib.

Apply this diff:

 .yarn
 **/pyodide
+# build outputs in all packages
+**/dist
+**/lib
 # too big
 fixture-docs/shared/crds/operator.tekton.dev_*.yaml
.changeset/dull-jeans-stare.md (1)

1-6: Confirm semver: monorepo migration may be user-visible; ensure “minor” is correct.

If import paths, CLI entry points, or package names changed for consumers, this would be a breaking change and should be a major bump. If behavior is preserved, minor is fine—please verify.

Also, expand the message to clarify what changed to help release notes readers.

Suggested tweak:

 ---
 "@alauda/doom-export": minor
 "@alauda/doom": minor
 ---
 
-feat: migrate to mono repo
+feat: migrate to monorepo, split into core (@alauda/doom) and export (@alauda/doom-export).
+No breaking changes to public APIs/import paths.
.github/workflows/pkg-pr-new.yml (1)

35-35: Double-check glob quoting for pkg-pr-new.

Quoting './packages/*' prevents shell expansion and passes the glob literally to pkg-pr-new. If the tool expects expanded directories, drop the quotes; if it supports its own globbing, keeping quotes is fine. Please verify the intended behavior.

If shell expansion is desired, apply:

-        run: yarn dlx pkg-pr-new publish './packages/*' --packageManager=yarn # --compact
+        run: yarn dlx pkg-pr-new publish ./packages/* --packageManager=yarn # --compact

Note: Yarn v4 usage in this repo is compatible with yarn dlx; no issues there.

eslint.config.js (1)

15-15: Use **/dist to cover nested package builds.

Given the monorepo, dist at the root isn’t sufficient. Mirror the lib/pyodide approach for dist.

-    ignores: ['dist', '**/lib', '**/pyodide'],
+    ignores: ['**/dist', '**/lib', '**/pyodide'],
packages/export/src/helpers.ts (1)

4-9: Minor cleanup: prefer path.dirname (or import.meta.dirname) for clarity; optionally export PKG_DIR.

Functionally correct, but path.dirname(fileURLToPath(import.meta.url)) is clearer than resolving .. off the file path. If your Node engine is ≥20, import.meta.dirname is even cleaner. Exporting PKG_DIR can also be handy for consumers/tests.

Option A (Node < 20 safe):

-const BASE_DIR = path.resolve(fileURLToPath(import.meta.url), '..')
+const BASE_DIR = path.dirname(fileURLToPath(import.meta.url))
 
-const PKG_DIR = path.resolve(BASE_DIR, '..')
+export const PKG_DIR = path.resolve(BASE_DIR, '..')
 
 export const pkgResolve = (...paths: string[]) =>
-  path.resolve(PKG_DIR, ...paths)
+  path.resolve(PKG_DIR, ...paths)

Option B (Node ≥ 20):

-const BASE_DIR = path.resolve(fileURLToPath(import.meta.url), '..')
+const BASE_DIR = import.meta.dirname
-const PKG_DIR = path.resolve(BASE_DIR, '..')
+export const PKG_DIR = path.resolve(BASE_DIR, '..')
packages/export/src/merge-pdfs/index.ts (2)

18-21: Avoid hard process exit in a library function; prefer throwing.

This function is imported from other modules; calling process.exit(1) here can terminate consumers unexpectedly. Also, error messages should go to stderr.

Apply:

-  if (entries.length < 2) {
-    process.stdout.write(yellowBright('At least two PDF files.\n'))
-    process.exit(1)
-  }
+  if (entries.length < 2) {
+    process.stderr.write(yellowBright('At least two PDF files.\n'))
+    throw new Error('At least two PDF files.')
+  }

47-51: Normalize Windows paths when generating temp filenames.

filePath.split('/').join('-') misses backslashes on Windows, which then become literal characters in the filename. Normalize both separators.

-  entries.forEach((filePath) => {
-    const tempFileName = `/${filePath.split('/').join('-')}`
+  entries.forEach((filePath) => {
+    const tempFileName = `/${filePath.replace(/[\\/]/g, '-')}`
     tempFileNameArr.push(tempFileName)
     pyodide.FS.writeFile(tempFileName, readFileSync(filePath))
   })
packages/export/package.json (1)

16-23: Add types and publish config for better DX and first publish.

TypeScript will usually locate .d.ts next to .js under exports, but being explicit helps editors. Also, scoped packages default to “restricted” on first publish unless access=public is set.

 {
   "name": "@alauda/doom-export",
   "version": "0.0.0",
   "type": "module",
   "description": "Doctor Doom making docs.",
+  "types": "./lib/index.d.ts",
   "repository": {
@@
   "exports": {
     ".": "./lib/index.js",
     "./package.json": "./package.json"
   },
+  "publishConfig": {
+    "access": "public"
+  },
+  "sideEffects": false,
   "files": [
     "lib",
     "pyodide"
   ],
packages/export/src/export-pdf-core/utils/mergePDF.ts (2)

90-96: Guard against outline length mismatch.

outlines[index] can be undefined if the PDF’s internal outline count differs from outlineNodes length, causing a crash on outline.children access.

-  for (const [index, outlineNode] of outlineNodes.entries()) {
-    const outline = outlines[index]
+  for (const [index, outlineNode] of outlineNodes.entries()) {
+    const outline = outlines[index]
+    if (!outline) continue
     outlineMap.set(outlineNode, outline)
     for (const [index, outlineChild] of outlineNode.children.entries()) {
-      outlineMap.set(outlineChild, outline.children[index])
+      const child = outline.children[index]
+      if (child) outlineMap.set(outlineChild, child)
     }
   }

190-191: Handle cross-device rename (EXDEV).

fs.rename can fail across mount points. Fallback to copy+unlink.

-  } else if (pages.length === 1) {
-    await fs.rename(pages[0].pagePath, saveFilePath)
+  } else if (pages.length === 1) {
+    try {
+      await fs.rename(pages[0].pagePath, saveFilePath)
+    } catch (err) {
+      const code = (err as NodeJS.ErrnoException)?.code
+      if (code === 'EXDEV') {
+        await fs.copyFile(pages[0].pagePath, saveFilePath)
+        await fs.unlink(pages[0].pagePath)
+      } else {
+        throw err
+      }
+    }
packages/export/tsconfig.json (2)

2-2: Use explicit .json in extends to avoid tooling edge cases.

Some tooling (including editors and build scripts) can mis-resolve extensionless config paths. Prefer ../../tsconfig.base.json.

Apply this diff:

-  "extends": "../../tsconfig.base",
+  "extends": "../../tsconfig.base.json",

3-8: Consider adding TS project references if this package depends on other workspaces.

Since composite: true is enabled, references unlock faster incremental builds across workspaces.

Would you like me to propose a references block once we confirm inter-package deps?

Example:

{
  "references": [{ "path": "../doom" }]
}
packages/export/src/html-export-pdf/core/printer.ts (3)

301-318: Path check may fail on Windows due to URL vs FS path differences.

pathname from URL isn’t an OS path on Windows (/C:/...), and may be percent-encoded. Use fileURLToPath (as shown above) to normalize before path.relative.


286-295: Prefer logging over writing raw output for missing browser instance.

process.stdout.write(red('Browser instance not found')) can be missed by consumers and lacks newline. Consider using your logger or console.warn with newline.

-      process.stdout.write(red('Browser instance not found'))
+      console.warn(red('Browser instance not found'))

1-3: Minor: consider adding a debounce for concurrent setup() calls.

Two concurrent calls before this.page is set can launch two browsers. A simple setupPromise guard avoids this.

packages/doom/src/cli/export.ts (2)

91-99: Potential type mismatch: port is a string from CLI; ensure GeneratePdfOptions.port accepts string or cast to number.

Commander options are strings by default. If GeneratePdfOptions['port'] is numeric, cast once to avoid implicit coercions later.

-      port: port!,
+      port: port ? Number(port) : undefined,

183-187: Out file name may contain illegal filename characters.

When deriving from sidebar text, consider sanitizing to a safe filename (remove slashes, control chars).

-          outFile: `${item.name || (foundSidebarItems.find((it) => it.link?.endsWith('/index')) ?? foundSidebarItems[0]).text}-${lang}.pdf`,
+          outFile: `${sanitizeFileName(item.name || (foundSidebarItems.find((it) => it.link?.endsWith('/index')) ?? foundSidebarItems[0]).text)}-${lang}.pdf`,

Outside this hunk, you can add a small helper:

function sanitizeFileName(s: string) {
  return s.replace(/[\\\/:*?"<>|\u0000-\u001F]/g, '_').trim()
}
packages/export/src/export-pdf-core/utils/index.ts (1)

1-3: Naming consistency: mergePDF.ts vs camelCase.

Minor: consider renaming to mergePdf.ts for consistency with typical file casing.

packages/export/src/html-export-pdf/index.ts (1)

1-2: Consider explicitly curating the public API instead of export * barrels.

Wildcard re-exports can leak internals and cause accidental API surface growth. Export named symbols from ./core and ./utils to keep the surface stable.

tsconfig.base.json (1)

12-15: Optional: confirm rewriteRelativeImportExtensions usage.

That flag is designed to work best with .js in source under NodeNext. If you move to Option A (use .js), keep this flag; if you choose Option B (use .ts), this flag becomes less useful.

tsconfig.json (1)

6-10: Follow-up: ensure package subpath exports exist for consumers.

Since you’ve introduced new barrels (e.g., html-export-pdf), make sure packages/export/package.json exposes subpath exports like "./html-export-pdf": { "types": "./lib/html-export-pdf/index.d.ts", "import": "./lib/html-export-pdf/index.js" }. Without that, consumers can’t import @alauda/doom-export/html-export-pdf.

packages/export/src/html-export-pdf/utils/index.ts (1)

1-7: Optional: avoid star-exports to keep the utils surface stable.

Consider explicitly re-exporting only the intended public helpers to prevent leaking internals and to aid tree-shaking.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 14f1b72 and 4f9517b.

⛔ Files ignored due to path filters (6)
  • packages/doom/assets/logo.svg is excluded by !**/*.svg
  • packages/export/pyodide/pyodide.asm.wasm is excluded by !**/*.wasm
  • packages/export/pyodide/pyodide.js.map is excluded by !**/*.map
  • packages/export/pyodide/pyodide.mjs.map is excluded by !**/*.map
  • packages/export/pyodide/python_stdlib.zip is excluded by !**/*.zip
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (30)
  • .changeset/dull-jeans-stare.md (1 hunks)
  • .github/workflows/pkg-pr-new.yml (1 hunks)
  • .prettierignore (1 hunks)
  • eslint.config.js (1 hunks)
  • package.json (3 hunks)
  • packages/doom/package.json (1 hunks)
  • packages/doom/src/cli/export.ts (1 hunks)
  • packages/doom/tsconfig.json (1 hunks)
  • packages/export/package.json (1 hunks)
  • packages/export/src/export-pdf-core/generatePdf.ts (1 hunks)
  • packages/export/src/export-pdf-core/index.ts (1 hunks)
  • packages/export/src/export-pdf-core/utils/index.ts (1 hunks)
  • packages/export/src/export-pdf-core/utils/mergePDF.ts (1 hunks)
  • packages/export/src/helpers.ts (1 hunks)
  • packages/export/src/html-export-pdf/core/index.ts (1 hunks)
  • packages/export/src/html-export-pdf/core/printer.ts (1 hunks)
  • packages/export/src/html-export-pdf/index.ts (1 hunks)
  • packages/export/src/html-export-pdf/utils/getDirname.ts (1 hunks)
  • packages/export/src/html-export-pdf/utils/index.ts (1 hunks)
  • packages/export/src/index.ts (1 hunks)
  • packages/export/src/merge-pdfs/index.ts (1 hunks)
  • packages/export/tsconfig.json (1 hunks)
  • src/cli/export-pdf-core/index.ts (0 hunks)
  • src/cli/export-pdf-core/utils/index.ts (0 hunks)
  • src/cli/html-export-pdf/core/index.ts (0 hunks)
  • src/cli/html-export-pdf/index.ts (0 hunks)
  • src/cli/html-export-pdf/utils/index.ts (0 hunks)
  • src/tsconfig.json (0 hunks)
  • tsconfig.base.json (1 hunks)
  • tsconfig.json (1 hunks)
💤 Files with no reviewable changes (6)
  • src/cli/export-pdf-core/index.ts
  • src/cli/html-export-pdf/index.ts
  • src/cli/export-pdf-core/utils/index.ts
  • src/tsconfig.json
  • src/cli/html-export-pdf/core/index.ts
  • src/cli/html-export-pdf/utils/index.ts
🧰 Additional context used
🧠 Learnings (8)
📓 Common learnings
Learnt from: JounQin
PR: alauda/doom#30
File: src/runtime/components/K8sCrd.tsx:5-5
Timestamp: 2025-05-26T09:09:21.339Z
Learning: The alauda/doom project uses yarn v4 for dependency management, which handles package exports and module resolution correctly, so imports like `rspress/core/theme` work without any ESLint errors.
Learnt from: JounQin
PR: alauda/doom#75
File: src/cli/load-config.ts:4-7
Timestamp: 2025-06-09T03:10:41.010Z
Learning: The alauda/doom project uses yarn v4 as the package manager, not npm. Always reference yarn commands when suggesting package management operations.
📚 Learning: 2025-05-26T08:59:41.491Z
Learnt from: JounQin
PR: alauda/doom#30
File: src/runtime/components/K8sCrd.tsx:5-5
Timestamp: 2025-05-26T08:59:41.491Z
Learning: In rspress/core v2.0.0-beta.7, the '/theme' export is available in the package exports field as `"./theme": { "default": "./theme.ts" }`, so imports like `import { Badge, Button } from 'rspress/core/theme'` are valid even if ESLint shows resolution errors.

Applied to files:

  • packages/export/src/html-export-pdf/index.ts
📚 Learning: 2025-05-26T09:09:21.339Z
Learnt from: JounQin
PR: alauda/doom#30
File: src/runtime/components/K8sCrd.tsx:5-5
Timestamp: 2025-05-26T09:09:21.339Z
Learning: The alauda/doom project uses yarn v4 for dependency management, which handles package exports and module resolution correctly, so imports like `rspress/core/theme` work without any ESLint errors.

Applied to files:

  • .changeset/dull-jeans-stare.md
  • tsconfig.json
  • packages/export/package.json
  • package.json
  • packages/doom/package.json
📚 Learning: 2025-05-12T11:11:41.048Z
Learnt from: JounQin
PR: alauda/doom#9
File: src/cli/load-config.ts:27-27
Timestamp: 2025-05-12T11:11:41.048Z
Learning: The yoctocolors package is used in the codebase for colored terminal output, with the cyan function imported in src/cli/load-config.ts.

Applied to files:

  • packages/export/src/merge-pdfs/index.ts
📚 Learning: 2025-06-09T03:10:41.010Z
Learnt from: JounQin
PR: alauda/doom#75
File: src/cli/load-config.ts:4-7
Timestamp: 2025-06-09T03:10:41.010Z
Learning: The alauda/doom project uses yarn v4 as the package manager, not npm. Always reference yarn commands when suggesting package management operations.

Applied to files:

  • packages/export/package.json
  • package.json
  • packages/doom/package.json
📚 Learning: 2025-05-29T16:25:28.086Z
Learnt from: JounQin
PR: alauda/doom#40
File: src/plugins/sitemap/index.ts:7-7
Timestamp: 2025-05-29T16:25:28.086Z
Learning: In rspress/shared v2.0.0-beta.8, the '/logger' export is available in the package exports field, so imports like `import { logger } from 'rspress/shared/logger'` are valid even if ESLint shows resolution errors. This is used throughout the codebase in files like src/cli/translate.ts, src/cli/load-config.ts, src/utils/git.ts, and src/plugins/sitemap/index.ts.

Applied to files:

  • packages/export/src/html-export-pdf/utils/index.ts
📚 Learning: 2025-05-26T09:09:21.339Z
Learnt from: JounQin
PR: alauda/doom#30
File: src/runtime/components/K8sCrd.tsx:5-5
Timestamp: 2025-05-26T09:09:21.339Z
Learning: JounQin has mentioned multiple times that the alauda/doom project uses yarn v4, and there are no ESLint import resolution errors for rspress/core subpath imports.

Applied to files:

  • package.json
  • packages/doom/package.json
📚 Learning: 2025-06-06T07:08:55.881Z
Learnt from: JounQin
PR: alauda/doom#69
File: package.json:101-101
Timestamp: 2025-06-06T07:08:55.881Z
Learning: When a package has peer dependencies that require TypeScript (like `eslint-react/eslint-plugin`), TypeScript should be moved from devDependencies to dependencies to satisfy the peer dependency requirement.

Applied to files:

  • package.json
🧬 Code graph analysis (1)
packages/export/src/helpers.ts (1)
packages/doom/src/utils/constants.ts (2)
  • BASE_DIR (4-4)
  • PKG_DIR (6-6)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Build and Lint with Node.js 20 on ubuntu-latest
  • GitHub Check: Build and Lint with Node.js 22 on ubuntu-latest
  • GitHub Check: Build and Lint with Node.js 24 on ubuntu-latest
🔇 Additional comments (13)
packages/export/src/helpers.ts (1)

8-9: Scope check: ensure this Node-only helper isn’t imported in browser bundles.

fileURLToPath(import.meta.url) assumes a file: URL and a Node ESM context. If any consumer bundles this module for browser runtimes, it will break. If it’s strictly used by the CLI/server-side export code, you’re good—just confirm usage boundaries.

packages/export/src/merge-pdfs/index.ts (1)

5-6: Import path and asset inclusion verified

  • Confirmed that packages/export/pyodide/pyodide.js (and its .map) exist in the repository.
  • Verified that the packages/export/package.json “files” array includes the pyodide directory, ensuring the asset will be published.

All set for publishing.

packages/export/package.json (1)

24-31: Sanity-check: Playwright as a hard dependency.

Given this package performs PDF exports headlessly, bundling playwright is reasonable but heavy. If you expect users to import only helpers without running the export, consider making playwright an optionalDependency with runtime checks. If export is the primary purpose, current placement is fine.

packages/doom/package.json (2)

16-25: Confirm intentional omission of root export in package.json

  • Verified that no internal files import the package by its bare specifier (@alauda/doom), so omitting the "." export doesn’t break any in-repo code.
  • If external consumers need to do import '@alauda/doom', you’ll need to add a root export. Otherwise, keeping only subpath exports is fine.

Recommended diff (if you want to support root imports):

 "exports": {
+  ".": "./lib/index.js",
   "./config": "./lib/config.js",
   "./cspell": "./lib/cspell.js",
   "./eslint": "./lib/eslint.js",
   "./runtime": "./lib/runtime/index.js",
   "./theme": "./lib/theme.js",
   "./types": "./lib/types.js",
   "./package.json": "./package.json"
 }

26-31: global.d.ts presence confirmed in package files

  • packages/doom/global.d.ts exists in the repository.
  • "global.d.ts" is listed in the files array of packages/doom/package.json (lines 26–31).

No further action required.

package.json (3)

9-13: Monorepo scaffolding LGTM.

private + workspaces + pinned Yarn v4 are set correctly. Matches prior Yarn v4 usage in this repo.


15-22: Script rewires look correct for the new layout.

tsc -b at root and the dev/doom script paths now target packages/doom sources. Release via changesets is aligned with workspaces.

Also applies to: 28-28


66-74: Type coverage ignore patterns updated appropriately.

Switching to globbing under packages/* ensures emitted d.ts and pyodide assets stay out of coverage. Good catch.

packages/doom/tsconfig.json (1)

1-10: Per-package tsconfig looks correct for composite builds

Extends the base, sets composite + outDir/lib + rootDir/src. This aligns with a Yarn v4 monorepo and tsc project references.

packages/export/src/html-export-pdf/core/printer.ts (1)

14-16: Switch to .ts specifiers looks good; ensure TS config supports it.

This relies on allowImportingTsExtensions: true in your TS config (ideally the base config). See my tsconfig.json comment.

packages/doom/src/cli/export.ts (1)

4-9: Verified: Dependency & TS Path Mapping Are Correct

  • packages/doom/package.json declares "@alauda/doom-export": "^0.0.0" under dependencies, satisfying Yarn v4 PnP requirements.
  • Root tsconfig.json includes a "paths" mapping for "@alauda/doom-export"["./packages/export/src/index.ts"], ensuring imports resolve to the local source during development.

All checks pass—these changes are ready to merge.

packages/export/src/export-pdf-core/utils/index.ts (1)

1-3: Barrel looks good; confirm TS extension import support.

Re-exports with ./*.ts require allowImportingTsExtensions. See tsconfig comment. If you don’t need to publish these as .ts subpaths, you could also drop the extensions in the source and let NodeNext resolution handle it.

tsconfig.json (1)

6-10: Paths and project references look correct for the new monorepo.

  • Path aliases point to per-package sources which is fine with project references.
  • Reference order builds export before doom, matching the dependency direction (doom → doom-export).

Also applies to: 12-19

@JounQin JounQin merged commit a7af4c7 into main Aug 26, 2025
16 checks passed
@JounQin JounQin deleted the feat/monorepo branch August 26, 2025 10:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor: migrate to monorepo, split into doom core and rspress plugins

2 participants