Skip to content

Commit

Permalink
Merge pull request #2 from TanStack/improve-bundling
Browse files Browse the repository at this point in the history
Improve bundling
  • Loading branch information
crutchcorn authored Aug 31, 2023
2 parents d849910 + d4bd1d7 commit 922465e
Show file tree
Hide file tree
Showing 32 changed files with 3,043 additions and 3,099 deletions.
69 changes: 69 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// @ts-check

/** @type {import('eslint').Linter.Config} */
const config = {
root: true,
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'compat', 'import'],
extends: [
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:compat/recommended',
'plugin:import/recommended',
'plugin:import/typescript',
'prettier',
],
env: {
browser: true,
es2020: true,
},
parserOptions: {
tsconfigRootDir: __dirname,
project: './tsconfig.json',
sourceType: 'module',
ecmaVersion: 2020,
},
settings: {
'import/parsers': {
'@typescript-eslint/parser': ['.ts', '.tsx'],
},
'import/resolver': {
typescript: true,
},
react: {
version: 'detect',
},
},
rules: {
'@typescript-eslint/ban-types': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/consistent-type-imports': 'error',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-empty-interface': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-unnecessary-condition': 'error',
'@typescript-eslint/no-inferrable-types': [
'error',
{
ignoreParameters: true,
},
],
'no-shadow': 'error',
'import/no-cycle': 'error',
'import/no-unresolved': ['error', { ignore: ['^@tanstack/'] }],
'import/no-unused-modules': ['off', { unusedExports: true }],
'no-redeclare': 'off',
'@typescript-eslint/no-unused-vars': 'off',
},
overrides: [
{
files: ['**/*.test.{ts,tsx}'],
rules: {
'@typescript-eslint/no-unnecessary-condition': 'off',
},
},
],
}

module.exports = config
File renamed without changes.
74 changes: 74 additions & 0 deletions nx.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{
"$schema": "./node_modules/nx/schemas/nx-schema.json",
"affected": {
"defaultBase": "main"
},
"tasksRunnerOptions": {
"default": {
"runner": "nx-cloud",
"options": {
"cacheableOperations": [
"test:lib",
"test:eslint",
"test:types",
"test:build",
"build"
],
"parallel": 5,
"accessToken": "OTI3Y2U3NGQtYzQ3ZC00ZmE3LWJjZWQtYTYxOTEyNmNiN2IyfHJlYWQtb25seQ=="
}
}
},
"defaultBase": "main",
"pluginsConfig": {
"@nrwl/js": {
"analyzeSourceFiles": false
}
},
"namedInputs": {
"sharedGlobals": [
"{workspaceRoot}/.browserslistrc",
"{workspaceRoot}/.eslintrc.cjs",
"{workspaceRoot}/babel.config.cjs",
"{workspaceRoot}/package.json",
"{workspaceRoot}/scripts/getRollupConfig.js",
"{workspaceRoot}/tsconfig.json"
],
"default": [
"sharedGlobals",
"{projectRoot}/**/*",
"!{projectRoot}/**/*.md"
],
"public": [
"default",
"{projectRoot}/build",
"{projectRoot}/dist",
"!{projectRoot}/.eslintrc.cjs",
"!{projectRoot}/tsconfig.eslint.json"
]
},
"targetDefaults": {
"test:lib": {
"dependsOn": ["^build"],
"inputs": ["default", "^public"],
"outputs": ["{projectRoot}/coverage"]
},
"test:eslint": {
"dependsOn": ["^build"],
"inputs": ["default", "^public"]
},
"test:types": {
"dependsOn": ["^build"],
"inputs": ["default", "^public"]
},
"build": {
"dependsOn": ["^build"],
"inputs": ["default", "^public"],
"outputs": ["{projectRoot}/build", "{projectRoot}/dist"]
},
"test:build": {
"dependsOn": ["build"],
"inputs": ["^public"]
}
}
}
106 changes: 54 additions & 52 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
{
"private": true,
"repository": "https://github.com/tanstack/store.git",
"packageManager": "pnpm@8.5.1",
"type": "module",
"scripts": {
"clean-dist": "pnpm -rc --parallel exec 'rm -rf build dist'",
"clean-all": "pnpm -rc --parallel exec 'rm -rf build dist node_modules'",
"test": "is-ci-cli test:ci test:dev",
"test:ci": "pnpm --parallel test",
"test:dev": "vitest",
"buildNx": "nx run-many --target=build --projects=@tanstack/* --exclude=@tanstack/react-start",
"build": "rollup --config rollup.config.js && pnpm typecheck",
"watch": "concurrently --no-color --prefix \"watch\" --kill-others --raw \"rollup --config rollup.config.js -w\" \"tsc -b --watch --preserveWatchOutput\"",
"dev": "pnpm watch",
"prettier": "prettier \"packages/*/{src/**,examples/**/src/**}.{md,js,jsx,ts,tsx,json}\" --write",
"visualize": "pnpm -rc --parallel exec open build/stats-html.html",
"cipublish": "ts-node scripts/publish.ts",
"cipublishforce": "CI=true pnpm cipublish",
"typecheck": "tsc -b",
"typecheck-perf": "tsc -b --generateTrace ts-perf"
"clean": "pnpm --filter \"./packages/**\" run clean",
"preinstall": "node -e \"if(process.env.CI == 'true') {console.log('Skipping preinstall...'); process.exit(1)}\" || npx -y only-allow pnpm",
"install:csb": "corepack enable && pnpm install --frozen-lockfile",
"test": "pnpm run test:ci",
"test:ci": "nx run-many --exclude=examples/** --targets=test:format,test:eslint,test:lib,test:types,test:build,test:bundle,build",
"test:eslint": "nx affected --target=test:eslint",
"test:format": "pnpm run prettier --check",
"test:lib": "nx affected --target=test:lib",
"test:lib:dev": "pnpm --filter \"./packages/**\" run test:lib:dev",
"test:build": "nx affected --target=test:build",
"test:types": "nx affected --target=test:types",
"test:bundle": "nx affected --target=test:bundle",
"build": "nx affected --target=build",
"build:all": "nx run-many --exclude=examples/** --target=build",
"watch": "pnpm run build:all && nx watch --all -- pnpm run build:all",
"dev": "pnpm run watch",
"prettier": "prettier --plugin-search-dir . \"{examples,integrations,packages,scripts}/**/*.{md,js,jsx,cjs,ts,tsx,json,vue,svelte}\"",
"prettier:write": "pnpm run prettier --write",
"cipublish": "node scripts/publish.js"
},
"workspaces": [
"./packages/*",
Expand All @@ -33,62 +39,58 @@
}
},
"devDependencies": {
"@babel/core": "^7.17.9",
"@babel/preset-env": "^7.16.11",
"@babel/preset-react": "^7.16.7",
"@babel/preset-typescript": "^7.16.7",
"@commitlint/parse": "^16.2.1",
"@faker-js/faker": "^6.3.1",
"@nrwl/nx-cloud": "latest",
"@rollup/plugin-babel": "^5.3.1",
"@rollup/plugin-node-resolve": "^13.2.1",
"@rollup/plugin-replace": "^4.0.0",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^14.0.0",
"@testing-library/react-hooks": "^8.0.1",
"@testing-library/user-event": "^14.4.3",
"@tsconfig/svelte": "^3.0.0",
"@types/luxon": "^2.3.1",
"@types/node": "^17.0.25",
"@types/eslint": "^8.44.2",
"@types/luxon": "^3.3.0",
"@types/node": "^18.16.0",
"@types/react": "^18.0.26",
"@types/react-dom": "^18.0.9",
"@types/semver": "^7.3.13",
"@types/semver": "^7.5.0",
"@types/testing-library__jest-dom": "5.14.5",
"axios": "^0.26.1",
"@typescript-eslint/eslint-plugin": "^6.4.1",
"@typescript-eslint/parser": "^6.4.1",
"@vitest/coverage-istanbul": "^0.33.0",
"axios": "^1.4.0",
"babel-eslint": "^10.1.0",
"babel-plugin-transform-async-to-promises": "^0.8.18",
"babel-preset-solid": "^1.5.4",
"concurrently": "^7.1.0",
"chalk": "^5.2.0",
"concurrently": "^8.0.1",
"current-git-branch": "^1.1.0",
"esbuild": "^0.18.13",
"esbuild-plugin-file-path-extensions": "^1.0.0",
"eslint": "^8.48.0",
"eslint-config-prettier": "^9.0.0",
"eslint-import-resolver-typescript": "^3.6.0",
"eslint-plugin-compat": "^4.1.4",
"eslint-plugin-import": "^2.28.1",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"git-log-parser": "^1.2.0",
"luxon": "^2.3.2",
"jsdom": "^22.0.0",
"nx": "15.9.2",
"nx-cloud": "^16.0.1",
"jsdom": "^22.1.0",
"jsonfile": "^6.1.0",
"luxon": "^3.3.0",
"nx": "^16.5.2",
"nx-cloud": "^16.1.0",
"prettier": "^2.8.1",
"publint": "^0.2.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-virtual": "^2.10.4",
"rollup": "^2.70.2",
"rollup-plugin-dts": "^4.2.2",
"rollup-plugin-size": "^0.2.2",
"rollup-plugin-svelte": "^7.1.0",
"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-visualizer": "^5.6.0",
"solid-js": "^1.6.5",
"rimraf": "^5.0.1",
"semver": "^7.3.8",
"stream-to-array": "^2.3.0",
"svelte": "^3.55.0",
"ts-node": "^10.7.0",
"tsup": "^7.1.0",
"type-fest": "^3.13.0",
"typescript": "^4.9.5",
"vue": "^3.2.33"
},
"dependencies": {
"@rollup/plugin-commonjs": "^23.0.4",
"@types/babel__core": "^7.1.20",
"@types/fs-extra": "^9.0.13",
"fs-extra": "^10.1.0",
"is-ci-cli": "^2.2.0",
"vite": "^4.4.9",
"vitest": "^0.34.3",
"zod": "^3.20.2"
"vite": "^4.4.4",
"vitest": "^0.33.0",
"vue": "^3.3.4"
}
}
17 changes: 17 additions & 0 deletions packages/react-store/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// @ts-check

/** @type {import('eslint').Linter.Config} */
const config = {
extends: ['plugin:react/recommended', 'plugin:react-hooks/recommended'],
parserOptions: {
tsconfigRootDir: __dirname,
project: './tsconfig.json',
},
rules: {
'react/jsx-key': ['error', { checkFragmentShorthand: true }],
'react-hooks/exhaustive-deps': 'error',
'react/no-children-prop': 'off',
},
}

module.exports = config
38 changes: 26 additions & 12 deletions packages/react-store/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"registry": "https://registry.npmjs.org/"
},
"keywords": [
"loaders",
"store",
"react",
"typescript"
],
Expand All @@ -19,21 +19,35 @@
"url": "https://github.com/sponsors/tannerlinsley"
},
"scripts": {
"build": "rollup --config rollup.config.js",
"test": "vitest",
"test:dev": "vitest --watch"
},
"module": "build/esm/index.js",
"main": "build/cjs/index.js",
"browser": "build/umd/index.production.js",
"types": "build/types/index.d.ts",
"engines": {
"node": ">=12"
"clean": "rimraf ./build && rimraf ./coverage",
"test:eslint": "eslint --ext .ts,.tsx ./src",
"test:types": "tsc",
"test:lib": "vitest run --coverage",
"test:lib:dev": "pnpm run test:lib --watch",
"test:build": "publint --strict",
"build": "tsup"
},
"files": [
"build/**",
"build",
"src"
],
"type": "module",
"types": "build/legacy/index.d.ts",
"main": "build/legacy/index.cjs",
"module": "build/legacy/index.js",
"exports": {
".": {
"import": {
"types": "./build/modern/index.d.ts",
"default": "./build/modern/index.js"
},
"require": {
"types": "./build/modern/index.d.cts",
"default": "./build/modern/index.cjs"
}
},
"./package.json": "./package.json"
},
"sideEffects": false,
"peerDependencies": {
"react": ">=16",
Expand Down
11 changes: 0 additions & 11 deletions packages/react-store/rollup.config.js

This file was deleted.

3 changes: 1 addition & 2 deletions packages/react-store/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as React from 'react'
import { AnyUpdater, Store } from '@tanstack/store'
import type { AnyUpdater, Store } from '@tanstack/store'
import { useSyncExternalStoreWithSelector } from 'use-sync-external-store/shim/with-selector'

export * from '@tanstack/store'
Expand Down
Loading

0 comments on commit 922465e

Please sign in to comment.