bahmutov / bahmutov/rollem

require in rollem.config.js doesn't work

Open
#21 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
JavaScript
Stars
52
Forks
12
PR merge metrics
No merged PRs in 30d

Description

When I am trying to import relative module, like it doesn't work. For example, the following rollem.config.js fails

import helper from './my-helper';

export default [/* ...entries... */]

Gives me an error Error: Cannot find module './my-helper.js'

It happens because you are using eval that uses require from the current module context, but not the original rollem.config.js location.

See how that was worked around in Rollup. I think that this trick with temporary replaced require hook should be ported there as well.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with the rollem.config.js example and its relative ./my-helper import. Read the Rollup runRollup.js workaround linked in the issue, then trace the eval/require handling in Rollem. Done means relative modules imported from rollem.config.js resolve from that configuration file's location.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, rollup
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.