Skip to content

Conversation

@bengl
Copy link
Member

@bengl bengl commented Sep 23, 2025

If import is used to load hook.js, then any additional loaders running before IITM that assign result.source (as indicated by the Node.js docs) on CommonJS files will cause a not-implemented error to be thrown inside Node.js. This is probably a bug in Node.js, but this ought to be an appropriate workaround (espectially since IITM supports old versions of Node.js).

Here is a reproduction without using IITM: https://gist.github.com/bengl/75470adfc01e83886572132ab1ce7af4

An issue will be opened on Node.js core soon.

If import is used to load hook.js, then any loaders that assign
`result.source` (as indicated by the Node.js docs) on CommonJS files
will cause a not-implemented error to be thrown inside Node.js. This is
probably a bug in Node.js, but this ought to be an appropriate
workaround (espectially since IITM supports old versions of Node.js).
@timfish timfish changed the title fix: use createRequire to load hook.js fix: use createRequire to load hook.js Sep 24, 2025
@timfish timfish merged commit 81a2ae0 into nodejs:main Sep 24, 2025
51 checks passed
timfish added a commit to timfish/import-in-the-middle that referenced this pull request Sep 25, 2025
bengl added a commit to bengl/import-in-the-middle that referenced this pull request Sep 25, 2025
This is a second attempt at fixing the double-loader issue in nodejs#205. The
tests from that commit are included.
bengl added a commit to bengl/import-in-the-middle that referenced this pull request Sep 25, 2025
This is a second attempt at fixing the double-loader issue in nodejs#205. The
tests from that commit are included.
bengl added a commit to bengl/import-in-the-middle that referenced this pull request Sep 25, 2025
This is a second attempt at fixing the double-loader issue in nodejs#205. The
tests from that commit are included.
bengl added a commit to bengl/import-in-the-middle that referenced this pull request Oct 14, 2025
This is a second attempt at fixing the double-loader issue in nodejs#205. The
tests from that commit are included.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants