-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: proper imports in esm context #718
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor things inline, also desc of PR should use "Closes: XXX" so it can go into the QA column
packages/puppeteer/src/legacy.ts
Outdated
let axeCorePath = ''; | ||
if (typeof require === 'function' && typeof require.resolve === 'function') { | ||
axeCorePath = require.resolve('axe-core'); | ||
} else { | ||
const { createRequire } = (await import('node:module')) as any; | ||
const filename = pathToFileURL(getFilename()).toString(); | ||
|
||
const require = createRequire(filename); | ||
axeCorePath = require.resolve('axe-core'); | ||
} | ||
|
||
const source = fs.readFileSync(axeCorePath, 'utf8'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should comment on why this was necessary to add vs just using __filename
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry - forgot to add, we should add a test
Closes: #717