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

Generate truffle library webpack bundle for package main #2226

Merged
merged 1 commit into from
Jul 28, 2019
Merged

Generate truffle library webpack bundle for package main #2226

merged 1 commit into from
Jul 28, 2019

Conversation

cgewecke
Copy link
Contributor

@cgewecke cgewecke commented Jul 17, 2019

#2222

Makes the following possible (in a plugin context, for example).

const truffle = require("truffle");
await truffle.contracts.compile(config);

Implementation Details

  • In Plugin improvement: expose truffle-core's index.js in webpack bundle  #2222 I proposed using webpack expose-loader for this because I was concerned about the bundle size growing a lot. The unpacked version is bigger here (25-30%), but the packed version sent over the wire from npm is still quite small and it doesn't affect installation speeds. I published my own version to test that issue & validate the POC in the code snippet above - everything worked. Also expose-loader is a nightmare.

  • Added ganache-core to the truffle-core exports so consumer can spin up an in-process provider.

  • Added top layer API correctness tests - you'll get a scenario test failure if you delete/rename one of those methods.

cf: solidity-coverage 0.7.0

@coveralls
Copy link

coveralls commented Jul 17, 2019

Coverage Status

Coverage remained the same at 70.595% when pulling ccdf497 on cgewecke:truffle-library into 7fcc3fe on trufflesuite:develop.

@cgewecke
Copy link
Contributor Author

Also had a thought about the API reliability question Nick raises in #2222 - perhaps the simplest thing is to document this feature in the plugin docs, declare the API all-caps unstable (except for truffle.version) and advise people to use individual semvered truffle- modules when possible. Happy to open a PR for that as well.

I my case I really need to be able to invoke the test.run logic after manipulating the config. The absence require("truffle") would mean I'd have to include truffle-core as a dependency (which is a heavy payload for a plugin).

@eggplantzzz
Copy link
Contributor

Thanks for the PR @cgewecke, I'll try and look over this soon!

@cgewecke
Copy link
Contributor Author

@eggplantzzz Thanks! Just lmk if/when you want a rebase.

Copy link
Contributor

@gnidan gnidan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cgewecke Finally got time to sit down and think about this one. Your point about notifying instability has sold me. If you wouldn't mind opening the PR for that docs change, I'd be grateful for one less thing to do 🙇

For now though, approving and merging! Thanks!

@gnidan gnidan merged commit 86e39f8 into trufflesuite:develop Jul 28, 2019
@cgewecke
Copy link
Contributor Author

@gnidan Awesome, thanks so much! Will open the docs PR tomorrow.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants