The jQuery wrapper is seamlessly integrated into the existing Rollup build system with zero impact on the core library:
Build Outputs:
dist/
├── tablixjs.esm.js # Core library (ES Modules)
├── tablixjs.umd.js # Core library (Universal)
├── tablix.jquery.js # Bundled: TablixJS + jQuery wrapper
├── tablix-jquery-plugin.js # Standalone: jQuery plugin only
└── (minified versions of all)
Key Technical Details:
The wrapper enhances npm publishing without breaking existing functionality:
Package.json Structure:
{
"main": "./dist/tablixjs.cjs.js", // Core library (default)
"module": "./dist/tablixjs.esm.js", // Core library (ESM)
"exports": {
".": { // Core library entry
"import": "./dist/tablixjs.esm.js",
"require": "./dist/tablixjs.cjs.js",
"browser": "./dist/tablixjs.umd.min.js"
},
"./jquery": { // jQuery wrapper entry
"import": "./dist/tablix.jquery.js",
"require": "./dist/tablix.jquery.js",
"browser": "./dist/tablix.jquery.min.js"
}
},
"peerDependencies": {
"jquery": ">=3.0.0" // Optional peer dependency
},
"peerDependenciesMeta": {
"jquery": { "optional": true } // Marked as optional
}
}
For Existing Users:
For New Users:
Availability Decision: YES ✅
Option 1: NPM with Selective Imports
// Vanilla only (zero deps)
import { Table } from 'tablixjs';
// With jQuery wrapper
import 'tablixjs/jquery';
$('#table').tablixjs(options);
Option 2: CDN/Direct File Loading
<!-- Vanilla only -->
<script src="tablixjs.umd.min.js"></script>
<!-- OR bundled with jQuery -->
<script src="jquery.min.js"></script>
<script src="tablix.jquery.min.js"></script>
<!-- OR modular loading -->
<script src="jquery.min.js"></script>
<script src="tablixjs.umd.min.js"></script>
<script src="tablix-jquery-plugin.min.js"></script>
Option 3: Mix and Match
// Use vanilla TablixJS via npm
import { Table } from 'tablixjs';
const table1 = new Table(element1, options);
// Use jQuery via CDN
$('#table2').tablixjs(options);
Runtime Checks in Every jQuery File:
1. Standalone Plugin (tablix-jquery-plugin.js):
// Multi-environment jQuery detection
const $ = (typeof window !== 'undefined' && (window.jQuery || window.$)) ||
(typeof global !== 'undefined' && (global.jQuery || global.$));
// TablixJS detection
const TablixJS = (typeof window !== 'undefined' && window.TablixJS) ||
(typeof global !== 'undefined' && global.TablixJS);
// Only register if both are available
if ($ && $.fn && TablixJS) {
$.fn.tablixjs = function(options) { /* ... */ };
} else {
console.warn('TablixJS jQuery plugin requires both jQuery and TablixJS to be loaded');
}
2. Bundled Version (tablix.jquery.js):
// Check for jQuery availability
if (typeof window !== 'undefined' && window.jQuery) {
// Register jQuery plugin
window.jQuery.fn.tablixjs = function(options) { /* ... */ };
} else if (typeof $ !== 'undefined' && $.fn) {
// Alternative jQuery reference
$.fn.tablixjs = function(options) { /* ... */ };
}
Graceful Degradation:
Zero Forced Dependencies:
{
"dependencies": {}, // Core has NO dependencies
"peerDependencies": { // Optional integrations only
"jquery": ">=3.0.0",
"react": ">=16.8.0"
},
"peerDependenciesMeta": { // Marked as optional
"jquery": { "optional": true },
"react": { "optional": true }
}
}
Installation Behavior:
npm install tablixjs
# ✅ Installs with ZERO dependencies
# ✅ No jQuery/React downloaded unless you want them
# ✅ No peer dependency warnings unless you use wrappers
Import Behavior:
// ✅ Core import: Zero dependencies
import { Table } from 'tablixjs';
// ✅ jQuery import: Checks for jQuery at runtime
import 'tablixjs/jquery';
// ❌ Missing jQuery: Warning logged, no crash
The jQuery wrapper integration is a perfect example of how to extend a dependency-free library:
The jQuery wrapper enhances TablixJS without compromising its core principles. It's a textbook example of optional integration done right.
For New Projects:
For Existing jQuery Projects:
tablix.jquery.min.js) for quickest integrationFor Libraries: