Skip to content

Commit

Permalink
Fixed build process to re-target browser field to ES version.
Browse files Browse the repository at this point in the history
  • Loading branch information
ricmoo committed Aug 25, 2019
1 parent 73a0077 commit 3a91e91
Show file tree
Hide file tree
Showing 57 changed files with 1,326 additions and 21,723 deletions.
27 changes: 24 additions & 3 deletions admin/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const resolve = require("path").resolve;
const spawn = require("child_process").spawn;

const { dirnames } = require("./local");
const { loadPackage } = require("./depgraph");
const { loadPackage, savePackage } = require("./local");
const { loadJson, saveJson } = require("./utils");

function run(progname, args, ignoreErrorStream) {
Expand Down Expand Up @@ -49,6 +49,14 @@ function run(progname, args, ignoreErrorStream) {
}

function setupConfig(outDir, moduleType, targetType) {
function update(value) {
let comps = value.split("/");
if (comps.length >= 3 && comps[0] === "." && comps[1].match(/^lib(\.esm)?$/)) {
return outDir + comps.slice(2).join("/");
}
return value;
}

// Configure the tsconfit.package.json...
const path = resolve(__dirname, "../tsconfig.package.json");
const content = loadJson(path);
Expand All @@ -57,7 +65,20 @@ function setupConfig(outDir, moduleType, targetType) {
saveJson(path, content);

dirnames.forEach((dirname) => {
if (loadPackage(dirname)._ethers_nobuild) { return; }
let info = loadPackage(dirname);

if (info._ethers_nobuild) { return; }

if (info.browser) {
if (typeof(info.browser) === "string") {
info.browser = update(info.browser);
} else {
for (let key in info.browser) {
info.browser[key] = update(info.browser[key]);
}
}
}
savePackage(dirname, info);

let path = resolve(__dirname, "../packages", dirname, "tsconfig.json");
let content = loadJson(path);
Expand All @@ -82,7 +103,7 @@ function runBuild(buildModule) {
}

function runDist() {
return run("npx", [ "lerna", "run", "dist" ], true);
return run("npm", [ "run", "_dist_ethers" ], true);
}

module.exports = {
Expand Down
8 changes: 4 additions & 4 deletions admin/cmds/update-versions.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const { getPackageVersion } = require("../npm");
const { resolve } = require("../utils");
const { colorify, log } = require("../log");

const { getProgressBar } = require("../../packages/cli/prompt");
const { prompt } = require("../../packages/cli");

let dirnames = getOrdered();

Expand All @@ -41,7 +41,7 @@ if (process.argv.length > 2) {
}

(async function() {
let progress = getProgressBar(colorify("Updating versions", "bold"));
let progress = prompt.getProgressBar(colorify("Updating versions", "bold"));

for (let i = 0; i < dirnames.length; i++) {
progress(i / dirnames.length);
Expand Down Expand Up @@ -87,7 +87,7 @@ if (process.argv.length > 2) {
log("<bold:Building TypeScript source (es6)...>");
await runBuild(true);
log("<bold:Building TypeScript source (commonjs)...>");
await runBuild();
await runBuild(false);
log("<bold:Building distribution files...>");
let content = await runDist();
console.log(content);
Expand All @@ -98,7 +98,7 @@ if (process.argv.length > 2) {
}

// Update the tarball hash now that _version and package.json may have changed.
progress = getProgressBar(colorify("Updating tarballHash", "bold"));
progress = prompt.getProgressBar(colorify("Updating tarballHash", "bold"));
for (let i = 0; i < dirnames.length; i++) {
progress(i / dirnames.length);
await updatePackage(dirnames[i]);
Expand Down
2 changes: 1 addition & 1 deletion admin/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const resolve = require("path").resolve;
const AES = require("aes-js");
const scrypt = require("scrypt-js");

const prompt = require("../packages/cli/prompt");
const { prompt } = require("../packages/cli");
const randomBytes = require("../packages/random").randomBytes;
const computeHmac = require("../packages/sha2").computeHmac;

Expand Down
6 changes: 3 additions & 3 deletions admin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const resolve = require("path").resolve;
const diff = require("diff");
const semver = require("semver");

const { getProgressBar, prompt } = require("../packages/cli/prompt");
const { prompt } = require("../packages/cli");

const build = require("./build");
const changelog = require("./changelog");
Expand Down Expand Up @@ -158,7 +158,7 @@ async function runUpdate(dirnames) {
// @TODO: Root

// Update all the package.json and _version.ts
let progress = getProgressBar(colorify("Updating versions", "bold"));
let progress = prompt.getProgressBar(colorify("Updating versions", "bold"));
for (let i = 0; i < dirnames.length; i++) {
progress(i / dirnames.length);

Expand Down Expand Up @@ -205,7 +205,7 @@ async function runUpdate(dirnames) {
// @TODO:

// Update the tarball hash now that _version and package.json may have changed.
progress = getProgressBar(colorify("Updating tarballHash", "bold"));
progress = prompt.getProgressBar(colorify("Updating tarballHash", "bold"));
for (let i = 0; i < dirnames.length; i++) {
progress(i / dirnames.length);
await local.updatePackage(dirnames[i]);
Expand Down
2 changes: 1 addition & 1 deletion admin/npm.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const local = require("./local");

const keccak256 = require("../packages/keccak256").keccak256;
const fetchJson = require("../packages/web").fetchJson;
const prompt = require("../packages/cli/prompt");
const { prompt } = require("../packages/cli");

const colorify = require("./log").colorify;
const git = require("./git");
Expand Down
4 changes: 0 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,19 @@
"bootstrap": "node ./admin/cmds/reset-build.js && node ./admin/cmds/update-depgraph && lerna bootstrap --hoist",
"build": "tsc --build ./tsconfig.project.json",
"clean": "node ./admin/cmds/reset-build.js && tsc --build --clean ./tsconfig.project.json",

"_dist_prepare": "npm run clean && npm run bootstrap && npm run build",
"_dist_ethers": "rollup -c && rollup -c --configMinify && rollup -c --configModule && rollup -c --configModule --configMinify",
"_dist_tests": "rollup -c --configTest && rollup -c --configTest --configMinify && rollup -c --configTest --configModule && rollup -c --configTest --configModule --configMinify",

"_test_prepare": "npm run _dist_prepare && npm run _dist_tests",
"_test_node": "cd packages/tests && mocha --no-colors --reporter ./tests/reporter ./tests/test-*.js",
"test_node": "npm run _test_prepare && npm run _test_node",

"_dist_old": "npm run clean && npm run bootstrap && npm run build && lerna run dist",
"old-test": "npm run _dist_old && npm run test-check",
"old-test-check": "if [ \"$RUN_PHANTOMJS\" = \"1\" ]; then npm run-script test-phantomjs; else npm run-script test-node; fi",
"old-test-node": "cd packages/tests && mocha --no-colors --reporter ./tests/reporter ./tests/test-*.js",
"old-test-phantomjs": "cd packages/tests && npm run dist-phantomjs && phantomjs --web-security=false ../../node_modules/mocha-phantomjs-core/mocha-phantomjs-core.js ./test.html ./tests/reporter.js",
"old-test-aion": "npm run dist && npm run test-aion-node",
"old-test-aion-node": "cd packages/aion-tests && mocha --no-colors --reporter ../tests/tests/reporter ./tests/test-*.js",

"update-versions": "npm run _dist_prepare && node ./admin/cmds/update-versions",
"publish-all": "node ./admin/cmds/publish",
"build-docs": "flatworm docs.wrm docs"
Expand Down
2 changes: 1 addition & 1 deletion packages/abi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
"url": "git://github.com/ethers-io/ethers.js.git"
},
"module": "./lib.esm/index.js",
"tarballHash": "0x39e9e020225c070444d3030a0423e986c5c8b25ee3279341641f4b6bf343f4a2"
"tarballHash": "0x48cbad8938a128d8f52b87e30c92a1ad2b28af9aee2d1faf1a4c23d60a14b2d3"
}
6 changes: 1 addition & 5 deletions packages/abstract-provider/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
"version": "5.0.0-beta.131",
"description": "An Abstract Class for describing an Ethereum Provider for ethers.",
"main": "./lib/index.js",
"browser": {
"net": "./browser-net.js",
"./ipc-provider": "./browser-ipc-provider"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
Expand All @@ -33,5 +29,5 @@
"url": "git://github.com/ethers-io/ethers.js.git"
},
"module": "./lib.esm/index.js",
"tarballHash": "0x4b955417ad50b4c8fa7d7ac8f3de84a9f7948381e3f79f6e301a1bdfdd95066c"
"tarballHash": "0x478d4364ced856f3b5ee51da258a5ae239b97a5d1a58f25dd25b8e81f692683c"
}
2 changes: 1 addition & 1 deletion packages/abstract-signer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@
"url": "git://github.com/ethers-io/ethers.js.git"
},
"module": "./lib.esm/index.js",
"tarballHash": "0xaa4a4086f9fea3265ac7918227914cf63bf4dc082ea2bc4457dc009fafb51437"
"tarballHash": "0xc1853f4ac83975080e51babe4f0613122ce5b1b5d68287c84d44a5663cf5546c"
}
2 changes: 1 addition & 1 deletion packages/address/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@
"url": "git://github.com/ethers-io/ethers.js.git"
},
"module": "./lib.esm/index.js",
"tarballHash": "0xf52fe7ac31abf75d751e23e06fad681acee39ae9d1153f9c24d5feae7018f22d"
"tarballHash": "0x3f3fd1c8422ddd05719dfb37df8292d27e93ae1ce0d0d48e5cdc263082e35a78"
}
4 changes: 2 additions & 2 deletions packages/base64/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "5.0.0-beta.126",
"description": "Base64 coder.",
"main": "./lib/index.js",
"browser": "browser.js",
"browser": "./lib/browser.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
Expand All @@ -24,5 +24,5 @@
"url": "git://github.com/ethers-io/ethers.js.git"
},
"module": "./lib.esm/index.js",
"tarballHash": "0xf6efb1c57508f4e699d90f6423068a95189bc5b750430f294661e2dcf75d919c"
"tarballHash": "0x390db88947a298518774fc7b8d5f9b36191df44152bca2370a890d44d44e731f"
}
2 changes: 1 addition & 1 deletion packages/basex/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@
"url": "git://github.com/ethers-io/ethers.js.git"
},
"module": "./lib.esm/index.js",
"tarballHash": "0x07d12f5f71d62ecbc4240de5bc05e6031f4e0e0620e280eba2c18b2e294d4ff5"
"tarballHash": "0x6375a21ec47208aa3a867f26061dbd56afcb7eb51f70c6955b99718fe3ebc32a"
}
2 changes: 1 addition & 1 deletion packages/bignumber/lib.esm/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { BigNumber, BigNumberish } from "./bignumber";
export { FixedNumber } from "./fixednumber";
export { formatFixed, FixedFormat, FixedNumber, parseFixed } from "./fixednumber";
2 changes: 1 addition & 1 deletion packages/bignumber/lib.esm/index.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { BigNumber } from "./bignumber";
export { FixedNumber } from "./fixednumber";
export { formatFixed, FixedFormat, FixedNumber, parseFixed } from "./fixednumber";
2 changes: 1 addition & 1 deletion packages/bignumber/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@
"url": "git://github.com/ethers-io/ethers.js.git"
},
"module": "./lib.esm/index.js",
"tarballHash": "0x78dadd02c7c23e71e8bc51a5a21843437363b7ab29d16de0290e25f12d7fe6f6"
"tarballHash": "0x3b0c080f96f262333cb2191f8160e1aef0d93f9af107c1aa0876d007817c9e76"
}
2 changes: 1 addition & 1 deletion packages/bytes/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@
"url": "git://github.com/ethers-io/ethers.js.git"
},
"module": "./lib.esm/index.js",
"tarballHash": "0x7092fb4f0431cc7edeabb25e101d0d73a378bbb842c38e48b8eb41031d97d2f2"
"tarballHash": "0x4b7f4f6a34bc4d5c4fe15a01b7c698e8250f828933bb6202248a660d0fb5edfb"
}
5 changes: 5 additions & 0 deletions packages/cli/lib.esm/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import * as cli from "./cli";
import * as prompt from "./prompt";
import * as solc from "./solc";
import * as typescript from "./typescript";
export { cli, prompt, solc, typescript, };
6 changes: 6 additions & 0 deletions packages/cli/lib.esm/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
"use strict";
import * as cli from "./cli";
import * as prompt from "./prompt";
import * as solc from "./solc";
import * as typescript from "./typescript";
export { cli, prompt, solc, typescript, };
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@
"url": "git://github.com/ethers-io/ethers.js.git"
},
"module": "./lib.esm/index.js",
"tarballHash": "0xba8cdd7f8648de30fba61ce68e7592be382a490cb92217765fb926cdd99942b8"
"tarballHash": "0x047aa677370e57a4c356aa7ca5d3e692038f4863413141cd1f325526c59a4096"
}
2 changes: 1 addition & 1 deletion packages/constants/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@
"url": "git://github.com/ethers-io/ethers.js.git"
},
"module": "./lib.esm/index.js",
"tarballHash": "0x3ece9df573db39c560dac46836c5bc16d4c46a504991a726262f5f0ca8b1b2f1"
"tarballHash": "0x29b69bfc747774d3debf9874b27f05d4c8ea232d709ce955d931d18624a7b0d3"
}
2 changes: 1 addition & 1 deletion packages/contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
"url": "git://github.com/ethers-io/ethers.js.git"
},
"module": "./lib.esm/index.js",
"tarballHash": "0x2b3d95a50f2ca8c9bfc0537b3ba0709961462384296311ea188b3b96e3f58b83"
"tarballHash": "0xd9caa174a4d078052aef924411d3175358bd4539b192b625b3ee3a7a9ba9d653"
}
2 changes: 1 addition & 1 deletion packages/errors/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@
"url": "git://github.com/ethers-io/ethers.js.git"
},
"module": "./lib.esm/index.js",
"tarballHash": "0x38cdacb3663d11ec01cd55e8b13e4d77c8aa5b754dbaa9424bb4bb3de18071db"
"tarballHash": "0x7acbc055896e553d4aa8a18f61197c58d726ef6f44d01a403c323f28ce41330d"
}
Loading

0 comments on commit 3a91e91

Please sign in to comment.