Contributing to SquibView

We welcome contributions to SquibView! Here’s how you can help.

Getting Started

  1. Fork the repository on GitHub.
  2. Clone your fork locally: git clone https://github.com/YOUR_USERNAME/squibview.git
  3. Install dependencies: npm install

Development Workflow

  1. Create a new branch for your feature or bug fix: git checkout -b my-feature-branch
  2. Make your changes.
  3. Build the project: See the “Building and Versioning” section below.
  4. Test your changes: See the “Testing and Debugging” section below.
  5. Commit your changes: git commit -am "Add some feature"
  6. Push to your branch: git push origin my-feature-branch
  7. Create a Pull Request on GitHub.

Building and Versioning

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.

Source of Truth for Version

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.

Development Scripts

Build Targets and Commands

⚠️ WARNING: Full builds take significant time (several minutes), especially standalone builds. Use targeted builds during development.

Individual Build Commands

Comprehensive Build Commands

Supporting Build Tools

Build Architecture Details

  1. Version Management: tools/updateVersion.js reads package.json and generates src/version.js
  2. Bundling: Rollup.js with different configurations for each target
  3. CSS Processing: Custom minification via tools/minifyCSS.cjs
  4. Distribution: All builds output to dist/ directory

Version Runtime Access

SquibView reports its version at runtime via:

console.log(SquibView.version); // e.g., "1.0.5-dev.2"console.log(SquibView.version.version); // Version stringconsole.log(SquibView.version.url); // Repository URL

Build Troubleshooting

Testing and Debugging

Running Tests

Debugging Tests in VS Code (or similar IDEs with Jest integration)

Most modern IDEs offer excellent Jest integration for debugging.

  1. Install the Jest extension for your IDE if you haven’t already (e.g., “Jest” by Orta for VS Code).
  2. Set breakpoints in your test files (*.test.js) or the source files (src/*.js).
  3. 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 describe or it blocks in your test files.

Debugging in the Browser

For issues that are hard to reproduce in the JSDOM environment provided by Jest, or for visual/interaction debugging:

  1. Use debug.html or debug-dev.html: These files in the dev/ directory are set up to load SquibView. You can open them in a browser.
  2. 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 initialContent or inputContentType directly in the script tag within debug-dev.html to load specific Markdown or HTML.
    • Add debugger; statements in src/squibview.js or other relevant source files where you want the browser’s debugger to pause.
  3. 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.

Tips for Debugging SquibView

Code Style

Please follow the existing code style. We generally adhere to common JavaScript best practices.

Reporting Bugs

Thank you for contributing to SquibView!