fix(package): emit CJS as .cjs, add exports map, expose control classes in bundles
- type:module + CJS .js main broke import/require in Node; main now dist/testdrive-jsui.cjs - exports map: types, import->esm, require->cjs, browser->min, ./style.css, ./dist/* - dist bundles failed on load (ControlBase is not defined): bundler shims module, so the window.X else-branch never ran; controls now always set window globals - npm pkg fix applied (repository url normalised) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Assistant: claude-code Assistant-Model: sonnet Assistant-Process: 299063@bnt-lap001 Assistant-Session: 53eb1e1c-c13a-4277-9ce2-3702960d93f7
This commit is contained in:
parent
f17363c491
commit
a9a27b86bb
8 changed files with 43 additions and 11 deletions
|
|
@ -5,7 +5,7 @@ Verified as part of JSUI-WP-0002 (2026-07-08).
|
|||
## Build outputs
|
||||
|
||||
- [x] `npm run build` / `npm run build:prod` produces `dist/` bundles
|
||||
- [x] `dist/testdrive-jsui.cjs.js` — CommonJS entry (`package.json` `main`)
|
||||
- [x] `dist/testdrive-jsui.cjs` — CommonJS entry (`package.json` `main`)
|
||||
- [x] `dist/testdrive-jsui.esm.js` — ESM entry (`module`)
|
||||
- [x] `dist/testdrive-jsui.min.js` — UMD/browser (`browser`, `unpkg`, `jsdelivr`)
|
||||
- [x] `dist/testdrive-jsui.css` — packaged styles (`style` field)
|
||||
|
|
|
|||
|
|
@ -282,6 +282,8 @@ class ContentsControl extends ControlBase {
|
|||
// Export for module systems or attach to global for direct usage
|
||||
if (typeof module !== 'undefined' && module.exports) {
|
||||
module.exports = ContentsControl;
|
||||
} else {
|
||||
}
|
||||
// Also expose globally: bundlers shim `module`, so the else-branch never ran in dist builds
|
||||
if (typeof window !== 'undefined') {
|
||||
window.ContentsControl = ContentsControl;
|
||||
}
|
||||
|
|
@ -847,6 +847,8 @@ class ControlBase {
|
|||
// Export for module systems or attach to global for direct usage
|
||||
if (typeof module !== 'undefined' && module.exports) {
|
||||
module.exports = ControlBase;
|
||||
} else {
|
||||
}
|
||||
// Also expose globally: bundlers shim `module`, so the else-branch never ran in dist builds
|
||||
if (typeof window !== 'undefined') {
|
||||
window.ControlBase = ControlBase;
|
||||
}
|
||||
|
|
@ -478,6 +478,8 @@ class DebugControl extends ControlBase {
|
|||
// Export for module systems or attach to global for direct usage
|
||||
if (typeof module !== 'undefined' && module.exports) {
|
||||
module.exports = DebugControl;
|
||||
} else {
|
||||
}
|
||||
// Also expose globally: bundlers shim `module`, so the else-branch never ran in dist builds
|
||||
if (typeof window !== 'undefined') {
|
||||
window.DebugControl = DebugControl;
|
||||
}
|
||||
|
|
@ -568,6 +568,8 @@ class EditControl extends ControlBase {
|
|||
// Export for module systems or attach to global for direct usage
|
||||
if (typeof module !== 'undefined' && module.exports) {
|
||||
module.exports = EditControl;
|
||||
} else {
|
||||
}
|
||||
// Also expose globally: bundlers shim `module`, so the else-branch never ran in dist builds
|
||||
if (typeof window !== 'undefined') {
|
||||
window.EditControl = EditControl;
|
||||
}
|
||||
|
|
@ -366,6 +366,8 @@ class StatusControl extends ControlBase {
|
|||
// Export for module systems or attach to global for direct usage
|
||||
if (typeof module !== 'undefined' && module.exports) {
|
||||
module.exports = StatusControl;
|
||||
} else {
|
||||
}
|
||||
// Also expose globally: bundlers shim `module`, so the else-branch never ran in dist builds
|
||||
if (typeof window !== 'undefined') {
|
||||
window.StatusControl = StatusControl;
|
||||
}
|
||||
30
package.json
30
package.json
|
|
@ -3,12 +3,25 @@
|
|||
"version": "1.0.0",
|
||||
"description": "JavaScript-first markdown editor library with interactive UI",
|
||||
"type": "module",
|
||||
"main": "dist/testdrive-jsui.cjs.js",
|
||||
"main": "dist/testdrive-jsui.cjs",
|
||||
"module": "dist/testdrive-jsui.esm.js",
|
||||
"browser": "dist/testdrive-jsui.min.js",
|
||||
"style": "dist/testdrive-jsui.css",
|
||||
"unpkg": "dist/testdrive-jsui.min.js",
|
||||
"jsdelivr": "dist/testdrive-jsui.min.js",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./types/index.d.ts",
|
||||
"import": "./dist/testdrive-jsui.esm.js",
|
||||
"require": "./dist/testdrive-jsui.cjs",
|
||||
"browser": "./dist/testdrive-jsui.min.js",
|
||||
"default": "./dist/testdrive-jsui.esm.js"
|
||||
},
|
||||
"./style.css": "./dist/testdrive-jsui.css",
|
||||
"./dist/testdrive-jsui.css": "./dist/testdrive-jsui.css",
|
||||
"./dist/*": "./dist/*",
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"types": "types/index.d.ts",
|
||||
"files": [
|
||||
"dist/",
|
||||
|
|
@ -34,7 +47,7 @@
|
|||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/markitect/testdrive-jsui.git"
|
||||
"url": "git+https://github.com/markitect/testdrive-jsui.git"
|
||||
},
|
||||
"keywords": [
|
||||
"markdown",
|
||||
|
|
@ -145,8 +158,17 @@
|
|||
"jest"
|
||||
],
|
||||
"rules": {
|
||||
"semi": ["error", "always"],
|
||||
"indent": ["error", 4, { "SwitchCase": 1 }],
|
||||
"semi": [
|
||||
"error",
|
||||
"always"
|
||||
],
|
||||
"indent": [
|
||||
"error",
|
||||
4,
|
||||
{
|
||||
"SwitchCase": 1
|
||||
}
|
||||
],
|
||||
"space-before-function-paren": "off",
|
||||
"no-console": "warn",
|
||||
"no-debugger": "error"
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ export default [
|
|||
{
|
||||
input: 'src/index.js',
|
||||
output: {
|
||||
file: 'dist/testdrive-jsui.cjs.js',
|
||||
file: 'dist/testdrive-jsui.cjs',
|
||||
format: 'cjs',
|
||||
sourcemap: true,
|
||||
exports: 'named'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue