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

singleton dependency not working with sourcebuild #3134

Open
5 tasks done
yf-yang opened this issue Oct 30, 2024 · 2 comments
Open
5 tasks done

singleton dependency not working with sourcebuild #3134

yf-yang opened this issue Oct 30, 2024 · 2 comments

Comments

@yf-yang
Copy link

yf-yang commented Oct 30, 2024

Describe the bug

I am using modern.js's source build (rspack source build plugin I guess) with module federation. In the reproduction repo, there are three apps/packages

  • app -> lazy-dep
  • lazy-dep -> singleton-dep
    In package app, singleton-dep is specified as a singleton in the module federation configuration.

Now, if singleton-dep's dist/ folder does not exist, it is expected to use its source code for module federation. However, it does not work. The dist/ folder seems to be required.

I'd like to know if it is not supported, or I misconfigured something, or it is a bug.

To reproduce:

pnpm i
cd apps/app
pnpm dev

# open another shell
rm -r packages/singleton-dep/dist

From app's log, it shows it is expecting packages/singleton-dep/dist/es/index.js
After dist/ is removed, app could not compile and says × resolving fallback for shared module singleton-dep, the app could not run either.

Reproduction

https://github.com/yf-yang/module-federation-sourcebuild-debug

Used Package Manager

pnpm

System Info

System:
    OS: macOS 13.2.1
    CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
    Memory: 21.04 MB / 32.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 22.4.1 - /usr/local/bin/node
    npm: 10.8.1 - /usr/local/bin/npm
    pnpm: 9.5.0 - /usr/local/bin/pnpm
    bun: 1.0.29 - ~/.bun/bin/bun
    Watchman: 2023.10.09.00 - /usr/local/bin/watchman
  Browsers:
    Chrome: 130.0.6723.70
    Safari: 16.3

Validations

@ScriptedAlchemy
Copy link
Member

Use rslib?

@yf-yang
Copy link
Author

yf-yang commented Oct 30, 2024

@ScriptedAlchemy Could you be more specific?

I'm expecting:

  • app: using modernjs (rspack)
  • two dependencies: no need to build them during development, rspack's source build mode would handle them and build them (if that is applicable)

In other words, without building dist/ folders in those dependencies packages, could they be used as module federation singleton packages?

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

No branches or pull requests

2 participants