NOTE

react 패키지를 next로 컴파일 하는 패키지

ssund 2023. 8. 6. 10:42

react에서 사용했던 패키지를 next환경에서 써야하는 상황

next 환경에서 작동할수있도록 컴파일 해주는 패키지 발견 

https://www.npmjs.com/package/next-transpile-modules

 

1. npm 모듈 설치

npm i next-transpile-modules

2. next.config 파일 설정하기

const config = require('config');
const { format } = require('date-fns');
const { ko } = require('date-fns/locale');

/** @type {import('next').NextConfig} */
const withTM = require("next-transpile-modules")([
  "@fullcalendar/common",
  "@fullcalendar/daygrid",
  "@fullcalendar/interaction",
  "@fullcalendar/react",
  "@fullcalendar/timegrid",
]);


/** @type {import('next').NextConfig} */
const nextConfig = withTM({
  reactStrictMode: true, 
  ... 다른옵션들
});

module.exports = nextConfig;

 

react node-module을 컴파일해서 next환경에서도 이슈없도록 해준다.!