Skip to content

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.

1 participant