리눅스는 사용자당 만들 수 있는 inotify 감시 개수에 상한(max_user_watches)이 있다. 파일이 많아 상한을 넘으면 System limit for number of file watchers reached 가 나고 webpack 의 파일 감시가 변경을 알아채지 못한다. /etc/sysctl.conf 에 fs.inotify.max_user_watches=524288 을 넣고 sysctl -p 로 적용한다.

-- inotify: 사용자당 감시 개수에 상한이 있다
watched :: [File] -> Bool
watched files = length files <= maxUserWatches   -- 넘으면 webpack 이 변경을 못 알아챈다
                                                 -- "System limit for number of file watchers reached"
-- echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
#234

webpack 은 .mjs 파일을 javascript/esm 으로 다뤄 require·module.exports 같은 CommonJS 를 막는다. node_modules 의 .mjs 가 CommonJS 를 섞어 쓰면 빌드가 깨지므로, 규칙에 type: javascript/auto 를 직접 주면 기본 규칙을 건너뛰고 둘 다 허용한다.

-- webpack: .mjs 는 javascript/esm — CommonJS(require·module.exports) 금지
moduleType :: [Rule] -> File -> ModuleType
moduleType rules f = case find (`matches` f) rules of
  Just r | Just t <- ruleType r -> t        -- type 을 직접 주면 기본 규칙을 건너뛴다
  _ | ".mjs" `isSuffixOf` f      -> JavascriptEsm
    | otherwise                  -> JavascriptAuto

-- { test: /\.mjs$/, include: /node_modules/, type: 'javascript/auto' }
#292