diff --git a/landing/package.json b/landing/package.json index 8f15de1ac..aed21cc40 100644 --- a/landing/package.json +++ b/landing/package.json @@ -1,58 +1,59 @@ { "name": "landing", "version": "0.0.1", "type": "module", "private": true, "license": "BSD-3-Clause", "scripts": { "clean": "rm -rf dist/ && rm -rf node_modules/", "dev": "yarn workspace keyserver babel-build-comm-config && yarn concurrently --names=\"NODESSR,BROWSER\" -c \"bgBlue.bold,bgMagenta.bold\" \"yarn webpack --config webpack.config.cjs --config-name=server --watch\" \"yarn webpack-dev-server --config webpack.config.cjs --config-name=browser\"", "prod": "yarn workspace keyserver babel-build-comm-config && yarn webpack --config webpack.config.cjs --env prod --progress" }, "devDependencies": { "@babel/core": "^7.23.7", "@babel/plugin-transform-class-properties": "^7.23.3", "@babel/plugin-transform-nullish-coalescing-operator": "^7.23.4", "@babel/plugin-transform-object-rest-spread": "^7.23.4", "@babel/plugin-transform-optional-chaining": "^7.23.4", "@babel/plugin-transform-react-constant-elements": "^7.23.3", "@babel/plugin-transform-private-methods": "^7.24.1", "@babel/plugin-transform-runtime": "^7.23.7", "@babel/preset-env": "^7.23.7", "@babel/preset-flow": "^7.23.3", "@babel/preset-react": "^7.23.3", "babel-plugin-transform-remove-console": "^6.9.4", "concurrently": "^5.3.0", "flow-bin": "^0.202.1", "flow-typed": "^3.2.1", "webpack-cli": "^5.0.1", "webpack-dev-server": "^4.11.1", "webpack-manifest-plugin": "^5.0.0" }, "dependencies": { "@babel/runtime": "^7.23.7", "@farcaster/auth-kit": "^0.2.1", "@fortawesome/fontawesome-svg-core": "1.2.25", "@fortawesome/free-brands-svg-icons": "5.15.4", "@fortawesome/free-regular-svg-icons": "5.11.2", "@fortawesome/free-solid-svg-icons": "5.11.2", "@fortawesome/react-fontawesome": "0.1.5", "@lottiefiles/lottie-interactivity": "^1.6.2", "@lottiefiles/lottie-player": "^2.0.2", "@rainbow-me/rainbowkit": "^2.0.4", "@tanstack/react-query": "^5.28.9", + "buffer": "^6.0.3", "classnames": "^2.2.5", "core-js": "^3.6.5", "ethers": "^6.11.1", "invariant": "^2.2.4", "isomorphic-fetch": "^3.0.0", "lib": "0.0.1", "lodash": "^4.17.21", "react": "18.1.0", "react-dom": "18.1.0", "react-router": "^5.2.0", "react-router-dom": "^5.2.0", "viem": "^2.9.5", "wagmi": "^2.5.16" } } diff --git a/lib/webpack/shared.cjs b/lib/webpack/shared.cjs index e268afe8e..6ad5f8b03 100644 --- a/lib/webpack/shared.cjs +++ b/lib/webpack/shared.cjs @@ -1,300 +1,303 @@ const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin'); const { CleanWebpackPlugin } = require('clean-webpack-plugin'); const CssMinimizerPlugin = require('css-minimizer-webpack-plugin'); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); const TerserPlugin = require('terser-webpack-plugin'); const webpack = require('webpack'); async function getConfig(configName) { const { getCommConfig } = await import( '../../keyserver/dist/lib/utils/comm-config.js' ); return await getCommConfig(configName); } const sharedPlugins = [ new webpack.optimize.LimitChunkCountPlugin({ maxChunks: 1, }), ]; const cssLoader = { loader: 'css-loader', options: { modules: { mode: 'local', localIdentName: '[path][name]__[local]--[contenthash:base64:5]', }, }, }; const cssExtractLoader = { loader: MiniCssExtractPlugin.loader, }; const styleLoader = { loader: 'style-loader', }; function getBabelRule(babelConfig) { return { test: /\.js$/, exclude: /node_modules\/(?!lib)/, loader: 'babel-loader', options: babelConfig, }; } function getBrowserBabelRule(babelConfig) { const babelRule = getBabelRule(babelConfig); return { ...babelRule, options: { ...babelRule.options, presets: [ ...babelRule.options.presets, [ '@babel/preset-env', { targets: 'defaults', useBuiltIns: 'usage', corejs: '3.6', }, ], ], }, }; } const imageRule = { test: /\.(png|svg)$/, type: 'asset/inline', }; const typographyRule = { test: /\.(woff2|woff)$/, type: 'asset/inline', }; function createBaseBrowserConfig(baseConfig) { return { ...baseConfig, name: 'browser', optimization: { minimizer: [new TerserPlugin(), new CssMinimizerPlugin()], }, plugins: [ ...(baseConfig.plugins ?? []), ...sharedPlugins, new webpack.ProvidePlugin({ Buffer: ['buffer', 'Buffer'], }), new CleanWebpackPlugin({ cleanOnceBeforeBuildPatterns: [], }), ], node: { global: true, }, }; } async function getConfigs() { const [alchemySecret, walletConnectSecret] = await Promise.all([ getConfig({ folder: 'secrets', name: 'alchemy' }), getConfig({ folder: 'secrets', name: 'walletconnect' }), ]); const alchemyKey = alchemySecret?.key; const walletConnectKey = walletConnectSecret?.key; return { alchemyKey, walletConnectKey }; } async function createProdBrowserConfig(baseConfig, babelConfig, envVars) { const browserConfig = createBaseBrowserConfig(baseConfig); const babelRule = getBrowserBabelRule(babelConfig); const { alchemyKey, walletConnectKey } = await getConfigs(); return { ...browserConfig, mode: 'production', plugins: [ ...browserConfig.plugins, new webpack.DefinePlugin({ 'process.env': { NODE_ENV: JSON.stringify('production'), BROWSER: true, COMM_ALCHEMY_KEY: JSON.stringify(alchemyKey), COMM_WALLETCONNECT_KEY: JSON.stringify(walletConnectKey), ...envVars, }, }), new MiniCssExtractPlugin({ filename: 'prod.[contenthash:12].build.css', }), ], module: { rules: [ { ...babelRule, options: { ...babelRule.options, plugins: [ ...babelRule.options.plugins, '@babel/plugin-transform-react-constant-elements', ['transform-remove-console', { exclude: ['error', 'warn'] }], ], }, }, { test: /\.css$/, exclude: /node_modules\/.*\.css$/, use: [ cssExtractLoader, { ...cssLoader, options: { ...cssLoader.options, url: false, }, }, ], }, { test: /node_modules\/.*\.css$/, sideEffects: true, use: [ cssExtractLoader, { ...cssLoader, options: { ...cssLoader.options, url: false, modules: false, }, }, ], }, ], }, }; } async function createDevBrowserConfig(baseConfig, babelConfig, envVars) { const browserConfig = createBaseBrowserConfig(baseConfig); const babelRule = getBrowserBabelRule(babelConfig); const { alchemyKey, walletConnectKey } = await getConfigs(); return { ...browserConfig, mode: 'development', plugins: [ ...browserConfig.plugins, new webpack.DefinePlugin({ 'process.env': { NODE_ENV: JSON.stringify('development'), BROWSER: true, COMM_ALCHEMY_KEY: JSON.stringify(alchemyKey), COMM_WALLETCONNECT_KEY: JSON.stringify(walletConnectKey), ...envVars, }, }), new ReactRefreshWebpackPlugin(), ], module: { rules: [ { ...babelRule, options: { ...babelRule.options, plugins: [ require.resolve('react-refresh/babel'), ...babelRule.options.plugins, ], }, }, imageRule, typographyRule, { test: /\.css$/, exclude: /node_modules\/.*\.css$/, use: [styleLoader, cssLoader], }, { test: /node_modules\/.*\.css$/, sideEffects: true, use: [ styleLoader, { ...cssLoader, options: { ...cssLoader.options, modules: false, }, }, ], }, ], }, devtool: 'eval-cheap-module-source-map', }; } async function createNodeServerRenderingConfig(baseConfig, babelConfig) { const { alchemyKey, walletConnectKey } = await getConfigs(); return { ...baseConfig, name: 'server', target: 'node', module: { rules: [ getBabelRule(babelConfig), { test: /\.css$/, use: { ...cssLoader, options: { ...cssLoader.options, modules: { ...cssLoader.options.modules, exportOnlyLocals: true, }, }, }, }, ], }, plugins: [ ...sharedPlugins, new webpack.DefinePlugin({ 'process.env': { COMM_ALCHEMY_KEY: JSON.stringify(alchemyKey), COMM_WALLETCONNECT_KEY: JSON.stringify(walletConnectKey), }, }), ], }; } function createWebWorkersConfig(env, baseConfig, babelConfig) { return { ...baseConfig, name: 'webworkers', target: 'webworker', mode: env.prod ? 'production' : 'development', module: { rules: [getBrowserBabelRule(babelConfig)], }, plugins: [ ...sharedPlugins, ...baseConfig.plugins, new webpack.DefinePlugin({ 'process.env': { NODE_ENV: JSON.stringify(env.prod ? 'production' : 'development'), BROWSER: true, }, }), + new webpack.ProvidePlugin({ + Buffer: ['buffer', 'Buffer'], + }), ], }; } module.exports = { createProdBrowserConfig, createDevBrowserConfig, createNodeServerRenderingConfig, createWebWorkersConfig, }; diff --git a/web/package.json b/web/package.json index 5a30741b5..e98c34f7a 100644 --- a/web/package.json +++ b/web/package.json @@ -1,129 +1,130 @@ { "name": "web", "version": "0.0.1", "type": "module", "private": true, "license": "BSD-3-Clause", "scripts": { "clean": "rm -rf dist/ && rm -rf node_modules/ && rm -rf shared-worker/sqlite/ && rm -f backup-client-wasm/wasm/backup-client-wasm_bg.wasm && rm -f backup-client-wasm/wasm/backup-client-wasm.js && rm -rf backup-client-wasm/target", "dev": "yarn workspace keyserver babel-build-comm-config && yarn concurrently --names=\"NODESSR,BROWSER,WORKERS\" -c \"bgBlue.bold,bgMagenta.bold,bgCyan.bold\" \"yarn webpack --config webpack.config.cjs --config-name=server --watch\" \"yarn webpack-dev-server --config webpack.config.cjs --config-name=browser\" \"yarn webpack --config webpack.config.cjs --config-name=webworkers --watch\"", "prod": "yarn workspace keyserver babel-build-comm-config && yarn webpack --config webpack.config.cjs --env prod --progress", "test": "jest", "build-db-wasm": "./scripts/run_emscripten.sh", "clean-db-wasm": "rm -rf shared-worker/_generated/ && rm -rf shared-worker/sqlite/", "build-backup-client-wasm": "./scripts/run-wasmpack.sh", "codegen-identity-grpc": "./scripts/codegen-identity-grpc.sh", "postinstall": "bash ./scripts/postinstall.sh" }, "devDependencies": { "@babel/core": "^7.23.7", "@babel/plugin-transform-class-properties": "^7.23.3", "@babel/plugin-transform-nullish-coalescing-operator": "^7.23.4", "@babel/plugin-transform-object-rest-spread": "^7.23.4", "@babel/plugin-transform-optional-chaining": "^7.23.4", "@babel/plugin-transform-react-constant-elements": "^7.23.3", "@babel/plugin-transform-runtime": "^7.23.7", "@babel/preset-env": "^7.23.7", "@babel/preset-flow": "^7.23.3", "@babel/preset-react": "^7.23.3", "babel-jest": "^29.7.0", "babel-plugin-transform-remove-console": "^6.9.4", "concurrently": "^5.3.0", "copy-webpack-plugin": "^11.0.0", "flow-bin": "^0.202.1", "flow-typed": "^3.2.1", "identity-obj-proxy": "^3.0.0", "jest": "^29.7.0", "jest-environment-jsdom": "^29.7.0", "protoc-gen-js": "^3.21.2", "wasm-pack": "^0.12.1", "webpack-cli": "^5.0.1", "webpack-dev-server": "^4.11.1", "webpack-manifest-plugin": "^5.0.0" }, "dependencies": { "@babel/runtime": "^7.23.7", "@commapp/olm": "0.1.1", "@commapp/opaque-ke-wasm": "npm:@commapp/opaque-ke-wasm@^0.0.3", "@emoji-mart/data": "^1.1.2", "@emoji-mart/react": "^1.1.1", "@fortawesome/fontawesome-svg-core": "1.2.25", "@fortawesome/free-regular-svg-icons": "5.11.2", "@fortawesome/free-solid-svg-icons": "5.11.2", "@fortawesome/react-fontawesome": "0.1.5", "@matrix-org/olm": "3.2.14", "@rainbow-me/rainbowkit": "^2.0.4", "@tanstack/react-query": "^5.28.9", "basscss": "8.0.2", "brotli": "^1.3.3", + "buffer": "^6.0.3", "classnames": "^2.2.5", "core-js": "^3.6.5", "dateformat": "^3.0.3", "detect-browser": "^4.0.4", "emoji-mart": "^5.5.2", "ethers": "^6.11.1", "exif-js": "^2.3.0", "google-protobuf": "^3.21.2", "grpc-web": "^1.4.2", "history": "^4.6.3", "invariant": "^2.2.4", "is-svg": "^4.3.0", "isomorphic-fetch": "^3.0.0", "lib": "0.0.1", "localforage": "^1.10.0", "lodash": "^4.17.21", "qrcode.react": "^3.1.0", "react": "18.1.0", "react-circular-progressbar": "^2.0.2", "react-color": "^2.13.0", "react-dnd": "^11.1.3", "react-dnd-html5-backend": "^11.1.3", "react-dom": "18.1.0", "react-feather": "^2.0.3", "react-icomoon": "^2.5.7", "react-icons": "^4.4.0", "react-redux": "^7.1.1", "react-router": "^5.2.0", "react-router-dom": "^5.2.0", "react-switch": "^7.0.0", "react-timeago": "^7.1.0", "react-virtualized-auto-sizer": "^1.0.19", "react-window": "^1.8.9", "redux": "^4.0.4", "redux-devtools-extension": "^2.13.2", "redux-persist": "^6.0.0", "redux-thunk": "^2.2.0", "reselect": "^4.0.0", "simple-markdown": "^0.7.2", "siwe": "^1.1.6", "thumbhash": "^0.1.1", "tinycolor2": "^1.4.1", "uuid": "^3.4.0", "viem": "^2.9.5", "visibilityjs": "^2.0.2", "wagmi": "^2.5.16" }, "jest": { "roots": [ "" ], "transform": { "\\.js$": [ "babel-jest", { "rootMode": "upward" } ] }, "transformIgnorePatterns": [ "/node_modules/(?!(@babel/runtime|thumbhash))" ], "moduleNameMapper": { "\\.(css)$": "identity-obj-proxy" }, "setupFiles": [ "/jest-setup.js" ], "testEnvironment": "jsdom" } }