Skip to content
This repository was archived by the owner on Mar 16, 2023. It is now read-only.

Commit ab1ad09

Browse files
authored
Merge pull request #539 from AztecProtocol/fix/include-wasm-in-node-build
fix(aztec.js): fix node build
2 parents fed09a1 + 2d36421 commit ab1ad09

File tree

4 files changed

+36
-6
lines changed

4 files changed

+36
-6
lines changed

packages/aztec.js/src/note/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,10 +307,12 @@ export function encodeMetadata(noteArray) {
307307
* @returns {Note} created note instance
308308
*/
309309
export async function fromEventLog(logNoteData, spendingKey = null) {
310-
const publicKey = noteCoder.decodeNoteFromEventLog(logNoteData);
311-
const newNote = new Note(publicKey, null);
310+
const notePublicKey = noteCoder.decodeNoteFromEventLog(logNoteData);
311+
const newNote = new Note(notePublicKey, null);
312312
if (spendingKey) {
313313
await newNote.derive(spendingKey);
314+
const { address } = secp256k1.accountFromPrivateKey(spendingKey);
315+
newNote.owner = address;
314316
}
315317
return newNote;
316318
}

packages/aztec.js/webpack.common.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,4 @@ module.exports = {
3737
maxAssetSize: 200000,
3838
maxEntrypointSize: 400000,
3939
},
40-
resolve: {
41-
extensions: ['.js', '.json'],
42-
},
4340
};

packages/aztec.js/webpack.dev.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
const merge = require('webpack-merge');
2+
const CopyWebpackPlugin = require('copy-webpack-plugin');
3+
24
const common = require('./webpack.common.js');
35

46
const config = {
@@ -14,13 +16,27 @@ const nodeConfig = merge(common, {
1416
},
1517
output: { filename: 'bundle.node.js' },
1618
target: 'node',
19+
plugins: [
20+
new CopyWebpackPlugin([
21+
{
22+
from: 'node_modules/@aztec/bn128/**/*.wasm',
23+
to: '[name].[ext]',
24+
},
25+
]),
26+
],
27+
resolve: {
28+
extensions: ['.js', '.json', '.wasm'],
29+
},
1730
});
1831

1932
const webConfig = merge(common, {
2033
...config,
2134
node: { crypto: true, fs: 'empty' },
2235
output: { filename: 'bundle.web.js' },
2336
target: 'web',
37+
resolve: {
38+
extensions: ['.js', '.json'],
39+
},
2440
});
2541

2642
module.exports = [nodeConfig, webConfig];

packages/aztec.js/webpack.prod.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
const merge = require('webpack-merge');
2+
const CopyWebpackPlugin = require('copy-webpack-plugin');
23
const common = require('./webpack.common.js');
34

45
const config = {
56
mode: 'production',
6-
devtool: '',
7+
devtool: 'inline-source-map',
78
};
89

910
const nodeConfig = merge(common, {
@@ -14,13 +15,27 @@ const nodeConfig = merge(common, {
1415
},
1516
output: { filename: 'bundle.node.js' },
1617
target: 'node',
18+
plugins: [
19+
new CopyWebpackPlugin([
20+
{
21+
from: 'node_modules/@aztec/bn128/**/*.wasm',
22+
to: '[name].[ext]',
23+
},
24+
]),
25+
],
26+
resolve: {
27+
extensions: ['.js', '.json', '.wasm'],
28+
},
1729
});
1830

1931
const webConfig = merge(common, {
2032
...config,
2133
node: { crypto: true, fs: 'empty' },
2234
output: { filename: 'bundle.web.js' },
2335
target: 'web',
36+
resolve: {
37+
extensions: ['.js', '.json'],
38+
},
2439
});
2540

2641
module.exports = [nodeConfig, webConfig];

0 commit comments

Comments
 (0)