Skip to content

Commit

Permalink
chore(deps): update dev dependencies (#2479)
Browse files Browse the repository at this point in the history
* chore(deps): update dev dependencies

* downgrade user-evnet

* fix type with vi.fn

* for older ts

* hack for older ts

* hack for older ts 2

* hack for older ts 3

* hack for older ts 4

* hack for older ts 5

* hack for older ts 6

* hack for older ts 7

* hack for older ts 8

* resolve replacement

* update snapshots

* do not use default export

* Revert "do not use default export"

This reverts commit 0a64673.

* update package.json

* wip: fix cjs

* wip: for other builds

* wip: fix previous commit

* wip: esm and system

* system cannot be tested

* wip: fix esm

* wip: RESET

* wip: RESET 2

* wip: tsconfig

* revert it

* wip: patch test

* wip: fix regex

* wip: patch dist

* patch test with require

* wip: fix path

* fix cjs&umd

* skip one test with umd

* can we remove this?

* Revert "can we remove this?"

This reverts commit 1efc0b5.
  • Loading branch information
dai-shi authored Apr 7, 2024
1 parent 93a6fb9 commit c09843a
Show file tree
Hide file tree
Showing 10 changed files with 534 additions and 565 deletions.
13 changes: 8 additions & 5 deletions .github/workflows/test-multiple-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
fail-fast: false
matrix:
build: [cjs, umd] # [cjs, esm, umd, system]
build: [cjs, esm, umd]
env: [development, production]
steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -40,24 +40,27 @@ jobs:
- name: Patch for CJS
if: ${{ matrix.build == 'cjs' }}
run: |
sed -i~ "s/<rootDir>\/src\(.*\)\.ts/<rootDir>\/dist\1.js/" package.json
sed -i~ "s/resolve('\.\/src\(.*\)\.ts')/resolve('\.\/dist\1.js')/" vitest.config.ts
sed -i~ "s/import { useResetAtom } from 'jotai\/react\/utils'/const { useResetAtom } = require('..\/..\/..\/dist\/react\/utils.js')/" tests/react/utils/useResetAtom.test.tsx
sed -i~ "s/import { RESET, atomWithReducer, atomWithReset } from 'jotai\/vanilla\/utils'/const { RESET, atomWithReducer, atomWithReset } = require('..\/..\/..\/dist\/vanilla\/utils.js')/" tests/react/utils/useResetAtom.test.tsx
- name: Patch for ESM
if: ${{ matrix.build == 'esm' }}
run: |
sed -i~ "s/<rootDir>\/src\(.*\)\.ts/<rootDir>\/dist\/esm\1.js" package.json
sed -i~ "s/resolve('\.\/src\(.*\)\.ts')/resolve('\.\/dist\/esm\1.mjs')/" vitest.config.ts
sed -i~ "1s/^/import.meta.env=import.meta.env||{};import.meta.env.MODE='${NODE_ENV}';/" tests/*/*.tsx tests/*/*/*.tsx
env:
NODE_ENV: ${{ matrix.env }}
- name: Patch for UMD
if: ${{ matrix.build == 'umd' }}
run: |
sed -i~ "s/<rootDir>\/src\(.*\)\.ts/<rootDir>\/dist\/umd\1.${NODE_ENV}.js/" package.json
sed -i~ "s/resolve('\.\/src\(.*\)\.ts')/resolve('\.\/dist\/umd\1.${NODE_ENV}.js')/" vitest.config.ts
rm tests/react/utils/useResetAtom.test.tsx # FIXME we skip this for now. Actually I'm not sure if we really run tests with UMD build
env:
NODE_ENV: ${{ matrix.env }}
- name: Patch for SystemJS
if: ${{ matrix.build == 'system' }}
run: |
sed -i~ "s/<rootDir>\/src\(.*\)\.ts/<rootDir>\/dist\/system\1.${NODE_ENV}.js/" package.json
sed -i~ "s/resolve('\.\/src\(.*\)\.ts')/resolve('\.\/dist\/system\1.${NODE_ENV}.js')/" vitest.config.ts
env:
NODE_ENV: ${{ matrix.env }}
- name: Test ${{ matrix.build }} ${{ matrix.env }}
Expand Down
17 changes: 16 additions & 1 deletion .github/workflows/test-old-typescript.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
sed -i~ 's/"jotai\/\*": \["\.\/src\/\*\.ts"\]/"jotai\/*": [".\/dist\/*.d.ts"]/' tsconfig.json
sed -i~ 's/"include": .*/"include": ["src\/types.d.ts", "dist\/**\/*", "tests\/**\/*"],/' tsconfig.json
- name: Patch for Old TS
if: ${{ matrix.typescript == '4.7.4' || matrix.typescript == '4.6.4' || matrix.typescript == '4.5.5' || matrix.typescript == '4.4.4' || matrix.typescript == '4.3.5' || matrix.typescript == '4.2.3' || matrix.typescript == '4.1.5' || matrix.typescript == '4.0.5' || startsWith(matrix.typescript, '3.') }}
if: ${{ matrix.typescript == '4.7.4' || matrix.typescript == '4.6.4' || matrix.typescript == '4.5.5' || matrix.typescript == '4.4.4' || matrix.typescript == '4.3.5' || matrix.typescript == '4.2.3' || matrix.typescript == '4.1.5' || matrix.typescript == '4.0.5' || startsWith(matrix.typescript, '3.') }}
run: |
sed -i~ 's/\/\/ @ts-expect-error.*\[LATEST-TS-ONLY\]//' tests/*/*.tsx tests/*/*/*.tsx
sed -i~ 's/"target":/"skipLibCheck":true,"target":/' tsconfig.json
Expand All @@ -70,6 +70,21 @@ jobs:
rm -r tests/react/vanilla-utils/atomWithObservable.*
- name: Install old TypeScript
run: yarn add -D typescript@${{ matrix.typescript }}
- name: Patch testing setup for Old TS
if: ${{ matrix.typescript == '4.4.4' || matrix.typescript == '4.3.5' || matrix.typescript == '4.2.3' || matrix.typescript == '4.1.5' || matrix.typescript == '4.0.5' || startsWith(matrix.typescript, '3.') }}
run: |
rm node_modules/@vitest/expect/dist/*.d.ts
echo "declare module '@vitest/expect'" >> ./src/types.d.ts
rm node_modules/@vitest/runner/dist/*.d.ts
echo "declare module '@vitest/runner'" >> ./src/types.d.ts
rm node_modules/@vitest/spy/dist/*.d.ts
echo "declare module '@vitest/spy'" >> ./src/types.d.ts
rm node_modules/@vitest/utils/dist/*.d.ts
echo "declare module '@vitest/utils'" >> ./src/types.d.ts
rm node_modules/vite-node/dist/*.d.ts
echo "declare module 'vite-node'" >> ./src/types.d.ts
rm node_modules/vitest/dist/*.d.ts
echo "declare module 'vitest'" >> ./src/types.d.ts
- name: Patch testing setup for older TS
if: ${{ matrix.typescript == '4.0.5' || startsWith(matrix.typescript, '3.') }}
run: |
Expand Down
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@
},
"homepage": "https://github.com/pmndrs/jotai",
"devDependencies": {
"@babel/core": "^7.24.3",
"@babel/core": "^7.24.4",
"@babel/plugin-transform-react-jsx": "^7.23.4",
"@babel/plugin-transform-typescript": "^7.24.1",
"@babel/preset-env": "^7.24.3",
"@babel/plugin-transform-typescript": "^7.24.4",
"@babel/preset-env": "^7.24.4",
"@babel/template": "^7.24.0",
"@babel/types": "^7.24.0",
"@redux-devtools/extension": "^3.3.0",
Expand All @@ -131,13 +131,13 @@
"@testing-library/react": "^14.2.2",
"@testing-library/user-event": "14.4.3",
"@types/babel__core": "^7.20.5",
"@types/node": "^20.11.30",
"@types/node": "^20.12.4",
"@types/react": "18.2.56",
"@types/react-dom": "^18.2.23",
"@types/react-dom": "^18.2.24",
"@typescript-eslint/eslint-plugin": "7.2.0",
"@typescript-eslint/parser": "7.2.0",
"@vitest/coverage-v8": "0.33.0",
"@vitest/ui": "0.33.0",
"@vitest/coverage-v8": "^1.4.0",
"@vitest/ui": "^1.4.0",
"benny": "^3.7.1",
"concurrently": "^8.2.2",
"downlevel-dts": "^0.11.0",
Expand All @@ -149,14 +149,14 @@
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-react": "^7.34.1",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-vitest": "^0.4.0",
"eslint-plugin-vitest": "^0.4.1",
"jsdom": "^24.0.0",
"json": "^11.0.0",
"prettier": "^3.2.5",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"redux": "^5.0.1",
"rollup": "^4.13.2",
"rollup": "^4.14.0",
"rollup-plugin-banner2": "^1.2.3",
"rollup-plugin-esbuild": "^6.1.1",
"rxjs": "^7.8.1",
Expand All @@ -165,7 +165,7 @@
"ts-node": "^10.9.2",
"tslib": "^2.6.2",
"typescript": "^5.4.3",
"vitest": "0.33.0",
"vitest": "^1.4.0",
"wonka": "^6.3.4"
},
"resolutions": {
Expand Down
58 changes: 29 additions & 29 deletions tests/babel/plugin-debug-label.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,29 @@ const transform = (
it('Should add a debugLabel to an atom', () => {
expect(transform(`const countAtom = atom(0);`)).toMatchInlineSnapshot(`
"const countAtom = atom(0);
countAtom.debugLabel = \\"countAtom\\";"
countAtom.debugLabel = "countAtom";"
`)
})

it('Should handle a atom from a default export', () => {
expect(transform(`const countAtom = jotai.atom(0);`)).toMatchInlineSnapshot(`
"const countAtom = jotai.atom(0);
countAtom.debugLabel = \\"countAtom\\";"
countAtom.debugLabel = "countAtom";"
`)
})

it('Should handle a atom being exported', () => {
expect(transform(`export const countAtom = atom(0);`)).toMatchInlineSnapshot(`
"export const countAtom = atom(0);
countAtom.debugLabel = \\"countAtom\\";"
countAtom.debugLabel = "countAtom";"
`)
})

it('Should handle a default exported atom', () => {
expect(transform(`export default atom(0);`, 'countAtom.ts'))
.toMatchInlineSnapshot(`
"const countAtom = atom(0);
countAtom.debugLabel = \\"countAtom\\";
countAtom.debugLabel = "countAtom";
export default countAtom;"
`)
})
Expand All @@ -48,7 +48,7 @@ it('Should handle a default exported atom in a barrel file', () => {
expect(transform(`export default atom(0);`, 'atoms/index.ts'))
.toMatchInlineSnapshot(`
"const atoms = atom(0);
atoms.debugLabel = \\"atoms\\";
atoms.debugLabel = "atoms";
export default atoms;"
`)
})
Expand All @@ -64,9 +64,9 @@ it('Should handle all types of exports', () => {
),
).toMatchInlineSnapshot(`
"export const countAtom = atom(0);
countAtom.debugLabel = \\"countAtom\\";
countAtom.debugLabel = "countAtom";
const atoms = atom(0);
atoms.debugLabel = \\"atoms\\";
atoms.debugLabel = "atoms";
export default atoms;"
`)
})
Expand Down Expand Up @@ -112,52 +112,52 @@ it('Should handle all atom types', () => {
),
).toMatchInlineSnapshot(`
"export const countAtom = atom(0);
countAtom.debugLabel = \\"countAtom\\";
countAtom.debugLabel = "countAtom";
const myFamily = atomFamily(param => atom(param));
myFamily.debugLabel = \\"myFamily\\";
myFamily.debugLabel = "myFamily";
const countAtomWithDefault = atomWithDefault(get => get(countAtom) * 2);
countAtomWithDefault.debugLabel = \\"countAtomWithDefault\\";
countAtomWithDefault.debugLabel = "countAtomWithDefault";
const observableAtom = atomWithObservable(() => {});
observableAtom.debugLabel = \\"observableAtom\\";
observableAtom.debugLabel = "observableAtom";
const reducerAtom = atomWithReducer(0, () => {});
reducerAtom.debugLabel = \\"reducerAtom\\";
reducerAtom.debugLabel = "reducerAtom";
const resetAtom = atomWithReset(0);
resetAtom.debugLabel = \\"resetAtom\\";
resetAtom.debugLabel = "resetAtom";
const storageAtom = atomWithStorage('count', 1);
storageAtom.debugLabel = \\"storageAtom\\";
storageAtom.debugLabel = "storageAtom";
const freezedAtom = freezeAtom(atom({
count: 0
}));
freezedAtom.debugLabel = \\"freezedAtom\\";
freezedAtom.debugLabel = "freezedAtom";
const loadedAtom = loadable(countAtom);
loadedAtom.debugLabel = \\"loadedAtom\\";
loadedAtom.debugLabel = "loadedAtom";
const selectedValueAtom = selectAtom(atom({
a: 0,
b: 'othervalue'
}), v => v.a);
selectedValueAtom.debugLabel = \\"selectedValueAtom\\";
selectedValueAtom.debugLabel = "selectedValueAtom";
const splittedAtom = splitAtom(atom([]));
splittedAtom.debugLabel = \\"splittedAtom\\";
splittedAtom.debugLabel = "splittedAtom";
const unwrappedAtom = unwrap(asyncArrayAtom, () => []);
unwrappedAtom.debugLabel = \\"unwrappedAtom\\";
unwrappedAtom.debugLabel = "unwrappedAtom";
const someatomWithSubscription = atomWithSubscription(() => {});
someatomWithSubscription.debugLabel = \\"someatomWithSubscription\\";
someatomWithSubscription.debugLabel = "someatomWithSubscription";
const someAtomWithStore = atomWithStore(() => {});
someAtomWithStore.debugLabel = \\"someAtomWithStore\\";
someAtomWithStore.debugLabel = "someAtomWithStore";
const someAtomWithHash = atomWithHash('', '');
someAtomWithHash.debugLabel = \\"someAtomWithHash\\";
someAtomWithHash.debugLabel = "someAtomWithHash";
const someAtomWithLocation = atomWithLocation();
someAtomWithLocation.debugLabel = \\"someAtomWithLocation\\";
someAtomWithLocation.debugLabel = "someAtomWithLocation";
const someFocusAtom = focusAtom(someAtom, () => {});
someFocusAtom.debugLabel = \\"someFocusAtom\\";
someFocusAtom.debugLabel = "someFocusAtom";
const someAtomWithValidate = atomWithValidate('', {});
someAtomWithValidate.debugLabel = \\"someAtomWithValidate\\";
someAtomWithValidate.debugLabel = "someAtomWithValidate";
const someValidateAtoms = validateAtoms({}, () => {});
someValidateAtoms.debugLabel = \\"someValidateAtoms\\";
someValidateAtoms.debugLabel = "someValidateAtoms";
const someAtomWithCache = atomWithCache(async () => {});
someAtomWithCache.debugLabel = \\"someAtomWithCache\\";
someAtomWithCache.debugLabel = "someAtomWithCache";
const someAtomWithRecoilValue = atomWithRecoilValue({});
someAtomWithRecoilValue.debugLabel = \\"someAtomWithRecoilValue\\";"
someAtomWithRecoilValue.debugLabel = "someAtomWithRecoilValue";"
`)
})

Expand All @@ -168,6 +168,6 @@ it('Handles custom atom names a debugLabel to an atom', () => {
]),
).toMatchInlineSnapshot(`
"const mySpecialThing = myCustomAtom(0);
mySpecialThing.debugLabel = \\"mySpecialThing\\";"
mySpecialThing.debugLabel = "mySpecialThing";"
`)
})
24 changes: 12 additions & 12 deletions tests/babel/plugin-react-refresh.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ it('Should add a cache for a single atom', () => {
return inst;
}
};
const countAtom = globalThis.jotaiAtomCache.get(\\"/src/atoms/index.ts/countAtom\\", atom(0));"
const countAtom = globalThis.jotaiAtomCache.get("/src/atoms/index.ts/countAtom", atom(0));"
`)
})

Expand All @@ -52,8 +52,8 @@ it('Should add a cache for multiple atoms', () => {
return inst;
}
};
const countAtom = globalThis.jotaiAtomCache.get(\\"/src/atoms/index.ts/countAtom\\", atom(0));
const doubleAtom = globalThis.jotaiAtomCache.get(\\"/src/atoms/index.ts/doubleAtom\\", atom(get => get(countAtom) * 2));"
const countAtom = globalThis.jotaiAtomCache.get("/src/atoms/index.ts/countAtom", atom(0));
const doubleAtom = globalThis.jotaiAtomCache.get("/src/atoms/index.ts/doubleAtom", atom(get => get(countAtom) * 2));"
`)
})

Expand All @@ -77,8 +77,8 @@ it('Should add a cache for multiple exported atoms', () => {
return inst;
}
};
export const countAtom = globalThis.jotaiAtomCache.get(\\"/src/atoms/index.ts/countAtom\\", atom(0));
export const doubleAtom = globalThis.jotaiAtomCache.get(\\"/src/atoms/index.ts/doubleAtom\\", atom(get => get(countAtom) * 2));"
export const countAtom = globalThis.jotaiAtomCache.get("/src/atoms/index.ts/countAtom", atom(0));
export const doubleAtom = globalThis.jotaiAtomCache.get("/src/atoms/index.ts/doubleAtom", atom(get => get(countAtom) * 2));"
`)
})

Expand All @@ -95,7 +95,7 @@ it('Should add a cache for a default exported atom', () => {
return inst;
}
};
export default globalThis.jotaiAtomCache.get(\\"/src/atoms/index.ts/defaultExport\\", atom(0));"
export default globalThis.jotaiAtomCache.get("/src/atoms/index.ts/defaultExport", atom(0));"
`)
})

Expand All @@ -119,8 +119,8 @@ it('Should add a cache for mixed exports of atoms', () => {
return inst;
}
};
export const countAtom = globalThis.jotaiAtomCache.get(\\"/src/atoms/index.ts/countAtom\\", atom(0));
export default globalThis.jotaiAtomCache.get(\\"/src/atoms/index.ts/defaultExport\\", atom(get => get(countAtom) * 2));"
export const countAtom = globalThis.jotaiAtomCache.get("/src/atoms/index.ts/countAtom", atom(0));
export default globalThis.jotaiAtomCache.get("/src/atoms/index.ts/defaultExport", atom(get => get(countAtom) * 2));"
`)
})

Expand Down Expand Up @@ -160,9 +160,9 @@ it('Should handle atoms returned from functions (#891)', () => {
anAtom.debugLabel = label;
return anAtom;
}
const countAtom = globalThis.jotaiAtomCache.get(\\"/src/atoms/index.ts/countAtom\\", atom(0));
const countAtom2 = createAtom(\\"countAtom2\\");
const countAtom3 = createAtom(\\"countAtom3\\");"
const countAtom = globalThis.jotaiAtomCache.get("/src/atoms/index.ts/countAtom", atom(0));
const countAtom2 = createAtom("countAtom2");
const countAtom3 = createAtom("countAtom3");"
`)
})

Expand All @@ -184,6 +184,6 @@ it('Should handle custom atom names', () => {
return inst;
}
};
const mySpecialThing = globalThis.jotaiAtomCache.get(\\"/src/atoms/index.ts/mySpecialThing\\", myCustomAtom(0));"
const mySpecialThing = globalThis.jotaiAtomCache.get("/src/atoms/index.ts/mySpecialThing", myCustomAtom(0));"
`)
})
Loading

0 comments on commit c09843a

Please sign in to comment.