Skip to content

Commit

Permalink
의존성 최신화 (#55)
Browse files Browse the repository at this point in the history
* chore: `parcel` 업데이트

* chore: `core-js` 업데이트

* Revert "chore: `core-js` 업데이트"

This reverts commit 6c26696.

* chore: `jest` 버전 업데이트 및 일부 `vitest` 적용

* chore: `babel-jest` 제거

* ci: 커버리지 설정 업데이트

* chore: export 전용 파일 ignore 처리

* chore: `babel` 의존성 위치 이동 및 업데이트

* chore: 미사용 의존성 제거

* chore: `webpack` 및 `eslint` 업데이트

* chore: `babel` 및 `webpack` 빌드 설정 업데이트

* chore: `eslint-plugin-compat` 제거

Babel transpile 및 polyfill 사용 설정하여 불필요
  • Loading branch information
Xvezda authored Dec 14, 2023
1 parent 560556f commit 5dbfdd5
Show file tree
Hide file tree
Showing 28 changed files with 2,838 additions and 2,239 deletions.
5 changes: 1 addition & 4 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = {
'es2021': true,
'jest': true
},
'extends': ['eslint:recommended', 'plugin:compat/recommended'],
'extends': ['eslint:recommended'],
'parserOptions': {
'ecmaVersion': 13,
'sourceType': 'module'
Expand Down Expand Up @@ -41,9 +41,6 @@ module.exports = {
'overrides': [
{
'files': ['scripts/**/*.js', '*.spec.js'],
'rules': {
'compat/compat': 'off',
},
},
]
};
6 changes: 4 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ jobs:
node-version: 20
cache: 'pnpm'
- run: pnpm install
- run: pnpm test -- --ci --coverage
- run: pnpm run -r test --coverage
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
20 changes: 0 additions & 20 deletions babel.config.json

This file was deleted.

2 changes: 1 addition & 1 deletion examples/basic-routing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},
"private": true,
"devDependencies": {
"parcel": "latest"
"parcel": "^2.10.3"
},
"dependencies": {
"@vomjs/tools": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion examples/counter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"private": true,
"devDependencies": {
"parcel": "latest"
"parcel": "^2.10.3"
},
"dependencies": {
"vomjs": "workspace:*"
Expand Down
3 changes: 1 addition & 2 deletions examples/tic-tac-toe/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
},
"private": true,
"devDependencies": {
"core-js": "^3.18.1",
"parcel": "latest"
"parcel": "^2.10.3"
},
"dependencies": {
"vomjs": "workspace:*"
Expand Down
41 changes: 6 additions & 35 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "@vomjs/monorepo",
"private": true,
"author": {
"name": "Xvezda",
"email": "xvezda@naver.com",
Expand All @@ -9,52 +10,22 @@
"prepare": "husky install",
"prepublishOnly": "pnpm run build",
"build": "turbo build",
"test": "jest --verbose --cache",
"test": "turbo test",
"lint": "eslint --cache .",
"define": "node scripts/defineSandbox.js",
"postversion": "pnpm run readme",
"readme": "pnpm run define 'docs: update README (%h)'"
},
"devDependencies": {
"@babel/core": "^7.16.0",
"@babel/plugin-transform-runtime": "^7.16.5",
"@babel/preset-env": "^7.16.0",
"@commitlint/cli": "^15.0.0",
"@commitlint/config-conventional": "^15.0.0",
"babel-jest": "^27.3.1",
"@commitlint/cli": "^18.4.3",
"@commitlint/config-conventional": "^18.4.3",
"ejs": "^3.1.6",
"eslint": "^8.4.1",
"eslint-plugin-compat": "^4.0.0",
"eslint": "^8.55.0",
"gh-pages": "^3.2.3",
"husky": "^7.0.4",
"jest": "^27.3.1",
"husky": "^8.0.3",
"lint-staged": ">=10",
"turbo": "^1.11.2"
},
"workspaces": [
"packages/*",
"examples/*"
],
"jest": {
"rootDir": ".",
"moduleNameMapper": {
"^vomjs$": "<rootDir>/packages/vomjs/src/",
"^@vomjs/(.*)$": "<rootDir>/packages/vomjs-$1/src/"
},
"transform": {
"^.+\\.js$": [
"babel-jest",
{
"rootMode": "upward"
}
]
},
"coveragePathIgnorePatterns": [
"/node_modules/",
"/dist/"
]
},
"private": true,
"lint-staged": {
"*.js": "eslint --cache --fix"
}
Expand Down
7 changes: 3 additions & 4 deletions packages/vomjs-store/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
"main": "src/index.js",
"devDependencies": {
"@babel/core": "^7.15.5",
"@jest/globals": "^29.7.0",
"babel-jest": "^27.2.0",
"jest": "^27.2.0"
"@vitest/coverage-v8": "^1.0.4",
"vitest": "^1.0.4"
},
"scripts": {
"test": "jest"
"test": "vitest run"
},
"author": {
"name": "Xvezda",
Expand Down
4 changes: 3 additions & 1 deletion packages/vomjs-store/src/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* v8 ignore start */
export { default as Dispatcher } from './dispatcher.js';
export { default as Store } from './store.js';
export { ReduceStore, createStore } from './reduce.js';
export { ReduceStore, createStore } from './reduce.js';
/* v8 ignore stop */
6 changes: 3 additions & 3 deletions packages/vomjs-store/src/reduce.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { jest } from '@jest/globals';
import { vi, test, expect } from 'vitest';
import { createStore } from './reduce.js';

test('카운터 예제 테스트', () => {
Expand All @@ -16,7 +16,7 @@ test('카운터 예제 테스트', () => {
}

const store = createStore(counterReducer);
const subscriberMock = jest.fn();
const subscriberMock = vi.fn();
store.subscribe(() => subscriberMock(store.getState()));

store.dispatch({type: 'counter/incremented'});
Expand All @@ -25,4 +25,4 @@ test('카운터 예제 테스트', () => {
expect(subscriberMock).toHaveBeenCalledWith({value: 2});
store.dispatch({type: 'counter/decremented'});
expect(subscriberMock).toHaveBeenCalledWith({value: 1});
});
});
11 changes: 9 additions & 2 deletions packages/vomjs-tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,19 @@
"description": "자주 쓰이는 코드를 chaining 방식으로 이용할 수 있도록 제공하는 도구모음 패키지",
"type": "module",
"main": "src/index.js",
"scripts": {},
"scripts": {
"test": "vitest run"
},
"author": {
"name": "Xvezda",
"email": "xvezda@naver.com",
"url": "https://xvezda.com/"
},
"license": "MIT",
"sideEffects": false
"sideEffects": false,
"devDependencies": {
"@vitest/coverage-v8": "^1.0.4",
"happy-dom": "^12.10.3",
"vitest": "^1.0.4"
}
}
1 change: 1 addition & 0 deletions packages/vomjs-tools/src/common.spec.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, test, expect } from 'vitest';
import { deepEquals } from './common.js';

describe('deepEquals', () => {
Expand Down
21 changes: 11 additions & 10 deletions packages/vomjs-tools/src/fp.spec.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
const {pipe} = require('./fp');
import { vi, beforeEach, afterEach, describe, test, expect } from 'vitest';
import { pipe } from './fp.js';

beforeEach(() => {
jest.useFakeTimers();
vi.useFakeTimers();
});

afterEach(() => {
jest.clearAllTimers();
jest.useRealTimers();
vi.clearAllTimers();
vi.useRealTimers();
});

async function runPendingPromise() {
Expand All @@ -16,7 +17,7 @@ async function runPendingPromise() {

describe('pipe', () => {
test('이전 함수의 반환값으로 호출', () => {
const mock = jest.fn(x => x);
const mock = vi.fn(x => x);
const isEven = xs => xs.filter(x => x % 2 === 0);
const biggerThan = n => xs => xs.filter(x => x > n);

Expand All @@ -34,7 +35,7 @@ describe('pipe', () => {
});

test('비동기 함수 처리', async () => {
const mock = jest.fn(x => x);
const mock = vi.fn(x => x);
pipe(
x => Promise.resolve(x),
mock
Expand All @@ -47,7 +48,7 @@ describe('pipe', () => {
});

test('비동기 지연 처리', async () => {
const mock = jest.fn(x => x);
const mock = vi.fn(x => x);
const delay = time => x =>
new Promise(resolve => setTimeout(() => resolve(x), time));

Expand All @@ -61,17 +62,17 @@ describe('pipe', () => {

expect(mock).not.toBeCalled();

jest.advanceTimersByTime(waitFor);
vi.advanceTimersByTime(waitFor);
await runPendingPromise();

expect(mock).toHaveBeenCalledTimes(1);
expect(mock).toHaveBeenNthCalledWith(1, 42);

jest.advanceTimersByTime(waitFor);
vi.advanceTimersByTime(waitFor);
await runPendingPromise();
await p;

expect(mock).toHaveBeenCalledTimes(2);
expect(mock).toHaveBeenNthCalledWith(2, 42);
});
});
});
4 changes: 3 additions & 1 deletion packages/vomjs-tools/src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/* v8 ignore start */
export * from './common.js';
export * from './selector.js';
export * from './pattern-match.js';
export * from './fp.js';
export * from './optimize.js';
export * from './optimize.js';
/* v8 ignore stop */
17 changes: 9 additions & 8 deletions packages/vomjs-tools/src/optimize.spec.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,45 @@
/**
* @jest-environment jsdom
* @vitest-environment happy-dom
*/
import { vi, test, expect } from 'vitest';
import { debounce, throttle } from './optimize.js';


const fps = 60;
const interval = Math.floor(1000 / fps);

jest.useFakeTimers();
vi.useFakeTimers();

jest
vi
.spyOn(window, 'requestAnimationFrame')
.mockImplementation(callback => setTimeout(callback, interval));

test('debounce', () => {
const arr = [1, 2, 3];
const mock = jest.fn();
const mock = vi.fn();
const debounced = debounce(200)(mock);


arr.forEach(debounced);
expect(mock).not.toBeCalled();

jest.runAllTimers();
vi.runAllTimers();

expect(mock).toBeCalledTimes(1);
});

test('throttle', () => {
const mock = jest.fn();
const mock = vi.fn();
const throttled = throttle(mock);

jest.advanceTimersByTime(8);
vi.advanceTimersByTime(8);
expect(mock).not.toBeCalled();

throttled();
expect(mock).not.toBeCalled();

throttled();
jest.advanceTimersByTime(16);
vi.advanceTimersByTime(16);

expect(mock).toBeCalledTimes(1);
});
Loading

0 comments on commit 5dbfdd5

Please sign in to comment.