feat: use rollup for bundling

This commit is contained in:
Yarmo Mackenbach 2023-07-08 08:36:57 +02:00
parent 0f7c444d3c
commit 535d35bd48
No known key found for this signature in database
GPG key ID: 3C57D093219103A3
12 changed files with 40901 additions and 50571 deletions

View file

@ -16,6 +16,7 @@ examples
package.json package.json
yarn.lock yarn.lock
rollup.config.js
\.editorconfig \.editorconfig
\.gitignore \.gitignore
\.licenseignore \.licenseignore

8957
dist/doip.core.js vendored Normal file

File diff suppressed because one or more lines are too long

20
dist/doip.core.min.js vendored Normal file

File diff suppressed because one or more lines are too long

28344
dist/doip.fetchers.js vendored Normal file

File diff suppressed because it is too large Load diff

1
dist/doip.fetchers.min.js vendored Normal file

File diff suppressed because one or more lines are too long

3237
dist/doip.fetchers.minimal.js vendored Normal file

File diff suppressed because it is too large Load diff

1
dist/doip.fetchers.minimal.min.js vendored Normal file

File diff suppressed because one or more lines are too long

49072
dist/doip.js vendored

File diff suppressed because one or more lines are too long

32
dist/doip.min.js vendored

File diff suppressed because one or more lines are too long

View file

@ -4,6 +4,20 @@
"description": "Decentralized Online Identity Proofs library in Node.js", "description": "Decentralized Online Identity Proofs library in Node.js",
"type": "module", "type": "module",
"main": "./src/index.js", "main": "./src/index.js",
"exports": {
".": {
"node": "./src/index.js",
"default": "./dist/doip.core.js"
},
"./fetchers": {
"node": "./src/fetcher/index.js",
"default": "./dist/doip.fetchers.js"
},
"./fetchers-minimal": {
"node": "./src/fetcher/index.minimal.js",
"default": "./dist/doip.fetchers.minimal.js"
}
},
"packageManager": "yarn@1.22.19", "packageManager": "yarn@1.22.19",
"dependencies": { "dependencies": {
"@openpgp/hkp-client": "^0.0.3", "@openpgp/hkp-client": "^0.0.3",
@ -13,7 +27,7 @@
"axios": "^0.25.0", "axios": "^0.25.0",
"browser-or-node": "^1.3.0", "browser-or-node": "^1.3.0",
"cors": "^2.8.5", "cors": "^2.8.5",
"dotenv": "^8.2.0", "dotenv": "^16.3.1",
"entities": "^4.4.0", "entities": "^4.4.0",
"express": "^4.17.1", "express": "^4.17.1",
"express-validator": "^6.10.0", "express-validator": "^6.10.0",
@ -28,8 +42,9 @@
"validator": "^13.9.0" "validator": "^13.9.0"
}, },
"devDependencies": { "devDependencies": {
"browserify": "^17.0.0", "@rollup/plugin-commonjs": "^25.0.2",
"browserify-shim": "^3.8.14", "@rollup/plugin-json": "^6.0.0",
"@rollup/plugin-node-resolve": "^15.1.0",
"chai": "^4.2.0", "chai": "^4.2.0",
"chai-as-promised": "^7.1.1", "chai-as-promised": "^7.1.1",
"chai-match-pattern": "^1.2.0", "chai-match-pattern": "^1.2.0",
@ -39,26 +54,28 @@
"eslint-plugin-import": "^2.27.5", "eslint-plugin-import": "^2.27.5",
"eslint-plugin-n": "^15.7.0", "eslint-plugin-n": "^15.7.0",
"eslint-plugin-promise": "^6.1.1", "eslint-plugin-promise": "^6.1.1",
"esmify": "^2.1.1",
"husky": "^7.0.0", "husky": "^7.0.0",
"jsdoc": "^3.6.6", "jsdoc": "^3.6.6",
"license-check-and-add": "^4.0.3", "license-check-and-add": "^4.0.3",
"lint-staged": "^11.0.0", "lint-staged": "^11.0.0",
"minify": "^9.1", "minify": "^9.1",
"mocha": "^9.2.0", "mocha": "^9.2.0",
"nodemon": "^2.0.19" "nodemon": "^2.0.19",
"rollup": "^3.26.2",
"rollup-plugin-polyfill-node": "^0.12.0",
"rollup-plugin-visualizer": "^5.9.2"
}, },
"scripts": { "scripts": {
"release": "yarn run test && yarn run release:bundle && yarn run release:minify", "release": "yarn run test && yarn run build",
"release:bundle": "./node_modules/.bin/browserify ./src/index.js --standalone doip -p esmify -x openpgp -x @xmpp/client -x @xmpp/debug -x irc-upd -o ./dist/doip.js", "build": "rm -rf ./dist/ && yarn run build:bundle && yarn run build:minify",
"release:minify": "./node_modules/.bin/minify ./dist/doip.js > ./dist/doip.min.js", "build:bundle": "rollup -c",
"license:check": "./node_modules/.bin/license-check-and-add check", "build:minify": "minify ./dist/doip.core.js > ./dist/doip.core.min.js && minify ./dist/doip.fetchers.js > ./dist/doip.fetchers.min.js && minify ./dist/doip.fetchers.minimal.js > ./dist/doip.fetchers.minimal.min.js",
"license:add": "./node_modules/.bin/license-check-and-add add", "license:check": "license-check-and-add check",
"license:remove": "./node_modules/.bin/license-check-and-add remove", "license:add": "license-check-and-add add",
"docs:lib": "./node_modules/.bin/jsdoc -c jsdoc-lib.json -r -d ./docs -P package.json", "license:remove": "license-check-and-add remove",
"docs:lib": "jsdoc -c jsdoc-lib.json -r -d ./docs -P package.json",
"lint": "eslint ./src", "lint": "eslint ./src",
"lint:fix": "eslint ./src --fix", "lint:fix": "eslint ./src --fix",
"mocha": "./node_modules/.bin/mocha",
"test": "yarn lint && yarn rome check ./src/* && yarn run license:check && yarn run mocha", "test": "yarn lint && yarn rome check ./src/* && yarn run license:check && yarn run mocha",
"prepare": "husky install" "prepare": "husky install"
}, },
@ -76,13 +93,5 @@
"identity" "identity"
], ],
"author": "Yarmo Mackenbach <yarmo@yarmo.eu> (https://yarmo.eu)", "author": "Yarmo Mackenbach <yarmo@yarmo.eu> (https://yarmo.eu)",
"license": "Apache-2.0", "license": "Apache-2.0"
"browserify": {
"transform": [
"browserify-shim"
]
},
"browserify-shim": {
"openpgp": "global:openpgp"
}
} }

73
rollup.config.js Normal file
View file

@ -0,0 +1,73 @@
import commonjs from '@rollup/plugin-commonjs'
import json from '@rollup/plugin-json'
import { nodeResolve } from '@rollup/plugin-node-resolve'
import nodePolyfills from 'rollup-plugin-polyfill-node'
import { fileURLToPath } from 'node:url'
const fetchersExternalId = fileURLToPath(
new URL(
'src/fetcher/index.js',
import.meta.url
)
)
export default [
{
input: 'src/index.js',
output: {
file: './dist/doip.core.js',
format: 'iife',
name: 'doip',
globals: {
'openpgp': 'openpgp',
[fetchersExternalId]: 'doipFetchers'
},
},
watch: {
include: './src/**'
},
external: ['openpgp', './fetcher/index.js'],
plugins: [
commonjs(),
json(),
nodeResolve({
browser: true
}),
nodePolyfills()
]
},
{
input: 'src/fetcher/index.js',
output: {
file: './dist/doip.fetchers.js',
format: 'iife',
name: 'doipFetchers'
},
external: [],
plugins: [
commonjs(),
json(),
nodeResolve({
browser: true
}),
nodePolyfills()
]
},
{
input: 'src/fetcher/index.minimal.js',
output: {
file: './dist/doip.fetchers.minimal.js',
format: 'iife',
name: 'doipFetchers'
},
external: [],
plugins: [
commonjs(),
json(),
nodeResolve({
browser: true
}),
nodePolyfills()
]
}
]

1681
yarn.lock

File diff suppressed because it is too large Load diff