-
Notifications
You must be signed in to change notification settings - Fork 26
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
docs, test: clarify how to hook a module sub-path using .cjs extension #89
base: main
Are you sure you want to change the base?
Conversation
// E.g., a Hook arg of `cjs-sub-module/foo` will **not** hook | ||
// `./node_modules/cjs-sub-module/foo.cjs`. This is different compared to `.js` | ||
// file extension usage. The difference is that Node.js's `require()` treats | ||
// `.js` and `.cjs` differently. | ||
// See https://nodejs.org/api/modules.html#file-modules |
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.
I understand the reasoning, but it would make instrumenting modules very complicated. The end user API of require-in-the-middle
is that the export of whatever targeted module is provided to the hook function. The (package.json).exports
map complicates this as it can resolve the same export name to multiple extensions. In my view, the hook function shouldn't need to know about that detail. It should just receive the right thing.
the `modules` entry. E.g. `@langchain/core/dist/callbacks/manager.cjs` is | ||
required to hook | ||
`.../node_modules/@langchain/core/dist/callbacks/manager.cjs`. | ||
This is because []`.cjs` is not handled specially by `require()` the way |
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.
This is because []`.cjs` is not handled specially by `require()` the way | |
This is because [`.cjs` is not handled specially by `require()` the way |
Refs: #88 (comment)
Repeating part of that comment above: