Skip to content
This repository has been archived by the owner on May 30, 2023. It is now read-only.

Adds require.resolve() functionality for better combatibility with node modules. #11972

Merged
2 commits merged into from
Jan 8, 2018

Conversation

alxarch
Copy link
Contributor

@alxarch alxarch commented Feb 11, 2014

The ability to know the filename that will be resolved by require comes in handy in many cases.

One example would be to use the resolved filename with page.injectJs() for injection of modules installed via npm.

npm install jquery
// In a module:
page.injectJs(require.resolve("jquery"));

As things stand now, i use the module._getFilename() method to achieve the same.
Adding it to resolve would make it easier to have code that runs both on node and phantomjs.

See http://nodejs.org/api/modules.html#modules_all_together for examples in nodejs.

In order to improve node module combatibility.
@ariya
Copy link
Owner

ariya commented Feb 20, 2014

Thanks for the patch! Please check the contribution guide first. Please squash both commits into one. Also, take a look at the test suite and add a new one for this feature.

@vitallium vitallium force-pushed the master branch 2 times, most recently from b3cd914 to c4df640 Compare June 27, 2015 08:43
@vitallium vitallium force-pushed the master branch 2 times, most recently from 573e969 to b483dd6 Compare October 6, 2015 20:31
@vitallium vitallium force-pushed the master branch 2 times, most recently from 1842ba8 to 842715b Compare March 15, 2016 17:40
@vitallium vitallium force-pushed the master branch 2 times, most recently from e024f31 to 5d99f2a Compare May 19, 2016 20:53
@ghost ghost merged commit 9fc2852 into ariya:master Jan 8, 2018
ghost pushed a commit that referenced this pull request Jan 8, 2018
ghost pushed a commit that referenced this pull request Jan 8, 2018
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants