Skip to content

Entry point and bundling changes #368

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 4 additions & 1 deletion .github/workflows/test-bundle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,12 @@ jobs:
with:
node-version: 18.x

- name: Install deps & build
- name: Install deps
run: yarn

- name: Build
run: yarn build

- name: Create tarball for importing in bundle checks
run: yarn pack --filename sdk-bundle-tests.tgz

Expand Down
20 changes: 20 additions & 0 deletions clean-package.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"replace": {
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "./dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"require": "./dist/index.js",
"import": "./dist/index.mjs"
},
"./umd": {
"types": "./dist/index.d.ts",
"default": "./dist/index.umd.js"
},
"./package.json": "./package.json"
}
},
"remove": ["clean-package", "peerDependencies"]
}
48 changes: 18 additions & 30 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,11 @@
"description": "⚒️An SDK for building applications on top of Vocdoni API",
"repository": "https://github.com/vocdoni/vocdoni-sdk.git",
"license": "AGPL-3.0-or-later",
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "./dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"require": "./dist/index.js",
"import": "./dist/index.mjs"
},
"./umd": {
"types": "./dist/index.d.ts",
"default": "./dist/index.umd.js"
},
"./package.json": "./package.json"
},
"main": "src/index.ts",
"output": "dist/index",
"files": [
"dist",
"src",
"package.json"
],
"engines": {
Expand Down Expand Up @@ -55,7 +43,8 @@
"test:census3:integration": "jest test/census3/integration",
"lint": "eslint src test --ext .js,.jsx,.ts,.tsx",
"lintfix": "yarn lint --fix",
"prepare": "yarn build",
"prepack": "clean-package",
"postpack": "mv -fv package.json.backup package.json",
"size": "size-limit",
"watch": "yarn build --watch"
},
Expand Down Expand Up @@ -89,31 +78,28 @@
}
],
"devDependencies": {
"@rollup/plugin-commonjs": "^24.0.0",
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-json": "^6.0.0",
"@rollup/plugin-node-resolve": "^15.0.1",
"@types/jest": "^29.2.2",
"@typescript-eslint/eslint-plugin": "^5.42.1",
"@typescript-eslint/parser": "^5.42.1",
"blakejs": "^1.2.1",
"blindsecp256k1": "^0.0.9",
"buffer": "^6.0.3",
"circomlibjs": "^0.1.7",
"esbuild": "^0.17.10",
"clean-package": "^2.2.0",
"esbuild": "^0.20.2",
"eslint": "^8.27.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.2.1",
"ffjavascript": "0.2.59",
"husky": "^8.0.2",
"jest": "^29.3.0",
"prettier": "^2.7.1",
"rimraf": "^3.0.2",
"rollup": "^3.22.0",
"rollup-plugin-dts": "^5.1.1",
"rollup-plugin-esbuild": "^5.0.0",
"rollup-plugin-polyfill-node": "^0.12.0",
"rollup": "^4.13.2",
"rollup-plugin-dts": "^6.1.0",
"rollup-plugin-esbuild": "^6.1.1",
"rollup-plugin-polyfill-node": "^0.13.0",
"size-limit": "^8.1.0",
"snarkjs": "vocdoni/snarkjs#v0.7.0-groth16browser",
"ts-jest": "^29.0.3",
"tslib": "^2.4.0",
"typescript": "^4.8.4"
Expand All @@ -130,20 +116,22 @@
"@ethersproject/units": "^5.7.0",
"@ethersproject/wallet": "^5.7.0",
"@size-limit/file": "^8.2.4",
"@vocdoni/proto": "1.15.8",
"@vocdoni/proto": "1.15.9",
"axios": "0.28.1",
"blindsecp256k1": "^0.0.9",
"blake2b": "^2.1.4",
"buffer": "^6.0.3",
"circomlibjs": "vocdoni/circomlibjs#f/browser",
"iso-language-codes": "^1.1.0",
"js-sha256": "^0.10.1",
"readable-stream": "^4.4.2",
"snarkjs": "vocdoni/snarkjs#f/browser",
"tiny-invariant": "^1.3.1",
"tweetnacl": "^1.0.3",
"wasmbuilder": "^0.0.16",
"wasmcurves": "0.2.1",
"web-worker": "^1.2.0",
"yup": "^0.32.11"
},
"resolutions": {
"ffjavascript": "0.2.59"
}
"clean-package": "./clean-package.config.json"
}
38 changes: 8 additions & 30 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -1,41 +1,19 @@
import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
import resolve from '@rollup/plugin-node-resolve';
import dts from 'rollup-plugin-dts';
import esbuild from 'rollup-plugin-esbuild';
import nodePolyfills from 'rollup-plugin-polyfill-node';
import { default as pkg } from './package.json' assert { type: 'json' };
import json from '@rollup/plugin-json';

// take name from package "main" defined file
const name = pkg.main.replace(/\.js$/, '');
const embeded = [
'blakejs/blake2b',
'blindsecp256k1',
'circomlibjs',
'blake-hash',
'ffjavascript',
'crypto',
'os',
'ethers',
'assert',
'snarkjs',
'circom_runtime',
'@iden3/binfileutils',
];
// take name from package "output" defined field
const name = pkg.output;

// generics
const bundle = (config) => ({
...config,
input: 'src/index.ts',
external: (id) => {
if (embeded.includes(id)) {
return false;
}
if (process.platform === 'win32') {
return !id.includes('src');
}
return !id.startsWith('src') && !/^[./]/.test(id);
},
input: pkg.main,
external: [...Object.keys(pkg.dependencies), '@vocdoni/proto/vochain'],
});

export default [
Expand All @@ -59,20 +37,20 @@ export default [
{
file: `${name}.js`,
format: 'cjs',
sourcemap: true,
sourcemap: false,
},
// es modules
{
file: `${name}.mjs`,
format: 'es',
sourcemap: true,
sourcemap: false,
},
// umd
{
name: 'VocdoniSDK',
file: `${name}.umd.js`,
format: 'umd',
sourcemap: true,
sourcemap: false,
},
],
}),
Expand Down
Loading