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

feat: add possibility to get modules #170

Conversation

fyodorovandrei
Copy link
Contributor

What's the problem this PR addresses?
I needed to access the static modules multiple times. As shown in the links, people require them.

https://github.com/module-federation/universe/blob/main/packages/storybook-addon/src/lib/storybook-addon.ts#L81
https://github.com/nuxt-modules/storybook/blob/95cd445eed0cdc570bbfba03ff9589c727a41ee8/src/webpack.ts#L32C99-L32C99
...

How did you fix it?
A new method has been added to retrieve static modules.
...

@larixer
Copy link
Member

larixer commented Oct 1, 2023

getModules is a confusing API. How should I know as a developer that it returns only static modules and not both static and dynamic?

@larixer
Copy link
Member

larixer commented Oct 1, 2023

I'd prefer to have an API like getModuleList(options?: enum {ALL | STATIC | DYNAMIC}) and getModule(name: string) and the implementation would use _staticModules and finalInputFileSystem._virtualFiles to determine the module type and its contents. I'm not sure if you are willing to contribute that. It's more effort, but will result in a more roboust solution IMO.

@larixer
Copy link
Member

larixer commented Oct 1, 2023

Maybe it's okay to not distinguish between static and dynamic modules and return all module paths, i.e. have getModuleList() without options. But returning only static modules feels confusing for sure

@fyodorovandrei
Copy link
Contributor Author

@larixer Could you please provide me with your feedback on whether I have extracted the dynamic modules correctly? Thank you.

@fyodorovandrei fyodorovandrei changed the title feat: add possibility to get static modules feat: add possibility to get modules Oct 2, 2023
@larixer
Copy link
Member

larixer commented Oct 3, 2023

@fyodorovandrei Many thanks, looks good!

@larixer larixer merged commit 60f2206 into sysgears:master Oct 3, 2023
3 checks passed
@fyodorovandrei fyodorovandrei deleted the feature-add-possibility-to-get-static-modules branch October 3, 2023 15:13
@larixer
Copy link
Member

larixer commented Oct 3, 2023

@fyodorovandrei Published as webpack-virtual-modules@0.6.0

@fyodorovandrei
Copy link
Contributor Author

Nice! Thank you @larixer

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.

2 participants