Repository navigation
feat(blocks): dual format (ESM + CommonJS) support for blocks package - #27
Conversation
📝 WalkthroughWalkthroughpackages/blocks/package.json was updated to set "type": "module", add an 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
Pre-merge checks✅ Passed checks (3 passed)
Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
Signed-off-by: Andy Jakubowski <hello@andyjakubowski.com>
82eec90 to
c492fd3
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 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
Signed-off-by: Andy Jakubowski <hello@andyjakubowski.com>
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 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
| "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", |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 581msThere was a problem hiding this comment.
@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.
There was a problem hiding this comment.
@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>
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 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
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 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.
Signed-off-by: Andy Jakubowski hello@andyjakubowski.com
Summary by CodeRabbit