Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: using common dependencies so versions are not duplicated #26

Merged
merged 1 commit into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/build/**
136 changes: 68 additions & 68 deletions apps/sample-react-app/config-overrides.js
Original file line number Diff line number Diff line change
@@ -1,85 +1,85 @@
const path = require("node:path");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const webpack = require("webpack");
const paths = require("react-scripts/config/paths");
const { overrideDevServer } = require("customize-cra");
const path = require('node:path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const webpack = require('webpack');
const paths = require('react-scripts/config/paths');
const { overrideDevServer } = require('customize-cra');

paths.appSrc = path.resolve(__dirname, "src");
paths.appSrc = path.resolve(__dirname, 'src');
// Tell the app that "src/index.tsx" has moved to "src/popup/index.tsx"
paths.appIndexJs = path.resolve(__dirname, "src/index.tsx");
paths.appIndexJs = path.resolve(__dirname, 'src/index.tsx');

// Adds a manifest file to the build according to the current context,
// and deletes files from the build that are not needed in the current context
const devServerConfig = () => (config) => {
return {
...config,
// webpackDevService doesn't write the files to desk
// so we need to tell it to do so so we can load the
// extension with chrome
hot: true,
liveReload: true,
devMiddleware: {
writeToDisk: true,
},
};
return {
...config,
// webpackDevService doesn't write the files to desk
// so we need to tell it to do so so we can load the
// extension with chrome
hot: true,
liveReload: true,
devMiddleware: {
writeToDisk: true,
},
};
};

module.exports = {
webpack(config) {
// Disable bundle splitting,
// a single bundle file has to loaded as `content_script`.
config.optimization.splitChunks = {
cacheGroups: {
default: false,
},
};
webpack(config) {
// Disable bundle splitting,
// a single bundle file has to loaded as `content_script`.
config.optimization.splitChunks = {
cacheGroups: {
default: false,
},
};

// `false`: each entry chunk embeds runtime.
// The extension is built with a single entry including all JS.
// https://symfonycasts.com/screencast/webpack-encore/single-runtime-chunk
config.optimization.runtimeChunk = false;
// `false`: each entry chunk embeds runtime.
// The extension is built with a single entry including all JS.
// https://symfonycasts.com/screencast/webpack-encore/single-runtime-chunk
config.optimization.runtimeChunk = false;

config.entry = {
// Main Entry
main: "./src/index.tsx",
};
config.entry = {
// Main Entry
main: './src/index.tsx',
};

// Filenames of bundles must not include `[contenthash]`, so that they can be referenced in `extension-manifest.json`.
// The `[name]` is taken from `config.entry` properties, so if we have `main` and `background` as properties, we get 2 output files - main.js and background.js.
config.output.filename = "[name].js";
// Filenames of bundles must not include `[contenthash]`, so that they can be referenced in `extension-manifest.json`.
// The `[name]` is taken from `config.entry` properties, so if we have `main` and `background` as properties, we get 2 output files - main.js and background.js.
config.output.filename = '[name].js';

// `MiniCssExtractPlugin` is used by the default CRA webpack configuration for
// extracting CSS into separate files. The plugin has to be removed because it
// uses `[contenthash]` in filenames of the separate CSS files.
config.plugins = config.plugins
.filter((plugin) => !(plugin instanceof MiniCssExtractPlugin))
.concat(
// `MiniCssExtractPlugin` is used with its default config instead,
// which doesn't contain `[contenthash]`.
new MiniCssExtractPlugin()
);
// `MiniCssExtractPlugin` is used by the default CRA webpack configuration for
// extracting CSS into separate files. The plugin has to be removed because it
// uses `[contenthash]` in filenames of the separate CSS files.
config.plugins = config.plugins
.filter((plugin) => !(plugin instanceof MiniCssExtractPlugin))
.concat(
// `MiniCssExtractPlugin` is used with its default config instead,
// which doesn't contain `[contenthash]`.
new MiniCssExtractPlugin(),
);

const fallback = config.resolve.fallback || {};
Object.assign(fallback, {
crypto: require.resolve("crypto-browserify"),
stream: require.resolve("stream-browserify"),
assert: require.resolve("assert"),
http: require.resolve("stream-http"),
https: require.resolve("https-browserify"),
os: require.resolve("os-browserify"),
url: require.resolve("url"),
"process/browser": require.resolve("process/browser"),
});
config.resolve.fallback = fallback;
const fallback = config.resolve.fallback || {};
Object.assign(fallback, {
crypto: require.resolve('crypto-browserify'),
stream: require.resolve('stream-browserify'),
assert: require.resolve('assert'),
http: require.resolve('stream-http'),
https: require.resolve('https-browserify'),
os: require.resolve('os-browserify'),
url: require.resolve('url'),
'process/browser': require.resolve('process/browser'),
});
config.resolve.fallback = fallback;

config.plugins = (config.plugins || []).concat([
new webpack.ProvidePlugin({
process: "process/browser",
Buffer: ["buffer", "Buffer"],
}),
]);
config.plugins = (config.plugins || []).concat([
new webpack.ProvidePlugin({
process: 'process/browser',
Buffer: ['buffer', 'Buffer'],
}),
]);

return config;
},
devServer: overrideDevServer(devServerConfig()),
return config;
},
devServer: overrideDevServer(devServerConfig()),
};
46 changes: 23 additions & 23 deletions apps/sample-react-app/public/manifest.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "logo192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "logo512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "logo192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "logo512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
2 changes: 1 addition & 1 deletion commitlint.config.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = { extends: ["@commitlint/config-conventional"] };
module.exports = { extends: ['@commitlint/config-conventional'] };
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"build:deps": "turbo build --no-daemon --filter='@vechain/*'",
"clean": "npx turbo@latest run clean && rm -rf node_modules .turbo",
"dev": "turbo run dev --no-daemon",
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
"format": "prettier --write \"**/*.{ts,tsx,md,json,js,jsx}\"",
"install:all": "yarn && yarn run build:deps",
"lint": "turbo run lint",
"prepare": "husky install",
Expand Down Expand Up @@ -40,8 +40,8 @@
"husky": "^8.0.0",
"lint-staged": "^15.0.2",
"prettier": "^2.5.1",
"tsconfig": "*",
"turbo": "latest"
"turbo": "latest",
"typescript": "4.9.5"
},
"packageManager": "[email protected]"
}
8 changes: 3 additions & 5 deletions packages/react-wallet-kit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@
"devDependencies": {
"@types/react": "^18.2.28",
"@types/react-dom": "^18.2.13",
"@vechain/repo-config": "https://github.com/vechainfoundation/repo-config#v0.0.1",
"eslint": "^8.4.1",
"eslint": "*",
"react": "^18.2.0",
"tsconfig": "*",
"tsup": "^5.10.1",
"typescript": "4.9.5"
"tsup": "*",
"typescript": "*"
}
}
7 changes: 3 additions & 4 deletions packages/wallet-connect/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@
"@vechain/connex-types": "2.1.0",
"@vechain/repo-config": "https://github.com/vechainfoundation/repo-config#v0.0.1",
"@walletconnect/types": "2.10.2",
"eslint": "^8.4.1",
"tsconfig": "*",
"tsup": "^5.10.1",
"typescript": "4.9.5"
"eslint": "*",
"tsup": "*",
"typescript": "*"
}
}
10 changes: 5 additions & 5 deletions packages/wallet-kit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
"@vechain/wallet-connect": "*"
},
"devDependencies": {
"@vechain/repo-config": "https://github.com/vechainfoundation/repo-config#v0.0.1",
"eslint": "^8.4.1",
"tsconfig": "*",
"tsup": "^5.10.1",
"typescript": "4.9.5"
"@types/react": "^18.2.28",
"@types/react-dom": "^18.2.13",
"eslint": "*",
"tsup": "*",
"typescript": "*"
}
}
9 changes: 2 additions & 7 deletions packages/wallet-kit/src/signer-manager.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
import type { ConnexOptions, ConnexSigner } from './types';
import { WalletSource } from './wallet';
import type { WalletSource } from './wallet';
import { createSigner } from './signer';

class SignerManager implements ConnexSigner {
private signers: Record<WalletSource, ConnexSigner | undefined> = {
[WalletSource.WalletConnect]: undefined,
[WalletSource.VeWorldExtension]: undefined,
[WalletSource.Sync]: undefined,
[WalletSource.Sync2]: undefined,
};
private signers: Record<string, ConnexSigner | undefined> = {};

private currentSource: WalletSource | undefined;

Expand Down
22 changes: 0 additions & 22 deletions packages/wallet-kit/src/vendor-driver.ts

This file was deleted.

5 changes: 4 additions & 1 deletion packages/wallet-kit/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"extends": "@vechain/repo-config/src/tsconfig/base.json",
"include": ["."],
"exclude": ["dist", "node_modules"]
"exclude": ["dist", "node_modules"],
"compilerOptions": {
"target": "ES6"
}
}
36 changes: 18 additions & 18 deletions turbo.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
{
"$schema": "https://turbo.build/schema.json",
"pipeline": {
"build": {
"outputs": ["build/**", "dist/**"],
"dependsOn": ["^build"]
},
"test": {
"outputs": ["coverage/**"],
"dependsOn": ["build"]
},
"lint": {},
"dev": {
"cache": false,
"persistent": true
},
"clean": {
"cache": false
"$schema": "https://turbo.build/schema.json",
"pipeline": {
"build": {
"outputs": ["build/**", "dist/**"],
"dependsOn": ["^build"]
},
"test": {
"outputs": ["coverage/**"],
"dependsOn": ["build"]
},
"lint": {},
"dev": {
"cache": false,
"persistent": true
},
"clean": {
"cache": false
}
}
}
}
Loading