mirror of
https://github.com/cypress-io/cypress.git
synced 2025-12-30 11:09:49 -06:00
* chore: set up sharing of react via module federation in studio * chore: add ability to load types from the studio bundle * fix build * fix build * fix build * PR comments * Update guides/studio-development.md Co-authored-by: Matt Schile <mschile@cypress.io> * fix test --------- Co-authored-by: Matt Schile <mschile@cypress.io>
20 lines
468 B
TypeScript
20 lines
468 B
TypeScript
import Module from 'module'
|
|
|
|
/**
|
|
* requireScript, does just that, requires the passed in script as if it was a module.
|
|
* @param script - string
|
|
* @returns exports
|
|
*/
|
|
export const requireScript = <T>(script: string): T => {
|
|
const mod = new Module('id', module)
|
|
|
|
mod.filename = ''
|
|
// _compile is a private method
|
|
// @ts-expect-error
|
|
mod._compile(script, mod.filename)
|
|
|
|
module.children.splice(module.children.indexOf(mod), 1)
|
|
|
|
return mod.exports as T
|
|
}
|