Merge pull request #311 from status-im/minify-2

This commit is contained in:
Franck Royer 2021-10-12 13:38:13 +11:00 committed by GitHub
commit 6c18eafeac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 1523 additions and 36 deletions

View File

@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added ### Added
- If the `callback` function passed to`WakuStore.queryHistory` returns `true`, then no further pages are retrieved from the store. - If the `callback` function passed to`WakuStore.queryHistory` returns `true`, then no further pages are retrieved from the store.
- Use webpack to build UMD bundle of the library.
### Changed ### Changed
- **Breaking**: Renamed `WakuStore.QueryOptions`'s `direction` to `pageDirection` (and its type) as it only affects the page ordering, - **Breaking**: Renamed `WakuStore.QueryOptions`'s `direction` to `pageDirection` (and its type) as it only affects the page ordering,

View File

@ -0,0 +1,3 @@
# Remove ReactJS warning about webpack
# because this is not a monorepo, ReactJS projects are examples
SKIP_PREFLIGHT_CHECK=true

3
examples/eth-pm/.env Normal file
View File

@ -0,0 +1,3 @@
# Remove ReactJS warning about webpack
# because this is not a monorepo, ReactJS projects are examples
SKIP_PREFLIGHT_CHECK=true

View File

@ -0,0 +1,3 @@
# Remove ReactJS warning about webpack
# because this is not a monorepo, ReactJS projects are examples
SKIP_PREFLIGHT_CHECK=true

View File

@ -0,0 +1,3 @@
# Remove ReactJS warning about webpack
# because this is not a monorepo, ReactJS projects are examples
SKIP_PREFLIGHT_CHECK=true

3
examples/web-chat/.env Normal file
View File

@ -0,0 +1,3 @@
# Remove ReactJS warning about webpack
# because this is not a monorepo, ReactJS projects are examples
SKIP_PREFLIGHT_CHECK=true

1341
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -4,7 +4,11 @@
"description": "TypeScript implementation of the Waku v2 protocol", "description": "TypeScript implementation of the Waku v2 protocol",
"main": "build/main/index.js", "main": "build/main/index.js",
"typings": "build/main/index.d.ts", "typings": "build/main/index.d.ts",
"module": "build/module/index.js", "module": "build/esm/index.js",
"exports": {
"require": "./build/main/index.js",
"import": "./build/esm/index.js"
},
"repository": "https://github.com/status-im/js-waku", "repository": "https://github.com/status-im/js-waku",
"license": "MIT OR Apache-2.0", "license": "MIT OR Apache-2.0",
"keywords": [ "keywords": [
@ -16,10 +20,14 @@
"dapps" "dapps"
], ],
"scripts": { "scripts": {
"build": "run-s build:*", "build": "run-s build:**",
"build:main": "tsc -p tsconfig.json", "build:main": "tsc -p tsconfig.json",
"build:module": "tsc -p tsconfig.module.json",
"build:dev": "tsc -p tsconfig.dev.json", "build:dev": "tsc -p tsconfig.dev.json",
"build:esm": "tsc --module es2015 --target es5 --outDir build/esm",
"build:umd": "webpack --config webpack.config.js",
"build:umd:min": "webpack --config webpack.config.min.js",
"build:umd:bundle": "webpack --config webpack.config.bundle.js",
"build:umd:min:bundle": "webpack --config webpack.config.min.bundle.js",
"fix": "run-s fix:*", "fix": "run-s fix:*",
"fix:prettier": "prettier \"src/**/*.ts\" \"./*.json\" \"*.conf.js\" --write", "fix:prettier": "prettier \"src/**/*.ts\" \"./*.json\" \"*.conf.js\" --write",
"fix:lint": "eslint src --ext .ts --fix", "fix:lint": "eslint src --ext .ts --fix",
@ -78,7 +86,10 @@
"@typescript-eslint/eslint-plugin": "^4.0.1", "@typescript-eslint/eslint-plugin": "^4.0.1",
"@typescript-eslint/parser": "^4.0.1", "@typescript-eslint/parser": "^4.0.1",
"app-root-path": "^3.0.0", "app-root-path": "^3.0.0",
"assert": "^2.0.0",
"buffer": "^6.0.3",
"chai": "^4.3.4", "chai": "^4.3.4",
"crypto-browserify": "^3.12.0",
"cspell": "^4.1.0", "cspell": "^4.1.0",
"eslint": "^7.8.0", "eslint": "^7.8.0",
"eslint-config-prettier": "^6.11.0", "eslint-config-prettier": "^6.11.0",
@ -97,17 +108,23 @@
"nyc": "^15.1.0", "nyc": "^15.1.0",
"p-timeout": "^4.1.0", "p-timeout": "^4.1.0",
"prettier": "^2.1.1", "prettier": "^2.1.1",
"process": "^0.11.10",
"puppeteer": "^10.1.0", "puppeteer": "^10.1.0",
"stream-browserify": "^3.0.0",
"tail": "^2.2.0", "tail": "^2.2.0",
"ts-loader": "^9.2.6",
"ts-node": "^9.1.1", "ts-node": "^9.1.1",
"ts-proto": "^1.82.5", "ts-proto": "^1.82.5",
"typedoc": "^0.20.29", "typedoc": "^0.20.29",
"typedoc-plugin-no-inherit": "^1.3.0", "typedoc-plugin-no-inherit": "^1.3.0",
"typescript": "^4.0.2" "typescript": "^4.0.2",
"webpack": "^5.58.1",
"webpack-cli": "^4.9.0"
}, },
"files": [ "files": [
"build/main", "build/main",
"build/module", "build/esm",
"build/umd",
"!**/*.spec.*", "!**/*.spec.*",
"!**/*.json", "!**/*.json",
"CHANGELOG.md", "CHANGELOG.md",

View File

@ -1,9 +1,10 @@
{ {
"extends": "./tsconfig", "extends": "./tsconfig",
"compilerOptions": { "compilerOptions": {
"target": "esnext", "module": "UMD",
"outDir": "build/module", "target": "es6",
"module": "esnext" "removeComments": true,
"outFile": "build/min.js"
}, },
"exclude": ["node_modules/**", "src/**/*.spec.ts", "src/test_utils"] "exclude": ["node_modules/**", "src/**/*.spec.ts", "src/test_utils"]
} }

39
webpack.config.bundle.js Normal file
View File

@ -0,0 +1,39 @@
const webpack = require('webpack');
const path = require('path');
module.exports = {
mode: 'development',
entry: {
"js-waku": './src/index.ts'
},
devtool: 'inline-source-map',
module: {
rules: [{
test: /\.ts$/,
use: 'ts-loader',
exclude: /node_modules/
}]
},
plugins: [
new webpack.ProvidePlugin({
process: 'process/browser.js',
Buffer: ['buffer', 'Buffer'],
})
],
resolve: {
extensions: ['.ts', '.js'],
fallback: {
buffer: require.resolve('buffer/'),
crypto: require.resolve('crypto-browserify'),
stream: require.resolve('stream-browserify'),
assert: require.resolve('assert'),
},
},
output: {
filename: '[name].bundle.js',
path: path.resolve(__dirname, 'build/umd'),
library: 'jswaku',
libraryTarget: 'umd',
globalObject: 'this',
}
};

45
webpack.config.js Normal file
View File

@ -0,0 +1,45 @@
const webpack = require('webpack');
const path = require('path');
module.exports = {
mode: 'development',
entry: {
"js-waku": './src/index.ts'
},
devtool: 'inline-source-map',
module: {
rules: [{
test: /\.ts$/,
use: 'ts-loader',
exclude: /node_modules/
}]
},
plugins: [
new webpack.ProvidePlugin({
process: 'process/browser.js',
Buffer: ['buffer', 'Buffer'],
})
],
resolve: {
extensions: ['.ts', '.js'],
fallback: {
buffer: require.resolve('buffer/'),
crypto: require.resolve('crypto-browserify'),
stream: require.resolve('stream-browserify'),
assert: require.resolve('assert'),
},
},
output: {
filename: '[name].js',
path: path.resolve(__dirname, 'build/umd'),
library: 'jswaku',
libraryTarget: 'umd',
globalObject: 'this',
},
optimization: {
splitChunks: {
name: 'vendors',
chunks: 'all',
}
}
};

View File

@ -0,0 +1,39 @@
const webpack = require('webpack');
const path = require('path');
module.exports = {
mode: 'production',
entry: {
"js-waku": './src/index.ts'
},
devtool: 'inline-source-map',
module: {
rules: [{
test: /\.ts$/,
use: 'ts-loader',
exclude: /node_modules/
}]
},
plugins: [
new webpack.ProvidePlugin({
process: 'process/browser.js',
Buffer: ['buffer', 'Buffer'],
})
],
resolve: {
extensions: ['.ts', '.js'],
fallback: {
buffer: require.resolve('buffer/'),
crypto: require.resolve('crypto-browserify'),
stream: require.resolve('stream-browserify'),
assert: require.resolve('assert'),
},
},
output: {
filename: '[name].min.bundle.js',
path: path.resolve(__dirname, 'build/umd'),
library: 'jswaku',
libraryTarget: 'umd',
globalObject: 'this',
}
};

45
webpack.config.min.js vendored Normal file
View File

@ -0,0 +1,45 @@
const webpack = require('webpack');
const path = require('path');
module.exports = {
mode: 'production',
entry: {
"js-waku": './src/index.ts'
},
devtool: 'inline-source-map',
module: {
rules: [{
test: /\.ts$/,
use: 'ts-loader',
exclude: /node_modules/
}]
},
plugins: [
new webpack.ProvidePlugin({
process: 'process/browser.js',
Buffer: ['buffer', 'Buffer'],
})
],
resolve: {
extensions: ['.ts', '.js'],
fallback: {
buffer: require.resolve('buffer/'),
crypto: require.resolve('crypto-browserify'),
stream: require.resolve('stream-browserify'),
assert: require.resolve('assert'),
},
},
output: {
filename: '[name].min.js',
path: path.resolve(__dirname, 'build/umd'),
library: 'jswaku',
libraryTarget: 'umd',
globalObject: 'this',
},
optimization: {
splitChunks: {
name: 'vendors',
chunks: 'all',
}
}
};