DEV Community

kthjm
kthjm

Posted on

4

Workspaces and Rollup

How to resolve modules located in workspaces by rollup.

situation is:
workspace-a and workspace-b that contain modules are set in "workspaces".

// package.json
"private": true,
"workspaces": [
  "workspace-a/*", // workspace-a/[module]/package.json
  "workspace-b/*"
],

To resolve the modules, pass the directories to rollup-plugin-node-resolve via customResolveOptions.moduleDirectory.

// rollup.config.js
import Resolve from 'rollup-plugin-node-resolve'

const resolve = Resolve({
  customResolveOptions: {
    moduleDirectory: [ // as array
      'workspace-a',
      'workspace-b',
    ]
  }
})

And it is necessary that [module]'s dirname equals to its "name" in package.json.


There may be the way more smart, this is just a solution.😗

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay