Skip to content

Commit

Permalink
chore: fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
immortal-tofu committed Jun 16, 2024
1 parent 948c9ac commit 65a1f68
Show file tree
Hide file tree
Showing 6 changed files with 347 additions and 141 deletions.
2 changes: 1 addition & 1 deletion config/paths.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const path = require('path');

const PATHS = {
web: path.resolve(__dirname, '../lib/web.js'),
web: path.resolve(__dirname, '../lib/web/index.js'),
build: path.resolve(__dirname, '../bundle'),
};

Expand Down
62 changes: 51 additions & 11 deletions config/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,64 @@
import { createRequire } from 'node:module';

import { wasm } from '@rollup/plugin-wasm';
import alias from '@rollup/plugin-alias';
import typescript from '@rollup/plugin-typescript';
import replace from '@rollup/plugin-replace';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import copy from 'rollup-plugin-copy';
import nodePolyfills from 'rollup-plugin-polyfill-node';

const plugins = [
const require = createRequire(import.meta.url);

const nodePlugins = [
alias({
entries: [
{
find: 'node-kms',
replacement: require.resolve('../src/kms/node/index.js'),
},
],
}),
copy({
targets: [
{
src: require.resolve('../src/kms/node/kms_lib_bg.wasm'),
dest: 'lib/node/',
},
],
}),
commonjs(),
typescript({
tsconfig: './tsconfig.node.rollup.json',
}),
];

const webPlugins = [
alias({
entries: [
{
find: 'node-kms',
replacement: require.resolve('../src/kms/web/kms_lib.js'),
},
],
}),
copy({
targets: [
{
src: require.resolve('../src/kms/web/kms_lib_bg.wasm'),
dest: 'lib/web',
},
],
}),
nodePolyfills(),
replace({
preventAssignment: true,
'node-tfhe': 'tfhe',
'kms/node/': 'kms/web/',
}),
typescript({
tsconfig: './tsconfig.rollup.json',
tsconfig: './tsconfig.web.rollup.json',
exclude: 'node_modules/**',
}),
wasm({
Expand All @@ -32,24 +77,19 @@ export default [
{
input: 'src/web.ts',
output: {
dir: 'lib',
file: 'lib/web/index.js',
name: 'fhevm',
format: 'es',
},
plugins: [...plugins],
plugins: [...webPlugins],
},
{
input: 'src/node.ts',
output: {
file: 'lib/node.cjs',
file: 'lib/node/index.cjs',
name: 'fhevm',
format: 'cjs',
},
plugins: [
commonjs(),
typescript({
tsconfig: './tsconfig.rollup.json',
}),
],
plugins: [...nodePlugins],
},
];
Loading

0 comments on commit 65a1f68

Please sign in to comment.