-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
Add find
method to require
#70
Comments
Implementing this behaviour on your own is trivial: function find( moduleName ){
try {
return require.resolve( moduleName );
} catch( e ){
return null;
}
} What exactly is |
@missinglink Yep, it's trivial. And platform API should be clean and trivial, isn't? But the problem is that |
-1. The module loading code is Just use @missinglink's snippet or the |
@fampinheiro Are you serious? Was you looking it's source? It will not work like it should because it not context-dependent and couldn't be. |
Why can't it? |
@aredridel Because iojs could not control Joyent policy so backward compatibility will be broken soon (after version 1.0). To prevent a mess of io and node packages module directory should be renamed. |
Not sure why they'd be separate. and there's no guarantee that a breaking change will ever happen, nor would changing the folder name help that (it'd only break more) |
@rumkin, @aredridel please stick to the reported issue and avoid speculation. |
1. We parse error stack in chakra_shim to make it simliar to that of v8. However we were missing the case if stack messages has `\n`. Fixed it. Fixes: nodejs#78 2. Fixed Error.captureStackTrace Since `chakra_shim.js` that patches `Error.captureStackTrace` runs under strict mode, it was not able to get caller information. Having caller information is much reliable in captureStackTrace than matching using `function.name`. Removed `use strict` and disabled eslint rule for `use strict`. This helped in matching caller exactly regardless of name of form `o.p.q` in `Error.captureStackTrace`. Fixes: nodejs#75 3. Added missing functions on StackFrame Added following missing methods on StackFrame: * getFunction * getMethodName * getTypeName * isConstructor * isToplevel * isNative Implemented `getFunction`. `getFunction` currently works if `.stack` is called from same callsite where `new Error()` or `Error.captureStackTrace()` was called. However currently we don't record and store the callstack when these functions were called and so we lose the information of `.caller` when called later while populating `e.stack`. If we save the callstack, we would be holding references to all the functions in the callstack which doesn't seem right. I have added a TODO to solve this, but wanted to send this out so we get better coverage on node compatibility. Fixes : nodejs#70 PR-URL: nodejs/node-chakracore#85 Reviewed-By: Jianchun Xu <Jianchun.Xu@microsoft.com>
First, GCC doesn't seem to implement an interface keyword. Workaround here is to use struct instead of interface. This is nodejs/abi-stable-node#69 Second, GCC doesn't support the flavor of static_assert which takes a single parameter. Just added a second parameter message here.
Original commit message: [M86 LTS] Disable failing tests Disable failing tests backported from ToT. No existing tests are disabled. No-Try: true No-Presubmit: true No-Tree-Checks: true Bug: None Change-Id: I94d2cd4827ce6fd1875c66912b4841a4a7c72ab3 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2764754 Reviewed-by: Artem Sumaneev <asumaneev@google.com> Commit-Queue: Victor-Gabriel Savu <vsavu@google.com> Cr-Commit-Position: refs/branch-heads/8.6@{nodejs#70} Cr-Branched-From: a64aed2333abf49e494d2a5ce24bbd14fff19f60-refs/heads/8.6.395@{#1} Cr-Branched-From: a626bc036236c9bf92ac7b87dc40c9e538b087e3-refs/heads/master@{#69472} Refs: v8/v8@5678ebe
Original commit message: [M86 LTS] Disable failing tests Disable failing tests backported from ToT. No existing tests are disabled. No-Try: true No-Presubmit: true No-Tree-Checks: true Bug: None Change-Id: I94d2cd4827ce6fd1875c66912b4841a4a7c72ab3 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2764754 Reviewed-by: Artem Sumaneev <asumaneev@google.com> Commit-Queue: Victor-Gabriel Savu <vsavu@google.com> Cr-Commit-Position: refs/branch-heads/8.6@{nodejs#70} Cr-Branched-From: a64aed2333abf49e494d2a5ce24bbd14fff19f60-refs/heads/8.6.395@{#1} Cr-Branched-From: a626bc036236c9bf92ac7b87dc40c9e538b087e3-refs/heads/master@{#69472} Refs: v8/v8@5678ebe
Original commit message: [M86 LTS] Disable failing tests Disable failing tests backported from ToT. No existing tests are disabled. No-Try: true No-Presubmit: true No-Tree-Checks: true Bug: None Change-Id: I94d2cd4827ce6fd1875c66912b4841a4a7c72ab3 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2764754 Reviewed-by: Artem Sumaneev <asumaneev@google.com> Commit-Queue: Victor-Gabriel Savu <vsavu@google.com> Cr-Commit-Position: refs/branch-heads/8.6@{#70} Cr-Branched-From: a64aed2333abf49e494d2a5ce24bbd14fff19f60-refs/heads/8.6.395@{#1} Cr-Branched-From: a626bc036236c9bf92ac7b87dc40c9e538b087e3-refs/heads/master@{#69472} Refs: v8/v8@5678ebe PR-URL: #38275 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Shelley Vohr <codebytere@gmail.com>
Actually it's very strange behaviour of require.resolve, which throws an error when package not found. Add require.find method which would return null if package not found.
The text was updated successfully, but these errors were encountered: