Setup rollup, move files to dist/

This commit is contained in:
Franck Royer 2022-05-27 23:01:52 +10:00
parent 82aba32f9e
commit c4758a8737
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
8 changed files with 426 additions and 424 deletions

1
.gitignore vendored
View File

@ -2,6 +2,7 @@
.nyc_output
.angular
build
dist
node_modules
src/**.js
coverage

View File

@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Changed
- Published files moved from `build` to `dist/`.
## [0.24.0] - 2022-05-27
### Added

781
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -2,10 +2,10 @@
"name": "js-waku",
"version": "0.24.0",
"description": "TypeScript implementation of the Waku v2 protocol",
"types": "./build/esm/index.d.ts",
"types": "./dist/esm/index.d.ts",
"exports": {
"node": {
"import": "./build/esm/index.js"
"import": "./dist/esm/index.js"
}
},
"type": "module",
@ -21,12 +21,10 @@
],
"scripts": {
"prepare": "husky install",
"build": "rimraf ./build; run-p build:**",
"build": "rimraf ./dist; run-s build:**",
"build:esm": "tsc",
"build:umd": "webpack --config webpack.config.cjs",
"build:umd:min": "webpack --config webpack.config.min.cjs",
"build:umd:bundle": "webpack --config webpack.config.bundle.cjs",
"build:umd:min:bundle": "webpack --config webpack.config.min.bundle.cjs",
"build:umd": "rollup --config rollup.config.js -- dist/esm/index.js",
"build:umd:min": "terser --ecma 6 --compress --mangle -o dist/umd/index.min.js -- dist/umd/index.js && gzip -9 -c dist/umd/index.min.js > dist/umd/index.min.js.gz",
"size": "npm run build:esm && size-limit",
"fix": "run-s fix:*",
"fix:prettier": "prettier \"src/**/*.ts\" \"./*.json\" \"*.*js\" \".github/**/*.yml\" --write",
@ -90,6 +88,9 @@
},
"devDependencies": {
"@istanbuljs/nyc-config-typescript": "^1.0.1",
"@rollup/plugin-commonjs": "^22.0.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^13.3.0",
"@size-limit/preset-big-lib": "^7.0.8",
"@types/app-root-path": "^1.2.4",
"@types/chai": "^4.2.15",
@ -132,20 +133,21 @@
"process": "^0.11.10",
"protons": "^3.0.4",
"puppeteer": "^13.0.1",
"rollup": "^2.75.0",
"rollup-plugin-polyfill-node": "^0.9.0",
"size-limit": "^7.0.8",
"stream-browserify": "^3.0.0",
"tail": "^2.2.0",
"terser": "^5.13.1",
"ts-loader": "^9.2.6",
"ts-node": "^10.4.0",
"typedoc": "^0.22.10",
"typedoc-plugin-no-inherit": "^1.3.1",
"typescript": "^4.5.5",
"webpack": "^5.58.1",
"webpack-cli": "^4.9.0"
"typescript": "^4.5.5"
},
"files": [
"build/esm",
"build/umd",
"dist/esm",
"dist/umd",
"src/lib/**/*.ts",
"src/proto/**/*.ts",
"!**/*.spec.*",
@ -162,7 +164,7 @@
},
"size-limit": [
{
"path": "build/esm/index.js",
"path": "dist/esm/index.js",
"import": "{ Waku }",
"config": "./webpack.config.cjs"
}

21
rollup.config.js Normal file
View File

@ -0,0 +1,21 @@
import { nodeResolve } from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import json from "@rollup/plugin-json";
import nodePolyfills from "rollup-plugin-polyfill-node";
export default {
output: {
file: "dist/umd/index.js",
format: "umd",
name: "jswaku",
},
plugins: [
commonjs(),
json(),
nodePolyfills(),
nodeResolve({
browser: true,
preferBuiltins: false,
}),
],
};

View File

@ -1,8 +1,8 @@
{
"compilerOptions": {
"incremental": true,
"target": "es2015",
"outDir": "build/esm",
"target": "es2020",
"outDir": "dist/esm",
"rootDir": "src",
"moduleResolution": "node",
"module": "es2020",

View File

@ -1,9 +0,0 @@
{
"extends": "./tsconfig",
"compilerOptions": {
"module": "UMD",
"target": "es6",
"removeComments": true,
"outFile": "build/min.js"
}
}

View File

@ -10,7 +10,7 @@ module.exports = {
module: {
rules: [
{
test: /\.ts$/,
test: /\.(js|tsx?)$/,
use: "ts-loader",
exclude: /(node_modules)|(node\.spec\.ts)/,
},