Skip to content

Commit 3527791

Browse files
committed
Move to TSUP for build
Move to tsup to build and bundle
1 parent b7039c5 commit 3527791

19 files changed

+47
-77
lines changed

.babelrc

-3
This file was deleted.

package.json

+5-14
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"name": "json-rules-engine",
33
"version": "8.0.0-alpha.1",
44
"description": "Rules Engine expressed in simple json",
5-
"main": "dist/index.js",
5+
"main": "dist/index.cjs",
6+
"module": "dist/index.js",
67
"types": "types/index.d.ts",
78
"type": "module",
89
"engines": {
@@ -12,9 +13,8 @@
1213
"test": "vitest --typecheck",
1314
"lint": "eslint",
1415
"format": "prettier -w .",
15-
"prepublishOnly": "npm run build",
16-
"build": "babel --stage 1 -d dist/ src/",
17-
"watch": "babel --watch --stage 1 -d dist/ src",
16+
"build": "tsup",
17+
"watch": "tsup --watch",
1818
"examples": "./test/support/example_runner.sh"
1919
},
2020
"repository": {
@@ -40,22 +40,13 @@
4040
"homepage": "https://github.com/cachecontrol/json-rules-engine",
4141
"devDependencies": {
4242
"@eslint/js": "^9.13.0",
43-
"babel-cli": "6.26.0",
44-
"babel-core": "6.26.3",
45-
"babel-eslint": "10.1.0",
46-
"babel-loader": "8.2.2",
47-
"babel-polyfill": "6.26.0",
48-
"babel-preset-es2015": "~6.24.1",
49-
"babel-preset-stage-0": "~6.24.1",
50-
"babel-register": "6.26.0",
51-
"colors": "~1.4.0",
52-
"dirty-chai": "2.0.1",
5343
"eslint": "^9.13.0",
5444
"globals": "^15.11.0",
5545
"lodash": "4.17.21",
5646
"perfy": "^1.1.5",
5747
"prettier": "^3.3.3",
5848
"tsd": "^0.17.0",
49+
"tsup": "^8.3.0",
5950
"typescript": "^5.6.3",
6051
"typescript-eslint": "^8.11.0",
6152
"vitest": "^2.1.3"

src/almanac.js renamed to src/almanac.mjs

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
"use strict";
2-
3-
import Fact from "./fact";
4-
import { UndefinedFactError } from "./errors";
5-
import debug from "./debug";
1+
import Fact from "./fact.mjs";
2+
import { UndefinedFactError } from "./errors.mjs";
3+
import debug from "./debug.mjs";
64

75
import { JSONPath } from "jsonpath-plus";
86

src/condition.js renamed to src/condition.mjs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
"use strict";
2-
3-
import debug from "./debug";
1+
import debug from "./debug.mjs";
42

53
export default class Condition {
64
constructor(properties) {

src/debug.js renamed to src/debug.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function createDebug() {
1212
) {
1313
return console.debug.bind(console);
1414
}
15-
} catch (ex) {
15+
} catch (_error) {
1616
// Do nothing
1717
}
1818
return () => {};

src/engine-default-operator-decorators.js renamed to src/engine-default-operator-decorators.mjs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
"use strict";
2-
3-
import OperatorDecorator from "./operator-decorator";
1+
import OperatorDecorator from "./operator-decorator.mjs";
42

53
const OperatorDecorators = [];
64

src/engine-default-operators.js renamed to src/engine-default-operators.mjs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
"use strict";
2-
3-
import Operator from "./operator";
1+
import Operator from "./operator.mjs";
42

53
const Operators = [];
64
Operators.push(new Operator("equal", (a, b) => a === b));

src/engine.js renamed to src/engine.mjs

+8-10
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
"use strict";
2-
3-
import Fact from "./fact";
4-
import Rule from "./rule";
5-
import Almanac from "./almanac";
1+
import Fact from "./fact.mjs";
2+
import Rule from "./rule.mjs";
3+
import Almanac from "./almanac.mjs";
64
import EventEmitter from "eventemitter2";
7-
import defaultOperators from "./engine-default-operators";
8-
import defaultDecorators from "./engine-default-operator-decorators";
9-
import debug from "./debug";
10-
import Condition from "./condition";
11-
import OperatorMap from "./operator-map";
5+
import defaultOperators from "./engine-default-operators.mjs";
6+
import defaultDecorators from "./engine-default-operator-decorators.mjs";
7+
import debug from "./debug.mjs";
8+
import Condition from "./condition.mjs";
9+
import OperatorMap from "./operator-map.mjs";
1210

1311
export const READY = "READY";
1412
export const RUNNING = "RUNNING";

src/errors.js renamed to src/errors.mjs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
"use strict";
2-
31
export class UndefinedFactError extends Error {
42
constructor(...props) {
53
super(...props);

src/fact.js renamed to src/fact.mjs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
"use strict";
2-
31
import hash from "hash-it";
42

53
class Fact {

src/index.js

-3
This file was deleted.

src/index.mjs

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import Engine from "./engine.mjs";
2+
import Fact from "./fact.mjs";
3+
import Rule from "./rule.mjs";
4+
import Operator from "./operator.mjs";
5+
import Almanac from "./almanac.mjs";
6+
import OperatorDecorator from "./operator-decorator.mjs";
7+
8+
export { Fact, Rule, Operator, Engine, Almanac, OperatorDecorator };
9+
export default function (rules, options) {
10+
return new Engine(rules, options);
11+
}

src/json-rules-engine.js

-11
This file was deleted.

src/operator-decorator.js renamed to src/operator-decorator.mjs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
"use strict";
2-
3-
import Operator from "./operator";
1+
import Operator from "./operator.mjs";
42

53
export default class OperatorDecorator {
64
/**

src/operator-map.js renamed to src/operator-map.mjs

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
"use strict";
2-
3-
import Operator from "./operator";
4-
import OperatorDecorator from "./operator-decorator";
5-
import debug from "./debug";
1+
import Operator from "./operator.mjs";
2+
import OperatorDecorator from "./operator-decorator.mjs";
3+
import debug from "./debug.mjs";
64

75
export default class OperatorMap {
86
constructor() {

src/operator.js renamed to src/operator.mjs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
"use strict";
2-
31
export default class Operator {
42
/**
53
* Constructor

src/rule-result.js renamed to src/rule-result.mjs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
"use strict";
2-
31
import deepClone from "clone";
42

53
export default class RuleResult {

src/rule.js renamed to src/rule.mjs

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
"use strict";
2-
3-
import Condition from "./condition";
4-
import RuleResult from "./rule-result";
5-
import debug from "./debug";
1+
import Condition from "./condition.mjs";
2+
import RuleResult from "./rule-result.mjs";
3+
import debug from "./debug.mjs";
64
import deepClone from "clone";
75
import EventEmitter from "eventemitter2";
86

tsup.config.ts

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { defineConfig } from "tsup";
2+
3+
export default defineConfig({
4+
entry: ["src/index.mjs"],
5+
sourcemap: true,
6+
format: ["esm", "cjs"],
7+
target: ["es2015"],
8+
cjsInterop: true,
9+
});

0 commit comments

Comments
 (0)