Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

🎨 Update the webpack to build per package #5140

Merged
merged 24 commits into from
Jun 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
7cd4060
webpack required pckages and script
jdevcs Jun 7, 2022
c656a39
initial webpack build config
jdevcs Jun 7, 2022
c29f3d3
libs install changes yarnlock
jdevcs Jun 7, 2022
3fa93d0
webpack clean dist
jdevcs Jun 7, 2022
1753ce9
webpack build
jdevcs Jun 7, 2022
70186f2
allow dist dir at root
jdevcs Jun 7, 2022
c09f323
initial test build
jdevcs Jun 7, 2022
59e9c59
Merge branch '4.x' into junaid/4xwebpackbuildconfig
jdevcs Jun 7, 2022
6c89905
webpack build config
jdevcs Jun 7, 2022
5facb46
dnt commit build
jdevcs Jun 13, 2022
3af86da
remove build
jdevcs Jun 13, 2022
ab02583
web3 min
jdevcs Jun 13, 2022
fcfda1c
Merge branch '4.x' into junaid/4xwebpackbuildconfig
jdevcs Jun 13, 2022
d1a2044
Merge branch '4.x' into junaid/4xwebpackbuildconfig
jdevcs Jun 15, 2022
500413e
:art: Update the webpack to build per package
nazarhussain Jun 16, 2022
4b27a19
Merge branch '4.x' into nh/webpack-refactor
nazarhussain Jun 16, 2022
0e63a3e
:see_no_evil: Ignore the webpack config from linting
nazarhussain Jun 16, 2022
3ff5700
Merge branch '4.x' into nh/webpack-refactor
avkos Jun 20, 2022
6b718f9
Merge branch '4.x' into nh/webpack-refactor
nazarhussain Jun 22, 2022
cd36a14
Merge branch 'nh/webpack-refactor' of github.com:ChainSafe/web3.js in…
nazarhussain Jun 22, 2022
39c21ed
:green_heart: Update web build step to CI
nazarhussain Jun 22, 2022
63bf32e
:art: Merge the build tasks
nazarhussain Jun 22, 2022
432f379
:rotating_light: Fix lint error
nazarhussain Jun 22, 2022
c1cba82
Merge branch '4.x' into nh/webpack-refactor
avkos Jun 23, 2022
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
3 changes: 2 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ jobs:
node-version: 14
cache: yarn
- run: yarn

- run: yarn build:web

lint:
name: lint
needs: build
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
]
},
"scripts": {
"build": "yarn clean && lerna run build --stream && webpack --config webpackprod.config.js",
"prebuild": "yarn clean",
"build": "lerna run build --stream",
"build:web": "lerna run build:web --stream",
"clean": "lerna run clean --stream --parallel",
"ganache:start": "WEB3_SYSTEM_TEST_BACKEND=ganache && ./scripts/ganache.sh start",
"ganache:start:background": "WEB3_SYSTEM_TEST_BACKEND=ganache && ./scripts/ganache.sh start 1",
Expand Down
1 change: 1 addition & 0 deletions packages/web3-validator/.eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
dist
jest.config.js
.eslintrc.js
webpack.config.js
2 changes: 2 additions & 0 deletions packages/web3-validator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "0.1.0-alpha.0",
"description": "JSON-Schema compatible validator for web3",
"main": "dist/index.js",
"browser": "dist/index.min.js",
"repository": "https://github.com/ChainSafe/web3.js",
"author": "ChainSafe Systems",
"license": "LGPL-3.0",
Expand All @@ -13,6 +14,7 @@
"clean": "rimraf dist",
"prebuild": "rimraf dist",
"build": "tsc --build",
"build:web": "npx webpack",
"build:check": "node -e \"require('./dist')\"",
"lint": "eslint --ext .js,.ts .",
"lint:fix": "eslint --fix --ext .js,.ts .",
Expand Down
20 changes: 20 additions & 0 deletions packages/web3-validator/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
This file is part of web3.js.

web3.js is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

web3.js is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with web3.js. If not, see <http://www.gnu.org/licenses/>.
*/

const { getWebPackConfig } = require('../../webpack.base.config');

module.exports = getWebPackConfig(__dirname, 'index.min.js', 'web3-validator');
1 change: 1 addition & 0 deletions packages/web3/.eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
dist
jest.config.js
webpack.config.js
.eslintrc.js
2 changes: 2 additions & 0 deletions packages/web3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "4.0.0-alpha.1",
"description": "Ethereum JavaScript API",
"main": "dist/index.js",
"browser": "dist/web3.min.js",
"repository": "https://github.com/ChainSafe/web3.js",
"engines": {
"node": ">=12.0.0"
Expand All @@ -21,6 +22,7 @@
"clean": "rimraf dist",
"prebuild": "rimraf dist",
"build": "tsc --build",
"build:web": "npx webpack",
"build:check": "node -e \"require('./dist')\"",
"lint": "eslint --ext .js,.ts .",
"lint:fix": "eslint --fix --ext .js,.ts .",
Expand Down
20 changes: 20 additions & 0 deletions packages/web3/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
This file is part of web3.js.

web3.js is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

web3.js is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with web3.js. If not, see <http://www.gnu.org/licenses/>.
*/

const { getWebPackConfig } = require('../../webpack.base.config');

module.exports = getWebPackConfig(__dirname, 'web3.min.js', 'Web3');
86 changes: 86 additions & 0 deletions webpack.base.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/*
This file is part of web3.js.

web3.js is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

web3.js is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with web3.js. If not, see <http://www.gnu.org/licenses/>.
*/

const webpack = require('webpack');
const path = require('path');

/**
* Shared webpack configuration for all packages
*/
function getWebPackConfig(packagePath, filename, library) {
return {
mode: 'production',
entry: path.resolve(packagePath, 'src/index.ts'),
output: {
path: path.resolve(packagePath, 'dist'),
filename: filename,
library: library,
libraryExport: 'default',
libraryTarget: 'umd',
globalObject: 'this',
},

module: {
rules: [
{
test: /\.ts$/,
loader: 'ts-loader',
exclude: ['/node_modules/', '/test/'],
},
],
},
resolve: {
extensions: ['.ts', '.js'],
fallback: {
child_process: false,
fs: false,
net: false,
path: false,
os: false,
util: require.resolve('util'),
http: require.resolve('http-browserify'),
https: require.resolve('https-browserify'),
crypto: require.resolve('crypto-browserify'),
stream: require.resolve('readable-stream'),
},
alias: {
// To avoid blotting up the `bn.js` library all over the packages
// use single library instance.
'bn.js': path.resolve(__dirname, 'node_modules/bn.js'),
},
},
devtool: 'source-map',
plugins: [
new webpack.IgnorePlugin({
checkResource(resource) {
// "@ethereumjs/common/genesisStates" consists ~800KB static files which are no more needed
return /(.*\/genesisStates\/.*\.json)/.test(resource);
},
}),
new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer'],
}),
new webpack.ProvidePlugin({
process: 'process/browser',
}),
],
};
}

module.exports = {
getWebPackConfig,
};
68 changes: 0 additions & 68 deletions webpackprod.config.js

This file was deleted.