In a puppeteer script I want to inject some utility functions to a webpage via page.addScriptTag and use some exports defined in the file.
await page.addScriptTag({path: './utils/browser.js', type: 'module'})
await page.evaluate(() => {
// how do I do `import { foo } from './utils/browser.js'` here?
})
The injected file looks like this:
export function foo() {}
I'm using '"type": "module"' in my package.json if this is relevant.