rollem icon indicating copy to clipboard operation
rollem copied to clipboard

require in rollem.config.js doesn't work

Open just-boris opened this issue 9 years ago • 1 comments

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.

just-boris avatar Dec 18 '16 19:12 just-boris

You've found the proverbial needle in the haystack @just-boris. Unfortunately "overriding require" required the use of an undocumented api.

module._compile.

Not saying this makes a non-starter. Just more a heads up from my own PTSD. I've been running into the same issue and may have a fix. Seems like can dependency inject a require into a runable context. WHERE the require comes from is the mystery as i haven't dug in it too much.

snuggs avatar Dec 18 '16 19:12 snuggs