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

Is webpackConfig supported in non-cli usage? #394

Closed
jayu opened this issue Nov 14, 2020 · 3 comments · Fixed by #402
Closed

Is webpackConfig supported in non-cli usage? #394

jayu opened this issue Nov 14, 2020 · 3 comments · Fixed by #402
Labels
enhancement this will make dependency-cruiser sweeter

Comments

@jayu
Copy link

jayu commented Nov 14, 2020

Summary

Hey, I would like to make sure what's the status of support for webpack config, or actually using webpack aliases to module resolution while using dependency-cruiser as a module.
Documentation suggests that there is webpackConfig option available, but id do not work for me. After reading the code of src/main it seems that this option is not taken into account anywhere.

My questions are what's the status of webpack config support when using lib as a module, how much effort it will require to add support and how can I help :)?

Context

I'm building a small tool rev-dep based on dependency-cruiser and I wanted to add webpack aliases support.

Environment

n/a

@sverweij
Copy link
Owner

Hi @jayu it is supported, although the API expects the resolve part of the webpack config in an object that is already preprocessed. This pre-processing is currently part of the cli code, though (src/cli/get-resolve-config.js).

Come to think of it, that + similar pre-processing for typescript and babel configs should actually be in a more obvious spot.

@jayu
Copy link
Author

jayu commented Nov 16, 2020

Thanks for the clarification! How about moving src/cli/get-resolve-config.js to src/main/get-resolve-config.js and making use of it in src/main/resolve-options/normalize.js to support webpackingConfig in usage as a module ?

I checked and it works for me when I pass the proper alias object as the third argument to the cruise function however that would be handier to just pass a path to config instead of copying logic from get-resolve-config.js to my project :D
I can work on PR

@sverweij
Copy link
Owner

Hi @jayu exposing get-resolve-config (and the equivalents for babel, typescript and dependency-cruiser configs) through a stable API is the target solution I have in mind as well - I haven't had sufficient bandwidth to come up with a decent way to refactor this, though. Ideally it'd be something indeed available through the main interface.

In the mean time you can use the code in the cli folder without having to copy it over to your own project (const getResolveConfig = require('dependency-cruiser/src/cli/get-resolve-config'); - not beautiful, but it'll work).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement this will make dependency-cruiser sweeter
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants