We welcome contributions to SquibView! Here's how you can help.
- Fork the repository on GitHub.
- Clone your fork locally:
git clone https://github.com/YOUR_USERNAME/squibview.git - Install dependencies:
npm install
- Create a new branch for your feature or bug fix:
git checkout -b my-feature-branch - Make your changes.
- Build the project: See the "Building and Versioning" section below.
- Test your changes: See the "Testing and Debugging" section below.
- Commit your changes:
git commit -am "Add some feature" - Push to your branch:
git push origin my-feature-branch - Create a Pull Request on GitHub.
SquibView uses a combination of npm version and custom shell scripts to manage versioning, builds, and testing in an integrated way. IMPORTANT: SquibView supports multiple build targets (ESM, UMD, Standalone, React, Vue, CLI) - it's critical not to break any of these during development.
The canonical version number is stored in package.json. The src/version.js file, which makes the version available at runtime via SquibView.version, is automatically generated from package.json by the build process.
-
dev-bump-build-test.sh: Recommended for development iterations. This script automates bumping to a development version, building, and testing.- How to use it: Simply run
./dev-bump-build-test.shfrom the project root. - What it does:
- Determines the current version from
package.json. - If the current version is a pre-release (e.g.,
1.0.5-dev.0), it increments the pre-release part (e.g., to1.0.5-dev.1). - If the current version is a stable release (e.g.,
1.0.5), it adds-dev.0to create the first development version (e.g.,1.0.5-dev.0). - Runs
node tools/updateVersion.jsto updatesrc/version.js. - Runs
npm run build:esm(fast build for development). - Runs
npm test -- tests/SquibView.test.js(core tests only).
- Determines the current version from
- Why use it: Streamlines development by creating traceable dev versions and ensuring core functionality works.
- How to use it: Simply run
-
build-and-test.sh: For formal builds when you want to test a specific version.- How to use it:
- Manually update the
versioninpackage.json(e.g.,npm version patch,npm version minor, or edit directly). - Run
./build-and-test.sh.
- Manually update the
- What it does:
- Runs
node tools/updateVersion.jsto updatesrc/version.js. - Runs
npm run build(full build of all targets). - Runs
npm test(all tests).
- Runs
- How to use it:
-
npm run build:esm- ES Module build (fastest, ~2 seconds)- Outputs:
dist/squibview.esm.js,dist/squibview.esm.min.js - Use: Modern bundlers (Webpack, Vite, etc.)
- Outputs:
-
npm run build:umd- Universal Module Definition build (~3 seconds)- Outputs:
dist/squibview.umd.js,dist/squibview.umd.min.js - Use: Browser script tags, RequireJS, CommonJS
- Outputs:
-
npm run build:standalone- Self-contained build with all dependencies (⚠️ ~30+ seconds)- Outputs:
dist/squibview.standalone.min.js,dist/squibview.standalone.esm.js - Use: CDN deployment, no external dependencies needed
- Outputs:
-
npm run build:react- React component wrapper- Outputs:
dist/squibview-react.js,dist/squibview-react.min.js
- Outputs:
-
npm run build:cli- Command-line interface- Outputs:
cli/directory with CLI tools
- Outputs:
npm run build- Builds all library targets (ESM, UMD, Standalone, React, Vue)npm run build:all- Builds library + CLI (complete build)npm run build:fast- ESM build only (for development)
npm run updateVersion- Updatessrc/version.jsfrompackage.jsonnpm run minifyCSS- Processes and minifies CSS filesnpm run makeIndexHTML- Generates documentation HTML
- Version Management:
tools/updateVersion.jsreadspackage.jsonand generatessrc/version.js - Bundling: Rollup.js with different configurations for each target
- CSS Processing: Custom minification via
tools/minifyCSS.cjs - Distribution: All builds output to
dist/directory
SquibView reports its version at runtime via:
console.log(SquibView.version); // e.g., "1.0.5-dev.2"
console.log(SquibView.version.version); // Version string
console.log(SquibView.version.url); // Repository URL- Standalone builds fail: Often due to dependency compatibility issues
- UMD builds not working in browser: Check
docs/umd-build-configuration.md - Version mismatch: Run
npm run updateVersionmanually - CSS issues: Ensure
npm run minifyCSSruns after code changes
- Run all tests:
npm test - Run tests for a specific file:
npm test -- tests/SquibView.test.js(ornpx jest tests/SquibView.test.js) - Run tests with verbose output for debugging:
npm test -- --verbose - Run tests in watch mode:
npm test -- --watch
Most modern IDEs offer excellent Jest integration for debugging.
- Install the Jest extension for your IDE if you haven't already (e.g., "Jest" by Orta for VS Code).
- Set breakpoints in your test files (
*.test.js) or the source files (src/*.js). - Use the IDE's debugger UI to run the specific test or test suite. You can usually click a "Debug" button or icon that appears next to
describeoritblocks in your test files.
For issues that are hard to reproduce in the JSDOM environment provided by Jest, or for visual/interaction debugging:
- Use
debug.htmlordebug-dev.html: These files in thedev/directory are set up to load SquibView. You can open them in a browser. - Modify
debug-dev.html: This file is particularly useful as it often includes more complex setups or specific content to test features under development.- You can change the
initialContentorinputContentTypedirectly in the script tag withindebug-dev.htmlto load specific Markdown or HTML. - Add
debugger;statements insrc/squibview.jsor other relevant source files where you want the browser's debugger to pause.
- You can change the
- Use Browser Developer Tools: Open your browser's developer tools (usually F12 or right-click -> Inspect) to:
- Set breakpoints in the JavaScript source code.
- Inspect the DOM structure and CSS.
- Monitor console output (
console.log,console.warn, etc.). - Step through code execution.
- Isolate the Issue: Try to create the simplest possible Markdown or HTML snippet that reproduces the bug. Use this in
debug-dev.htmlor a new Jest test case. - Check
console.logoutput: Addconsole.logstatements strategically insquibview.jsorHtmlToMarkdown.jsto understand the state of variables or the flow of execution. - Understand the Rendering Pipeline:
- Markdown to HTML:
squibview.js->markdown-it(with custom fence renderers) -> HTML string -> DOM. - HTML to Markdown: HTML string (from contenteditable or input) ->
HtmlToMarkdown.js(which uses Turndown with custom rules) -> Markdown string.
- Markdown to HTML:
- Review Test Logs: Carefully examine the output from
npm test, especially the diffs provided by Jest when assertions fail. This often points directly to the problem. - Consider Mocks: Be aware of how mocks (e.g., for
hljs,mermaid,Papa) intests/SquibView.test.jsmight affect test behavior. Sometimes, unmocking a module or usingjest.requireActualis necessary for specific tests.
Please follow the existing code style. We generally adhere to common JavaScript best practices.
- Search existing issues to see if the bug has already been reported.
- Provide a clear and descriptive title.
- Include steps to reproduce the bug.
- Provide a code example or a link to a live example if possible.
- Describe the expected behavior and the actual behavior.
- Include your browser and OS information.
Thank you for contributing to SquibView!