Adjust esm -> cjs imports (4.0.2) (#185)
* Adjust esm -> cjs impors * cleanups * CHANGELOG * Apply suggestions from code review * Apply suggestions from code review * Apply suggestions from code review * Update packages/wasm-crypto-wasm/src/empty.ts * Apply suggestions from code review * Update packages/wasm-crypto-wasm/src/cjs/bytes.d.ts
This commit is contained in:
@@ -1,5 +1,12 @@
|
||||
# CHANGELOG
|
||||
|
||||
## 4.0.2 Mar 5, 2021
|
||||
|
||||
Changes:
|
||||
|
||||
- Add import indirection for both CJS & ESM (where generated source file is commonjs)
|
||||
|
||||
|
||||
## 4.0.1 Mar 4, 2021
|
||||
|
||||
**Important** In the 4.0 version the default package type has been changed to ESM modules by default. This should not affect usage, however since the output formats changed, a new major version is required.
|
||||
|
||||
+1
-1
@@ -28,5 +28,5 @@
|
||||
"fflate": "^0.6.7",
|
||||
"override-require": "^1.1.1"
|
||||
},
|
||||
"version": "4.0.1"
|
||||
"version": "4.0.2"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/wasm-crypto-asmjs",
|
||||
"version": "4.0.1",
|
||||
"version": "4.0.2",
|
||||
"type": "module",
|
||||
"description": "Asm.js content for wasm-crypto",
|
||||
"browser": "empty.js",
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
// Copyright 2019-2021 @polkadot/wasm-crypto-asmjs authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export declare const asmJsInit: null;
|
||||
@@ -0,0 +1,6 @@
|
||||
// Copyright 2019-2021 @polkadot/wasm-crypto-asmjs authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
const asmJsInit = null;
|
||||
|
||||
exports.asmJsInit = asmJsInit;
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"type": "commonjs"
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
// Copyright 2019-2021 @polkadot/wasm-crypto-asmjs authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export const asmJsInit = null;
|
||||
import { asmJsInit as _asmJsInit } from './cjs/data.js';
|
||||
|
||||
export const asmJsInit = _asmJsInit;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/wasm-crypto-wasm",
|
||||
"version": "4.0.1",
|
||||
"version": "4.0.2",
|
||||
"type": "module",
|
||||
"description": "Wasm content for wasm-crypto",
|
||||
"browser": "data.js",
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
// Copyright 2019-2021 @polkadot/wasm-crypto-wasm authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export const bytes = '';
|
||||
import { bytes as _bytes, sizeCompressed as _sizeCompressed, sizeUncompressed as _sizeUncompressed } from './cjs/bytes';
|
||||
|
||||
export const sizeCompressed = 0;
|
||||
export const bytes = _bytes;
|
||||
|
||||
export const sizeUncompressed = 0;
|
||||
export const sizeCompressed = _sizeCompressed;
|
||||
|
||||
export const sizeUncompressed = _sizeUncompressed;
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
// Copyright 2019-2021 @polkadot/wasm-crypto-wasm authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export declare const bytes = '';
|
||||
export declare const sizeCompressed = 0;
|
||||
export declare const sizeUncompressed = 0;
|
||||
@@ -0,0 +1,8 @@
|
||||
// Copyright 2019-2021 @polkadot/wasm-crypto-wasm authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
exports.bytes = '';
|
||||
|
||||
exports.sizeCompressed = 0;
|
||||
|
||||
exports.sizeUncompressed = 0;
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"type": "commonjs"
|
||||
}
|
||||
@@ -1,4 +1,8 @@
|
||||
// Copyright 2019-2021 @polkadot/wasm-crypto-wasm authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export const wasmBytes = null;
|
||||
export const bytes = null;
|
||||
|
||||
export const sizeCompressed = 0;
|
||||
|
||||
export const sizeUncompressed = 0;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/wasm-crypto",
|
||||
"version": "4.0.1",
|
||||
"version": "4.0.2",
|
||||
"type": "module",
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
"main": "index.js",
|
||||
@@ -10,8 +10,8 @@
|
||||
],
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.13.9",
|
||||
"@polkadot/wasm-crypto-asmjs": "^4.0.1",
|
||||
"@polkadot/wasm-crypto-wasm": "^4.0.1"
|
||||
"@polkadot/wasm-crypto-asmjs": "^4.0.2",
|
||||
"@polkadot/wasm-crypto-wasm": "^4.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/util": "^6.0.1-6",
|
||||
|
||||
@@ -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.cjs
|
||||
ASM=wasm-crypto-asmjs/build/cjs/data.js
|
||||
|
||||
# build new via wasm-pack
|
||||
echo "*** Building Rust sources"
|
||||
@@ -44,5 +44,5 @@ sed -i -e 's/var retasmFunc = /const asmJsInit = (wbg) => /' $ASM
|
||||
echo "module.exports = { asmJsInit };" >> $ASM
|
||||
|
||||
# cleanups
|
||||
rm -rf wasm-crypto-asmjs/build/*-e
|
||||
rm -rf wasm-crypto-wasm/build/*-e
|
||||
rm -rf wasm-crypto-asmjs/build/cjs/*-e
|
||||
rm -rf wasm-crypto-wasm/build/cjs/*-e
|
||||
|
||||
@@ -5,7 +5,7 @@ const fflate = require('fflate/node');
|
||||
const fs = require('fs');
|
||||
const { formatNumber } = require('@polkadot/util');
|
||||
|
||||
const A_NAME = 'wasm-crypto-asmjs';
|
||||
// const A_NAME = 'wasm-crypto-asmjs';
|
||||
const W_NAME = 'wasm-crypto-wasm';
|
||||
|
||||
function hdr (package) {
|
||||
@@ -25,17 +25,17 @@ function getWasmBuffer () {
|
||||
return { compressed, sizeUncompressed: data.length };
|
||||
}
|
||||
|
||||
fs.writeFileSync(`./${A_NAME}/build/data.js`, `${hdr(A_NAME)}
|
||||
export { asmJsInit } from './data.cjs';
|
||||
`);
|
||||
// fs.writeFileSync(`./${A_NAME}/build/data.js`, `${hdr(A_NAME)}
|
||||
// export { asmJsInit } from './data.cjs';
|
||||
// `);
|
||||
|
||||
fs.writeFileSync(`./${W_NAME}/build/bytes.js`, `${hdr(W_NAME)}
|
||||
export { bytes, sizeCompressed, sizeUncompressed } from './bytes.cjs';
|
||||
`);
|
||||
// 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.cjs`, `${hdr(W_NAME)}
|
||||
fs.writeFileSync(`./${W_NAME}/build/cjs/bytes.js`, `${hdr(W_NAME)}
|
||||
const sizeCompressed = ${compressed.length};
|
||||
const sizeUncompressed = ${sizeUncompressed};
|
||||
const bytes = '${compressed.toString('base64')}';
|
||||
|
||||
@@ -1878,7 +1878,7 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@polkadot/wasm-crypto-asmjs@^4.0.1, @polkadot/wasm-crypto-asmjs@workspace:packages/wasm-crypto-asmjs":
|
||||
"@polkadot/wasm-crypto-asmjs@^4.0.2, @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:
|
||||
@@ -1886,7 +1886,7 @@ __metadata:
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@polkadot/wasm-crypto-wasm@^4.0.1, @polkadot/wasm-crypto-wasm@workspace:packages/wasm-crypto-wasm":
|
||||
"@polkadot/wasm-crypto-wasm@^4.0.2, @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:
|
||||
@@ -1900,8 +1900,8 @@ __metadata:
|
||||
dependencies:
|
||||
"@babel/runtime": ^7.13.9
|
||||
"@polkadot/util": ^6.0.1-6
|
||||
"@polkadot/wasm-crypto-asmjs": ^4.0.1
|
||||
"@polkadot/wasm-crypto-wasm": ^4.0.1
|
||||
"@polkadot/wasm-crypto-asmjs": ^4.0.2
|
||||
"@polkadot/wasm-crypto-wasm": ^4.0.2
|
||||
"@polkadot/x-randomvalues": ^6.0.1-6
|
||||
peerDependencies:
|
||||
"@polkadot/util": "*"
|
||||
|
||||
Reference in New Issue
Block a user