개발37 remix ssr에서 esmodule 패키지 사용하기 (ex: swiper) 현재 Swiper 8버전처럼 esmodule로만 되어있는 패키지는 remix에서 사용시 Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/hj/study/keylogee/node_modules/.pnpm/swiper@8.2.4/node_modules/swiper/swiper.esm.js from /Users/hj/study/keylogee/api/index.js not supported. 와 같이 ERR_REQUIRE_ESM 에러가 나는데 이는 서버사이드에서 esmodule 방식을 컴파일을 하는 방법을 알지 못하기 때문이다. 이런 경우 config에 serverDependenciesToBundle 속성에 미리 의존성 번들을 추가해주어야 한다. remix.c.. 2022. 6. 16. ts) N차 함수 N번째 항에서 함수합성하기 두 개의 함수가 있다고 해보자. f: A -> B -> C g: C -> D 이 두 함수를 합성한다면 f∘g: A -> B -> D 처럼 된다. 문제는 이것을 typescript에서 어떻게 합성하냐인데.. 흔히 함수 합성에 자주 사용되는 pipe, flow를 사용하면 다음과 같이 해야한다. (pipe나 flow는 특정 함수의 이름이 아닌, 프로그래밍 언어 공통적으로 통용되는 기능의 용어이다. 그러므로 lodash, ramda, fp-ts 등의 많은 유틸리티 라이브러리에서 제공된다.) const f = (a: number) => (b: string) => new Array(a).fill(b) const g = (arr: string[]) => arr.map(str => ({data: str})) // co.. 2022. 5. 25. typescript generic의 사용 예와 identity function을 사용한 제네릭 인자 추론 // 1. 타입을 추론하는 함수는 다음과 같이 작성 type MakeTuple = (v: T) => [T, T] const makeTuple: MakeTuple = (v) => [v, v] // OK const tenTuple = makeTuple(10) // type: [number, number] // 2. 타입을 선언시 명시하고 싶다면 type TypedMakeTuple = (v: T) => [T, T] const makeNumberTuple: TypedMakeTuple = (v) => [v, v] const oneTuple = makeNumberTuple(1) // type: [number, number] // _MakeTuple은 망한 코드 (에러나 경고는 안남... 걍 주의하세요) // _Ma.. 2022. 5. 15. fp-ts를 통해 함수형 프로그래밍 용어 정리 https://github.com/rjcnd105/my-new-playgound/blob/main/apps/playground/fpts/guide.md GitHub - rjcnd105/my-new-playgound Contribute to rjcnd105/my-new-playgound development by creating an account on GitHub. github.com 제가 초반에 함수형 프로그래밍, 그리고 fp-ts 공부하면서 용어땜시 많은 어려움이 있었으니 정리할겸 다른 분들께 도움이 되라고 작성합니다. 계속 업데이트 중 임돠.. 허졉하지만 수학 관점에서 참고하실라면 https://hj1.notion.site/01f55ada5f6548b3a071275a984e03a7 이것도 보면 쪼금.. 2022. 5. 8. 이전 1 2 3 4 5 ··· 10 다음