Skip to content
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

Allow non-module resolves #390

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Allow non-module resolves #390

wants to merge 2 commits into from

Conversation

MrQubo
Copy link

@MrQubo MrQubo commented Mar 31, 2020

This will allow resolving paths that aren't necessarily pointing to modules.

This can be achieved by adding isModulePath option to transform function. It makes sense to add this option there because whether the path should be interpreted as a path to the module or not depends on the calling function.

My use case is for configuring views and static directory for express.js. With this PR I can do something like this:

app.use(express.static(resolvePath('$res/public/')));

Where resolvePath is just an identity function (see DOCS.md#usage-with-proxyquire) and is configured via transformFunctions options like this:

transformFunctions: [
  ['resolvePath', { isModulePath: false }],
],

In this example, it is also possible to add express.static to transformFunctions list.

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.

None yet

1 participant