-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate to rollup. FIx sha256 browser dependency. Remove esbuild. Add…
… esm browser build
- Loading branch information
1 parent
89623bb
commit 06f9ca5
Showing
13 changed files
with
2,582 additions
and
1,278 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import commonJS from '@rollup/plugin-commonjs'; | ||
import { nodeResolve } from '@rollup/plugin-node-resolve'; | ||
import terser from '@rollup/plugin-terser'; | ||
import typescript from '@rollup/plugin-typescript'; | ||
import tsConfig from '../tsconfig.json' assert { type: 'json' }; | ||
import packageJson from '../package.json' assert { type: 'json' }; | ||
|
||
const external = Object.keys(packageJson.peerDependencies || {}); | ||
|
||
const config = { | ||
input: 'src/index.ts', | ||
external, | ||
output: [ | ||
{ | ||
format: 'es', | ||
file: packageJson.exports['.'].browser, | ||
sourcemap: true | ||
} | ||
], | ||
treeshake: { | ||
preset: 'smallest' | ||
} | ||
}; | ||
|
||
export default [ | ||
// esm browser | ||
{ | ||
...config, | ||
plugins: [ | ||
typescript({ | ||
compilerOptions: { | ||
...tsConfig.compilerOptions | ||
} | ||
}), | ||
commonJS(), | ||
nodeResolve({ | ||
browser: true | ||
}), | ||
terser() | ||
] | ||
}, | ||
// umd browser | ||
{ | ||
...config, | ||
external: [], | ||
plugins: [ | ||
typescript({ | ||
compilerOptions: { | ||
...tsConfig.compilerOptions | ||
} | ||
}), | ||
commonJS(), | ||
nodeResolve({ | ||
browser: true | ||
}), | ||
terser() | ||
], | ||
output: [ | ||
{ | ||
format: 'iife', | ||
file: packageJson.exports['.'].umd, | ||
name: 'Iden3Core', | ||
sourcemap: true | ||
} | ||
] | ||
} | ||
]; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,36 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" | ||
content="IE=edge"> | ||
<meta name="viewport" | ||
content="width=device-width, initial-scale=1.0"> | ||
<script src="./dist/umd/index.js"></script> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<script src="./dist/browser/umd/index.js"></script> | ||
<title>Test</title> | ||
</head> | ||
<script type="importmap"> | ||
{ | ||
"imports": { | ||
"@iden3/js-crypto": "./node_modules/@iden3/js-crypto/dist/browser/esm/index.js" | ||
} | ||
} | ||
</script> | ||
</head> | ||
|
||
<body> | ||
Test UMD script work | ||
</body> | ||
<script> | ||
const claim = Iden3Core.Claim.newClaim(new Iden3Core.SchemaHash(), Iden3Core.ClaimOptions.withFlagUpdatable(true)); | ||
const { index, value } = claim.rawSlots(); | ||
console.log(index, value, claim); | ||
console.log(claim.hIndex()); | ||
console.assert(claim.value.length === 4); | ||
</script> | ||
<body> | ||
Test UMD/ESM script work | ||
|
||
<script type="module"> | ||
import * as esm from './dist/browser/esm/index.js'; | ||
function test(module) { | ||
const { Claim, SchemaHash, ClaimOptions, BytesHelper } = module; | ||
const claim = Claim.newClaim(new SchemaHash(), ClaimOptions.withFlagUpdatable(true)); | ||
const { index, value } = claim.rawSlots(); | ||
console.log(index, value, claim); | ||
console.log(claim.hIndex()); | ||
console.assert(claim.value.length === 4); | ||
console.log(BytesHelper.hashBytes('test')); | ||
} | ||
test(esm); | ||
test(Iden3Core); | ||
</script> | ||
</body> | ||
</html> |
Oops, something went wrong.