Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Move and optimize build process from ganache-cli to ganache-core #162

Merged
merged 44 commits into from
Sep 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
08350d9
get webpack ported over from ganache-cli
davidmurdoch Aug 3, 2018
24b9a43
add test script for testing against built lib
davidmurdoch Aug 7, 2018
bb6a964
Cherry pick commit from merkle-patricia-tree so it doesn't leak that …
davidmurdoch Aug 7, 2018
37f8f7d
add env flag to tests to determine which file to test against
davidmurdoch Aug 7, 2018
be40a22
add built files
davidmurdoch Aug 7, 2018
6a8b0d4
need mocha-webpack 2.0.0 in order to work with mocha 4
davidmurdoch Aug 7, 2018
4d93525
mocha webpack shrinkwrap changes
davidmurdoch Aug 7, 2018
e030850
small reorg of tests and a rebuild
davidmurdoch Aug 7, 2018
ed4bbb3
update test args
davidmurdoch Aug 20, 2018
a265356
don't include webpacked libs in repo
davidmurdoch Aug 21, 2018
9a28d06
ignore build directory
davidmurdoch Aug 21, 2018
e370ad8
Delete this one, too.
davidmurdoch Aug 21, 2018
7501217
update levelup/down so npm audit passes
davidmurdoch Aug 21, 2018
3ddc620
update builders
davidmurdoch Aug 21, 2018
a6aab4d
include shrinkwrap
davidmurdoch Aug 21, 2018
f290a3c
update tests to point to the new location of the webpacked build
davidmurdoch Aug 21, 2018
0edc6b0
add source-map-support
davidmurdoch Aug 22, 2018
13365c1
just trying something hacky
davidmurdoch Aug 22, 2018
5035e72
more hacks
davidmurdoch Aug 22, 2018
d2cb2e3
update packages then rewrap
davidmurdoch Aug 22, 2018
d502fac
don't need this experimental package now
davidmurdoch Aug 22, 2018
74e1ca6
well tests pass again
davidmurdoch Aug 24, 2018
d5aaad6
add secp256k1-pure to shrinkwrap
davidmurdoch Aug 24, 2018
932bfa4
use yarn and then create `npm-shrinkwrap.json` from yarn's installs
davidmurdoch Aug 25, 2018
17858e2
no go on yarn+npm shrinkwrap
davidmurdoch Aug 27, 2018
67e8103
Add .npmignore so when we publish we only publish what we need to
davidmurdoch Aug 28, 2018
02072c3
Make the default for running tests the webpacked config
davidmurdoch Aug 28, 2018
13cf085
Since we webpack everything now all dependencies are dev dependencies.
davidmurdoch Aug 28, 2018
8f0b1a2
expose `utils/to.js` to public interface in ganache-core
davidmurdoch Aug 28, 2018
47aeecc
Only partially webpack and add a `try/catch` around native deps
davidmurdoch Aug 29, 2018
e41d169
Rename env var TEST_BRANCH to TEST_BUILD because it's better
davidmurdoch Aug 30, 2018
83cdf44
Add clarifying comments to webpack config
davidmurdoch Aug 30, 2018
3bef5b7
Webpack actually neds to require the interface directly, not the try/…
davidmurdoch Aug 30, 2018
61d7acd
ganache-cli needs /lib
davidmurdoch Aug 30, 2018
e0cad9e
Renaming things after a fun round of wordsmithing and pedantry. Also:…
davidmurdoch Aug 30, 2018
a278035
naming things
davidmurdoch Aug 31, 2018
8005f28
Whitespace fix
davidmurdoch Aug 31, 2018
b639201
Don't need to remove uncaughtException in this test
davidmurdoch Aug 31, 2018
529ef02
Fix teh typo
davidmurdoch Aug 31, 2018
83b99b4
Another whitespace fix
davidmurdoch Aug 31, 2018
b3acad1
Only build full lib on `npm build` as other builds aren't currently u…
davidmurdoch Aug 31, 2018
d3b437e
update webpack
davidmurdoch Aug 31, 2018
9dbe41a
Merge branch 'develop' into test-portability
davidmurdoch Aug 31, 2018
912b009
add sanitizedData to list of akllowed leaked globals in mocha tests
davidmurdoch Aug 31, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ TODO
.DS_Store
.tern-port
.vscode
yarn.lock
build
13 changes: 13 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.npmignore
.tern-project
.tern-port
.dockerignore
.travis.yml
.eslintrc.js
*.log
Dockerfile
ISSUE_TEMPLATE.md
.vscode/
test/
webpack/
perf/
45 changes: 34 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,35 @@
var Provider = require("./lib/provider");
var Server = require("./lib/server");

// This interface exists so as not to cause breaking changes.
module.exports = {
server: function(options) {
return Server.create(options);
},
provider: function(options) {
return new Provider(options);
// make sourcemaps work!
require("source-map-support/register");

const debug = require("debug")("ganache");

// we use optional dependencies which may, or may not exist, so try native first
try {
// make sure these exist before we try to load ganache with native modules
const optionalDependencies = require("./package.json").optionalDependencies;
const wrongWeb3 = require("web3/package.json").version !== optionalDependencies["web3"];
const wrongEthereumJs = require("ethereumjs-wallet/package.json").version !== optionalDependencies["ethereumjs-wallet"];
if (wrongWeb3 || wrongEthereumJs) {
useBundled();
} else {
module.exports = require("./public-exports.js");
module.exports._webpacked = false;
debug("Optional dependencies installed; exporting ganache-core with native optional dependencies.");
}
} catch (nativeError) {
debug(nativeError);

// grabbing the native/optional deps failed, try using our webpacked build.
useBundled();
}

function useBundled() {
try {
module.exports = require("./build/ganache.core.node.js");
module.exports._webpacked = true;
debug("Optional dependencies not installed; exporting ganache-core from `./build` directory.");
} catch(webpackError) {
debug("ganache-core could not be exported; optional dependencies nor webpack build available for export.");
throw webpackError;
}
};
}
15 changes: 2 additions & 13 deletions lib/database.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
var LevelUpArrayAdapter = require("./database/leveluparrayadapter");
var LevelUpObjectAdapter = require("./database/levelupobjectadapter");
var levelup = require('levelup');
var encode = require('encoding-down')
var filedown = require("./database/filedown");
var cachedown = require("cachedown");
var Sublevel = require("level-sublevel");
Expand Down Expand Up @@ -32,19 +33,7 @@ Database.prototype.initialize = function(callback) {

getDir(function(err, directory) {
if (err) return callback(err);

levelup(directory, {
valueEncoding: "json",
db: function (location) {
if (self.options.db) return self.options.db;

// This cache size was chosen from a plethora of hand testing.
// It seems a not-too-large cache (100) size is the right amount.
// When higher (say 10000), it seems the benefits wear off.
// See /perf/transactions.js for a benchmark.
return cachedown(location, filedown).maxSize(100);
}
}, finishInitializing)
levelup(self.options.db || encode(cachedown(directory, filedown).maxSize(100)), {valueEncoding: "json"}, finishInitializing);
});

function finishInitializing(err, db) {
Expand Down
3 changes: 3 additions & 0 deletions lib/provider.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// make sourcemaps work!
require('source-map-support/register')

let ProviderEngine = require("web3-provider-engine");
let SubscriptionSubprovider = require('web3-provider-engine/subproviders/subscriptions');

Expand Down
3 changes: 3 additions & 0 deletions lib/server.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// make sourcemaps work!
require('source-map-support/register')

var Provider = require("./provider");
var webSocketServer = require("./webSocketServer");
var httpServer = require("./httpServer");
Expand Down
Loading