Skip to content

Commit e7d5416

Browse files
committed
feat: @web3uikit/config
1 parent 0898181 commit e7d5416

25 files changed

+690
-416
lines changed

.gitignore

+3-7
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
node_modules
2-
3-
packages/core/lib/
4-
packages/ui/lib/
5-
packages/styles/lib/
6-
apps/**/dist
7-
1+
**/node_modules
2+
**/dist
3+
**/*.tsbuildinfo
84
**/.DS_Store

.vscode/extensions.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"recommendations": ["dbaeumer.vscode-eslint", "esbenp.prettier-vscode"]
3+
}

.vscode/settings.json

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"files.exclude": {
3+
"**/.git": true,
4+
"**/.gitkeep": true,
5+
"**/node_modules": true
6+
},
7+
"prettier.configPath": ".prettierrc",
8+
"editor.defaultFormatter": "esbenp.prettier-vscode",
9+
"editor.formatOnSave": true,
10+
"editor.codeActionsOnSave": {
11+
"source.fixAll.eslint": true
12+
},
13+
"eslint.rules.customizations": [{ "rule": "*", "severity": "error" }],
14+
"scss.lint.unknownAtRules": "ignore",
15+
"typescript.tsdk": "./node_modules/typescript/lib"
16+
}

apps/example/package.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@
1010
"build": "vite build"
1111
},
1212
"dependencies": {
13-
"@web3uikit/core": "0.1.0",
14-
"@web3uikit/ui": "0.1.0",
13+
"@web3uikit/core": "*",
14+
"@web3uikit/ui": "*",
1515
"react": "^18.0.0",
1616
"react-dom": "^18.0.0",
1717
"react-router-dom": "^6.3.0"
18+
},
19+
"devDependencies": {
20+
"@web3uikit/config": "*"
1821
}
1922
}

apps/example/tsconfig.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2-
"extends": "../../tsconfig.ui.json",
2+
"extends": "@web3uikit/config/tsconfig.ui.json",
33
"compilerOptions": {
4-
"noEmit": true,
5-
"rootDir": "src"
4+
"baseUrl": ".",
5+
"rootDir": "src",
66
},
77
"include": ["src"]
88
}

apps/example/vite.config.ts

+1-7
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { resolve } from 'path';
22
import react from '@vitejs/plugin-react';
33
import { defineConfig } from 'vite';
44

5-
const { name, version, dependencies } = require('./package.json');
5+
const { dependencies } = require('./package.json');
66
const vendor = Object.keys(dependencies);
77

88
const renderChunks = (deps: Record<string, string>) => {
@@ -15,12 +15,6 @@ const renderChunks = (deps: Record<string, string>) => {
1515
};
1616

1717
export default defineConfig({
18-
define: {
19-
pkgJson: { name, version },
20-
},
21-
esbuild: {
22-
jsxInject: `import React from 'react'`,
23-
},
2418
plugins: [react()],
2519
server: {
2620
open: true,

nx.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"default": {
1818
"runner": "nx/tasks-runners/default",
1919
"options": {
20-
"cacheableOperations": ["build"]
20+
"cacheableOperations": ["build", "test"]
2121
}
2222
}
2323
},

package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
],
1111
"scripts": {
1212
"build": "nx run-many --target=build --all --parallel --verbose=true",
13+
"test": "nx affected --target=test --all --parallel --verbose=true",
14+
"nm:clear": "find . -name 'node_modules' -type d -prune -exec rm -rf '{}' +",
1315
"nx:clear": "nx clear-cache",
1416
"nx:graph": "nx graph --skip-nx-cache",
1517
"start:dev": "nx run-many --target=start:dev --all --parallel --verbose=true",
@@ -31,6 +33,7 @@
3133
"@nrwl/linter": "14.1.5",
3234
"@storybook/addon-essentials": "^6.4.22",
3335
"@storybook/addon-links": "^6.4.22",
36+
"@storybook/builder-vite": "^0.1.36",
3437
"@storybook/react": "^6.4.22",
3538
"@storybook/testing-react": "^1.2.4",
3639
"@testing-library/jest-dom": "^5.16.4",
@@ -51,7 +54,6 @@
5154
"react-dom": "^18.0.0",
5255
"react-lazily": "^0.9.1",
5356
"rollup-plugin-dts": "^4.2.1",
54-
"storybook-builder-vite": "^0.1.23",
5557
"styled-components": "^5.3.5",
5658
"ts-jest": "27.1.4",
5759
"ts-node": "9.1.1",

packages/config/index.ts

-3
This file was deleted.

packages/config/package.json

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "@web3uikit/config",
3+
"version": "0.1.0",
4+
"sideEffects": false,
5+
"devDependencies": {
6+
"@types/node": "^17.0.36",
7+
"@vitejs/plugin-react": "^1.3.2",
8+
"vite": "^2.9.9",
9+
"vite-plugin-dts": "^1.2.0",
10+
"vite-tsconfig-paths": "^3.5.0"
11+
}
12+
}
File renamed without changes.

tsconfig.ui.json packages/config/tsconfig.ui.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"extends": "./tsconfig.base.json",
2+
"extends": "./tsconfig.json",
33
"compilerOptions": {
44
"allowJs": true,
55
"allowSyntheticDefaultImports": true,

packages/config/vite.config.ts

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import react from '@vitejs/plugin-react';
2+
import tsconfigPaths from 'vite-tsconfig-paths';
3+
4+
import { UserConfigExport } from 'vite';
5+
import dts from 'vite-plugin-dts';
6+
7+
/**
8+
*
9+
* @param cwd
10+
* @param external
11+
*/
12+
const config = (cwd: string, external?: string[]): UserConfigExport => {
13+
return {
14+
root: cwd,
15+
plugins: [
16+
react(),
17+
tsconfigPaths({ root: cwd }),
18+
dts({ entryRoot: cwd + "/src", outputDir: cwd + "/dist" }),
19+
],
20+
build: {
21+
emptyOutDir: true,
22+
lib: {
23+
entry: cwd + '/src/index.ts',
24+
fileName: 'index',
25+
formats: ['es', 'cjs'],
26+
},
27+
outDir: cwd + '/dist',
28+
rollupOptions: {
29+
external,
30+
},
31+
},
32+
};
33+
};
34+
export default config;

packages/core/package.json

+8-7
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
"sideEffects": false,
66
"files": [
77
"package.json",
8-
"lib"
8+
"dist"
99
],
10-
"main": "./lib/index.umd.js",
11-
"module": "./lib/index.es.js",
12-
"types": "./lib/index.d.ts",
10+
"main": "./dist/index.cjs.js",
11+
"module": "./dist/index.es.js",
12+
"types": "./dist/index.d.ts",
1313
"exports": {
1414
".": {
15-
"import": "./lib/index.es.js",
16-
"require": "./lib/index.umd.js"
15+
"require": "./dist/index.cjs.js",
16+
"import": "./dist/index.es.js"
1717
}
1818
},
1919
"scripts": {
@@ -31,7 +31,8 @@
3131

3232
},
3333
"dependencies": {
34-
"@web3uikit/styles": "0.1.0",
34+
"@web3uikit/config": "*",
35+
"@web3uikit/styles": "*",
3536
"react-blockies": "^1.4.1"
3637
}
3738
}

packages/core/tsconfig.json

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
{
2-
"extends": "../../tsconfig.ui.json",
2+
"extends": "@web3uikit/config/tsconfig.ui.json",
33
"compilerOptions": {
44
"baseUrl": ".",
5-
"declarationDir": "lib",
6-
"emitDeclarationOnly": true,
75
"rootDir": "src"
86
},
9-
"include": ["src"],
10-
"exclude": ["node_modules", "package.json"]
7+
"include": ["src", "index.ts"]
118
}

packages/core/vite.config.ts

+2-32
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,4 @@
1-
import path from 'path';
2-
import react from '@vitejs/plugin-react';
3-
import tsconfigPaths from 'vite-tsconfig-paths';
4-
51
import { defineConfig } from 'vite';
6-
const { name, version } = require('./package.json');
7-
8-
import dts from 'vite-plugin-dts';
2+
import config from './node_modules/@web3uikit/config/vite.config';
93

10-
export default defineConfig({
11-
define: {
12-
pkgJson: { name, version },
13-
},
14-
plugins: [react(), tsconfigPaths(), dts({ entryRoot: './src' })],
15-
build: {
16-
lib: {
17-
entry: path.resolve(__dirname, 'src/index.ts'),
18-
fileName: 'index',
19-
formats: ['es'],
20-
},
21-
outDir: './lib',
22-
rollupOptions: {
23-
// externalize deps that shouldn't be bundled
24-
external: ['react', 'react-dom'],
25-
output: {
26-
// global vars to use in UMD build for externalized deps
27-
globals: {
28-
react: 'React',
29-
'react-dom': 'ReactDOM',
30-
},
31-
},
32-
},
33-
},
34-
});
4+
export default defineConfig({ ...config(__dirname) });

packages/styles/package.json

+9-6
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
"sideEffects": false,
66
"files": [
77
"package.json",
8-
"lib"
8+
"dist"
99
],
10-
"main": "./lib/index.umd.js",
11-
"module": "./lib/index.es.js",
12-
"types": "./lib/index.d.ts",
10+
"main": "./dist/index.cjs.js",
11+
"module": "./dist/index.es.js",
12+
"types": "./dist/index.d.ts",
1313
"exports": {
1414
".": {
15-
"import": "./lib/index.es.js",
16-
"require": "./lib/index.umd.js"
15+
"require": "./dist/index.cjs.js",
16+
"import": "./dist/index.es.js"
1717
}
1818
},
1919
"scripts": {
@@ -26,5 +26,8 @@
2626
"devDependencies": {
2727
"react": "^18.0.0",
2828
"react-dom": "^18.0.0"
29+
},
30+
"dependencies": {
31+
"@web3uikit/config": "*"
2932
}
3033
}

packages/styles/tsconfig.json

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
{
2-
"extends": "../../tsconfig.ui.json",
2+
"extends": "@web3uikit/config/tsconfig.ui.json",
33
"compilerOptions": {
44
"baseUrl": ".",
5-
"declarationDir": "lib",
6-
"emitDeclarationOnly": true,
7-
"rootDir": "src"
5+
"rootDir": "src",
86
},
9-
"include": ["src"],
10-
"exclude": ["node_modules", "package.json"]
7+
"include": ["src"]
118
}

packages/styles/vite.config.ts

+2-32
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,4 @@
1-
import path from 'path';
2-
import react from '@vitejs/plugin-react';
3-
import tsconfigPaths from 'vite-tsconfig-paths';
4-
51
import { defineConfig } from 'vite';
6-
const { name, version } = require('./package.json');
7-
8-
import dts from 'vite-plugin-dts';
2+
import config from './node_modules/@web3uikit/config/vite.config';
93

10-
export default defineConfig({
11-
define: {
12-
pkgJson: { name, version }
13-
},
14-
plugins: [react(), tsconfigPaths(), dts({ entryRoot: './src' })],
15-
build: {
16-
lib: {
17-
entry: path.resolve(__dirname, 'src/index.ts'),
18-
fileName: 'index',
19-
formats: ['es']
20-
},
21-
outDir: './lib',
22-
rollupOptions: {
23-
// externalize deps that shouldn't be bundled
24-
external: ['react', 'react-dom'],
25-
output: {
26-
// global vars to use in UMD build for externalized deps
27-
globals: {
28-
react: 'React',
29-
'react-dom': 'ReactDOM'
30-
}
31-
}
32-
}
33-
}
34-
});
4+
export default defineConfig({ ...config(__dirname) });

packages/ui/package.json

+9-8
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
"sideEffects": false,
66
"files": [
77
"package.json",
8-
"lib"
8+
"dist"
99
],
10-
"main": "./lib/index.umd.js",
11-
"module": "./lib/index.es.js",
12-
"types": "./lib/index.d.ts",
10+
"main": "./dist/index.cjs.js",
11+
"module": "./dist/index.es.js",
12+
"types": "./dist/index.d.ts",
1313
"exports": {
1414
".": {
15-
"import": "./lib/index.es.js",
16-
"require": "./lib/index.umd.js"
15+
"require": "./dist/index.cjs.js",
16+
"import": "./dist/index.es.js"
1717
}
1818
},
1919
"scripts": {
@@ -32,8 +32,9 @@
3232
"dependencies": {
3333
"@ethersproject/transactions": "^5.6.2",
3434
"@moralisweb3/evm-wallet-connect-connector": "2.0.0-alpha.1",
35-
"@web3uikit/core": "0.1.0",
36-
"@web3uikit/styles": "0.1.0",
35+
"@web3uikit/config": "*",
36+
"@web3uikit/core": "*",
37+
"@web3uikit/styles": "*",
3738
"react-blockies": "^1.4.1"
3839
}
3940
}

packages/ui/src/lib/ConnectButton/ConnectButton.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Button } from "@web3uikit/core"
1+
import { Button } from "@web3uikit/core"
22
import Moralis from '@moralisweb3/evm-wallet-connect-connector'
33
export const ConnectButton = () => {
44
return (

0 commit comments

Comments
 (0)