Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use new store by default #2641

Merged
merged 2 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,14 @@
"build:vanilla:utils": "rollup -c --config-vanilla_utils",
"build:react": "rollup -c --config-react --client-only",
"build:react:utils": "rollup -c --config-react_utils --client-only",
"build:experimental": "rollup -c --config-experimental",
"postbuild": "pnpm patch-d-ts && pnpm copy && pnpm patch-ts3.8 && pnpm patch-old-ts && pnpm patch-esm-ts && pnpm patch-readme",
"prettier": "prettier '*.{js,json,md}' '{src,tests,benchmarks,docs}/**/*.{ts,tsx,md,mdx}' --write",
"eslint": "eslint --fix --no-eslintrc --c .eslintrc.json '*.{js,json,ts}' '{src,tests,benchmarks}/**/*.{ts,tsx}'",
"test": "pnpm run '/^test:.*/'",
"test:format": "prettier '*.{js,json,md}' '{src,tests,benchmarks,docs}/**/*.{ts,tsx,md,mdx}' --list-different",
"test:types": "tsc --noEmit",
"test:lint": "eslint --no-eslintrc --c .eslintrc.json '*.{js,json,ts}' '{src,tests,benchmarks}/**/*.{ts,tsx}'",
"test:spec": "vitest run && USE_STORE2=true vitest run",
"test:spec": "vitest run",
"test-build:spec": "vitest run",
"patch-d-ts": "node -e \"var {entries}=require('./rollup.config.js');require('shelljs').find('dist/**/*.d.ts').forEach(f=>{entries.forEach(({find,replacement})=>require('shelljs').sed('-i',new RegExp(' from \\''+find.source.slice(0,-1)+'\\';$'),' from \\''+replacement+'\\';',f));require('shelljs').sed('-i',/ from '(\\.[^']+)\\.ts';$/,' from \\'\\$1\\';',f)})\"",
"copy": "shx cp -r dist/src/* dist/esm && shx cp -r dist/src/* dist && shx rm -rf dist/src && shx rm -rf dist/{src,tests} && downlevel-dts dist dist/ts3.8 --to=3.8 && shx cp package.json readme.md LICENSE dist && json -I -f dist/package.json -e \"this.private=false; this.devDependencies=undefined; this.optionalDependencies=undefined; this.scripts=undefined; this.prettier=undefined;\"",
Expand Down
4 changes: 0 additions & 4 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ function createESMConfig(input, output, clientOnly) {
'import.meta.env?.MODE':
'(import.meta.env ? import.meta.env.MODE : undefined)',
}),
'import.meta.env?.USE_STORE2': 'false',
delimiters: ['\\b', '\\b(?!(\\.|/))'],
preventAssignment: true,
}),
Expand All @@ -96,7 +95,6 @@ function createCommonJSConfig(input, output, clientOnly) {
resolve({ extensions }),
replace({
'import.meta.env?.MODE': 'process.env.NODE_ENV',
'import.meta.env?.USE_STORE2': 'false',
delimiters: ['\\b', '\\b(?!(\\.|/))'],
preventAssignment: true,
}),
Expand Down Expand Up @@ -134,7 +132,6 @@ function createUMDConfig(input, output, env, clientOnly) {
resolve({ extensions }),
replace({
'import.meta.env?.MODE': JSON.stringify(env),
'import.meta.env?.USE_STORE2': 'false',
delimiters: ['\\b', '\\b(?!(\\.|/))'],
preventAssignment: true,
}),
Expand All @@ -158,7 +155,6 @@ function createSystemConfig(input, output, env, clientOnly) {
resolve({ extensions }),
replace({
'import.meta.env?.MODE': JSON.stringify(env),
'import.meta.env?.USE_STORE2': 'false',
delimiters: ['\\b', '\\b(?!(\\.|/))'],
preventAssignment: true,
}),
Expand Down
11 changes: 0 additions & 11 deletions src/experimental.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
declare interface ImportMeta {
env?: {
MODE: string
USE_STORE2?: string
}
}
12 changes: 1 addition & 11 deletions src/vanilla.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
export { atom } from './vanilla/atom.ts'
export type { Atom, WritableAtom, PrimitiveAtom } from './vanilla/atom.ts'

// export { createStore, getDefaultStore } from './vanilla/store.ts'
import * as store from './vanilla/store.ts'
import * as store2 from './vanilla/store2.ts'
type CreateStore = typeof store.createStore
type GetDefaultStore = typeof store.getDefaultStore
export const createStore: CreateStore = import.meta.env?.USE_STORE2
? store2.createStore
: store.createStore
export const getDefaultStore: GetDefaultStore = import.meta.env?.USE_STORE2
? store2.getDefaultStore
: store.getDefaultStore
export { createStore, getDefaultStore } from './vanilla/store.ts'

export type {
Getter,
Expand Down
Loading
Loading