Skip to content

Commit

Permalink
move configureLegendState to /config to reduce size of core
Browse files Browse the repository at this point in the history
  • Loading branch information
jmeistrich committed Aug 21, 2024
1 parent 889172a commit 977ca2b
Show file tree
Hide file tree
Showing 12 changed files with 154 additions and 152 deletions.
1 change: 1 addition & 0 deletions config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { configureLegendState } from './src/configureLegendState';
1 change: 0 additions & 1 deletion index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
export { isObserved, shouldIgnoreUnobserved } from './src/ObservableObject';
export { batch, beginBatch, endBatch } from './src/batching';
export { computed } from './src/computed';
export { configureLegendState } from './src/config';
export { event } from './src/event';
export { isObservable } from './src/globals';
export {
Expand Down
3 changes: 2 additions & 1 deletion jest.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
"moduleNameMapper": {
"@legendapp/state/sync-plugins/crud": "<rootDir>/src/sync-plugins/crud",
"@legendapp/state/sync": "<rootDir>/sync",
"@legendapp/state/config": "<rootDir>/config",
"@legendapp/state": "<rootDir>/index"
},
"transform": {
"^.+\\.tsx?$": ["ts-jest", {"tsconfig": { "jsx": "react"}}]
"^.+\\.tsx?$": ["ts-jest", { "tsconfig": { "jsx": "react" } }]
}
}
275 changes: 138 additions & 137 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,138 +1,139 @@
{
"name": "@legendapp/state",
"version": "3.0.0-alpha.28",
"description": "legend-state",
"sideEffects": false,
"private": true,
"main": "./index.js",
"module": "./index.mjs",
"types": "./index.d.ts",
"files": [
"**"
],
"engines": {
"node": ">=16.6.0",
"npm": ">=8.11.0"
},
"scripts": {
"build": "npm run lint:check && npm run format:check && bun buntestsilent && bunx tsup && bun run posttsup.ts",
"test": "jest",
"postversion": "npm run build && git push --follow-tags",
"jestclear": "jest --clearCache",
"publish:manual": "npm run build && cd dist && npm publish",
"publish:minor": "npm version minor && cd dist && npm publish",
"publish:alpharelease": "npm version prerelease --preid=alpha && cd dist && npm publish --tag alpha",
"publish:betarelease": "npm version prerelease --preid=beta && cd dist && npm publish --tag beta",
"publish:nextrelease": "npm version prerelease --preid=next && cd dist && npm publish --tag next",
"publish:patch": "npm version patch && cd dist && npm publish",
"publish:premajor": "npm version premajor --preid=next && cd dist && npm publish --tag next",
"publish:preminor": "npm version preminor --preid=next && cd dist && npm publish --tag next",
"publish:prepatch": "npm version prepatch --preid=next && cd dist && npm publish --tag next",
"publish:rcrelease": "npm version prerelease --preid=rc && cd dist && npm publish --tag rc",
"checksize:core": "npx esbuild ./testbundles/bundlecore.js --bundle --outfile=temp-built.js --minify && gzip temp-built.js && stat -f%z ./temp-built.js.gz && rm temp-built.js.*",
"checksize:react": "npx esbuild ./testbundles/bundlereact.js --bundle --outfile=temp-built.js --minify --external:react --external:@legendapp/state && gzip temp-built.js && stat -f%z ./temp-built.js.gz && rm temp-built.js.*",
"checksize": "npm run checksize:core && npm run checksize:react",
"lint:write": "eslint ./src ./tests --fix --ext .ts,.tsx",
"lint:check": "eslint ./src ./tests --ext .ts,.tsx",
"format:write": "prettier --write \"src/**/*.{js,jsx,ts,tsx}\"",
"format:check": "prettier --check \"src/**/*.{js,jsx,ts,tsx}\"",
"release": "release-it",
"typecheck": "tsc --noEmit",
"buntest": "bun test --timeout 50",
"buntestsilent": "bun test --timeout 50 > /dev/null 2>&1",
"upgrade": "bunx npm-check-updates@latest --interactive --format group -p bun"
},
"lsexports": [
".",
"sync",
"react",
"trace",
"babel",
"as/*",
"config/*",
"helpers/*",
"persist-plugins/*",
"sync-plugins/*",
"react-hooks/*"
],
"devDependencies": {
"@babel/preset-env": "^7.24.7",
"@babel/preset-react": "^7.24.7",
"@babel/types": "^7.24.6",
"@commitlint/config-conventional": "^19.2.2",
"@evilmartians/lefthook": "^1.6.13",
"@happy-dom/global-registrator": "^14.12.0",
"@jest/globals": "^29.7.0",
"@react-native-async-storage/async-storage": "^1.23.1",
"@release-it/conventional-changelog": "^8.0.1",
"@supabase/supabase-js": "^2.43.4",
"@swc/cli": "^0.3.12",
"@swc/core": "^1.5.7",
"@tanstack/react-query": "^5.40.0",
"@testing-library/jest-dom": "^6.4.5",
"@testing-library/react": "^15.0.7",
"@types/bun": "^1.1.3",
"@types/jest": "^29.5.12",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@types/react-native": "^0.72.8",
"@types/use-sync-external-store": "^0.0.6",
"@typescript-eslint/eslint-plugin": "^7.11.0",
"@typescript-eslint/parser": "^7.11.0",
"babel-jest": "^29.7.0",
"babel-plugin-tester": "^11.0.4",
"commitlint": "^19.3.0",
"eslint": "^8.45.0",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.2",
"expect-type": "^0.19.0",
"fake-indexeddb": "^6.0.0",
"firebase": "^10.12.2",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"json": "^11.0.0",
"ksuid": "^3.0.0",
"next": "^14",
"prettier": "^3.2.5",
"react": "18.3.1",
"react-native": "^0.74.1",
"react-native-mmkv": "^2.12.2",
"react-test-renderer": "^18.3.1",
"release-it": "^17.3.0",
"ts-jest": "^29.1.4",
"tslib": "^2.6.2",
"tsup": "^8.0.2",
"typescript": "^5.5.2"
},
"dependencies": {
"use-sync-external-store": "^1.2.2"
},
"overrides": {
"react": "18.3.1"
},
"author": "Legend <[email protected]> (https://github.com/LegendApp)",
"keywords": [
"react",
"react-native",
"state",
"hooks",
"proxy"
],
"repository": {
"type": "git",
"url": "git+https://github.com/LegendApp/legend-state.git"
},
"license": "MIT",
"bugs": {
"url": "https://github.com/LegendApp/legend-state/issues"
},
"homepage": "https://github.com/LegendApp/legend-state#readme",
"publishConfig": {
"registry": "https://registry.npmjs.org/"
},
"commitlint": {
"extends": [
"@commitlint/config-conventional"
]
}
}
"name": "@legendapp/state",
"version": "3.0.0-alpha.28",
"description": "legend-state",
"sideEffects": false,
"private": true,
"main": "./index.js",
"module": "./index.mjs",
"types": "./index.d.ts",
"files": [
"**"
],
"engines": {
"node": ">=16.6.0",
"npm": ">=8.11.0"
},
"scripts": {
"build": "npm run lint:check && npm run format:check && bun buntestsilent && bunx tsup && bun run posttsup.ts",
"test": "jest",
"postversion": "npm run build && git push --follow-tags",
"jestclear": "jest --clearCache",
"publish:manual": "npm run build && cd dist && npm publish",
"publish:minor": "npm version minor && cd dist && npm publish",
"publish:alpharelease": "npm version prerelease --preid=alpha && cd dist && npm publish --tag alpha",
"publish:betarelease": "npm version prerelease --preid=beta && cd dist && npm publish --tag beta",
"publish:nextrelease": "npm version prerelease --preid=next && cd dist && npm publish --tag next",
"publish:patch": "npm version patch && cd dist && npm publish",
"publish:premajor": "npm version premajor --preid=next && cd dist && npm publish --tag next",
"publish:preminor": "npm version preminor --preid=next && cd dist && npm publish --tag next",
"publish:prepatch": "npm version prepatch --preid=next && cd dist && npm publish --tag next",
"publish:rcrelease": "npm version prerelease --preid=rc && cd dist && npm publish --tag rc",
"checksize:core": "npx esbuild ./testbundles/bundlecore.js --bundle --outfile=temp-built.js --minify && gzip temp-built.js && stat -f%z ./temp-built.js.gz && rm temp-built.js.*",
"checksize:react": "npx esbuild ./testbundles/bundlereact.js --bundle --outfile=temp-built.js --minify --external:react --external:@legendapp/state && gzip temp-built.js && stat -f%z ./temp-built.js.gz && rm temp-built.js.*",
"checksize": "npm run checksize:core && npm run checksize:react",
"lint:write": "eslint ./src ./tests --fix --ext .ts,.tsx",
"lint:check": "eslint ./src ./tests --ext .ts,.tsx",
"format:write": "prettier --write \"src/**/*.{js,jsx,ts,tsx}\"",
"format:check": "prettier --check \"src/**/*.{js,jsx,ts,tsx}\"",
"release": "release-it",
"typecheck": "tsc --noEmit",
"buntest": "bun test --timeout 50",
"buntestsilent": "bun test --timeout 50 > /dev/null 2>&1",
"upgrade": "bunx npm-check-updates@latest --interactive --format group -p bun"
},
"lsexports": [
".",
"sync",
"react",
"config",
"trace",
"babel",
"as/*",
"config/*",
"helpers/*",
"persist-plugins/*",
"sync-plugins/*",
"react-hooks/*"
],
"devDependencies": {
"@babel/preset-env": "^7.24.7",
"@babel/preset-react": "^7.24.7",
"@babel/types": "^7.24.6",
"@commitlint/config-conventional": "^19.2.2",
"@evilmartians/lefthook": "^1.6.13",
"@happy-dom/global-registrator": "^14.12.0",
"@jest/globals": "^29.7.0",
"@react-native-async-storage/async-storage": "^1.23.1",
"@release-it/conventional-changelog": "^8.0.1",
"@supabase/supabase-js": "^2.43.4",
"@swc/cli": "^0.3.12",
"@swc/core": "^1.5.7",
"@tanstack/react-query": "^5.40.0",
"@testing-library/jest-dom": "^6.4.5",
"@testing-library/react": "^15.0.7",
"@types/bun": "^1.1.3",
"@types/jest": "^29.5.12",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@types/react-native": "^0.72.8",
"@types/use-sync-external-store": "^0.0.6",
"@typescript-eslint/eslint-plugin": "^7.11.0",
"@typescript-eslint/parser": "^7.11.0",
"babel-jest": "^29.7.0",
"babel-plugin-tester": "^11.0.4",
"commitlint": "^19.3.0",
"eslint": "^8.45.0",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.2",
"expect-type": "^0.19.0",
"fake-indexeddb": "^6.0.0",
"firebase": "^10.12.2",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"json": "^11.0.0",
"ksuid": "^3.0.0",
"next": "^14",
"prettier": "^3.2.5",
"react": "18.3.1",
"react-native": "^0.74.1",
"react-native-mmkv": "^2.12.2",
"react-test-renderer": "^18.3.1",
"release-it": "^17.3.0",
"ts-jest": "^29.1.4",
"tslib": "^2.6.2",
"tsup": "^8.0.2",
"typescript": "^5.5.2"
},
"dependencies": {
"use-sync-external-store": "^1.2.2"
},
"overrides": {
"react": "18.3.1"
},
"author": "Legend <[email protected]> (https://github.com/LegendApp)",
"keywords": [
"react",
"react-native",
"state",
"hooks",
"proxy"
],
"repository": {
"type": "git",
"url": "git+https://github.com/LegendApp/legend-state.git"
},
"license": "MIT",
"bugs": {
"url": "https://github.com/LegendApp/legend-state/issues"
},
"homepage": "https://github.com/LegendApp/legend-state#readme",
"publishConfig": {
"registry": "https://registry.npmjs.org/"
},
"commitlint": {
"extends": [
"@commitlint/config-conventional"
]
}
}
3 changes: 2 additions & 1 deletion src/config/enable$GetSet.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { configureLegendState, internal } from '@legendapp/state';
import { internal } from '@legendapp/state';
import { configureLegendState } from '@legendapp/state/config';

export function enable$GetSet() {
configureLegendState({
Expand Down
11 changes: 2 additions & 9 deletions src/config/enableReactTracking.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
import {
type GetOptions,
configureLegendState,
internal,
isObject,
tracking,
type NodeInfo,
type TrackingType,
} from '@legendapp/state';
import { type GetOptions, internal, isObject, tracking, type NodeInfo, type TrackingType } from '@legendapp/state';
import { configureLegendState } from '@legendapp/state/config';
import { UseSelectorOptions, useSelector } from '@legendapp/state/react';
import { createContext, useContext } from 'react';
// @ts-expect-error Internals
Expand Down
3 changes: 2 additions & 1 deletion src/config/enableReactUse.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { configureLegendState, internal, NodeInfo } from '@legendapp/state';
import { internal, NodeInfo } from '@legendapp/state';
import { configureLegendState } from '@legendapp/state/config';
import { useSelector, UseSelectorOptions } from '@legendapp/state/react';

// TODO: Deprecated, remove in v4
Expand Down
3 changes: 2 additions & 1 deletion src/config/enable_PeekAssign.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { configureLegendState, internal } from '@legendapp/state';
import { internal } from '@legendapp/state';
import { configureLegendState } from '@legendapp/state/config';

export function enable_PeekAssign() {
configureLegendState({
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/tests.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Observable } from '../src/observableTypes';
import { batch, beginBatch, endBatch } from '../src/batching';
import { configureLegendState } from '../src/config';
import { configureLegendState } from '../src/configureLegendState';
import { enable$GetSet } from '../src/config/enable$GetSet';
import { enable_PeekAssign } from '../src/config/enable_PeekAssign';
import { event } from '../src/event';
Expand Down
3 changes: 3 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@
"@legendapp/state": [
"index"
],
"@legendapp/state/config": [
"config"
],
"@legendapp/state/persist": [
"persist"
],
Expand Down
1 change: 1 addition & 0 deletions tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const external = [
'@tanstack/react-query',
'@tanstack/query-core',
'@legendapp/state',
'@legendapp/state/config',
'@legendapp/state/persist',
'@legendapp/state/sync',
'@legendapp/state/sync-plugins/crud',
Expand Down

0 comments on commit 977ca2b

Please sign in to comment.