현재 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.config.js
/**
* @type {import('@remix-run/dev').AppConfig}
*/
module.exports = {
server: './server.js',
ignoredRouteFiles: ['**/.*'],
serverDependenciesToBundle: ["swiper", 'swiper/react', 'ssr-window', 'dom7']
}
위와 같이 패키지에서 사용되는 번들들을 전부 추가해주어야한다.
'개발 > typescript, web' 카테고리의 다른 글
type safety한 RESTful을 위한 zodios (nextjs13 appDir, monorepo) (1) | 2022.12.16 |
---|---|
Module Augmentation와 Interface Merge를 활용한 bottom - up 식 구현 (1) | 2022.07.24 |
ts) N차 함수 N번째 항에서 함수합성하기 (2) | 2022.05.25 |
typescript generic의 사용 예와 identity function을 사용한 제네릭 인자 추론 (0) | 2022.05.15 |
fp-ts를 통해 함수형 프로그래밍 용어 정리 (0) | 2022.05.08 |