Skip to content

Commit 0bf8e70

Browse files
committed
Merge remote-tracking branch 'origin/main' into next
2 parents b9f45ad + c09b4c1 commit 0bf8e70

17 files changed

+1350
-129
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858
node-version: '22.x'
5959

6060
- name: Install
61-
run: npm ci
61+
run: npm ci --include=dev
6262

6363
- name: Build
6464
run: npm run build

docs/USAGE.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,41 @@ npm config list
4949
npm install @mitre-attack/attack-data-model
5050
```
5151

52+
## Module Format Support
53+
54+
The ATT&CK Data Model is built using [tsup](https://github.com/egoist/tsup), which compiles the TypeScript code to both ESM (ECMAScript Modules) and CJS (CommonJS) formats. This dual-format approach allows the library to be used in various JavaScript environments:
55+
56+
- **ESM**: Modern environments that support ES modules (Node.js with `"type": "module"` in package.json, or modern bundlers like Webpack, Rollup, etc.)
57+
- **CJS**: Traditional Node.js applications and environments that use CommonJS modules (Node.js with `"type": "commonjs"` in package.json)
58+
59+
### ESM Usage Example
60+
61+
```javascript
62+
// In a package with "type": "module" in package.json
63+
import { AttackDataModel } from '@mitre-attack/attack-data-model';
64+
65+
// Create an instance with a UUID and an empty array of attack objects
66+
const uuid = "my-unique-id";
67+
const attackObjects = [];
68+
const attackDataModel = new AttackDataModel(uuid, attackObjects);
69+
70+
console.log('AttackDataModel instance created with UUID:', attackDataModel.getUuid());
71+
```
72+
73+
### CommonJS Usage Example
74+
75+
```javascript
76+
// In a package with "type": "commonjs" in package.json
77+
const { AttackDataModel } = require('@mitre-attack/attack-data-model');
78+
79+
// Create an instance with a UUID and an empty array of attack objects
80+
const uuid = "my-unique-id";
81+
const attackObjects = [];
82+
const attackDataModel = new AttackDataModel(uuid, attackObjects);
83+
84+
console.log('AttackDataModel instance created with UUID:', attackDataModel.getUuid());
85+
```
86+
5287
## Package Structure
5388

5489
Understanding the package structure will help you locate and use various components of the API effectively.

0 commit comments

Comments
 (0)