Open OR13 opened 4 months ago
Thanks for the report. I'll check tomorrow.
If I figure it out before then, I will update the PR and mark it "not draft", with some comments.
Please don't let my comments here keep you awake.
Interestingly switching from:
import { AeadId, CipherSuite, KdfId, KemId } from "hpke-js";
import { AeadId, CipherSuite, KdfId, KemId } from "@hpke/core";
causes a different error:
of the same form:
Uncaught Error: Cannot find module '../src/aeads/aesGcm.js'
Seems to be the first "none type" export here:
https://github.com/dajiaji/hpke-js/blob/main/core/mod.ts#L16
Seems like webpack needs to be instructed to use node modules resolve relative paths in dependencies properly
Possibly relevant: https://github.com/webpack/webpack/issues/472
This worked:
const path = require('path');
module.exports = [{
mode: 'development',
entry: './index.js',
watch: true,
plugins: [],
resolve: {
alias: {
'@hpke/core': path.resolve('./node_modules/@hpke/core')
},
fallback: {
"crypto": false
}
}
}];
Please don't let my comments here keep you awake.
Don't worry. I fell asleep before I saw your comment above :-) I'll now check your PR.
For those trying to use this library in next 14 or greater:
You can update webpack used by next, like this:
https://nextjs.org/docs/app/api-reference/next-config-js/webpack
const path = require("path");
module.exports = {
webpack: (
config,
{ buildId, dev, isServer, defaultLoaders, nextRuntime, webpack }
) => {
// Important: return the modified config
return {
...config,
resolve: {
...config.resolve,
alias: {
...config.resolve.alias,
"hpke-js": path.resolve("./node_modules/hpke-js"),
},
fallback: {
...config.resolve.fallback,
"crypto": false,
},
},
}
},
}
This error occurs when bundling with web pack, a typescript application, that included hpke-js.
I created a PoC here: https://github.com/dajiaji/hpke-js/pull/301