Default build to type: module (#180)

* Defaul build to type: module

* Add packageInfo

* 4.0

* pre

* Adjust tests

* jest js, rest cjs

* Bump dev
This commit is contained in:
Jaco Greeff
2021-03-02 17:27:41 +01:00
committed by GitHub
parent 854d209be8
commit 0f6e143a6f
22 changed files with 56 additions and 79 deletions
+3 -3
View File
@@ -19,14 +19,14 @@
"test": "yarn test:wasm:rust",
"test:wasm:js": "yarn test:wasm:js:jest && yarn test:wasm:js:node",
"test:wasm:js:jest": "polkadot-dev-run-test ./test/jest.spec.js",
"test:wasm:js:node": "cd packages/wasm-crypto && node ./test/wasm.js && node ./test/asm.js",
"test:wasm:js:node": "cd packages/wasm-crypto && node ./test/wasm.cjs && node ./test/asm.cjs",
"test:wasm:rust": "cd packages/wasm-crypto && RUST_BACKTRACE=full cargo test --release -- --nocapture"
},
"devDependencies": {
"@babel/core": "^7.13.8",
"@polkadot/dev": "^0.61.31",
"@polkadot/dev": "^0.62.1",
"fflate": "^0.6.7",
"override-require": "^1.1.1"
},
"version": "3.2.5-0"
"version": "4.0.0-1"
}
+3 -2
View File
@@ -1,6 +1,7 @@
{
"name": "@polkadot/wasm-crypto-asmjs",
"version": "3.2.5-0",
"version": "4.0.0-1",
"type": "module",
"description": "Asm.js content for wasm-crypto",
"browser": "empty.js",
"main": "empty.js",
@@ -13,6 +14,6 @@
"bugs": "https://github.com/polkadot-js/wasm/issues",
"homepage": "https://github.com/polkadot-js/wasm",
"dependencies": {
"@babel/runtime": "^7.13.8"
"@babel/runtime": "^7.13.9"
}
}
@@ -1,6 +1,6 @@
// Copyright 2017-2021 @polkadot/dev authors & contributors
// Copyright 2017-2021 @polkadot/wasm-crypto-asmjs authors & contributors
// SPDX-License-Identifier: Apache-2.0
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/wasm-crypto-asmjs', version: '3.2.5-0' };
export const packageInfo = { name: '@polkadot/wasm-crypto-asmjs', version: '4.0.0-1' };
+3 -2
View File
@@ -1,6 +1,7 @@
{
"name": "@polkadot/wasm-crypto-wasm",
"version": "3.2.5-0",
"version": "4.0.0-1",
"type": "module",
"description": "Wasm content for wasm-crypto",
"browser": "data.js",
"main": "data.js",
@@ -13,6 +14,6 @@
"bugs": "https://github.com/polkadot-js/wasm/issues",
"homepage": "https://github.com/polkadot-js/wasm",
"dependencies": {
"@babel/runtime": "^7.13.8"
"@babel/runtime": "^7.13.9"
}
}
+2 -2
View File
@@ -1,6 +1,6 @@
// Copyright 2017-2021 @polkadot/dev authors & contributors
// Copyright 2017-2021 @polkadot/wasm-crypto-wasm authors & contributors
// SPDX-License-Identifier: Apache-2.0
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/wasm-crypto-wasm', version: '3.2.5-0' };
export const packageInfo = { name: '@polkadot/wasm-crypto-wasm', version: '4.0.0-1' };
+6 -5
View File
@@ -1,16 +1,17 @@
{
"name": "@polkadot/wasm-crypto",
"version": "3.2.5-0",
"version": "4.0.0-1",
"type": "module",
"author": "Jaco Greeff <jacogr@gmail.com>",
"main": "index.js",
"sideEffects": [
"./detectPackage.js",
"./detectPackage.mjs"
"./detectPackage.cjs"
],
"dependencies": {
"@babel/runtime": "^7.13.8",
"@polkadot/wasm-crypto-asmjs": "^3.2.5-0",
"@polkadot/wasm-crypto-wasm": "^3.2.5-0"
"@babel/runtime": "^7.13.9",
"@polkadot/wasm-crypto-asmjs": "^4.0.0-1",
"@polkadot/wasm-crypto-wasm": "^4.0.0-1"
},
"devDependencies": {
"@polkadot/util": "^5.9.2",
-15
View File
@@ -1,21 +1,6 @@
// Copyright 2017-2021 @polkadot/wasm-crypto authors & contributors
// SPDX-License-Identifier: Apache-2.0
// For esm, this should be import.meta.url or to get the same behavior as __dirname, we can use
//
// new URL(import.meta.url).pathname)
//
// The issue is the WP4 has "some" issues with import.meta.url. So because of bundlers, we can't have
// nice things... In this case it is even worse since import.meta.url won't even make it compile, so
// there is a complete dead end with usage thereof
//
// When that is fixed, a solution is to have both .js & .mjs files, with the following content -
//
// cjs: util.detectPackage(packageInfo, () => __dirname);
// esm: detectPackage(packageInfo, () => import.meta.url);
//
// With the above we additionally need a .d.ts to just export the packageInfo
import { detectPackage } from '@polkadot/util';
import { packageInfo } from './packageInfo';
+2 -2
View File
@@ -1,6 +1,6 @@
// Copyright 2017-2021 @polkadot/dev authors & contributors
// Copyright 2017-2021 @polkadot/wasm-crypto authors & contributors
// SPDX-License-Identifier: Apache-2.0
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/wasm-crypto', version: '3.2.5-0' };
export const packageInfo = { name: '@polkadot/wasm-crypto', version: '4.0.0-1' };
@@ -7,6 +7,6 @@ require('override-require')(
request.endsWith('@polkadot/wasm-crypto-wasm'),
(request) =>
request.endsWith('@polkadot/wasm-crypto-asmjs')
? require('../../wasm-crypto-asmjs/build/data')
: require('../../wasm-crypto-wasm/build/empty')
? require('../../wasm-crypto-asmjs/build/data.cjs')
: require('../../wasm-crypto-wasm/build/empty.cjs')
);
@@ -1,12 +1,12 @@
// Copyright 2019-2021 @polkadot/wasm-crypto authors & contributors
// SPDX-License-Identifier: Apache-2.0
const wasm = require('../../build/index');
const bip39 = require('./bip39');
const ed25519 = require('./ed25519');
const hashing = require('./hashing');
const sr25519 = require('./sr25519');
const vrf = require('./vrf');
const wasm = require('../../build/index.cjs');
const bip39 = require('./bip39.cjs');
const ed25519 = require('./ed25519.cjs');
const hashing = require('./hashing.cjs');
const sr25519 = require('./sr25519.cjs');
const vrf = require('./vrf.cjs');
const tests = {
...bip39,
@@ -3,8 +3,8 @@
global.WebAssembly = null;
require('./alias-imports');
require('./alias-imports.cjs');
const { runUnassisted } = require('./all');
const { runUnassisted } = require('./all/index.cjs');
runUnassisted();
+1 -1
View File
@@ -7,7 +7,7 @@
// override-require in jest.config.js
const { beforeAll, tests, wasm } = require('./all');
import { beforeAll, tests, wasm } from './all/index.cjs';
describe('wasm-crypto', () => {
beforeEach(async () => {
@@ -1,8 +1,8 @@
// Copyright 2019-2021 @polkadot/wasm-crypto authors & contributors
// SPDX-License-Identifier: Apache-2.0
require('./alias-imports');
require('./alias-imports.cjs');
const { runUnassisted } = require('./all');
const { runUnassisted } = require('./all/index.cjs');
runUnassisted();
+1 -1
View File
@@ -10,7 +10,7 @@ RUST_VER=nightly-2020-10-25
WSM=bytes/wasm_bg.wasm
OPT=bytes/wasm_opt.wasm
ASM=wasm-crypto-asmjs/build/data.js
ASM=wasm-crypto-asmjs/build/data.cjs
# build new via wasm-pack
echo "*** Building Rust sources"
-11
View File
@@ -26,11 +26,6 @@ unamestr=`uname`
rustup toolchain install $RUST_VER -c rust-src -t wasm32-unknown-unknown
cargo install xargo
# if ! [ -x "$(command -v wasm-pack)" ]; then
# echo "*** Installing wasm-pack"
# curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
# fi
if [[ "$unamestr" == 'Linux' ]]; then
echo "*** Detected Linux"
BINARYEN_ZIP=binaryen-$BINARYEN_VER-x86_64-linux
@@ -59,9 +54,3 @@ if [ ! -d "bindgen" ]; then
mv $BINDGEN_ZIP bindgen
ls -alR bindgen
fi
# if [ ! -d "wabt" ]; then
# echo "*** Downloading wabt"
# curl -L $WABT_REPO/releases/download/$WABT_VER/$WABT_ZIP.tar.gz | tar xz
# mv wabt-$WABT_VER wabt
# fi
+5 -5
View File
@@ -29,17 +29,17 @@ function getWasmBuffer (lib = 'fflate') {
return { compressed, sizeUncompressed: data.length };
}
fs.writeFileSync(`./${A_NAME}/build/data.mjs`, `${hdr(A_NAME)}
export { asmJsInit } from './data.js';
fs.writeFileSync(`./${A_NAME}/build/data.js`, `${hdr(A_NAME)}
export { asmJsInit } from './data.cjs';
`);
fs.writeFileSync(`./${W_NAME}/build/bytes.mjs`, `${hdr(W_NAME)}
export { bytes, sizeCompressed, sizeUncompressed } from './bytes.js';
fs.writeFileSync(`./${W_NAME}/build/bytes.js`, `${hdr(W_NAME)}
export { bytes, sizeCompressed, sizeUncompressed } from './bytes.cjs';
`);
const { compressed, sizeUncompressed } = getWasmBuffer();
fs.writeFileSync(`./${W_NAME}/build/bytes.js`, `${hdr(W_NAME)}
fs.writeFileSync(`./${W_NAME}/build/bytes.cjs`, `${hdr(W_NAME)}
const sizeCompressed = ${compressed.length};
const sizeUncompressed = ${sizeUncompressed};
const bytes = '${compressed.toString('base64')}';
+16 -16
View File
@@ -1295,12 +1295,12 @@ __metadata:
languageName: node
linkType: hard
"@babel/runtime@npm:^7.13.8, @babel/runtime@npm:^7.8.4":
version: 7.13.8
resolution: "@babel/runtime@npm:7.13.8"
"@babel/runtime@npm:^7.13.8, @babel/runtime@npm:^7.13.9, @babel/runtime@npm:^7.8.4":
version: 7.13.9
resolution: "@babel/runtime@npm:7.13.9"
dependencies:
regenerator-runtime: ^0.13.4
checksum: d8db125d3629c4000322e8264d7510640ac671136f416d1fcd4b74d26d7e703bf671820fab81a29a5ee0bd11e981de518666619398ec29b1ab5e155ab8131812
checksum: e6f79d20e10c2921520c499f3cf295a9ee5c137e73f77f77eedde9f9073bc3541c1fc7fa6c97b0613f4140303ac00d08506e9f090068d219c58781d2b62c662d
languageName: node
linkType: hard
@@ -1773,9 +1773,9 @@ __metadata:
languageName: node
linkType: hard
"@polkadot/dev@npm:^0.61.31":
version: 0.61.31
resolution: "@polkadot/dev@npm:0.61.31"
"@polkadot/dev@npm:^0.62.1":
version: 0.62.1
resolution: "@polkadot/dev@npm:0.62.1"
dependencies:
"@babel/cli": ^7.13.0
"@babel/core": ^7.13.8
@@ -1859,7 +1859,7 @@ __metadata:
polkadot-exec-tsc: scripts/polkadot-exec-tsc.cjs
polkadot-exec-typedoc: scripts/polkadot-exec-typedoc.cjs
polkadot-exec-webpack: scripts/polkadot-exec-webpack.cjs
checksum: 087b0f00c94d11f03e10731101a9c81c4034ca3d49d838fb602b95db611bdd9968006610c3b1abdf8977162ccce6e5edceff64636bfd69fae45a2c649f6c2257
checksum: e45a19d9c7768fa08e74eda4bbcfb0dfd0ad57a867a41768b0d165d3600f4981df4f72c265be2329815f8885f5f03c2818254a56e2c8f89e19cf410f22df252b
languageName: node
linkType: hard
@@ -1878,19 +1878,19 @@ __metadata:
languageName: node
linkType: hard
"@polkadot/wasm-crypto-asmjs@^3.2.5-0, @polkadot/wasm-crypto-asmjs@workspace:packages/wasm-crypto-asmjs":
"@polkadot/wasm-crypto-asmjs@^4.0.0-1, @polkadot/wasm-crypto-asmjs@workspace:packages/wasm-crypto-asmjs":
version: 0.0.0-use.local
resolution: "@polkadot/wasm-crypto-asmjs@workspace:packages/wasm-crypto-asmjs"
dependencies:
"@babel/runtime": ^7.13.8
"@babel/runtime": ^7.13.9
languageName: unknown
linkType: soft
"@polkadot/wasm-crypto-wasm@^3.2.5-0, @polkadot/wasm-crypto-wasm@workspace:packages/wasm-crypto-wasm":
"@polkadot/wasm-crypto-wasm@^4.0.0-1, @polkadot/wasm-crypto-wasm@workspace:packages/wasm-crypto-wasm":
version: 0.0.0-use.local
resolution: "@polkadot/wasm-crypto-wasm@workspace:packages/wasm-crypto-wasm"
dependencies:
"@babel/runtime": ^7.13.8
"@babel/runtime": ^7.13.9
languageName: unknown
linkType: soft
@@ -1898,10 +1898,10 @@ __metadata:
version: 0.0.0-use.local
resolution: "@polkadot/wasm-crypto@workspace:packages/wasm-crypto"
dependencies:
"@babel/runtime": ^7.13.8
"@babel/runtime": ^7.13.9
"@polkadot/util": ^5.9.2
"@polkadot/wasm-crypto-asmjs": ^3.2.5-0
"@polkadot/wasm-crypto-wasm": ^3.2.5-0
"@polkadot/wasm-crypto-asmjs": ^4.0.0-1
"@polkadot/wasm-crypto-wasm": ^4.0.0-1
"@polkadot/x-randomvalues": ^5.9.2
peerDependencies:
"@polkadot/util": "*"
@@ -8788,7 +8788,7 @@ fsevents@~2.1.2:
resolution: "root-workspace-0b6124@workspace:."
dependencies:
"@babel/core": ^7.13.8
"@polkadot/dev": ^0.61.31
"@polkadot/dev": ^0.62.1
fflate: ^0.6.7
override-require: ^1.1.1
languageName: unknown