rewiremock icon indicating copy to clipboard operation
rewiremock copied to clipboard

Typescript setup Error: Rewiremock: there is no "parent module". Is there two HotModuleReplacementPlugins?

Open jamlen opened this issue 1 year ago • 0 comments

I'm trying to use rewiremock after converting from using rewire in a typescript project.

// ./rewiremock.ts
import rewiremock, {addPlugin, plugins} from 'rewiremock'

rewiremock.overrideEntryPoint(module) // this is important. This command is "transfering" this module parent to rewiremock
addPlugin(plugins.nodejs)
// we need webpack aliases
addPlugin(plugins.webpackAlias)
// and all stub names would be a relative
addPlugin(plugins.relative)
// and all stubs should be used. Lets make it default!
addPlugin(plugins.usedByDefault)

export { rewiremock }

// ./test/demo.test.ts
import { rewiremock } from '../rewiremock'

Even just importing is enough for the error to occur.

This has the same error as https://github.com/theKashey/rewiremock/issues/137 but a different environment and setup.

jamlen avatar Jul 29 '22 11:07 jamlen