Skip to content

Commit

Permalink
build: split devDependencies into sub modules
Browse files Browse the repository at this point in the history
  • Loading branch information
e7h4n committed Dec 7, 2024
1 parent 6aba3e4 commit d9ee255
Show file tree
Hide file tree
Showing 36 changed files with 2,642 additions and 2,300 deletions.
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
dist
pnpm-lock.yaml
32 changes: 29 additions & 3 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import tseslint from 'typescript-eslint';
import { config, configs } from 'typescript-eslint';
import vitest from 'eslint-plugin-vitest';
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
import importPlugin from 'eslint-plugin-import';

export default tseslint.config(
export default config(
{
extends: [...tseslint.configs.strictTypeChecked, ...tseslint.configs.stylisticTypeChecked],
extends: [...configs.strictTypeChecked, ...configs.stylisticTypeChecked],
files: ['**/*.ts', '**/*.tsx'],
languageOptions: {
parserOptions: {
Expand All @@ -22,6 +23,31 @@ export default tseslint.config(
...vitest.configs.recommended.rules,
},
},
importPlugin.flatConfigs.recommended,
{
settings: {
'import/parsers': {
'@typescript-eslint/parser': ['.ts', '.tsx'],
},
'import/resolver': {
typescript: {
project: ['tsconfig.json', 'packages/*/tsconfig.json'],
},
node: {
project: ['tsconfig.json', 'packages/*/tsconfig.json'],
},
},
},
rules: {
'import/no-extraneous-dependencies': ['error'],
},
},
{
languageOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
},
},
eslintPluginPrettierRecommended,
{ ignores: ['**/dist/', 'coverage/'] },
);
10 changes: 10 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@
"postbuild": "pnpm run --sequential '/^postbuild:.*/'",
"postbuild:copy": "pnpm -F rippling exec shx cp package.json ../../README.md ../../LICENSE dist",
"postbuild:patch:package_private": "pnpm -F rippling exec json -I -f dist/package.json -e \"this.private=false;\"",
"postbuild:patch:package_dev_deps": "pnpm -F rippling exec json -I -f dist/package.json -e \"this.devDependencies=undefined;\"",
"postbuild:patch:package_scripts": "pnpm -F rippling exec json -I -f dist/package.json -e \"this.scripts=undefined;\"",
"postbuild:patch:package_dist_main": "pnpm -F rippling exec json -I -f dist/package.json -e \"this.main='./index.cjs';\"",
"postbuild:patch:package_dist_dot_import": "pnpm -F rippling exec json -I -f dist/package.json -e \"this.exports['.'].import='./index.js';\"",
"postbuild:patch:package_dist_dot_require": "pnpm -F rippling exec json -I -f dist/package.json -e \"this.exports['.'].require='./index.cjs';\"",
"postbuild:patch:package_dist_sub_import": "pnpm -F rippling exec json -I -f dist/package.json -e \"this.exports['./*'].import='./*/index.js';\"",
"postbuild:patch:package_dist_sub_require": "pnpm -F rippling exec json -I -f dist/package.json -e \"this.exports['./*'].require='./*/index.cjs';\"",
"dev:devtools": "pnpm -F rippling-devtools exec vite",
"preview:devtools": "pnpm -F rippling-devtools exec vite build --watch",
"ci:version": "changeset version && pnpm lint-staged",
Expand Down Expand Up @@ -62,6 +69,8 @@
"autoprefixer": "^10.4.20",
"eslint": "^9.10.0",
"eslint-config-prettier": "^9.1.0",
"eslint-import-resolver-typescript": "^3.7.0",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-vitest": "^0.5.4",
"happy-dom": "^15.11.7",
Expand All @@ -81,6 +90,7 @@
"shx": "^0.3.4",
"signal-timers": "^1.0.4",
"tailwindcss": "^3.4.16",
"tsconfig-moon": "^1.3.0",
"typescript": "^5.6.3",
"typescript-eslint": "^8.15.0",
"vite": "^6.0.3",
Expand Down
13 changes: 11 additions & 2 deletions packages/devtools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,16 @@
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"dependencies": {
"rippling": "workspace:*"
"devDependencies": {
"@playwright/test": "^1.49.0",
"@testing-library/jest-dom": "^6.6.3",
"@types/react": "^18.3.12",
"@types/react-dom": "^18.3.1",
"playwright": "^1.49.0",
"react": "^18.3.1",
"react-json-view": "^1.21.3",
"rippling": "workspace:^",
"vite": "^6.0.3",
"vitest": "^2.1.8"
}
}
16 changes: 3 additions & 13 deletions packages/devtools/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
{
"extends": "../../tsconfig.options.json",
"compilerOptions": {
"target": "ES2020",
"jsx": "react-jsx",
"useDefineForClassFields": true,
"lib": ["ES2020", "DOM"],
"module": "ESNext",
/* Bundler mode */
"moduleResolution": "bundler",
"isolatedModules": true,
"moduleDetection": "force",
"composite": false,
"noEmit": true,
/* Linting */
"strict": true
"jsx": "react-jsx"
},
"include": ["src", "e2e", "vite.config.ts", "vitest.config.ts", "playwright.config.ts"]
"include": ["src/**/*", "e2e/**/*", "vite.config.ts", "vitest.config.ts", "playwright.config.ts"]
}
3 changes: 1 addition & 2 deletions packages/devtools/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { defineConfig } from 'vitest/config';
import { configDefaults } from 'vitest/config';
import { configDefaults, defineConfig } from 'vitest/config';

export default defineConfig({
test: {
Expand Down
4 changes: 2 additions & 2 deletions packages/rippling/__bench__/atom-read.bench.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { bench, describe } from 'vitest';
import { setupStore, setupStoreWithoutSub } from './case';
import { Value } from '../src';
import { PrimitiveAtom } from 'jotai/vanilla';
import type { Value } from '../src';
import type { PrimitiveAtom } from 'jotai/vanilla';
import { ripplingStrategy } from './strategy/rippling';
import { jotaiStrategy } from './strategy/jotai';
import { signalStrategy } from './strategy/signals';
Expand Down
4 changes: 2 additions & 2 deletions packages/rippling/__bench__/atom-read.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect, test } from 'vitest';
import { setupStore } from './case';
import { Value } from '../src';
import { PrimitiveAtom } from 'jotai/vanilla';
import type { Value } from '../src';
import type { PrimitiveAtom } from 'jotai/vanilla';
import { ripplingStrategy } from './strategy/rippling';
import { jotaiStrategy } from './strategy/jotai';
import { signalStrategy } from './strategy/signals';
Expand Down
2 changes: 1 addition & 1 deletion packages/rippling/__bench__/case.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Strategy } from './strategy/type';
import type { Strategy } from './strategy/type';

function fib(n: number): number {
if (n <= 1) return n;
Expand Down
5 changes: 3 additions & 2 deletions packages/rippling/__bench__/strategy/jotai.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { atom, Atom, createStore, PrimitiveAtom } from 'jotai/vanilla';
import { Strategy } from './type';
import { atom, createStore } from 'jotai/vanilla';
import type { Strategy } from './type';
import type { Atom, PrimitiveAtom } from 'jotai/vanilla';

export const jotaiStrategy: Strategy<Atom<number>, ReturnType<typeof createStore>> = {
createStore() {
Expand Down
5 changes: 3 additions & 2 deletions packages/rippling/__bench__/strategy/rippling.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Strategy } from './type';
import { createStore, Computed, Value, $computed, $effect, $value } from '../../src';
import type { Strategy } from './type';
import { createStore, $computed, $effect, $value } from '../../src';
import type { Computed, Value } from '../../src';

export const ripplingStrategy: Strategy<Value<number> | Computed<number>, ReturnType<typeof createStore>> = {
createStore() {
Expand Down
7 changes: 4 additions & 3 deletions packages/rippling/__bench__/strategy/signals.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { computed, effect, signal, Signal } from '@preact/signals';
import { Strategy } from './type';
import { computed, effect, signal } from '@preact/signals';
import type { Signal } from '@preact/signals';
import type { Strategy } from './type';

interface SignalStore {
set: (signal: Signal<number>, value: number) => void;
Expand All @@ -20,8 +21,8 @@ export const signalStrategy: Strategy<Signal<number>, SignalStore> = {
},
sub(store, signal, callback) {
return effect(() => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const a = signal.value;
void a;
callback();
});
},
Expand Down
14 changes: 14 additions & 0 deletions packages/rippling/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,19 @@
"react": {
"optional": true
}
},
"devDependencies": {
"@codspeed/vitest-plugin": "^3.1.1",
"@preact/signals": "^1.3.1",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-node-resolve": "^15.3.0",
"@testing-library/react": "^16.0.1",
"@testing-library/user-event": "^14.5.2",
"@types/react": "^18.3.12",
"jest-leak-detector": "^29.7.0",
"jotai": "^2.10.3",
"rollup-plugin-dts": "^6.1.1",
"signal-timers": "^1.0.4",
"vitest": "^2.1.8"
}
}
3 changes: 2 additions & 1 deletion packages/rippling/src/core/__tests__/memory.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import LeakDetector from 'jest-leak-detector';
import { expect, it } from 'vitest';
import { $value, Value, Computed, $computed, createStore, $effect } from '..';
import { $value, $computed, createStore, $effect } from '..';
import { createDebugStore } from '../../debug';
import type { Computed, Value } from '..';

it('should release memory after delete value', async () => {
const store = createStore();
Expand Down
3 changes: 2 additions & 1 deletion packages/rippling/src/core/__tests__/rippling.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { expect, test, vi } from 'vitest';
import { $value, createStore, Value, $computed, Computed, $effect, Effect } from '..';
import { $value, createStore, $computed, $effect } from '..';
import type { Computed, Effect, Value } from '..';
import { createDebugStore } from '../../debug';

test('should work', () => {
Expand Down
3 changes: 2 additions & 1 deletion packages/rippling/src/core/__tests__/store.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { describe, expect, it, vi } from 'vitest';
import { $computed, createStore, $effect, $value, Getter } from '..';
import { $computed, createStore, $effect, $value } from '..';
import type { Getter } from '..';
import { suspense } from './utils';
import { createDebugStore } from '../../debug';

Expand Down
2 changes: 1 addition & 1 deletion packages/rippling/src/core/atom-manager.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ReadableAtom, Effect, Getter, Computed, Value } from '../../types/core/atom';
import type { ReadableAtom, Effect, Getter, Computed, Value } from '../../types/core/atom';
const EMPTY_MAP = new Map<ReadableAtom<unknown>, number>();

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

interface Options {
debugLabel?: string;
Expand Down
7 changes: 3 additions & 4 deletions packages/rippling/src/core/store.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ReadableAtom, Effect, Getter, Value, Updater, Setter } from '../../types/core/atom';
import { Store } from '../../types/core/store';
import type { ReadableAtom, Effect, Getter, Value, Updater, Setter } from '../../types/core/atom';
import type { Store } from '../../types/core/store';
import { AtomManager, ListenerManager } from './atom-manager';

export class StoreImpl implements Store {
Expand All @@ -8,8 +8,6 @@ export class StoreImpl implements Store {
protected readonly listenerManager: ListenerManager,
) {}

private isOuterSet = false;

private innerSet = <T, Args extends unknown[]>(
atom: Value<T> | Effect<T, Args>,
...args: [T | Updater<T>] | Args
Expand Down Expand Up @@ -37,6 +35,7 @@ export class StoreImpl implements Store {
atomState.val = newValue;
atomState.epoch += 1;
this.listenerManager.markPendingListeners(this.atomManager, atom);
return undefined;
};

get: Getter = <T>(atom: ReadableAtom<T>): T => {
Expand Down
11 changes: 6 additions & 5 deletions packages/rippling/src/debug/debug-store.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { DebugStore } from '../../types/debug/debug-store';
import { NestedAtom } from '../../types/debug/util';
import { Computed, Effect, Subscribe, Value } from '../core';
import { AtomManager, ComputedState, ListenerManager } from '../core/atom-manager';
import type { DebugStore } from '../../types/debug/debug-store';
import type { NestedAtom } from '../../types/debug/util';
import type { Computed, Effect, Subscribe, Value } from '../core';
import { AtomManager, ListenerManager } from '../core/atom-manager';
import type { ComputedState } from '../core/atom-manager';
import { StoreImpl } from '../core/store';

class DebugStoreImpl extends StoreImpl implements DebugStore {
private readonly subscribedAtoms = new Map<Value<unknown> | Computed<unknown>, number>();

sub: Subscribe = (
override sub: Subscribe = (
atoms: (Value<unknown> | Computed<unknown>)[] | (Value<unknown> | Computed<unknown>),
cbEffect: Effect<unknown, unknown[]>,
): (() => void) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/rippling/src/debug/util.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NestedAtom, NestedString } from '../../types/debug/util';
import type { NestedAtom, NestedString } from '../../types/debug/util';

export function nestedAtomToString(atoms: NestedAtom): NestedString {
return atoms.map((atom) => {
Expand Down
3 changes: 2 additions & 1 deletion packages/rippling/src/react/__tests__/loadable.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import { render, cleanup, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { afterEach, expect, it, vi } from 'vitest';
import { $computed, createStore, $value, Value, Computed } from '../../core';
import { $computed, createStore, $value } from '../../core';
import type { Computed, Value } from '../../core';
import { StrictMode, useEffect, version as reactVersion, Suspense } from 'react';
import { StoreProvider, useGet, useSet, useLoadable } from '..';
import { delay } from 'signal-timers';
Expand Down
3 changes: 2 additions & 1 deletion packages/rippling/src/react/__tests__/memory.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import LeakDetector from 'jest-leak-detector';
import { expect, it } from 'vitest';
import { $value, Value, createStore } from '../../core';
import { $value, createStore } from '../../core';
import type { Value } from '../../core';
import { useGet, StoreProvider } from '../';
import { cleanup, render } from '@testing-library/react';

Expand Down
2 changes: 1 addition & 1 deletion packages/rippling/src/react/provider.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createContext, useContext } from 'react';
import { Store } from '../core';
import type { Store } from '../core';

const StoreContext = createContext<Store | null>(null);

Expand Down
3 changes: 2 additions & 1 deletion packages/rippling/src/react/useGet.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useSyncExternalStore } from 'react';
import { useStore } from './provider';
import { $effect, Computed, Value } from '../core';
import { $effect } from '../core';
import type { Computed, Value } from '../core';

export function useGet<T>(atom: Value<T> | Computed<T>) {
const store = useStore();
Expand Down
2 changes: 1 addition & 1 deletion packages/rippling/src/react/useLoadable.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useEffect, useState } from 'react';
import { useGet } from './useGet';
import { Computed, Value } from '../core';
import type { Computed, Value } from '../core';

type Loadable<T> =
| {
Expand Down
2 changes: 1 addition & 1 deletion packages/rippling/src/react/useResolved.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Computed, Value } from '../core';
import { useLoadable } from './useLoadable';
import type { Computed, Value } from '../core';

export function useResolved<T>(atom: Value<Promise<T>> | Computed<Promise<T>>): T | undefined {
const loadable = useLoadable(atom);
Expand Down
2 changes: 1 addition & 1 deletion packages/rippling/src/react/useSet.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Effect, Updater, Value } from '../core';
import { useStore } from './provider';
import type { Effect, Updater, Value } from '../core';

export function useSet<T>(atom: Value<T>): (value: T | Updater<T>) => void;
export function useSet<T, ARGS extends unknown[]>(atom: Effect<T, ARGS>): (...args: ARGS) => T;
Expand Down
16 changes: 3 additions & 13 deletions packages/rippling/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
{
"extends": "../../tsconfig.options.json",
"compilerOptions": {
"target": "ES2020",
"jsx": "react-jsx",
"useDefineForClassFields": true,
"lib": ["ES2020", "DOM"],
"module": "ESNext",
/* Bundler mode */
"moduleResolution": "bundler",
"isolatedModules": true,
"moduleDetection": "force",
"composite": false,
"noEmit": true,
/* Linting */
"strict": true
"jsx": "react-jsx"
},
"include": ["src", "types", "__bench__", "vitest.config.ts"]
"include": ["src/**/*", "types/**/*", "__bench__/**/*", "vitest.config.ts"]
}
2 changes: 1 addition & 1 deletion packages/rippling/types/core/store.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ReadableAtom, Effect, Getter, Setter } from './atom';
import type { ReadableAtom, Effect, Getter, Setter } from './atom';

export interface Store {
get: Getter;
Expand Down
6 changes: 3 additions & 3 deletions packages/rippling/types/debug/debug-store.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Computed, Value } from '../core/atom';
import { Store } from '../core/store';
import { NestedAtom } from './util';
import type { Computed, Value } from '../core/atom';
import type { Store } from '../core/store';
import type { NestedAtom } from './util';

export interface DebugStore extends Store {
getReadDependencies: (atom: Computed<unknown>) => NestedAtom;
Expand Down
Loading

0 comments on commit d9ee255

Please sign in to comment.