Skip to content

Commit 10a1799

Browse files
authored
Monorepo (#150)
* refactor(monorepo): merge js sdk * refactor(monorepo): pass build, lint * refactor(monorepo): stop using prettier with beemo * refactor(monorepo): preserve prose wrap in prettier * refactor(monorepo): use vite builder and make things more standard * refactor(monorepo): remove useless package * refactor(monorepo): improve vite config * refactor(monorepo): use vite to build xstate wip * refactor(monorepo): rename simple project to empty project * refactor: rename to testing-project * refactor(monorepo): remove references to workspace in crm example * refactor(monorepo): move stuff to .config directory * refactor(monorepo): lint * refactor(monorepo): reuse root files * refactor(monorepo): rename directories according to current npm package names * refactor(monorepo): correct root package.json * refactor(monorepo): wip example with stable state management * refactor(monorepo): wip - simplify example
1 parent a26c751 commit 10a1799

File tree

136 files changed

+24813
-3139
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

136 files changed

+24813
-3139
lines changed

.changeset/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Changesets
2+
3+
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool
4+
that works with multi-package repos, or single-package repos to help you version and publish your
5+
code. You can find the full documentation for it
6+
[in our repository](https://github.com/changesets/changesets)
7+
8+
We have a quick list of common questions to get you started engaging with this project in
9+
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)

.changeset/config.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"$schema": "https://unpkg.com/@changesets/config@1.6.0/schema.json",
3+
"changelog": "@changesets/cli/changelog",
4+
"commit": false,
5+
"linked": [],
6+
"access": "restricted",
7+
"baseBranch": "main",
8+
"updateInternalDependencies": "patch",
9+
"ignore": []
10+
}

.config/.eslintignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
node_modules/
2+
build/
3+
cjs/
4+
coverage/
5+
dist/
6+
dts/
7+
esm/
8+
lib/
9+
mjs/
10+
umd/
11+
*.min.js
12+
*.map
13+
*.snap

.config/.eslintrc

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"es6": true,
5+
"node": true
6+
},
7+
"ignorePatterns": ["**/dist", "**/build", "**/.next"],
8+
"extends": ["react-app", "plugin:react/recommended", "plugin:react-hooks/recommended"],
9+
"parserOptions": {
10+
// "project": "./tsconfig.json"
11+
"project": ["packages/*/tsconfig.json", "examples/*/tsconfig.json"]
12+
},
13+
"plugins": ["react", "@typescript-eslint", "react-hooks", "simple-import-sort"],
14+
"rules": {
15+
"no-use-before-define": "off",
16+
"simple-import-sort/exports": "error",
17+
18+
"simple-import-sort/imports": [
19+
"error",
20+
{
21+
"groups": [
22+
// Node.js builtins. You could also generate this regex if you use a `.js` config.
23+
// For example: `^(${require("module").builtinModules.join("|")})(/|$)`
24+
[
25+
"^(assert|buffer|child_process|cluster|console|constants|crypto|dgram|dns|domain|events|fs|http|https|module|net|os|path|punycode|querystring|readline|repl|stream|string_decoder|sys|timers|tls|tty|url|util|vm|zlib|freelist|v8|process|async_hooks|http2|perf_hooks)(/.*|$)"
26+
],
27+
// Packages
28+
["^\\w"],
29+
// Internal packages.
30+
["^(@|config/)(/*|$)"],
31+
// Side effect imports.
32+
["^\\u0000"],
33+
// Parent imports. Put `..` last.
34+
["^\\.\\.(?!/?$)", "^\\.\\./?$"],
35+
// Other relative imports. Put same-folder imports and `.` last.
36+
["^\\./(?=.*/)(?!/?$)", "^\\.(?!/?$)", "^\\./?$"],
37+
// Style imports.
38+
["^.+\\.s?css$"]
39+
]
40+
}
41+
],
42+
"import/no-anonymous-default-export": [
43+
"error",
44+
{
45+
"allowArrowFunction": true,
46+
"allowAnonymousFunction": true
47+
}
48+
]
49+
}
50+
}

.config/.prettierignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
node_modules/
2+
build/
3+
cjs/
4+
coverage/
5+
dist/
6+
dts/
7+
esm/
8+
lib/
9+
mjs/
10+
umd/
11+
CHANGELOG.md
12+
lerna.json
13+
package.json
14+
tsconfig.json
15+
tsconfig.*.json
16+
*.d.ts

.config/jest.config.base.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
module.exports = {
2+
rootDir: process.cwd(),
3+
roots: ['<rootDir>/src', '<rootDir>/tests'],
4+
transform: {
5+
'^.+\\.ts$': 'ts-jest'
6+
},
7+
testRegex: '(/tests/.*.(test|spec)).(jsx?|tsx?)$',
8+
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
9+
collectCoverage: true,
10+
// coveragePathIgnorePatterns: ['(tests/.*.mock).(jsx?|tsx?)$'],
11+
verbose: true,
12+
testTimeout: 30000,
13+
globals: {
14+
'ts-jest': {
15+
isolatedModules: true
16+
}
17+
}
18+
}

.config/jest.config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const base = require('./jest.config.base.js')
2+
3+
module.exports = {
4+
...base,
5+
projects: ['<rootDir>/packages/*/jest.config.js'],
6+
coverageDirectory: '<rootDir>/coverage/'
7+
}

.config/prettier.config.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
module.exports = {
2+
"$schema": "http://json.schemastore.org/prettierrc",
3+
"arrowParens": "always",
4+
"bracketSameLine": false,
5+
"bracketSpacing": true,
6+
"endOfLine": "lf",
7+
"printWidth": 100,
8+
"proseWrap": "preserve",
9+
"semi": false,
10+
"singleQuote": true,
11+
"tabWidth": 2,
12+
"trailingComma": "none",
13+
"useTabs": false,
14+
"overrides": [
15+
{
16+
"files": [
17+
"*.json",
18+
"*.yaml"
19+
],
20+
"options": {
21+
"useTabs": false
22+
}
23+
}
24+
]
25+
};

.config/vite.lib.js

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import fs from 'fs'
2+
import path from 'path'
3+
4+
import { defineConfig } from 'vite'
5+
import dts from 'vite-plugin-dts'
6+
import tsconfigPaths from 'vite-tsconfig-paths'
7+
8+
// import reactRefresh from '@vitejs/plugin-react-refresh'
9+
const PWD = process.env.PWD
10+
const pkg = require(path.join(PWD, 'package.json'))
11+
12+
export const lib = {
13+
entry: path.resolve(PWD, 'src/index.ts'),
14+
name: pkg.name,
15+
fileName: 'index'
16+
}
17+
export const basePlugins = [
18+
tsconfigPaths(),
19+
dts({
20+
exclude: ['**/*.spec.ts', '**/*.test.ts'],
21+
afterBuild: () => {
22+
const types = fs.readdirSync(path.join(PWD, 'dist/src'))
23+
types.forEach((file) => {
24+
fs.renameSync(path.join(PWD, 'dist/src', file), path.join(PWD, 'dist', file))
25+
})
26+
fs.rmdirSync(path.join(PWD, 'dist/src'))
27+
}
28+
})
29+
]
30+
31+
/**
32+
* @type {import('vite').UserConfig}
33+
*/
34+
export default defineConfig({
35+
plugins: basePlugins,
36+
build: {
37+
lib
38+
}
39+
})
40+
41+
// export const react = defineConfig({
42+
// plugins: [reactRefresh(), ...basePlugins],
43+
// build: {
44+
// lib,
45+
// rollupOptions: {
46+
// external: ['react'],
47+
// output: {
48+
// globals: {
49+
// react: 'react'
50+
// }
51+
// }
52+
53+
// // external: ['react', 'vue'],
54+
// // output: {
55+
// // globals: {
56+
// // react: 'react',
57+
// // vue: 'vue'
58+
// // }
59+
// // }
60+
// }
61+
// }
62+
// })

.config/vite.lib.react.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import fs from 'fs'
2+
3+
import { defineConfig } from 'vite'
4+
5+
import react from '@vitejs/plugin-react'
6+
7+
import { basePlugins, lib } from './vite.lib'
8+
9+
if (!fs.existsSync(lib.entry)) {
10+
lib.entry = lib.entry.replace('.ts', '.tsx')
11+
}
12+
13+
/**
14+
* @type {import('vite').UserConfig}
15+
*/
16+
export default defineConfig({
17+
plugins: [react(), ...basePlugins],
18+
build: {
19+
lib,
20+
rollupOptions: {
21+
external: ['react'],
22+
output: {
23+
globals: {
24+
react: 'react'
25+
}
26+
}
27+
28+
// external: ['react', 'vue'],
29+
// output: {
30+
// globals: {
31+
// react: 'react',
32+
// vue: 'vue' // ? check
33+
// }
34+
// }
35+
}
36+
}
37+
})

0 commit comments

Comments
 (0)