Skip to content

Commit

Permalink
upgrade to webpack
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanio committed Jul 3, 2020
1 parent 1404086 commit a9c0655
Show file tree
Hide file tree
Showing 31 changed files with 5,235 additions and 4,634 deletions.
4 changes: 2 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Fixes #(issue)
- [ ] I ran `npm run dtslint` with success and extended the tests and types if necessary.
- [ ] I ran `npm run test:unit` with success.
- [ ] I ran `npm run test:cov` and my test cases cover all the lines and branches of the added code.
- [ ] I ran `npm run build-all` and tested the resulting files from `dist` folder in a browser.
- [ ] I have updated the `CHANGELOG.md` file in the root folder.
- [ ] I ran `npm run build` and tested `dist/web3.min.js` in a browser.
- [ ] I have tested my code on the live network.
- [ ] I have checked the Deploy Preview and it looks correct.
- [ ] I have updated the `CHANGELOG.md` file in the root folder.
25 changes: 8 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Use the prebuilt `dist/web3.min.js`, or
build using the [web3.js][repo] repository:

```bash
npm run-script build
npm run build
```

Then include `dist/web3.js` in your html file.
Expand All @@ -54,10 +54,10 @@ UNPKG:
## Usage

```js
// in node.js
var Web3 = require('web3');
// In Node.js
const Web3 = require('web3');

var web3 = new Web3('ws://localhost:8546');
let web3 = new Web3('ws://localhost:8546');
console.log(web3);
> {
eth: ... ,
Expand Down Expand Up @@ -92,7 +92,7 @@ import Web3 from 'web3';
const web3 = new Web3('ws://localhost:8546');
```

If you are using the types in a `commonjs` module like for example a node app you just have to enable `esModuleInterop` in your `tsconfig` compile option, also enable `allowSyntheticDefaultImports` for typesystem compatibility:
If you are using the types in a `commonjs` module, like in a Node app, you just have to enable `esModuleInterop` and `allowSyntheticDefaultImports` in your `tsconfig` for typesystem compatibility:

```js
"compilerOptions": {
Expand All @@ -118,22 +118,14 @@ sudo apt-get install nodejs
sudo apt-get install npm
```
### Building (gulp)
### Building (webpack)
Build only the web3.js package:
Build the web3.js package:
```bash
npm run-script build
npm run build
```
Or build all sub packages as well:
```bash
npm run-script build-all
```
This will put all the browser build files into the `dist` folder.
### Testing (mocha)
```bash
Expand All @@ -150,7 +142,6 @@ This project adheres to the [Release Guidelines](./REVIEW.md).
- [Gitter][gitter-url]
- [StackExchange][stackexchange-url]
- [Forum](https://forum.ethereum.org/categories/ethereum-js)
### Similar libraries in other languages
Expand Down
3 changes: 0 additions & 3 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ The following describes the steps required to release a new version of `web3.js`
1. Add next anticipated release version number to bottom (as a placeholder for new changelog entries).
1. Create release commit and tags e.g. `lerna version 1.2.7-rc.0 --no-push`
1. (updates package version numbers, builds minified file (for `1.x`), creates release commit and tags.)
1. For `1.x`, save [index.html](https://github.com/ethereum/web3.js/blob/1.x/scripts/html/index.html) to your local machine and test loading minified file to ensure its integrity. Be sure to delete `index.html` after.
1. Check git working state is clean. Sometimes files modified by gulp are not included. If so, run `git commit --amend` and `git tag -d 1.2.7-rc.0` and `git tag 1.2.7-rc.0`.
1. Push release branch to origin with tags `git push origin release/1.2.7 --follow-tags`.
1. Create release PR as draft ([example](https://github.com/ethereum/web3.js/pull/3351)).
1. Ensure CI is green / passing.
Expand All @@ -107,7 +105,6 @@ The following describes the steps required to release a new version of `web3.js`
1. Create GitHub draft release from text of `rc` release.
1. Checkout release branch (e.g. `release/1.2.7`).
1. Create and push release commit and tags: `lerna version 1.2.7 --force-publish --no-push`
1. Check git working state is clean. Sometimes files modified by gulp are not included. If so, run `git commit --amend` and `git tag -d 1.2.7` and `git tag 1.2.7`.
1. Push release branch to origin with tags `git push origin release/1.2.7 --follow-tags`.
1. Publish the GitHub release.
1. A GitHub Webhook should trigger the ReadTheDocs build after the release is published.
Expand Down
50 changes: 49 additions & 1 deletion dist/web3.min.js

Large diffs are not rendered by default.

232 changes: 0 additions & 232 deletions gulpfile.js

This file was deleted.

22 changes: 11 additions & 11 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
// BROWSER_BUNDLE_TEST is set for an un-browserified check that both bundles load correctly.
// BROWSER_BUNDLE_TEST is not set for the e2e unit tests, which check that bundle internals are ok.
function getTestFiles(){
switch (process.env.BROWSER_BUNDLE_TEST){
function getTestFiles() {
switch (process.env.BROWSER_BUNDLE_TEST) {
case 'publishedDist':
return ["packages/web3/dist/web3.min.js", "test/e2e.minified.js"]
return ['packages/web3/dist/web3.min.js', 'test/e2e.minified.js'];
case 'gitRepoDist':
return ["dist/web3.min.js", "test/e2e.minified.js"]
return ['dist/web3.min.js', 'test/e2e.minified.js'];
default:
return ["test/**/e2e*.js"]
return ['test/**/e2e*.js'];
}
}

// Only loads browserified preprocessor for the logic unit tests so we can `require` stuff.
function getPreprocessors(){
if (!process.env.BROWSER_BUNDLE_TEST){
return { 'test/**/e2e*.js': [ 'browserify' ] }
function getPreprocessors() {
if (!process.env.BROWSER_BUNDLE_TEST) {
return { 'test/**/e2e*.js': ['browserify'] };
}
}

Expand All @@ -28,15 +28,15 @@ module.exports = function (config) {
'karma-firefox-launcher',
'karma-mocha',
'karma-browserify',
'karma-spec-reporter'
'karma-spec-reporter',
],
reporters: ['spec'],
port: 9876, // karma web server port
colors: true,
logLevel: config.LOG_INFO,
autoWatch: false,
browsers: ["ChromeHeadless", "FirefoxHeadless"],
browsers: ['ChromeHeadless', 'FirefoxHeadless'],
};

config.set(configuration);
};
};

0 comments on commit a9c0655

Please sign in to comment.