Skip to content

feat: add possibility to get modules#170

Merged
larixer merged 4 commits into
sysgears:masterfrom
fyodorovandrei:feature-add-possibility-to-get-static-modules
Oct 3, 2023
Merged

feat: add possibility to get modules#170
larixer merged 4 commits into
sysgears:masterfrom
fyodorovandrei:feature-add-possibility-to-get-static-modules

Conversation

@fyodorovandrei

Copy link
Copy Markdown
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

larixer commented Oct 1, 2023

Copy link
Copy Markdown
Member

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

larixer commented Oct 1, 2023

Copy link
Copy Markdown
Member

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

larixer commented Oct 1, 2023

Copy link
Copy Markdown
Member

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
Copy Markdown
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

larixer commented Oct 3, 2023

Copy link
Copy Markdown
Member

@fyodorovandrei Many thanks, looks good!

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

larixer commented Oct 3, 2023

Copy link
Copy Markdown
Member

@fyodorovandrei Published as webpack-virtual-modules@0.6.0

@fyodorovandrei

Copy link
Copy Markdown
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