Skip to content

Commit b54b703

Browse files
build: update package build scripts & outputs, imports in ~50 packages
BREAKING CHANGE: enabled multi-outputs (ES6 modules, CJS, UMD) - build scripts now first build ES6 modules in package root, then call `scripts/bundle-module` to build minified CJS & UMD bundles in `/lib` - all imports MUST be updated to only refer to package level (not individual files anymore). tree shaking in user land will get rid of all unused imported symbols.
1 parent f913d7b commit b54b703

File tree

344 files changed

+1862
-1595
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

344 files changed

+1862
-1595
lines changed

packages/associative/package.json

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
"name": "@thi.ng/associative",
33
"version": "0.6.23",
44
"description": "Alternative Set & Map data type implementations with customizable equality semantics & supporting operations",
5-
"main": "./index.js",
5+
"module": "./index.js",
6+
"main": "./lib/index.js",
7+
"umd:main": "./lib/index.umd.js",
68
"typings": "./index.d.ts",
79
"repository": {
810
"type": "git",
@@ -12,12 +14,14 @@
1214
"author": "Karsten Schmidt <[email protected]>",
1315
"license": "Apache-2.0",
1416
"scripts": {
15-
"build": "yarn clean && tsc --declaration",
16-
"clean": "rimraf *.js *.d.ts .nyc_output build coverage doc",
17+
"build": "yarn clean && yarn build:es6 && yarn build:bundle",
18+
"build:es6": "tsc --declaration",
19+
"build:bundle": "../../scripts/bundle-module associative api checks compare dcons equiv errors transducers",
20+
"test": "rimraf build && tsc -p test/tsconfig.json && nyc mocha build/test/*.js",
21+
"clean": "rimraf *.js *.d.ts .nyc_output build coverage doc lib",
1722
"cover": "yarn test && nyc report --reporter=lcov",
1823
"doc": "node_modules/.bin/typedoc --mode modules --out doc src",
19-
"pub": "yarn build && yarn publish --access public",
20-
"test": "rimraf build && tsc -p test && nyc mocha build/test/*.js"
24+
"pub": "yarn build && yarn publish --access public"
2125
},
2226
"devDependencies": {
2327
"@types/mocha": "^5.2.5",
@@ -53,5 +57,6 @@
5357
],
5458
"publishConfig": {
5559
"access": "public"
56-
}
60+
},
61+
"sideEffects": false
5762
}

packages/associative/src/api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
IEmpty,
55
IEquiv,
66
Predicate2
7-
} from "@thi.ng/api/api";
7+
} from "@thi.ng/api";
88

99
export interface IEquivSet<T> extends
1010
Set<T>,

packages/associative/src/array-set.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Pair, Predicate2, SEMAPHORE } from "@thi.ng/api/api";
1+
import { Pair, Predicate2, SEMAPHORE } from "@thi.ng/api";
22
import { equiv } from "@thi.ng/equiv";
33
import { EquivSetOpts, IEquivSet } from "./api";
44

packages/associative/src/common-keys.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { IObjectOf } from "@thi.ng/api/api";
1+
import { IObjectOf } from "@thi.ng/api";
22

33
/**
44
* Like `commonKeysObj()`, but for ES6 Maps.

packages/associative/src/equiv-map.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ import {
55
IObjectOf,
66
Pair,
77
SEMAPHORE
8-
} from "@thi.ng/api/api";
8+
} from "@thi.ng/api";
99
import { equiv } from "@thi.ng/equiv";
10-
1110
import { EquivMapOpts, IEquivSet } from "./api";
1211
import { ArraySet } from "./array-set";
1312

packages/associative/src/invert.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { IObjectOf } from "@thi.ng/api/api";
2-
1+
import { IObjectOf } from "@thi.ng/api";
32
import { empty } from "./utils";
43

54
/**

packages/associative/src/join.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { IObjectOf } from "@thi.ng/api/api";
2-
1+
import { IObjectOf } from "@thi.ng/api";
32
import { commonKeysObj } from "./common-keys";
43
import { indexed } from "./indexed";
54
import { invertObj } from "./invert";

packages/associative/src/ll-set.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import { Pair, Predicate2, SEMAPHORE } from "@thi.ng/api/api";
1+
import { Pair, Predicate2, SEMAPHORE } from "@thi.ng/api";
22
import { DCons } from "@thi.ng/dcons";
33
import { equiv } from "@thi.ng/equiv";
4-
54
import { EquivSetOpts, IEquivSet } from "./api";
65

76
interface SetProps<T> {

packages/associative/src/merge-apply.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import { IObjectOf } from "@thi.ng/api/api";
2-
import { isFunction } from "@thi.ng/checks/is-function";
3-
1+
import { IObjectOf } from "@thi.ng/api";
2+
import { isFunction } from "@thi.ng/checks";
43
import { copy } from "./utils";
54

65
/**

packages/associative/src/merge-deep.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import { IObjectOf } from "@thi.ng/api/api";
2-
import { isPlainObject } from "@thi.ng/checks/is-plain-object";
3-
1+
import { IObjectOf } from "@thi.ng/api";
2+
import { isPlainObject } from "@thi.ng/checks";
43
import { mergeObjWith } from "./merge-with";
54

65
export const mergeDeepObj =

packages/associative/src/merge-with.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { IObjectOf } from "@thi.ng/api/api";
2-
1+
import { IObjectOf } from "@thi.ng/api";
32
import { copy } from "./utils";
43

54
export const mergeMapWith = <K, V>(

packages/associative/src/merge.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { IObjectOf } from "@thi.ng/api/api";
1+
import { IObjectOf } from "@thi.ng/api";
22

33
/**
44
* Merges all given maps in left-to-right order into `dest`.

packages/associative/src/rename-keys.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { IObjectOf } from "@thi.ng/api/api";
2-
1+
import { IObjectOf } from "@thi.ng/api";
32
import { empty } from "./utils";
43

54
/**

packages/associative/src/select-keys.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { IObjectOf } from "@thi.ng/api/api";
2-
1+
import { IObjectOf } from "@thi.ng/api";
32
import { empty } from "./utils";
43

54
/**

packages/associative/src/sorted-map.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,17 @@ import {
88
Pair,
99
Predicate2,
1010
SEMAPHORE
11-
} from "@thi.ng/api/api";
12-
import { isArray } from "@thi.ng/checks/is-array";
11+
} from "@thi.ng/api";
12+
import { isArray } from "@thi.ng/checks";
1313
import { compare } from "@thi.ng/compare";
1414
import { equiv } from "@thi.ng/equiv";
15-
import { illegalArgs } from "@thi.ng/errors/illegal-arguments";
16-
import { IReducible, ReductionFn } from "@thi.ng/transducers/api";
17-
import { isReduced } from "@thi.ng/transducers/reduced";
18-
import { map } from "@thi.ng/transducers/xform/map";
19-
15+
import { illegalArgs } from "@thi.ng/errors";
16+
import {
17+
IReducible,
18+
isReduced,
19+
map,
20+
ReductionFn
21+
} from "@thi.ng/transducers";
2022
import { SortedMapOpts } from "./api";
2123

2224
// stores private properties for all instances

packages/associative/src/sorted-set.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
import { ICompare, Pair, } from "@thi.ng/api/api";
21
import { compare } from "@thi.ng/compare";
3-
import { IReducible, ReductionFn } from "@thi.ng/transducers/api";
4-
import { map } from "@thi.ng/transducers/xform/map";
5-
2+
import { IReducible, map, ReductionFn } from "@thi.ng/transducers";
63
import { IEquivSet, SortedSetOpts } from "./api";
74
import { SortedMap } from "./sorted-map";
5+
import { ICompare, Pair, } from "@thi.ng/api";
86

97
const __private = new WeakMap<SortedSet<any>, SortedMap<any, any>>();
108

packages/associative/src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { implementsFunction } from "@thi.ng/checks/implements-function";
1+
import { implementsFunction } from "@thi.ng/checks";
22

33
export const empty = (x, ctor) =>
44
implementsFunction(x, "empty") ? x.empty() : new (x[Symbol.species] || ctor)();

packages/associative/test/tsconfig.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
"extends": "../../../tsconfig.json",
33
"compilerOptions": {
44
"outDir": "../build",
5-
"module": "es6",
6-
"target": "es6"
5+
"module": "commonjs",
76
},
87
"include": [
98
"./**/*.ts",

packages/atom/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"description": "Mutable wrappers for nested immutable values w/ optional undo/redo history",
55
"module": "./index.js",
66
"main": "./lib/index.js",
7+
"umd:main": "./lib/index.umd.js",
78
"typings": "./index.d.ts",
89
"repository": {
910
"type": "git",
@@ -13,13 +14,11 @@
1314
"author": "Karsten Schmidt <[email protected]>",
1415
"license": "Apache-2.0",
1516
"scripts": {
16-
"build": "yarn clean && yarn build:es6 && yarn build:parcel && yarn build:parcel:min",
17+
"build": "yarn clean && yarn build:es6 && yarn build:bundle",
1718
"build:es6": "tsc --declaration",
18-
"build:parcel:min": "parcel build --global thing_atom -o index.min.js -d lib --experimental-scope-hoisting src/index.ts",
19-
"build:parcel": "parcel build --global thing_atom -d lib --no-minify --experimental-scope-hoisting src/index.ts && prettier --write lib/index.js",
20-
"build:gzip": "gzip -c lib/index.min.js > lib/index.min.js.gz",
21-
"clean": "rimraf *.js *.d.ts .cache .nyc_output build coverage doc lib",
22-
"test": "rimraf build && parcel build -d build --no-cache --no-minify --no-source-maps test/index.ts && nyc mocha build/index.js",
19+
"build:bundle": "../../scripts/bundle-module atom api checks equiv errors paths",
20+
"test": "rimraf build && tsc -p test/tsconfig.json && nyc mocha build/test/*.js",
21+
"clean": "rimraf *.js *.d.ts .nyc_output build coverage doc lib",
2322
"cover": "yarn test && nyc report --reporter=lcov",
2423
"doc": "typedoc --mode modules --out doc src",
2524
"pub": "yarn build && yarn publish --access public"
@@ -59,5 +58,6 @@
5958
"browser": {
6059
"process": false,
6160
"setTimeout": false
62-
}
61+
},
62+
"sideEffects": false
6363
}

packages/atom/src/api.ts

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
1-
import * as api from "@thi.ng/api/api";
1+
import {
2+
IDeref,
3+
IID,
4+
INotify,
5+
IRelease,
6+
IWatch,
7+
Predicate
8+
} from "@thi.ng/api";
29
import { Path } from "@thi.ng/paths";
310

411
export type SwapFn<T> = (curr: T, ...args: any[]) => T;
512

613
export type ViewTransform<T> = (x: any) => T;
714

815
export interface ReadonlyAtom<T> extends
9-
api.IDeref<T>,
10-
api.IRelease,
11-
api.IWatch<T>,
16+
IDeref<T>,
17+
IRelease,
18+
IWatch<T>,
1219
IViewable {
1320
}
1421

@@ -29,9 +36,9 @@ export interface ISwap<T> {
2936
}
3037

3138
export interface IView<T> extends
32-
api.IDeref<T>,
33-
api.IID<string>,
34-
api.IRelease {
39+
IDeref<T>,
40+
IID<string>,
41+
IRelease {
3542

3643
readonly path: PropertyKey[];
3744
readonly value: T;
@@ -47,13 +54,13 @@ export interface IViewable {
4754
export interface CursorOpts<T> {
4855
parent: IAtom<any>;
4956
path: Path | [(s: any) => T, (s: any, v: T) => any];
50-
validate?: api.Predicate<T>;
57+
validate?: Predicate<T>;
5158
id?: string;
5259
}
5360

5461
export interface IHistory<T> extends
5562
IAtom<T>,
56-
api.INotify {
63+
INotify {
5764

5865
canUndo(): boolean;
5966
canRedo(): boolean;

packages/atom/src/atom.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
import { IEquiv, Predicate, Watch } from "@thi.ng/api/api";
2-
import { IWatch } from "@thi.ng/api/mixins/iwatch";
3-
import { illegalState } from "@thi.ng/errors/illegal-state";
1+
import {
2+
IEquiv,
3+
IWatchMixin,
4+
Predicate,
5+
Watch
6+
} from "@thi.ng/api";
7+
import { illegalState } from "@thi.ng/errors";
48
import { Path, setIn, updateIn } from "@thi.ng/paths";
5-
69
import {
710
IAtom,
811
IView,
@@ -11,11 +14,12 @@ import {
1114
} from "./api";
1215
import { View } from "./view";
1316

17+
1418
/**
1519
* Mutable wrapper for an (usually) immutable value. Support for
1620
* watches.
1721
*/
18-
@IWatch
22+
@IWatchMixin
1923
export class Atom<T> implements
2024
IAtom<T>,
2125
IEquiv {

packages/atom/src/cursor.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
import { IID, IRelease, Watch } from "@thi.ng/api/api";
2-
import { isArray } from "@thi.ng/checks/is-array";
3-
import { isFunction } from "@thi.ng/checks/is-function";
4-
import { illegalArgs } from "@thi.ng/errors/illegal-arguments";
5-
import { illegalArity } from "@thi.ng/errors/illegal-arity";
1+
import { IID, IRelease, Watch } from "@thi.ng/api";
2+
import { isArray, isFunction } from "@thi.ng/checks";
3+
import { illegalArgs, illegalArity } from "@thi.ng/errors";
64
import { getter, Path, setter } from "@thi.ng/paths";
75
import {
86
CursorOpts,

packages/atom/src/history.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1-
import { Event, Predicate2, Watch } from "@thi.ng/api/api";
2-
import * as mixin from "@thi.ng/api/mixins/inotify";
1+
import {
2+
Event,
3+
INotifyMixin,
4+
Predicate2,
5+
Watch
6+
} from "@thi.ng/api";
37
import { equiv } from "@thi.ng/equiv";
48
import {
59
getIn,
610
Path,
711
setIn,
812
updateIn
913
} from "@thi.ng/paths";
10-
1114
import {
1215
IAtom,
1316
IHistory,
@@ -17,6 +20,7 @@ import {
1720
} from "./api";
1821
import { View } from "./view";
1922

23+
2024
/**
2125
* Undo/redo history stack wrapper for atoms and cursors. Implements
2226
* `IAtom` interface and so can be used directly in place and delegates
@@ -26,7 +30,7 @@ import { View } from "./view";
2630
* `INotify` interface to support event listeners for `undo()`, `redo()`
2731
* and `record()`.
2832
*/
29-
@mixin.INotify
33+
@INotifyMixin
3034
export class History<T> implements
3135
IHistory<T> {
3236

packages/atom/test/atom.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import { isNumber } from "@thi.ng/checks";
12
import * as assert from "assert";
23
import { Atom } from "../src/index";
3-
import { isNumber } from "@thi.ng/checks/is-number";
44

55
describe("atom", function () {
66

@@ -51,7 +51,7 @@ describe("atom", function () {
5151
assert.equal(a.reset(2), 2);
5252
assert.equal(a.reset("3"), 2);
5353
assert.equal(a.reset(null), 2);
54-
assert.equal(a.swap((x) => "3"), 2);
55-
assert.equal(a.swap((x) => null), 2);
54+
assert.equal(a.swap(() => "3"), 2);
55+
assert.equal(a.swap(() => null), 2);
5656
});
5757
});

packages/atom/test/cursor.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import * as assert from "assert";
1+
import { isNumber } from "@thi.ng/checks";
22
import { getIn } from "@thi.ng/paths";
3-
3+
import * as assert from "assert";
44
import { Atom, Cursor } from "../src/index";
5-
import { isNumber } from "@thi.ng/checks/is-number";
65

76
describe("cursor", function () {
87

packages/atom/test/history.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import * as assert from "assert";
2-
32
import { Atom } from "../src/atom";
43
import { Cursor } from "../src/cursor";
54
import { History } from "../src/history";

0 commit comments

Comments
 (0)