Search code examples
node.jstypescriptrollupjs

Rollup hangs on build


I have the follwing rollup config:

// @ts-check
import multiInput from "rollup-plugin-multi-input";
import typeScript from "rollup-plugin-typescript2";

export default [
  {
    input: "packages/**/*.tsx",
    output: {
      format: "esm",
      dir: ".registry/js"
    },
    plugins: [
      multiInput(),
      typeScript({
        tsconfig: "tsconfig.react.json"
      })
    ]
  },
  {
    input: "packages/etech-ui-utils/src/index.ts",
    output: {
      format: "esm",
      dir: "packages/etech-ui-utils/dist"
    },
    plugins: [
      multiInput(),
      typeScript({
        tsconfig: "tsconfig.lib.json"
      })
    ]
  }
];

When I run rollup -c the first config runs without issue. Then the command hangs. Here are the relevant parts of my package.json:

{
    "rollup": "^4.20.0",
    "rollup-plugin-multi-input": "^1.4.2",
    "rollup-plugin-swc3": "^0.11.2",
    "rollup-plugin-typescript2": "^0.36.0",
    "rollup-preserve-directives": "^1.1.1",
    "storybook": "^8.2.5",
    "swc-loader": "0.1.15",
}

I'm not getting an errors through logs or otherwise. I have tried:

  • Upgrading dependancies
  • Using pnpx to run

Here is some system enviorment:

System:

OS: macOS 14.6
CPU: (12) arm64 Apple M2 Max
Memory: 3.57 GB / 32.00 GB
Shell: 5.9 - /bin/zsh

Binaries:

Node: 22.5.1 - /opt/homebrew/bin/node
npm: 10.8.2 - /opt/homebrew/bin/npm
pnpm: 9.6.0 - /opt/homebrew/bin/pnpm

Managers:

Cargo: 1.78.0 - ~/.cargo/bin/cargo
Homebrew: 4.3.12 - /opt/homebrew/bin/brew
pip3: 24.0 - /opt/homebrew/bin/pip3
RubyGems: 3.0.3.1 - /usr/bin/gem

Utilities:

Make: 3.81 - /usr/bin/make
GCC: 15.0.0 - /usr/bin/gcc
Git: 2.39.3 - /usr/bin/git
Clang: 15.0.0 - /usr/bin/clang
FFmpeg: 7.0.1 - /opt/homebrew/bin/ffmpeg
Curl: 8.7.1 - /usr/bin/curl
OpenSSL: 3.3.1 - /opt/homebrew/bin/openssl

Servers:

Apache: 2.4.59 - /usr/sbin/apachectl

Virtualization: Docker: 27.0.3 - /usr/local/bin/docker Parallels: 19.3.0 - /usr/local/bin/prlctl SDKs:

iOS SDK:
  Platforms: DriverKit 23.5, iOS 17.5, macOS 14.5, tvOS 17.5, visionOS 1.2, watchOS 10.5

IDEs:

VSCode: 1.92.0 - /usr/local/bin/code
Vim: 9.0 - /usr/bin/vim
Xcode: 15.4/15F31d - /usr/bin/xcodebuild

Languages:

Bash: 3.2.57 - /bin/bash
Java: 21.0.2 - /usr/bin/javac
Perl: 5.34.1 - /usr/bin/perl
Python3: 3.12.4 - /opt/homebrew/bin/python3
Ruby: 2.6.10 - /usr/bin/ruby
Rust: 1.78.0 - /Users/ekrich/.cargo/bin/rustc

Databases:

SQLite: 3.43.2 - /usr/bin/sqlite3

Browsers:

Safari: 17.6

Is this a bug? What can I do to fix it?

After letting the command hang for a while I'm getting an error:

<--- Last few GCs --->

[38081:0x130008000]   426442 ms: Mark-Compact 8086.7 (8238.1) -> 8072.4 (8239.1) MB, pooled: 0 MB, 1576.38 / 0.00 ms  (average mu = 0.086, current mu = 0.054) allocation failure; scavenge might not succeed
[38081:0x130008000]   429408 ms: Mark-Compact 8088.2 (8239.1) -> 8073.7 (8240.1) MB, pooled: 0 MB, 2881.38 / 0.00 ms  (average mu = 0.050, current mu = 0.029) allocation failure; scavenge might not succeed


<--- JS stacktrace --->

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
----- Native stack trace -----

 1: 0x1027fff54 node::OOMErrorHandler(char const*, v8::OOMDetails const&) [/opt/homebrew/Cellar/node/22.5.1/bin/node]
 2: 0x10299e134 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [/opt/homebrew/Cellar/node/22.5.1/bin/node]
 3: 0x10299e0e8 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [/opt/homebrew/Cellar/node/22.5.1/bin/node]
 4: 0x102b47094 v8::internal::Heap::CallGCPrologueCallbacks(v8::GCType, v8::GCCallbackFlags, v8::internal::GCTracer::Scope::ScopeId) [/opt/homebrew/Cellar/node/22.5.1/bin/node]
 5: 0x102b48dd0 v8::internal::Heap::DevToolsTraceEventScope::~DevToolsTraceEventScope() [/opt/homebrew/Cellar/node/22.5.1/bin/node]
 6: 0x102b47748 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags)::$_8::operator()() const [/opt/homebrew/Cellar/node/22.5.1/bin/node]
 7: 0x102b473fc void heap::base::Stack::SetMarkerAndCallbackImpl<v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags)::$_8>(heap::base::Stack*, void*, void const*) [/opt/homebrew/Cellar/node/22.5.1/bin/node]
 8: 0x102710028 PushAllRegistersAndIterateStack [/opt/homebrew/Cellar/node/22.5.1/bin/node]
 9: 0x102b45dc4 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/opt/homebrew/Cellar/node/22.5.1/bin/node]
10: 0x102b3c3d8 v8::internal::HeapAllocator::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/opt/homebrew/Cellar/node/22.5.1/bin/node]
11: 0x102b3cb44 v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/opt/homebrew/Cellar/node/22.5.1/bin/node]
12: 0x102b23f8c v8::internal::Factory::NewFillerObject(int, v8::internal::AllocationAlignment, v8::internal::AllocationType, v8::internal::AllocationOrigin) [/opt/homebrew/Cellar/node/22.5.1/bin/node]
13: 0x102e3d4ec v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [/opt/homebrew/Cellar/node/22.5.1/bin/node]
14: 0x1025f201c Builtins_WasmCEntry [/opt/homebrew/Cellar/node/22.5.1/bin/node]
15: 0x1025f2464 Builtins_StringAdd_CheckNone [/opt/homebrew/Cellar/node/22.5.1/bin/node]
16: 0x10b74c69c 
17: 0x10b6baca4 
18: 0x10b67a714 
19: 0x10b689440 
20: 0x10255cef0 Builtins_InterpreterEntryTrampoline [/opt/homebrew/Cellar/node/22.5.1/bin/node]
21: 0x10255cef0 Builtins_InterpreterEntryTrampoline [/opt/homebrew/Cellar/node/22.5.1/bin/node]
22: 0x10255cef0 Builtins_InterpreterEntryTrampoline [/opt/homebrew/Cellar/node/22.5.1/bin/node]
23: 0x10255cef0 Builtins_InterpreterEntryTrampoline [/opt/homebrew/Cellar/node/22.5.1/bin/node]
24: 0x10255cef0 Builtins_InterpreterEntryTrampoline [/opt/homebrew/Cellar/node/22.5.1/bin/node]
25: 0x10255cef0 Builtins_InterpreterEntryTrampoline [/opt/homebrew/Cellar/node/22.5.1/bin/node]
26: 0x1026207dc Builtins_ArrayMap [/opt/homebrew/Cellar/node/22.5.1/bin/node]
27: 0x10255cef0 Builtins_InterpreterEntryTrampoline [/opt/homebrew/Cellar/node/22.5.1/bin/node]
28: 0x10255cef0 Builtins_InterpreterEntryTrampoline [/opt/homebrew/Cellar/node/22.5.1/bin/node]
29: 0x10255cef0 Builtins_InterpreterEntryTrampoline [/opt/homebrew/Cellar/node/22.5.1/bin/node]
30: 0x10255cef0 Builtins_InterpreterEntryTrampoline [/opt/homebrew/Cellar/node/22.5.1/bin/node]
31: 0x102599410 Builtins_AsyncFunctionAwaitResolveClosure [/opt/homebrew/Cellar/node/22.5.1/bin/node]
32: 0x102664578 Builtins_PromiseFulfillReactionJob [/opt/homebrew/Cellar/node/22.5.1/bin/node]
33: 0x102589714 Builtins_RunMicrotasks [/opt/homebrew/Cellar/node/22.5.1/bin/node]
34: 0x10255aaf4 Builtins_JSRunMicrotasksEntry [/opt/homebrew/Cellar/node/22.5.1/bin/node]
35: 0x102ab1918 v8::internal::(anonymous namespace)::Invoke(v8::internal::Isolate*, v8::internal::(anonymous namespace)::InvokeParams const&) [/opt/homebrew/Cellar/node/22.5.1/bin/node]
36: 0x102ab2020 v8::internal::(anonymous namespace)::InvokeWithTryCatch(v8::internal::Isolate*, v8::internal::(anonymous namespace)::InvokeParams const&) [/opt/homebrew/Cellar/node/22.5.1/bin/node]
37: 0x102ad5828 v8::internal::MicrotaskQueue::RunMicrotasks(v8::internal::Isolate*) [/opt/homebrew/Cellar/node/22.5.1/bin/node]
38: 0x102ad55b8 v8::internal::MicrotaskQueue::PerformCheckpointInternal(v8::Isolate*) [/opt/homebrew/Cellar/node/22.5.1/bin/node]
39: 0x102710b90 node::InternalCallbackScope::Close() [/opt/homebrew/Cellar/node/22.5.1/bin/node]
40: 0x1028730c4 node::PerIsolatePlatformData::RunForegroundTask(std::__1::unique_ptr<v8::Task, std::__1::default_delete<v8::Task>>) [/opt/homebrew/Cellar/node/22.5.1/bin/node]
41: 0x102872dd8 node::PerIsolatePlatformData::FlushForegroundTasksInternal() [/opt/homebrew/Cellar/node/22.5.1/bin/node]
42: 0x106b9a4a8 uv__async_io [/opt/homebrew/Cellar/libuv/1.48.0/lib/libuv.1.dylib]
43: 0x106baa164 uv__io_poll [/opt/homebrew/Cellar/libuv/1.48.0/lib/libuv.1.dylib]
44: 0x106b9a93c uv_run [/opt/homebrew/Cellar/libuv/1.48.0/lib/libuv.1.dylib]
45: 0x102711990 node::SpinEventLoopInternal(node::Environment*) [/opt/homebrew/Cellar/node/22.5.1/bin/node]
46: 0x10284a08c node::NodeMainInstance::Run(node::ExitCode*, node::Environment*) [/opt/homebrew/Cellar/node/22.5.1/bin/node]
47: 0x102849de0 node::NodeMainInstance::Run() [/opt/homebrew/Cellar/node/22.5.1/bin/node]
48: 0x1027bcce0 node::Start(int, char**) [/opt/homebrew/Cellar/node/22.5.1/bin/node]
49: 0x19fe2f154 start [/usr/lib/dyld]

Edit 2: Here is my package.json:

{
  "name": "@etech-ui/source",
  "version": "0.0.0",
  "license": "MIT",
  "type": "module",
  "scripts": {
    "lint:check": "pnpx eslint .",
    "lint:fix": "pnpx eslint . --fix",
    "format:check": "pnpx prettier . --check",
    "format:fix": "pnpx prettier . --write",
    "language-lint": "pnpm alex",
    "test": "pnpx vitest",
    "storybook:dev": "pnpx nx run next:storybook --port 7009 & pnpx nx run vite-react:storybook --port 7008",
    "storybook:build": "pnpx nx run next:build-storybook & pnpx nx run vite-react:build-storybook",
    "build": "pnpx rollup -c && node build/buildTsx.js && node build/buildJsx.js && node build/cleanup.js",
    "docs:dev": "cd apps/docs && pnpm dev",
    "docs:build": "cd apps/docs && pnpm build",
    "prepare": "pnpx husky && husky install",
    "commitlint": "commitlint --edit"
  },
  "lint-staged": {
    "*.{js,ts,tsx,astro,mjs,cjs,spec.ts,spec.tsx}": "pnpx eslint --cache --fix",
    "*.{js,css,md,ts,tsx,astro,mjs,cjs}": "pnpx prettier --write",
    "*.{md,mdx}": "pnpm run language-lint",
    "*.js": "eslint --cache --fix",
    "*.{js,css,md}": "prettier --write"
  },
  "private": true,
  "devDependencies": {
    "@chromatic-com/storybook": "^1.6.1",
    "@commitlint/cli": "^19.3.0",
    "@commitlint/config-conventional": "^19.2.2",
    "@eslint/js": "^9.7.0",
    "@nx/js": "19.4.1",
    "@nx/rollup": "19.4.1",
    "@nx/storybook": "^19.5.1",
    "@nx/vite": "19.4.1",
    "@nx/web": "19.4.1",
    "@nx/workspace": "19.4.1",
    "@storybook/addon-essentials": "^8.2.4",
    "@storybook/addon-interactions": "^8.2.4",
    "@storybook/core-server": "^8.2.4",
    "@storybook/nextjs": "^8.2.4",
    "@storybook/react": "^8.2.4",
    "@storybook/react-vite": "^8.2.4",
    "@storybook/test": "^8.2.4",
    "@storybook/test-runner": "^0.19.1",
    "@swc-node/register": "~1.9.2",
    "@swc/cli": "~0.3.14",
    "@swc/core": "~1.5.29",
    "@swc/helpers": "~0.5.12",
    "@testing-library/react": "^16.0.0",
    "@types/eslint__js": "^8.42.3",
    "@types/node": "18.16.9",
    "@types/react": "^18.3.3",
    "@types/react-dom": "^18",
    "@vitejs/plugin-react-swc": "^3.7.0",
    "alex": "^11.0.1",
    "eslint": "^9.7.0",
    "happy-dom": "^14.12.3",
    "husky": "^9.1.1",
    "install": "^0.13.0",
    "nx": "19.4.1",
    "postcss": "^8.4.39",
    "prettier": "^2.8.8",
    "rollup": "^4.20.0",
    "rollup-plugin-multi-input": "^1.4.2",
    "rollup-plugin-typescript2": "^0.36.0",
    "storybook": "^8.2.5",
    "swc-loader": "0.1.15",
    "tailwindcss": "^3.4.6",
    "ts-node": "10.9.1",
    "tslib": "^2.6.3",
    "typescript": "~5.4.5",
    "typescript-eslint": "^7.16.1",
    "verdaccio": "^5.31.1",
    "vitest": "^2.0.3"
  },
  "nx": {
    "includedScripts": []
  },
  "dependencies": {
    "@changesets/cli": "^2.27.7",
    "eslint-plugin-react": "^7.34.4",
    "react": "^18.3.1",
    "react-dom": "^18.3.1",
    "tailwind-variants": "^0.2.1",
    "tsx-to-jsx": "^0.0.4",
    "vite": "^5.3.4"
  }
}

No circular deps were found in either of the input directories.

Edit 3:

Starting to think this is a bug in Rollup. I located the rollup shell file and traced the error to the last piece of working code exec node "$basedir/../rollup/dist/bin/rollup" "$@". When running this I get an error Error: Cannot find module '/rollup/dist/bin/rollup'


Solution

  • The problem was in a package called rollup-plugin-multi-entry. I refactored it to remove and fixed the problem.