This document provides information on how to build, test, and integrate the BackChannel plugin into your projects.
The BackChannel plugin is built as a single JavaScript file that can be included in any web page via a script tag. The build process uses Vite to bundle all necessary dependencies into a single file with source maps for debugging.
The build process is configured in vite.config.ts with the following key features:
- Output format: IIFE (Immediately Invoked Function Expression)
- Output file:
dist/backchannel.js - Source maps: Enabled
- Minification: Disabled (for readability)
- Global name:
BackChannel
To build the plugin, run:
yarn build-pluginThis will generate the following files in the dist directory:
backchannel.js- The main plugin file to be included in your web pagesbackchannel.js.map- Source map file for debugging
The plugin build process is tested using Vitest. Tests verify that:
- The build output files exist
- The plugin exposes the expected API
- Source maps are correctly referenced
To run the tests:
yarn testA test HTML page is provided at test/plugin-test.html to manually verify the plugin functionality. To test:
- Build the plugin:
yarn build-plugin - Start a development server:
yarn dev - Open the test page in your browser
- Click the "Initialize Plugin" button to test the plugin functionality
To integrate the BackChannel plugin into your project:
- Copy the
dist/backchannel.jsfile to your project - Include it in your HTML with a script tag:
<script src="path/to/backchannel.js"></script>
- Initialize the plugin:
BackChannel.init({ requireInitials: true, // Whether to require user initials for comments storageKey: 'your-storage-key' // localStorage key for storing comments });
The plugin exposes a global BackChannel object with the following method:
init(config): Initializes the plugin with the provided configurationconfig.requireInitials: Boolean indicating whether user initials are required for commentsconfig.storageKey: String key used for storing comments in localStorage
To modify the plugin:
- Edit the source files in the
srcdirectory - Run
yarn build-pluginto rebuild - Test your changes using the test page or automated tests
If you encounter issues:
- Check the browser console for errors
- Verify that the plugin is properly loaded (the BackChannel global object should be available)
- Ensure source maps are correctly loaded for debugging
- Check that the initialization configuration is correct