Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Auto detect text files and perform LF normalization
* text=auto

# ============================================================================
# EXPORT IGNORE - Excluded from `git archive` (production builds)
# ============================================================================

# Test files
__tests__/ export-ignore
vitest.config.mjs export-ignore
coverage/ export-ignore

# Development configuration
.github/ export-ignore
.gitattributes export-ignore

# Package management (not needed in production)
package.json export-ignore
package-lock.json export-ignore
node_modules/ export-ignore

# Documentation that's not needed in production
CHANGELOG.md export-ignore
CONTRIBUTING.md export-ignore
73 changes: 72 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ A lightweight module loader that lets DOM elements request their own JavaScript
- [Using Third-Party Modules](#using-third-party-modules)
- [Migration Guide (v2.x → v3.0)](#migration-guide-v2x--v30)
- [Troubleshooting](#troubleshooting)
- [Testing](#testing)
- [DOM... what?](#so-why-is-it-called-domule)
- [Notes](#notes)

Expand Down Expand Up @@ -1170,6 +1171,76 @@ Core features require ES6 module support. Optional features degrade gracefully:

---

## Testing

DOMule includes a comprehensive test suite using [Vitest](https://vitest.dev/).

### Running Tests

```bash
# Install dependencies (first time only)
npm install

# Run all tests
npm test

# Watch mode (re-runs on file changes)
npm run test:watch

# With coverage report
npm run test:coverage
```

### Test Structure

```
__tests__/
├── core.*.test.mjs # Core module tests (loader, registry, events, etc.)
├── util.*.test.mjs # Utility function tests (debounce, observe, format, etc.)
├── integration.test.mjs # Full loading flow tests
└── module.compat.test.mjs # Module compatibility checker
```

### Testing Your Custom Modules

Validate that your module is compatible with DOMule:

```bash
# Linux/Mac
MODULE=./modules/mymodule.mjs npm run test:module

# Windows CMD
set MODULE=./modules/mymodule.mjs && npm run test:module

# PowerShell
$env:MODULE="./modules/mymodule.mjs"; npm run test:module
```

This checks for:
- Required `NAME` export
- Valid `init(elements, context)` signature
- Optional `api()` and `destroy()` functions
- ModuleRegistry compatibility

### Production Distribution (without tests)

Two options for getting a clean distribution without test files:

**Option 1: npm pack**
```bash
npm pack
# Creates domule-3.2.0.tgz with only production files
```

**Option 2: git archive**
```bash
git archive --format=zip HEAD -o domule-production.zip
```

Both methods exclude `__tests__/`, `node_modules/`, and other development files. The `files` field in `package.json` controls npm pack output, while `.gitattributes` controls git archive.

---

## So, why is it called "DOMule"?

Great question.
Expand All @@ -1187,6 +1258,6 @@ DOM + Module + Mule.
This is a personal repository for maintaining the module system. Feel free to use it, but note: modules may change
without prior notice.

**Version:** 3.1.0
**Version:** 3.2.0
**License:** MIT
**Author:** Klaas Leussink / hnldesign
16 changes: 15 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
{
"name": "domule",
"version": "3.1.0",
"version": "3.2.0",
"description": "A lightweight module loader that lets DOM elements request their own JavaScript dependencies",
"type": "module",
"main": "DOMule.mjs",
"files": [
"core.*.mjs",
"util.*.mjs",
"modules/",
"DOMule.mjs",
"_template.mjs",
"README.md",
"LICENSE"
],
"repository": {
"type": "git",
"url": "https://github.com/c-kick/DOMule.git"
},
"scripts": {
"test": "vitest run",
"test:watch": "vitest",
Expand Down