Skip to content

Commit

Permalink
build: update package scripts, outputs, imports in remaining packages
Browse files Browse the repository at this point in the history
BREAKING CHANGE: enable 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 b54b703 commit f912a84
Show file tree
Hide file tree
Showing 81 changed files with 347 additions and 300 deletions.
17 changes: 11 additions & 6 deletions packages/hdom-canvas/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
"name": "@thi.ng/hdom-canvas",
"version": "0.1.20",
"description": "Declarative canvas scenegraph & visualization for @thi.ng/hdom",
"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 hdomCanvas api checks diff hdom",
"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 @@ -46,5 +50,6 @@
],
"publishConfig": {
"access": "public"
}
},
"sideEffects": false
}
17 changes: 9 additions & 8 deletions packages/hdom-canvas/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { IObjectOf } from "@thi.ng/api/api";
import { isArray } from "@thi.ng/checks/is-array";
import { isArrayLike } from "@thi.ng/checks/is-arraylike";
import { isNotStringAndIterable } from "@thi.ng/checks/is-not-string-iterable";
import { DiffMode } from "@thi.ng/diff/api";
import { diffArray } from "@thi.ng/diff/array";
import { HDOMImplementation, HDOMOpts } from "@thi.ng/hdom/api";
import { equiv, releaseTree } from "@thi.ng/hdom/diff";
import { IObjectOf } from "@thi.ng/api";
import { isArray, isArrayLike, isNotStringAndIterable } from "@thi.ng/checks";
import { diffArray, DiffMode } from "@thi.ng/diff";
import {
equiv,
HDOMImplementation,
HDOMOpts,
releaseTree
} from "@thi.ng/hdom";

interface DrawState {
attribs: IObjectOf<any>;
Expand Down
3 changes: 1 addition & 2 deletions packages/hdom-canvas/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
17 changes: 11 additions & 6 deletions packages/hdom-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
"name": "@thi.ng/hdom-components",
"version": "2.4.6",
"description": "Raw, skinnable UI & SVG components for @thi.ng/hdom",
"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 hdomComponents api checks math transducers transducers-stats",
"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 All @@ -41,5 +45,6 @@
],
"publishConfig": {
"access": "public"
}
},
"sideEffects": false
}
5 changes: 2 additions & 3 deletions packages/hdom-components/src/button-group.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { IObjectOf } from "@thi.ng/api/api";

import { ButtonArgs, Button } from "./button";
import { IObjectOf } from "@thi.ng/api";
import { Button, ButtonArgs } from "./button";
import { mergeAttribs } from "./utils/merge-attribs";

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/hdom-components/src/button.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";
import { mergeAttribs } from "./utils/merge-attribs";

export interface ButtonOpts {
Expand Down
4 changes: 2 additions & 2 deletions packages/hdom-components/src/fps-counter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { sma } from "@thi.ng/transducers-stats/sma";
import { step } from "@thi.ng/transducers/step";
import { step } from "@thi.ng/transducers";
import { sma } from "@thi.ng/transducers-stats";
import { sparkline, SparklineOpts } from "./sparkline";

export interface FpsCounterOpts {
Expand Down
2 changes: 1 addition & 1 deletion packages/hdom-components/src/link.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isString } from "@thi.ng/checks/is-string";
import { isString } from "@thi.ng/checks";

export const link = (attribs: any, body: any) =>
["a", isString(attribs) ? { href: attribs } : attribs, body];
Expand Down
2 changes: 1 addition & 1 deletion packages/hdom-components/src/notification.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";
import { appLink } from "./link";

export interface NotificationOpts {
Expand Down
3 changes: 1 addition & 2 deletions packages/hdom-components/src/pager.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { range } from "@thi.ng/transducers/iter/range";
import { map } from "@thi.ng/transducers/xform/map";
import { map, range } from "@thi.ng/transducers";

/**
* Configuration options for pager components.
Expand Down
5 changes: 2 additions & 3 deletions packages/hdom-components/src/sparkline.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { fitClamped } from "@thi.ng/math/fit";
import { str } from "@thi.ng/transducers/rfn/str";
import { mapIndexed } from "@thi.ng/transducers/xform/map-indexed";
import { fitClamped } from "@thi.ng/math";
import { mapIndexed, str } from "@thi.ng/transducers";

export interface SparklineOpts {
/**
Expand Down
3 changes: 1 addition & 2 deletions packages/hdom-components/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
20 changes: 13 additions & 7 deletions packages/hdom-mock/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{
"name": "@thi.ng/hdom-mock",
"version": "0.1.5",
"description": "TODO",
"main": "./index.js",
"description": "Mock base implementation for @thi.ng/hdom API",
"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 hdomMock api checks hdom",
"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 All @@ -29,6 +33,7 @@
},
"dependencies": {
"@thi.ng/api": "^4.2.4",
"@thi.ng/checks": "^1.5.14",
"@thi.ng/hdom": "^6.1.0"
},
"keywords": [
Expand All @@ -37,5 +42,6 @@
],
"publishConfig": {
"access": "public"
}
},
"sideEffects": false
}
16 changes: 10 additions & 6 deletions packages/hdom-mock/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import { IObjectOf } from "@thi.ng/api/api";
import { isFunction } from "@thi.ng/checks/is-function";
import { HDOMImplementation, HDOMOpts } from "@thi.ng/hdom/api";
import { diffTree } from "@thi.ng/hdom/diff";
import { createTree, hydrateTree } from "@thi.ng/hdom/dom";
import { normalizeTree } from "@thi.ng/hdom/normalize";
import { IObjectOf } from "@thi.ng/api";
import { isFunction } from "@thi.ng/checks";
import {
createTree,
diffTree,
HDOMImplementation,
HDOMOpts,
hydrateTree,
normalizeTree
} from "@thi.ng/hdom";

export const TEXT = Symbol();

Expand Down
3 changes: 1 addition & 2 deletions packages/hdom-mock/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
22 changes: 16 additions & 6 deletions packages/hdom/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
"name": "@thi.ng/hdom",
"version": "6.1.0",
"description": "Lightweight vanilla ES6 UI component trees with customizable branch-local behaviors",
"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 hdom api checks diff equiv errors hiccup",
"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": {
"@thi.ng/atom": "^1.5.8",
Expand All @@ -33,21 +37,27 @@
"@thi.ng/checks": "^1.5.14",
"@thi.ng/diff": "^2.0.2",
"@thi.ng/equiv": "^0.1.15",
"@thi.ng/errors": "^0.1.12",
"@thi.ng/hiccup": "^2.7.2"
},
"keywords": [
"browser",
"components",
"data driven",
"declarative",
"diff",
"DOM",
"ES6",
"functional",
"IOC",
"iterators",
"reactive",
"typescript",
"UI",
"VDOM"
],
"publishConfig": {
"access": "public"
}
},
"sideEffects": false
}
2 changes: 1 addition & 1 deletion packages/hdom/src/api.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";

export interface ILifecycle {
/**
Expand Down
6 changes: 2 additions & 4 deletions packages/hdom/src/diff.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { IObjectOf, SEMAPHORE } from "@thi.ng/api/api";
import { DiffMode } from "@thi.ng/diff/api";
import { diffArray } from "@thi.ng/diff/array";
import { diffObject } from "@thi.ng/diff/object";
import { IObjectOf, SEMAPHORE } from "@thi.ng/api";
import { diffArray, DiffMode, diffObject } from "@thi.ng/diff";
import {
equiv as _equiv,
equivArrayLike,
Expand Down
11 changes: 5 additions & 6 deletions packages/hdom/src/dom.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import * as isa from "@thi.ng/checks/is-array";
import * as isi from "@thi.ng/checks/is-not-string-iterable";
import { SVG_NS, SVG_TAGS } from "@thi.ng/hiccup/api";
import { css } from "@thi.ng/hiccup/css";
import { isArray as isa, isNotStringAndIterable as isi } from "@thi.ng/checks";
import { SVG_NS, SVG_TAGS } from "@thi.ng/hiccup";
import { css } from "@thi.ng/hiccup";
import { HDOMImplementation, HDOMOpts } from "./api";

const isArray = isa.isArray;
const isNotStringAndIterable = isi.isNotStringAndIterable
const isArray = isa;
const isNotStringAndIterable = isi;

/**
* See `HDOMImplementation` interface for further details.
Expand Down
2 changes: 2 additions & 0 deletions packages/hdom/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ export * from "./dom";
export * from "./normalize";
export * from "./render-once";
export * from "./start";

export * from "./utils";
14 changes: 6 additions & 8 deletions packages/hdom/src/normalize.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import * as isa from "@thi.ng/checks/is-array";
import * as insi from "@thi.ng/checks/is-not-string-iterable";
import * as iso from "@thi.ng/checks/is-plain-object";
import { illegalArgs } from "@thi.ng/errors/illegal-arguments";
import { NO_SPANS, TAG_REGEXP } from "@thi.ng/hiccup/api";
import { isArray as isa, isNotStringAndIterable as isi, isPlainObject as iso } from "@thi.ng/checks";
import { illegalArgs } from "@thi.ng/errors";
import { NO_SPANS, TAG_REGEXP } from "@thi.ng/hiccup";
import { HDOMOpts } from "./api";

const isArray = isa.isArray;
const isNotStringAndIterable = insi.isNotStringAndIterable;
const isPlainObject = iso.isPlainObject;
const isArray = isa;
const isNotStringAndIterable = isi;
const isPlainObject = iso;

/**
* Expands single hiccup element/component into its canonical form:
Expand Down
2 changes: 1 addition & 1 deletion packages/hdom/src/render-once.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { derefContext } from "@thi.ng/hiccup/deref";
import { derefContext } from "@thi.ng/hiccup";
import { HDOMImplementation, HDOMOpts } from "./api";
import { DEFAULT_IMPL } from "./default";
import { resolveRoot } from "./utils";
Expand Down
2 changes: 1 addition & 1 deletion packages/hdom/src/start.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { derefContext } from "@thi.ng/hiccup/deref";
import { derefContext } from "@thi.ng/hiccup";
import { HDOMImplementation, HDOMOpts } from "./api";
import { DEFAULT_IMPL } from "./default";
import { resolveRoot } from "./utils";
Expand Down
2 changes: 1 addition & 1 deletion packages/hdom/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isString } from "@thi.ng/checks/is-string";
import { isString } from "@thi.ng/checks";
import { HDOMImplementation } from "./api";

export const resolveRoot =
Expand Down
Loading

0 comments on commit f912a84

Please sign in to comment.