Skip to content

Commit

Permalink
Merge pull request #74 from zama-ai/build/change-build
Browse files Browse the repository at this point in the history
chore: rework the build process
  • Loading branch information
immortal-tofu authored Jun 20, 2024
2 parents f165143 + a9a5df6 commit 5981c8b
Show file tree
Hide file tree
Showing 16 changed files with 105 additions and 192 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/index.js'),
web: path.resolve(__dirname, '../lib/web.js'),
build: path.resolve(__dirname, '../bundle'),
};

Expand Down
37 changes: 11 additions & 26 deletions config/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,72 +12,57 @@ import nodePolyfills from 'rollup-plugin-polyfill-node';
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/',
src: './src/kms/node/*',
dest: 'lib/kms/node',
},
],
}),
wasm(),
commonjs(),
typescript({
tsconfig: './tsconfig.node.rollup.json',
tsconfig: './tsconfig.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',
src: './src/kms/web/*',
dest: 'lib/kms/web',
},
],
}),
nodePolyfills(),
replace({
preventAssignment: true,
'node-tfhe': 'tfhe',
'kms/node/': 'kms/web/',
'kms/node': 'kms/web',
}),
typescript({
tsconfig: './tsconfig.web.rollup.json',
tsconfig: './tsconfig.rollup.json',
exclude: 'node_modules/**',
}),
wasm({
targetEnv: 'browser',
maxFileSize: 10000000,
}),
commonjs(),
resolve({
browser: true,
resolveOnly: ['tfhe'],
extensions: ['.js', '.ts', '.wasm'],
}),
commonjs(),
];

export default [
{
input: 'src/web.ts',
output: {
file: 'lib/web/index.js',
file: 'lib/web.js',
name: 'fhevm',
format: 'es',
},
Expand All @@ -86,7 +71,7 @@ export default [
{
input: 'src/node.ts',
output: {
file: 'lib/node/index.cjs',
file: 'lib/node.cjs',
name: 'fhevm',
format: 'cjs',
},
Expand Down
1 change: 0 additions & 1 deletion config/webpack.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ const web = {
'tfhe_bg.wasm': require.resolve('tfhe/tfhe_bg.wasm'),
'node-tfhe': require.resolve('tfhe/tfhe'),
'kms_lib_bg.wasm': require.resolve('../src/kms/web/kms_lib_bg.wasm'),
'node-kms': require.resolve('../src/kms/web/kms_lib.js'),
buffer: require.resolve('buffer/'),
crypto: require.resolve('crypto-browserify'),
stream: require.resolve('stream-browserify'),
Expand Down
3 changes: 0 additions & 3 deletions jest.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ module.exports = {
},
testEnvironment: 'node',
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
moduleNameMapper: {
'^node-kms$': '<rootDir>/src/kms/node',
},
collectCoverageFrom: [
'src/**/*.ts',
'src/**/*.tsx',
Expand Down
Loading

0 comments on commit 5981c8b

Please sign in to comment.