Skip to content

Commit decfd70

Browse files
authored
Fix the 0.7 release (#152)
* Fix the 0.7 release Sets it back to the old release style. The thing produced by wasm-pack is a ES/nodenext module, but our shim still wraps it into a CJS module, so downstream consumers don't need to change anything. We lose our TS compile checking the validity of dependencies types (though our uses of them are still checked against their declarations). We do this on most (all?) of our other TS projects. * Fix tsconfig module type
1 parent 8c7b67f commit decfd70

File tree

4 files changed

+27
-14
lines changed

4 files changed

+27
-14
lines changed

Cargo.lock

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,32 @@ shell.cp("./recrypt_wasm_binding.d.ts", "./pkg");
4848

4949
//Compile our wasm-bindgen shim from TS to ES6 JS
5050
shell.exec(
51-
"./node_modules/typescript/bin/tsc --lib es6 --target ES2015 --sourceMap false --module nodenext --moduleResolution nodenext --outDir ./pkg lib/Api256Shim.ts"
51+
"./node_modules/typescript/bin/tsc --lib es6 --target ES2015 --sourceMap false --module esnext --skipLibCheck true --outDir ./pkg lib/Api256Shim.ts"
5252
);
5353
//Tweak wasm-bindgen import location since we moved the file to the same directory as the wasm-bindgen produced shim
54+
// WARNING: if the above module type changes to nodenext from esnext, this will go from an import to a require
55+
// and will need to be updated.
56+
const before = shell.exec(`shasum ./pkg/Api256Shim.js`, {silent: true}).stdout;
5457
shell.sed("-i", `from "../target/`, `from "./`, "./pkg/Api256Shim.js");
58+
const after = shell.exec(`shasum ./pkg/Api256Shim.js`, {silent: true}).stdout;
59+
if (before === after) {
60+
console.error("Error: failed to correct Api256Shim.js wasm import.");
61+
process.exit(1);
62+
}
5563

5664
//We need to tweak the wasm-pack generated package.json file since we have our own shim that fronts wasm-bindgen
5765
const generatedPackageJson = require("./pkg/package.json");
5866
generatedPackageJson.main = "Api256Shim.js";
59-
delete generatedPackageJson.module;
67+
delete generatedPackageJson.type;
6068
delete generatedPackageJson.files;
6169
generatedPackageJson.types = "recrypt_wasm_binding.d.ts";
6270

63-
fs.writeFileSync("./pkg/package.json", JSON.stringify(generatedPackageJson, null, 2));
71+
try {
72+
fs.writeFileSync("./pkg/package.json", JSON.stringify(generatedPackageJson, null, 2));
73+
console.log("File written successfully");
74+
} catch (err) {
75+
console.error("Write failed:", err);
76+
process.exit(1);
77+
}
6478

6579
shell.cp("./LICENSE", "./pkg");

lib/Api256Shim.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,6 @@ export const addPrivateKeys = (privateKeyA: Uint8Array, privateKeyB: Uint8Array)
265265
*/
266266
export const subtractPrivateKeys = (privateKeyA: Uint8Array, privateKeyB: Uint8Array): Uint8Array => Recrypt.subtractPrivateKeys(privateKeyA, privateKeyB);
267267

268-
269268
/**
270269
* Export the entire EncryptedSearch struct out directly. No need to shim this at any level.
271270
*/

tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
"noEmitOnError": true,
88
"noUnusedLocals": true,
99
"declaration": false,
10+
"skipLibCheck": true,
1011
"target": "ES2015",
11-
"module": "nodenext",
12-
"moduleResolution": "nodenext",
12+
"module": "esnext",
1313
"lib": ["es6", "dom"]
1414
},
1515
"exclude": ["node_modules"]

0 commit comments

Comments
 (0)