Skip to content

feat(blocks): dual format (ESM + CommonJS) support for blocks package - #27

Merged
Artmann merged 4 commits into
chris/add-deepnote-blocksfrom
andy/add-deepnote-blocks-updates
Oct 6, 2025
Merged

Artmann merged 4 commits into
chris/add-deepnote-blocksfrom
andy/add-deepnote-blocks-updates

Conversation

@andyjakubowski

@andyjakubowski andyjakubowski commented Oct 6, 2025 •

Copy link
Copy Markdown
Contributor

Signed-off-by: Andy Jakubowski hello@andyjakubowski.com

Summary by CodeRabbit

  • Chores
    • Package now provides both ESM and CommonJS entry points and exposes an exports map for improved resolution.
    • Published entry points and type declaration paths normalized to distribution output.
    • Build updated to produce ESM + CJS formats and type declarations; a watch script was added.
    • No functional API changes expected; verify import resolution if you rely on ESM-only imports.

@coderabbitai

coderabbitai Bot commented Oct 6, 2025 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

packages/blocks/package.json was updated to set "type": "module", add an exports map for . with import: "./dist/index.js", require: "./dist/index.cjs", and types: "./dist/index.d.ts". main was normalized to ./dist/index.cjs, module to ./dist/index.js, and types to ./dist/index.d.ts. The build script was changed to tsdown --format esm --format cjs --dts, and a watch script tsdown --watch --format esm --format cjs --dts was added. Other files, metadata, and dependencies were unchanged.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Dev as Developer
  participant TSDown as tsdown
  participant Repo as packages/blocks (package.json)
  participant Dist as ./dist
  participant Consumer as Consumer Code

  Note over Dev,TSDown: Build (new multi-format + dts)
  Dev->>TSDown: npm run build\n(tsdown --format esm --format cjs --dts)
  TSDown->>Dist: emit index.js, index.cjs, index.d.ts

  Note over Dev,TSDown: Watch mode (added)
  Dev->>TSDown: npm run watch\n(tsdown --watch --format esm --format cjs --dts)
  TSDown->>Dist: update artifacts on change

  Note over Consumer,Repo: Runtime resolution via exports map
  Consumer->>Repo: import "packages/blocks"
  alt ESM import
    Repo-->>Consumer: exports.import -> ./dist/index.js
  else CJS require
    Consumer-->>Repo: require("packages/blocks")
    Repo-->>Consumer: exports.require -> ./dist/index.cjs
  end
Loading

Pre-merge checks

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title clearly and concisely describes the primary change—adding dual ESM and CommonJS support to the blocks package—using standard conventional commit style and focusing on the main improvement without unnecessary detail.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov

codecov Bot commented Oct 6, 2025 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.67%. Comparing base (5ce16ba) to head (5c702ec).
⚠️ Report is 5 commits behind head on chris/add-deepnote-blocks.

Additional details and impacted files
@@                    Coverage Diff                     @@
##           chris/add-deepnote-blocks      #27   +/-   ##
==========================================================
  Coverage                      92.67%   92.67%           
==========================================================
  Files                             16       16           
  Lines                            505      505           
  Branches                         167      110   -57     
==========================================================
  Hits                             468      468           
  Misses                            37       37           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5ce16ba and 82eec90.

📒 Files selected for processing (1)
  • packages/blocks/package.json (1 hunks)

Comment thread packages/blocks/package.json Resolved
@andyjakubowski andyjakubowski changed the title chore(blocks): align package output with ESM conventions (.mjs/.mts) feat(blocks): update blocks package Oct 6, 2025
Signed-off-by: Andy Jakubowski <hello@andyjakubowski.com>
@andyjakubowski
andyjakubowski force-pushed the andy/add-deepnote-blocks-updates branch from 82eec90 to c492fd3 Compare October 6, 2025 14:09
@andyjakubowski
andyjakubowski marked this pull request as ready for review October 6, 2025 14:10

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 82eec90 and c492fd3.

📒 Files selected for processing (1)
  • packages/blocks/package.json (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: andyjakubowski
PR: deepnote/deepnote#27
File: packages/blocks/package.json:7-9
Timestamp: 2025-10-06T13:16:34.906Z
Learning: When using tsdown with `"type": "module"` in package.json and ESM format (the default), tsdown emits `.d.mts` declaration files by default, not `.d.ts`. Similarly, it emits `.mjs` for JavaScript output.
📚 Learning: 2025-10-06T13:16:34.906Z
Learnt from: andyjakubowski
PR: deepnote/deepnote#27
File: packages/blocks/package.json:7-9
Timestamp: 2025-10-06T13:16:34.906Z
Learning: When using tsdown with `"type": "module"` in package.json and ESM format (the default), tsdown emits `.d.mts` declaration files by default, not `.d.ts`. Similarly, it emits `.mjs` for JavaScript output.

Applied to files:

  • packages/blocks/package.json

Comment thread packages/blocks/package.json Resolved
Signed-off-by: Andy Jakubowski <hello@andyjakubowski.com>
@andyjakubowski andyjakubowski changed the title feat(blocks): update blocks package feat(blocks): dual format (ESM + CommonJS) support for blocks package Oct 6, 2025

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c492fd3 and a99ae34.

📒 Files selected for processing (1)
  • packages/blocks/package.json (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: andyjakubowski
PR: deepnote/deepnote#27
File: packages/blocks/package.json:7-9
Timestamp: 2025-10-06T13:16:34.906Z
Learning: When using tsdown with `"type": "module"` in package.json and ESM format (the default), tsdown emits `.d.mts` declaration files by default, not `.d.ts`. Similarly, it emits `.mjs` for JavaScript output.
📚 Learning: 2025-10-06T13:16:34.906Z
Learnt from: andyjakubowski
PR: deepnote/deepnote#27
File: packages/blocks/package.json:7-9
Timestamp: 2025-10-06T13:16:34.906Z
Learning: When using tsdown with `"type": "module"` in package.json and ESM format (the default), tsdown emits `.d.mts` declaration files by default, not `.d.ts`. Similarly, it emits `.mjs` for JavaScript output.

Applied to files:

  • packages/blocks/package.json

Comment on lines +7 to +17
"type": "module",
"exports": {
".": {
"import": "./dist/index.mjs",
"require": "./dist/index.cjs",
"types": "./dist/index.d.ts"
}
},
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",

@coderabbitai coderabbitai Bot Oct 6, 2025 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Fix the declaration target.
Tsdown with "type": "module" emits dist/index.d.mts, so both the top-level "types" field and the export map’s "types" entry currently point to a non-existent .d.ts file. Update them (or configure tsdown to emit .d.ts) so TypeScript consumers resolve declarations correctly. Based on learnings

🤖 Prompt for AI Agents
In packages/blocks/package.json around lines 7 to 17, the "types" top-level
field and the export map's "types" entry point to ./dist/index.d.ts but tsdown
with "type":"module" emits ./dist/index.d.mts; update both the top-level "types"
and the export map's "types" to point to ./dist/index.d.mts (or alternatively
adjust tsdown/tsconfig so it emits a .d.ts instead) so TypeScript consumers can
resolve the declaration files correctly.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not true, here’s the output of the build script:

pnpm --filter @deepnote/blocks build                                                                        16:17:53

> @deepnote/blocks@1.0.0 build /Users/work/repos/deepnote/deepnote/packages/blocks
> tsdown --format esm --format cjs --dts

ℹ tsdown v0.15.6 powered by rolldown v1.0.0-beta.41
ℹ entry: src/index.ts
ℹ tsconfig: ../../tsconfig.json
ℹ Build start
ℹ Cleaning 4 files
ℹ [CJS] dist/index.cjs  21.70 kB │ gzip: 4.46 kB
ℹ [CJS] 1 files, total: 21.70 kB
ℹ [ESM] dist/index.js    20.48 kB │ gzip: 4.01 kB
ℹ [ESM] dist/index.d.ts   0.84 kB │ gzip: 0.36 kB
ℹ [ESM] 2 files, total: 21.32 kB
ℹ [CJS] dist/index.d.cts  0.84 kB │ gzip: 0.36 kB
ℹ [CJS] 1 files, total: 0.84 kB
✔ Build complete in 581ms

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@andyjakubowski, you're right—I apologize for the incorrect comment. The declarations are fine (.d.ts).

However, there's a different mismatch: your package.json references ./dist/index.mjs for both the import export and the module field, but tsdown is outputting dist/index.js for the ESM bundle. Update those to ./dist/index.js:

"exports": {
  ".": {
    "import": "./dist/index.js",
    "require": "./dist/index.cjs",
    "types": "./dist/index.d.ts"
  }
},
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts"

✏️ Learnings added
Learnt from: andyjakubowski
PR: deepnote/deepnote#27
File: packages/blocks/package.json:7-17
Timestamp: 2025-10-06T14:32:59.050Z
Learning: When using tsdown with `"type": "module"` and `--format esm --format cjs --dts`, tsdown emits `dist/index.js` for ESM JavaScript (not `.mjs`), `dist/index.cjs` for CJS, `dist/index.d.ts` for ESM declarations, and `dist/index.d.cts` for CJS declarations.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.


⛔ Learnings removed
Learnt from: andyjakubowski
PR: deepnote/deepnote#27
File: packages/blocks/package.json:7-9
Timestamp: 2025-10-06T13:16:34.906Z
Learning: When using tsdown with `"type": "module"` in package.json and ESM format (the default), tsdown emits `.d.mts` declaration files by default, not `.d.ts`. Similarly, it emits `.mjs` for JavaScript output.

🧠 Learnings used
Learnt from: andyjakubowski
PR: deepnote/deepnote#27
File: packages/blocks/package.json:7-9
Timestamp: 2025-10-06T13:16:34.906Z
Learning: When using tsdown with `"type": "module"` in package.json and ESM format (the default), tsdown emits `.d.mts` declaration files by default, not `.d.ts`. Similarly, it emits `.mjs` for JavaScript output.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@andyjakubowski, thanks for the update! The paths now match tsdown's actual output.


🧠 Learnings used
Learnt from: andyjakubowski
PR: deepnote/deepnote#27
File: packages/blocks/package.json:7-17
Timestamp: 2025-10-06T14:32:59.050Z
Learning: When using tsdown with `"type": "module"` and `--format esm --format cjs --dts`, tsdown emits `dist/index.js` for ESM JavaScript (not `.mjs`), `dist/index.cjs` for CJS, `dist/index.d.ts` for ESM declarations, and `dist/index.d.cts` for CJS declarations.

Signed-off-by: Andy Jakubowski <hello@andyjakubowski.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a99ae34 and c7dcd7e.

📒 Files selected for processing (1)
  • packages/blocks/package.json (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: andyjakubowski
PR: deepnote/deepnote#27
File: packages/blocks/package.json:7-17
Timestamp: 2025-10-06T14:32:59.050Z
Learning: When using tsdown with `"type": "module"` and `--format esm --format cjs --dts`, tsdown emits `dist/index.js` for ESM JavaScript (not `.mjs`), `dist/index.cjs` for CJS, `dist/index.d.ts` for ESM declarations, and `dist/index.d.cts` for CJS declarations.
📚 Learning: 2025-10-06T14:32:59.050Z
Learnt from: andyjakubowski
PR: deepnote/deepnote#27
File: packages/blocks/package.json:7-17
Timestamp: 2025-10-06T14:32:59.050Z
Learning: When using tsdown with `"type": "module"` and `--format esm --format cjs --dts`, tsdown emits `dist/index.js` for ESM JavaScript (not `.mjs`), `dist/index.cjs` for CJS, `dist/index.d.ts` for ESM declarations, and `dist/index.d.cts` for CJS declarations.

Applied to files:

  • packages/blocks/package.json

Comment thread packages/blocks/package.json Resolved
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c7dcd7e and 5c702ec.

📒 Files selected for processing (1)
  • packages/blocks/package.json (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: andyjakubowski
PR: deepnote/deepnote#27
File: packages/blocks/package.json:7-17
Timestamp: 2025-10-06T14:32:59.050Z
Learning: When using tsdown with `"type": "module"` and `--format esm --format cjs --dts`, tsdown emits `dist/index.js` for ESM JavaScript (not `.mjs`), `dist/index.cjs` for CJS, `dist/index.d.ts` for ESM declarations, and `dist/index.d.cts` for CJS declarations.
📚 Learning: 2025-10-06T14:32:59.050Z
Learnt from: andyjakubowski
PR: deepnote/deepnote#27
File: packages/blocks/package.json:7-17
Timestamp: 2025-10-06T14:32:59.050Z
Learning: When using tsdown with `"type": "module"` and `--format esm --format cjs --dts`, tsdown emits `dist/index.js` for ESM JavaScript (not `.mjs`), `dist/index.cjs` for CJS, `dist/index.d.ts` for ESM declarations, and `dist/index.d.cts` for CJS declarations.

Applied to files:

  • packages/blocks/package.json
🔇 Additional comments (2)
packages/blocks/package.json (2)

7-17: ESM/CJS wiring looks correct.

Paths align with tsdown outputs; import/require/types and main/module/types are consistent. Good.


25-27: Build/watch parity is solid.

Both formats and dts are kept in sync during dev. LGTM.

Comment thread packages/blocks/package.json Resolved
@Artmann
Artmann merged commit b6ab456 into chris/add-deepnote-blocks Oct 6, 2025
@Artmann
Artmann deleted the andy/add-deepnote-blocks-updates branch October 6, 2025 17:06
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.

2 participants