Skip to content
This repository was archived by the owner on Apr 7, 2024. It is now read-only.

Commit a83c78c

Browse files
authored
Create config to build the npm package (#80)
* Start working on npm package build configs * Update package.json * Continue working on package * Add build config * Some changes * Some changes * Finally finish build config * Add eslint plugin
1 parent c9498d0 commit a83c78c

File tree

24 files changed

+1304
-738
lines changed

24 files changed

+1304
-738
lines changed

.eslintignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
babel.config.js
2+
babel.config.cjs.js
3+
babel.config.esm.js
24
metro.config.js
35
tailwind.config.js
6+
bob.config.js
47
index.js
8+
9+
# generated by bob
10+
dist/

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,5 @@ yarn-error.log
6262
# Temporary files created by Metro to check the health of the file watcher
6363
.metro-health-check*
6464

65-
# Turbo module logs and cache directory
66-
.turbo
65+
# generated by bob
66+
dist/

babel.config.cjs.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
module.exports = {
2+
presets: [
3+
[
4+
'@babel/preset-env',
5+
{
6+
modules: 'commonjs',
7+
useBuiltIns: false,
8+
targets: {
9+
browsers: [
10+
'>1%',
11+
'last 2 chrome versions',
12+
'last 2 edge versions',
13+
'last 2 firefox versions',
14+
'last 2 safari versions',
15+
'not dead',
16+
'not ie <= 11',
17+
'not op_mini all',
18+
'not android <= 4.4',
19+
'not samsung <= 4'
20+
],
21+
node: '16'
22+
}
23+
}
24+
],
25+
'@babel/preset-react',
26+
'@babel/preset-typescript'
27+
],
28+
plugins: [
29+
[
30+
'module-resolver',
31+
{
32+
root: ['./'],
33+
extensions: ['.ts', '.tsx', '.svg', '.json'],
34+
alias: {
35+
// This needs to be mirrored in tsconfig.json
36+
'@': './src'
37+
}
38+
}
39+
],
40+
'react-require'
41+
],
42+
comments: false
43+
};

babel.config.esm.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
module.exports = {
2+
presets: [
3+
[
4+
'@babel/preset-env',
5+
{
6+
modules: false,
7+
useBuiltIns: false,
8+
targets: {
9+
browsers: [
10+
'>1%',
11+
'last 2 chrome versions',
12+
'last 2 edge versions',
13+
'last 2 firefox versions',
14+
'last 2 safari versions',
15+
'not dead',
16+
'not ie <= 11',
17+
'not op_mini all',
18+
'not android <= 4.4',
19+
'not samsung <= 4'
20+
],
21+
node: '16'
22+
}
23+
}
24+
],
25+
'@babel/preset-react',
26+
'@babel/preset-typescript'
27+
],
28+
plugins: [
29+
[
30+
'module-resolver',
31+
{
32+
root: ['./'],
33+
extensions: ['.ts', '.tsx', '.svg', '.json'],
34+
alias: {
35+
// This needs to be mirrored in tsconfig.json
36+
'@': './src'
37+
}
38+
}
39+
],
40+
'react-require'
41+
],
42+
comments: false
43+
};

babel.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ module.exports = {
22
presets: ['module:metro-react-native-babel-preset'],
33
plugins: [
44
'react-native-reanimated/plugin',
5-
'nativewind/babel',
65
[
76
'module-resolver',
87
{

bob.config.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
module.exports = {
2+
source: 'src',
3+
output: 'dist',
4+
targets: [
5+
[
6+
'commonjs',
7+
{
8+
configFile: './babel.config.cjs.js'
9+
}
10+
],
11+
[
12+
'module',
13+
{
14+
configFile: './babel.config.esm.js'
15+
}
16+
]
17+
]
18+
};

index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1+
/**
2+
* This file is the entry point for the tester app using the library.
3+
*
4+
* It is used to test if everything works properly.
5+
*/
16
import { AppRegistry } from 'react-native';
2-
import App from 'src/App';
7+
import App from '@/examples/Development';
38

49
import { name as appName } from './app.json';
510

package.json

Lines changed: 48 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
{
22
"name": "react-native-force-graph",
3-
"version": "0.0.1",
3+
"description": "React Native library for creating dynamic force-directed graphs",
4+
"version": "0.0.1-development",
5+
"author": {
6+
"name": "Mateusz Łopaciński",
7+
"email": "lop.mateusz.2001@gmail.com"
8+
},
49
"dependencies": {
510
"@fortawesome/fontawesome-svg-core": "^6.4.0",
6-
"@fortawesome/free-regular-svg-icons": "^6.4.0",
711
"@fortawesome/free-solid-svg-icons": "^6.4.0",
812
"@fortawesome/react-native-fontawesome": "^0.3.0",
9-
"@shopify/react-native-skia": "^0.1.193",
10-
"nativewind": "^2.0.11",
11-
"postcss": "^8.4.24",
12-
"potpack": "^2.0.0",
13-
"react": "^18.2.0",
14-
"react-native": "^0.71.8",
15-
"react-native-gesture-handler": "^2.10.2",
16-
"react-native-reanimated": "^3.2.0",
17-
"react-native-svg": "^13.9.0"
13+
"potpack": "^2.0.0"
1814
},
1915
"devDependencies": {
2016
"@babel/core": "^7.22.1",
17+
"@babel/plugin-proposal-class-properties": "^7.18.6",
18+
"@babel/plugin-proposal-private-methods": "^7.18.6",
2119
"@babel/preset-env": "^7.22.4",
2220
"@babel/runtime": "^7.22.3",
2321
"@react-native-community/eslint-config": "^3.2.0",
22+
"@shopify/react-native-skia": "^0.1.193",
2423
"@tsconfig/react-native": "^3.0.2",
2524
"@types/jest": "^29.5.2",
2625
"@types/react": "^18.2.7",
2726
"@types/react-test-renderer": "^18.0.0",
2827
"babel-jest": "^29.5.0",
2928
"babel-plugin-module-resolver": "^5.0.0",
29+
"babel-plugin-react-require": "^4.0.0",
3030
"eslint": "^8.41.0",
3131
"eslint-import-resolver-typescript": "^3.5.5",
3232
"eslint-plugin-import": "^2.27.5",
@@ -38,33 +38,65 @@
3838
"husky": "^8.0.3",
3939
"jest": "^29.5.0",
4040
"lint-staged": "^13.2.2",
41+
"merge-dirs": "^0.2.1",
4142
"metro-react-native-babel-preset": "^0.76.5",
4243
"prettier": "^2.8.8",
44+
"react": "^18.2.0",
45+
"react-native": "^0.71.8",
46+
"react-native-builder-bob": "^0.20.4",
47+
"react-native-gesture-handler": "^2.10.2",
48+
"react-native-reanimated": "^3.2.0",
49+
"react-native-svg": "^13.9.0",
4350
"react-test-renderer": "^18.2.0",
4451
"syncpack": "^10.1.0",
4552
"tailwindcss": "^3.3.2",
53+
"tsc-alias": "^1.8.6",
4654
"typescript": "^5.1.0"
4755
},
56+
"files": [
57+
"dist"
58+
],
4859
"jest": {
49-
"preset": "react-native"
60+
"preset": "react-native",
61+
"modulePathIgnorePatterns": [
62+
"<rootDir>/dist/"
63+
]
5064
},
5165
"lint-staged": {
5266
"*.{js,jsx,ts,tsx}": [
5367
"eslint --fix",
54-
"prettier --write --ignore-unknown"
68+
"prettier --write --ignore-unknown",
69+
"yarn format:deps"
5570
]
5671
},
57-
"private": true,
72+
"main": "dist/commonjs/index.js",
73+
"module": "dist/module/index.js",
74+
"peerDependencies": {
75+
"@shopify/react-native-skia": ">=0.1.193",
76+
"react": ">=18.0.0",
77+
"react-native": ">=0.71.8",
78+
"react-native-gesture-handler": ">=2.0.0",
79+
"react-native-reanimated": ">=3.0.0",
80+
"react-native-svg": ">=13.0.0"
81+
},
82+
"publishConfig": {
83+
"access": "public"
84+
},
85+
"repository": "MatiPl01/react-native-force-graph",
5886
"scripts": {
5987
"android": "react-native run-android",
60-
"build:android": "cd android && ./gradlew assembleRelease",
88+
"build": "yarn clean && bob build && yarn declarations:emit",
89+
"clean": "rm -rf dist && rm -rf react-native-force-graph*.tgz",
90+
"declarations:emit": "tsc && tsc-alias",
6191
"format:code": "prettier --write .",
6292
"format:deps": "syncpack format",
6393
"ios": "react-native run-ios",
6494
"lint": "eslint .",
6595
"lint:fix": "eslint --fix .",
96+
"prepack": "yarn build",
6697
"prepare": "husky install",
6798
"start": "react-native start",
6899
"test": "jest"
69-
}
100+
},
101+
"types": "dist/types/index.d.ts"
70102
}

src/@types/app.d.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/__tests__/App.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import React from 'react';
77
// Note: test renderer must be required after react-native.
88
import { create } from 'react-test-renderer';
99

10-
import App from '@/App';
10+
import App from '@/examples/Development';
1111

1212
it('renders correctly', () => {
1313
create(<App />);

0 commit comments

Comments
 (0)