Skip to content

Commit

Permalink
build: update package build scripts & outputs, imports in ~50 packages
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
postspectacular committed Jan 8, 2019
1 parent f913d7b commit b54b703
Show file tree
Hide file tree
Showing 344 changed files with 1,862 additions and 1,595 deletions.
17 changes: 11 additions & 6 deletions packages/associative/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
"name": "@thi.ng/associative",
"version": "0.6.23",
"description": "Alternative Set & Map data type implementations with customizable equality semantics & supporting operations",
"main": "./index.js",
"module": "./index.js",
"main": "./lib/index.js",
"umd:main": "./lib/index.umd.js",
"typings": "./index.d.ts",
"repository": {
"type": "git",
Expand All @@ -12,12 +14,14 @@
"author": "Karsten Schmidt <[email protected]>",
"license": "Apache-2.0",
"scripts": {
"build": "yarn clean && tsc --declaration",
"clean": "rimraf *.js *.d.ts .nyc_output build coverage doc",
"build": "yarn clean && yarn build:es6 && yarn build:bundle",
"build:es6": "tsc --declaration",
"build:bundle": "../../scripts/bundle-module associative api checks compare dcons equiv errors transducers",
"test": "rimraf build && tsc -p test/tsconfig.json && nyc mocha build/test/*.js",
"clean": "rimraf *.js *.d.ts .nyc_output build coverage doc lib",
"cover": "yarn test && nyc report --reporter=lcov",
"doc": "node_modules/.bin/typedoc --mode modules --out doc src",
"pub": "yarn build && yarn publish --access public",
"test": "rimraf build && tsc -p test && nyc mocha build/test/*.js"
"pub": "yarn build && yarn publish --access public"
},
"devDependencies": {
"@types/mocha": "^5.2.5",
Expand Down Expand Up @@ -53,5 +57,6 @@
],
"publishConfig": {
"access": "public"
}
},
"sideEffects": false
}
2 changes: 1 addition & 1 deletion packages/associative/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
IEmpty,
IEquiv,
Predicate2
} from "@thi.ng/api/api";
} from "@thi.ng/api";

export interface IEquivSet<T> extends
Set<T>,
Expand Down
2 changes: 1 addition & 1 deletion packages/associative/src/array-set.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Pair, Predicate2, SEMAPHORE } from "@thi.ng/api/api";
import { Pair, Predicate2, SEMAPHORE } from "@thi.ng/api";
import { equiv } from "@thi.ng/equiv";
import { EquivSetOpts, IEquivSet } from "./api";

Expand Down
2 changes: 1 addition & 1 deletion packages/associative/src/common-keys.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IObjectOf } from "@thi.ng/api/api";
import { IObjectOf } from "@thi.ng/api";

/**
* Like `commonKeysObj()`, but for ES6 Maps.
Expand Down
3 changes: 1 addition & 2 deletions packages/associative/src/equiv-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ import {
IObjectOf,
Pair,
SEMAPHORE
} from "@thi.ng/api/api";
} from "@thi.ng/api";
import { equiv } from "@thi.ng/equiv";

import { EquivMapOpts, IEquivSet } from "./api";
import { ArraySet } from "./array-set";

Expand Down
3 changes: 1 addition & 2 deletions packages/associative/src/invert.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { IObjectOf } from "@thi.ng/api/api";

import { IObjectOf } from "@thi.ng/api";
import { empty } from "./utils";

/**
Expand Down
3 changes: 1 addition & 2 deletions packages/associative/src/join.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { IObjectOf } from "@thi.ng/api/api";

import { IObjectOf } from "@thi.ng/api";
import { commonKeysObj } from "./common-keys";
import { indexed } from "./indexed";
import { invertObj } from "./invert";
Expand Down
3 changes: 1 addition & 2 deletions packages/associative/src/ll-set.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Pair, Predicate2, SEMAPHORE } from "@thi.ng/api/api";
import { Pair, Predicate2, SEMAPHORE } from "@thi.ng/api";
import { DCons } from "@thi.ng/dcons";
import { equiv } from "@thi.ng/equiv";

import { EquivSetOpts, IEquivSet } from "./api";

interface SetProps<T> {
Expand Down
5 changes: 2 additions & 3 deletions packages/associative/src/merge-apply.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { IObjectOf } from "@thi.ng/api/api";
import { isFunction } from "@thi.ng/checks/is-function";

import { IObjectOf } from "@thi.ng/api";
import { isFunction } from "@thi.ng/checks";
import { copy } from "./utils";

/**
Expand Down
5 changes: 2 additions & 3 deletions packages/associative/src/merge-deep.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { IObjectOf } from "@thi.ng/api/api";
import { isPlainObject } from "@thi.ng/checks/is-plain-object";

import { IObjectOf } from "@thi.ng/api";
import { isPlainObject } from "@thi.ng/checks";
import { mergeObjWith } from "./merge-with";

export const mergeDeepObj =
Expand Down
3 changes: 1 addition & 2 deletions packages/associative/src/merge-with.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { IObjectOf } from "@thi.ng/api/api";

import { IObjectOf } from "@thi.ng/api";
import { copy } from "./utils";

export const mergeMapWith = <K, V>(
Expand Down
2 changes: 1 addition & 1 deletion packages/associative/src/merge.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IObjectOf } from "@thi.ng/api/api";
import { IObjectOf } from "@thi.ng/api";

/**
* Merges all given maps in left-to-right order into `dest`.
Expand Down
3 changes: 1 addition & 2 deletions packages/associative/src/rename-keys.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { IObjectOf } from "@thi.ng/api/api";

import { IObjectOf } from "@thi.ng/api";
import { empty } from "./utils";

/**
Expand Down
3 changes: 1 addition & 2 deletions packages/associative/src/select-keys.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { IObjectOf } from "@thi.ng/api/api";

import { IObjectOf } from "@thi.ng/api";
import { empty } from "./utils";

/**
Expand Down
16 changes: 9 additions & 7 deletions packages/associative/src/sorted-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@ import {
Pair,
Predicate2,
SEMAPHORE
} from "@thi.ng/api/api";
import { isArray } from "@thi.ng/checks/is-array";
} from "@thi.ng/api";
import { isArray } from "@thi.ng/checks";
import { compare } from "@thi.ng/compare";
import { equiv } from "@thi.ng/equiv";
import { illegalArgs } from "@thi.ng/errors/illegal-arguments";
import { IReducible, ReductionFn } from "@thi.ng/transducers/api";
import { isReduced } from "@thi.ng/transducers/reduced";
import { map } from "@thi.ng/transducers/xform/map";

import { illegalArgs } from "@thi.ng/errors";
import {
IReducible,
isReduced,
map,
ReductionFn
} from "@thi.ng/transducers";
import { SortedMapOpts } from "./api";

// stores private properties for all instances
Expand Down
6 changes: 2 additions & 4 deletions packages/associative/src/sorted-set.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { ICompare, Pair, } from "@thi.ng/api/api";
import { compare } from "@thi.ng/compare";
import { IReducible, ReductionFn } from "@thi.ng/transducers/api";
import { map } from "@thi.ng/transducers/xform/map";

import { IReducible, map, ReductionFn } from "@thi.ng/transducers";
import { IEquivSet, SortedSetOpts } from "./api";
import { SortedMap } from "./sorted-map";
import { ICompare, Pair, } from "@thi.ng/api";

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

Expand Down
2 changes: 1 addition & 1 deletion packages/associative/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { implementsFunction } from "@thi.ng/checks/implements-function";
import { implementsFunction } from "@thi.ng/checks";

export const empty = (x, ctor) =>
implementsFunction(x, "empty") ? x.empty() : new (x[Symbol.species] || ctor)();
Expand Down
3 changes: 1 addition & 2 deletions packages/associative/test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
"extends": "../../../tsconfig.json",
"compilerOptions": {
"outDir": "../build",
"module": "es6",
"target": "es6"
"module": "commonjs",
},
"include": [
"./**/*.ts",
Expand Down
14 changes: 7 additions & 7 deletions packages/atom/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"description": "Mutable wrappers for nested immutable values w/ optional undo/redo history",
"module": "./index.js",
"main": "./lib/index.js",
"umd:main": "./lib/index.umd.js",
"typings": "./index.d.ts",
"repository": {
"type": "git",
Expand All @@ -13,13 +14,11 @@
"author": "Karsten Schmidt <[email protected]>",
"license": "Apache-2.0",
"scripts": {
"build": "yarn clean && yarn build:es6 && yarn build:parcel && yarn build:parcel:min",
"build": "yarn clean && yarn build:es6 && yarn build:bundle",
"build:es6": "tsc --declaration",
"build:parcel:min": "parcel build --global thing_atom -o index.min.js -d lib --experimental-scope-hoisting src/index.ts",
"build:parcel": "parcel build --global thing_atom -d lib --no-minify --experimental-scope-hoisting src/index.ts && prettier --write lib/index.js",
"build:gzip": "gzip -c lib/index.min.js > lib/index.min.js.gz",
"clean": "rimraf *.js *.d.ts .cache .nyc_output build coverage doc lib",
"test": "rimraf build && parcel build -d build --no-cache --no-minify --no-source-maps test/index.ts && nyc mocha build/index.js",
"build:bundle": "../../scripts/bundle-module atom api checks equiv errors paths",
"test": "rimraf build && tsc -p test/tsconfig.json && nyc mocha build/test/*.js",
"clean": "rimraf *.js *.d.ts .nyc_output build coverage doc lib",
"cover": "yarn test && nyc report --reporter=lcov",
"doc": "typedoc --mode modules --out doc src",
"pub": "yarn build && yarn publish --access public"
Expand Down Expand Up @@ -59,5 +58,6 @@
"browser": {
"process": false,
"setTimeout": false
}
},
"sideEffects": false
}
25 changes: 16 additions & 9 deletions packages/atom/src/api.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
import * as api from "@thi.ng/api/api";
import {
IDeref,
IID,
INotify,
IRelease,
IWatch,
Predicate
} from "@thi.ng/api";
import { Path } from "@thi.ng/paths";

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

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

export interface ReadonlyAtom<T> extends
api.IDeref<T>,
api.IRelease,
api.IWatch<T>,
IDeref<T>,
IRelease,
IWatch<T>,
IViewable {
}

Expand All @@ -29,9 +36,9 @@ export interface ISwap<T> {
}

export interface IView<T> extends
api.IDeref<T>,
api.IID<string>,
api.IRelease {
IDeref<T>,
IID<string>,
IRelease {

readonly path: PropertyKey[];
readonly value: T;
Expand All @@ -47,13 +54,13 @@ export interface IViewable {
export interface CursorOpts<T> {
parent: IAtom<any>;
path: Path | [(s: any) => T, (s: any, v: T) => any];
validate?: api.Predicate<T>;
validate?: Predicate<T>;
id?: string;
}

export interface IHistory<T> extends
IAtom<T>,
api.INotify {
INotify {

canUndo(): boolean;
canRedo(): boolean;
Expand Down
14 changes: 9 additions & 5 deletions packages/atom/src/atom.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { IEquiv, Predicate, Watch } from "@thi.ng/api/api";
import { IWatch } from "@thi.ng/api/mixins/iwatch";
import { illegalState } from "@thi.ng/errors/illegal-state";
import {
IEquiv,
IWatchMixin,
Predicate,
Watch
} from "@thi.ng/api";
import { illegalState } from "@thi.ng/errors";
import { Path, setIn, updateIn } from "@thi.ng/paths";

import {
IAtom,
IView,
Expand All @@ -11,11 +14,12 @@ import {
} from "./api";
import { View } from "./view";


/**
* Mutable wrapper for an (usually) immutable value. Support for
* watches.
*/
@IWatch
@IWatchMixin
export class Atom<T> implements
IAtom<T>,
IEquiv {
Expand Down
8 changes: 3 additions & 5 deletions packages/atom/src/cursor.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { IID, IRelease, Watch } from "@thi.ng/api/api";
import { isArray } from "@thi.ng/checks/is-array";
import { isFunction } from "@thi.ng/checks/is-function";
import { illegalArgs } from "@thi.ng/errors/illegal-arguments";
import { illegalArity } from "@thi.ng/errors/illegal-arity";
import { IID, IRelease, Watch } from "@thi.ng/api";
import { isArray, isFunction } from "@thi.ng/checks";
import { illegalArgs, illegalArity } from "@thi.ng/errors";
import { getter, Path, setter } from "@thi.ng/paths";
import {
CursorOpts,
Expand Down
12 changes: 8 additions & 4 deletions packages/atom/src/history.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import { Event, Predicate2, Watch } from "@thi.ng/api/api";
import * as mixin from "@thi.ng/api/mixins/inotify";
import {
Event,
INotifyMixin,
Predicate2,
Watch
} from "@thi.ng/api";
import { equiv } from "@thi.ng/equiv";
import {
getIn,
Path,
setIn,
updateIn
} from "@thi.ng/paths";

import {
IAtom,
IHistory,
Expand All @@ -17,6 +20,7 @@ import {
} from "./api";
import { View } from "./view";


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

Expand Down
6 changes: 3 additions & 3 deletions packages/atom/test/atom.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { isNumber } from "@thi.ng/checks";
import * as assert from "assert";
import { Atom } from "../src/index";
import { isNumber } from "@thi.ng/checks/is-number";

describe("atom", function () {

Expand Down Expand Up @@ -51,7 +51,7 @@ describe("atom", function () {
assert.equal(a.reset(2), 2);
assert.equal(a.reset("3"), 2);
assert.equal(a.reset(null), 2);
assert.equal(a.swap((x) => "3"), 2);
assert.equal(a.swap((x) => null), 2);
assert.equal(a.swap(() => "3"), 2);
assert.equal(a.swap(() => null), 2);
});
});
5 changes: 2 additions & 3 deletions packages/atom/test/cursor.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import * as assert from "assert";
import { isNumber } from "@thi.ng/checks";
import { getIn } from "@thi.ng/paths";

import * as assert from "assert";
import { Atom, Cursor } from "../src/index";
import { isNumber } from "@thi.ng/checks/is-number";

describe("cursor", function () {

Expand Down
1 change: 0 additions & 1 deletion packages/atom/test/history.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as assert from "assert";

import { Atom } from "../src/atom";
import { Cursor } from "../src/cursor";
import { History } from "../src/history";
Expand Down
Loading

0 comments on commit b54b703

Please sign in to comment.