From 8d445e7ebbc2069b358fc9778483679aeb1c6679 Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Wed, 28 Oct 2020 15:02:59 -0400 Subject: [PATCH] updated build targets and tfjs to 2.7.0 --- README.md | 15 ++++++++------- package.json | 9 +++++---- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index cefed4f1..14b7c841 100644 --- a/README.md +++ b/README.md @@ -41,15 +41,16 @@ There are multiple ways to use `Human` library, pick one that suits you: - `dist/human.js`: IIFE format bundle with TFJS for Browsers - `dist/human.esm.js`: ESM format bundle with TFJS for Browsers - `dist/human.esm-nobundle.js`: ESM format bundle without TFJS for Browsers -- `dist/human.cjs`: CommonJS format bundle without TFJS for NodeJS +- `dist/human.node.js`: CommonJS format bundle with TFJS for NodeJS +- `dist/human.node-nobundle.js`: CommonJS format bundle without TFJS for NodeJS -All versions include `sourcemap` and build `manifest` +All versions include `sourcemap` *(.map)* and build `manifest` *(.json)* While `Human` is in pre-release mode, all bundles are non-minified Defaults: ```json { - "main": "dist/human.cjs", + "main": "dist/human.node.js", "module": "dist/human.esm.js", "browser": "dist/human.esm.js", } @@ -103,7 +104,7 @@ Install with: ```js import Human from '@vladmandic/human'; // points to @vladmandic/human/dist/human.esm.js // you can also force-load specific version - // for example: `@vladmandic/human/dist/human.esm.js` + // for example: `@vladmandic/human/dist/human.esm-nobundle.js` const human = new Human(); ``` @@ -123,7 +124,7 @@ Install with: *Recommended for `NodeJS` projects that will execute in the backend* -Entry point is bundle in CJS format `dist/human.node.js` +Entry point is bundle in CommonJS format `dist/human.node.js` You also need to install and include `tfjs-node` or `tfjs-node-gpu` in your project so it can register an optimized backend Install with: @@ -133,7 +134,7 @@ Install with: And then use with: ```js const tf = require('@tensorflow/tfjs-node'); // can also use '@tensorflow/tfjs-node-gpu' if you have environment with CUDA extensions - const Human = require('@vladmandic/human').default; // points to @vladmandic/human/dist/human.cjs + const Human = require('@vladmandic/human').default; // points to @vladmandic/human/dist/human.node.js const human = new Human(); ``` @@ -162,7 +163,7 @@ Browser: - `index.html`, `browser.js`, `worker.js`: Full demo using Browser with ESM module, includes selectable backends and webworkers NodeJS: -- `node.js`: Demo using NodeJS with CJS module +- `node.js`: Demo using NodeJS with CommonJS module This is a very simple demo as althought `Human` library is compatible with NodeJS execution and is able to load images and models from local filesystem, diff --git a/package.json b/package.json index 580bed83..e8dc5bd0 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "@tensorflow/tfjs-node": "^2.7.0", "@vladmandic/pilogger": "^0.2.6", "dayjs": "^1.9.4", - "esbuild": "^0.7.21", + "esbuild": "^0.7.22", "eslint": "^7.12.1", "eslint-config-airbnb-base": "^14.2.0", "eslint-plugin-import": "^2.22.1", @@ -42,9 +42,10 @@ "build-iife": "esbuild --bundle --platform=browser --sourcemap --target=esnext --format=iife --external:fs --global-name=Human --metafile=dist/human.json --outfile=dist/human.js src/human.js", "build-esm-bundle": "esbuild --bundle --platform=browser --sourcemap --target=esnext --format=esm --external:fs --metafile=dist/human.esm.json --outfile=dist/human.esm.js src/human.js", "build-esm-nobundle": "esbuild --bundle --platform=browser --sourcemap --target=esnext --format=esm --external:@tensorflow --external:fs --metafile=dist/human.esm-nobundle.json --outfile=dist/human.esm-nobundle.js src/human.js", - "build-node": "esbuild --bundle --platform=node --sourcemap --target=esnext --format=cjs --external:@tensorflow --metafile=dist/human.node.json --outfile=dist/human.node.js src/human.js", - "build": "rimraf dist/* && npm run build-iife && npm run build-esm-bundle && npm run build-esm-nobundle && npm run build-node && ls -l dist/", - "update": "npm update --depth 20 && npm dedupe && npm prune && npm audit", + "build-node": "esbuild --bundle --platform=node --sourcemap --target=esnext --format=cjs --metafile=dist/human.node.json --outfile=dist/human.node.js src/human.js", + "build-node-nobundle": "esbuild --bundle --platform=node --sourcemap --target=esnext --format=cjs --external:@tensorflow --metafile=dist/human.node.json --outfile=dist/human.node-nobundle.js src/human.js", + "build": "rimraf dist/* && npm run build-iife && npm run build-esm-bundle && npm run build-esm-nobundle && npm run build-node && npm run build-node-nobundle && ls -l dist/", + "update": "npm update --depth 20 --force && npm dedupe && npm prune && npm audit", "changelog": "node changelog.js" }, "keywords": [