Skip to content

Commit

Permalink
refactor: monorepo
Browse files Browse the repository at this point in the history
  • Loading branch information
e7h4n committed Dec 6, 2024
1 parent 127159a commit 54690b0
Show file tree
Hide file tree
Showing 61 changed files with 404 additions and 400 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
- name: Run test
uses: CodSpeedHQ/action@v3
with:
run: CI=true ${{ env.RUNNER_DEBUG && 'DEBUG=pw:api' || '' }} pnpm test
run: CI=true pnpm test
token: ${{ secrets.CODSPEED_TOKEN }}

- name: "Report Coverage"
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ dist-ssr
coverage/
*.tgz
playwright-report/
test-results/
test-results/
*.tsbuildinfo
67 changes: 14 additions & 53 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,26 @@
{
"name": "rippling",
"version": "0.1.0",
"private": true,
"repository": {
"type": "git",
"url": "git+/~https://github.com/e7h4n/rippling.git"
},
"license": "MIT",
"private": true,
"type": "module",
"scripts": {
"format": "prettier '*.{js,json,md}' '{src,tests,benchmarks,docs}/**/*.{ts,tsx,md,mdx}' --write",
"format": "prettier '**/*.{js,json,md,ts,tsx,md,mdx}' --write",
"test": "pnpm '/^test:.*/'",
"test:unit": "vitest --run --coverage",
"test:lint": "eslint .",
"test:format": "prettier '*.{js,json,md}' '{src,tests,benchmarks,docs}/**/*.{ts,tsx,md,mdx}' --list-different",
"test:type": "tsc --noEmit",
"test:format": "prettier '**/*.{js,json,md,ts,tsx,md,mdx}' --list-different",
"test:type": "pnpm -F '*' tsc --noEmit",
"test:bench": "vitest bench --run",
"test:e2e": "playwright test e2e",
"build": "pnpm '/^build:.*/'",
"build:lib": "rollup -c",
"build:devtool": "vite build -c packages/devtool/vite.config.ts",
"prebuild": "shx rm -rf dist && mkdir dist",
"postbuild": "pnpm run --sequential '/^postbuild:.*/'",
"postbuild:copy": "shx cp package.json README.md LICENSE dist",
"postbuild:patch:package_private": "json -I -f dist/package.json -e \"this.private=false;\"",
"postbuild:patch:package_dev_deps": "json -I -f dist/package.json -e \"this.devDependencies=undefined;\"",
"postbuild:patch:package_scripts": "json -I -f dist/package.json -e \"this.scripts=undefined;\"",
"build:lib": "pnpm -F '!devtool' exec rollup -c",
"build:devtool": "pnpm -F devtool exec vite build",
"prebuild": "pnpm -F '*' shx rm -rf dist",
"dev:devtool": "vite build --watch --mode development --config packages/devtool/vite.config.ts"
},
"engines": {
Expand All @@ -39,12 +35,13 @@
"@preact/signals": "^1.3.1",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-node-resolve": "^15.3.0",
"@rollup/plugin-typescript": "^12.1.1",
"@testing-library/dom": "^10.4.0",
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/react": "^16.0.1",
"@testing-library/user-event": "^14.5.2",
"@types/chrome": "^0.0.287",
"@types/node": "^22.5.5",
"@types/node": "^22.9.1",
"@types/react": "^18.3.12",
"@types/react-dom": "^18.3.1",
"@vitest/browser": "^2.1.6",
Expand All @@ -56,7 +53,6 @@
"happy-dom": "^15.11.7",
"jest-leak-detector": "^29.7.0",
"jotai": "^2.10.3",
"jsdom": "^25.0.1",
"json": "^11.0.0",
"playwright": "^1.49.0",
"postcss": "^8.4.49",
Expand All @@ -69,44 +65,9 @@
"shx": "^0.3.4",
"signal-timers": "^1.0.4",
"tailwindcss": "^3.4.16",
"typescript": "^5.6.2",
"typescript-eslint": "^8.6.0",
"typescript": "^5.6.3",
"typescript-eslint": "^8.15.0",
"vite": "^6.0.3",
"vitest": "^2.1.1"
},
"type": "module",
"files": [
"."
],
"main": "./index.cjs",
"exports": {
".": {
"import": "./index.js",
"require": "./index.cjs"
},
"./react": {
"import": "./react/index.js",
"require": "./react/index.cjs"
},
"./debug": {
"import": "./debug/index.js",
"require": "./debug/index.cjs"
},
"./core": {
"import": "./core/index.js",
"require": "./core/index.cjs"
}
},
"peerDependencies": {
"@types/react": ">=17.0.0",
"react": ">=17.0.0"
},
"peerDependenciesMeta": {
"@types/react": {
"optional": true
},
"react": {
"optional": true
}
"vitest": "^2.1.5"
}
}
}
15 changes: 0 additions & 15 deletions packages/aio/index.ts

This file was deleted.

24 changes: 0 additions & 24 deletions packages/aio/tsconfig.json

This file was deleted.

2 changes: 1 addition & 1 deletion packages/core/__tests__/store.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { describe, expect, it, vi } from "vitest";
import { $computed, createStore, $effect, $value } from "..";
import { suspense } from "./utils";
import { Getter } from "../typing/atom";
import { Getter } from "../types/atom";
import { createDebugStore } from "../../debug";

it("should not fire on subscribe", () => {
Expand Down
11 changes: 0 additions & 11 deletions packages/core/index.ts

This file was deleted.

12 changes: 12 additions & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "@rippling/core",
"private": true,
"version": "1.0.0",
"description": "Rippling Core",
"type": "module",
"main": "./dist/index.cjs",
"exports": {
"import": "./dist/index.js",
"require": "./dist/index.cjs"
}
}
9 changes: 9 additions & 0 deletions packages/core/rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import * as fs from "node:fs";
import { createTarget } from "../../shared/rollup.config.mjs";


const pkg = JSON.parse(
fs.readFileSync("./package.json", { encoding: "utf-8" }),
);

export default createTarget(pkg);
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ReadableAtom, Effect, Getter, Computed, Value } from "../typing/atom";
import { ReadableAtom, Effect, Getter, Computed, Value } from "../types/atom";
const EMPTY_MAP = new Map<ReadableAtom<unknown>, number>();

export interface StateState<T> {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/chore/atom.ts → packages/core/src/atom.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Computed, Effect, Read, Value, Write } from "../typing/atom";
import { Computed, Effect, Read, Value, Write } from "../types/atom";

interface Options {
debugLabel?: string;
Expand Down
14 changes: 14 additions & 0 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export { $value, $computed, $effect } from "./atom";
export { createStore, CoreStore } from "./store";
export { AtomManager, ListenerManager } from "./atom-manager";

export type {
Value,
Computed,
Effect,
Getter,
Setter,
Updater,
} from "../types/atom";
export type { Subscribe, Store } from "../types/store";
export type { ComputedState } from "./atom-manager";
8 changes: 4 additions & 4 deletions packages/core/chore/store.ts → packages/core/src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import {
Value,
Updater,
Setter,
} from "../typing/atom";
import { Store } from "../typing/store";
} from "../types/atom";
import { Store } from "../types/store";
import { AtomManager, ListenerManager } from "./atom-manager";

export class StoreImpl implements Store {
export class CoreStore implements Store {
constructor(
protected readonly atomManager: AtomManager,
protected readonly listenerManager: ListenerManager,
Expand Down Expand Up @@ -117,5 +117,5 @@ export function createStore(): Store {
const atomManager = new AtomManager();
const listenerManager = new ListenerManager();

return new StoreImpl(atomManager, listenerManager);
return new CoreStore(atomManager, listenerManager);
}
15 changes: 6 additions & 9 deletions packages/core/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"composite": true,
"noEmit": false
},
"include": [
"**/*"
]
}
"extends": "../../tsconfig.json",
"compilerOptions": {
"composite": true
},
"include": ["."]
}
File renamed without changes.
File renamed without changes.
5 changes: 1 addition & 4 deletions packages/core/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import { defineConfig } from "vitest/config";
import codspeedPlugin from "@codspeed/vitest-plugin";

export default defineConfig({
plugins: process.env.CI === "true" ? [codspeedPlugin()] : [],
});
export default defineConfig({});
4 changes: 2 additions & 2 deletions packages/debug/__tests__/debug.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect, it } from "vitest";
import { $computed, $effect, $value } from "../../core";
import { createDebugStore } from "../chore/debug-store";
import { nestedAtomToString } from "../chore/util";
import { createDebugStore } from "../src/debug-store";
import { nestedAtomToString } from "../src/util";

it("get all subscribed atoms", () => {
const store = createDebugStore();
Expand Down
3 changes: 0 additions & 3 deletions packages/debug/index.ts

This file was deleted.

15 changes: 15 additions & 0 deletions packages/debug/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "@rippling/debug",
"private": true,
"version": "1.0.0",
"description": "Debug utilities for rippling",
"dependencies": {
"@rippling/core": "workspace:^"
},
"type": "module",
"main": "./dist/index.cjs",
"exports": {
"import": "./dist/index.js",
"require": "./dist/index.cjs"
}
}
9 changes: 9 additions & 0 deletions packages/debug/rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import * as fs from "node:fs";
import { createTarget } from "../../shared/rollup.config.mjs";


const pkg = JSON.parse(
fs.readFileSync("./package.json", { encoding: "utf-8" }),
);

export default createTarget(pkg);
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
import { Computed, Effect, Subscribe, Value } from "../../core";
import {
AtomManager,
ComputedState,
ListenerManager,
} from "../../core/chore/atom-manager";
import { StoreImpl } from "../../core/chore/store";
import { DebugStore } from "../typing/debug-store";
import { NestedAtom } from "../typing/util";
import { Computed, Effect, Subscribe, Value, CoreStore } from "@rippling/core";
import { AtomManager, ComputedState, ListenerManager } from "@rippling/core";
import { DebugStore } from "../types/debug-store";
import { NestedAtom } from "../types/util";

class DebugStoreImpl extends StoreImpl implements DebugStore {
class DebugStoreImpl extends CoreStore implements DebugStore {
private readonly subscribedAtoms = new Map<
Value<unknown> | Computed<unknown>,
number
Expand Down
4 changes: 4 additions & 0 deletions packages/debug/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export { createDebugStore } from "./debug-store";
export type { DebugStore } from "../types/debug-store";
export { nestedAtomToString } from "./util";

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NestedAtom, NestedString } from "../typing/util";
import { NestedAtom, NestedString } from "../types/util";

export function nestedAtomToString(atoms: NestedAtom): NestedString {
return atoms.map((atom) => {
Expand Down
20 changes: 6 additions & 14 deletions packages/debug/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"composite": true,
"noEmit": false
},
"include": [
"."
],
"references": [
{
"path": "../core"
}
]
}
"extends": "../../tsconfig.json",
"compilerOptions": {
"composite": true
},
"include": ["."]
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Computed, Store, Value } from "../../core";
import { Computed, Store, Value } from "@rippling/core";
import { NestedAtom } from "./util";

export interface DebugStore extends Store {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Computed, Effect, Value } from "../../core";
import { Computed, Effect, Value } from "@rippling/core";

export type NestedAtom = (
| Value<unknown>
Expand Down
Loading

0 comments on commit 54690b0

Please sign in to comment.