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

[Bug]: modern-module library compilation mode not exported properly #8546

Open
lzxb opened this issue Nov 27, 2024 · 22 comments
Open

[Bug]: modern-module library compilation mode not exported properly #8546

lzxb opened this issue Nov 27, 2024 · 22 comments
Assignees
Labels
bug Something isn't working

Comments

@lzxb
Copy link
Contributor

lzxb commented Nov 27, 2024

System Info

System:
OS: macOS 15.0.1
CPU: (8) arm64 Apple M1
Memory: 125.64 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 22.9.0 - ~/.nvm/versions/node/v22.9.0/bin/node
Yarn: 1.22.22 - ~/.nvm/versions/node/v22.9.0/bin/yarn
npm: 10.8.3 - ~/.nvm/versions/node/v22.9.0/bin/npm
pnpm: 9.13.2 - ~/.nvm/versions/node/v22.9.0/bin/pnpm
bun: 1.1.27 - ~/.bun/bin/bun
Browsers:
Safari: 18.0.1
npmPackages:
@rspack/cli: 1.1.4 => 1.1.4
@rspack/core: 1.1.4 => 1.1.4

Details

Source code
Image

Compile code
Image

Reproduce link

https://github.com/lzxb/rspack-externals-error

Reproduce Steps

pnpm i
pnpm build

@lzxb lzxb added bug Something isn't working pending triage The issue/PR is currently untouched. labels Nov 27, 2024
@lzxb
Copy link
Contributor Author

lzxb commented Nov 27, 2024

If mode equal to production , It is ok。

@fi3ework fi3ework self-assigned this Nov 27, 2024
@fi3ework
Copy link
Member

The reason of the verbose output is due to lacking the following configurations:

  experiments: {
    outputModule: true,
+    rspackFuture: {
+      bundlerInfo: {
+        force: false,
+      },
+    },
  },
  optimization: {
    minimize: false,
+   concatenateModules: true,
  },
  1. manually enable concatenateModules in development mode, as it's the premise of modern-module. I think it's reasonable to check it's enabled before build by default.
  2. disable bundlerInfo to avoid unneed debug info.

@lzxb
Copy link
Contributor Author

lzxb commented Nov 27, 2024

I use modern-module, which can cause many module compilation errors. Canmodule support export *?

@lzxb
Copy link
Contributor Author

lzxb commented Nov 27, 2024

My Config
Image

Source code
Image

Output
Image

@lzxb
Copy link
Contributor Author

lzxb commented Nov 27, 2024

The content output here has lost its export.

@fi3ework
Copy link
Member

I use modern-module, which can cause many module compilation errors.

Could you provide the error so we can fix it?

Canmodule support export *?

No.

@fi3ework
Copy link
Member

A reproduce repository please? It is hard to reproduce via a screenshot.

@lzxb
Copy link
Contributor Author

lzxb commented Nov 27, 2024

A reproduce repository please? It is hard to reproduce via a screenshot.

I updated code.
https://github.com/lzxb/rspack-externals-error

@lzxb
Copy link
Contributor Author

lzxb commented Nov 27, 2024

Image
Image

@fi3ework
Copy link
Member

fi3ework commented Nov 27, 2024

Same as web-infra-dev/rslib#316.

Workaround for now it's to use two splitted build process.

@fi3ework
Copy link
Member

Specify different layer (https://rspack.dev/config/experiments#experimentslayers) for each entry is also a workaround.

@lzxb
Copy link
Contributor Author

lzxb commented Nov 27, 2024

Is there a plan to solve it in the future?

@fi3ework
Copy link
Member

It should be resolved, but the time is not promised.

@lzxb
Copy link
Contributor Author

lzxb commented Nov 27, 2024

I'll try usingexternals first to solve it

@lzxb
Copy link
Contributor Author

lzxb commented Nov 27, 2024

I have solved the above problem using externals. But we encountered a new problem

@lzxb
Copy link
Contributor Author

lzxb commented Nov 27, 2024

  1. Clone https://github.com/dp-os/gez/tree/feat-modern-module
  2. pnpm i
  3. pnpm build:packages
  4. cd examples/ssr-html
  5. pnpm dev
    Image

Image

Image

pnpm build:ssr is ok.

@lzxb
Copy link
Contributor Author

lzxb commented Nov 27, 2024

Build target node is ok.
Image

@fi3ework
Copy link
Member

It's because of the https://github.com/dp-os/gez/blob/78da1962deea63a7e4efdf91873448984aea8e4e/packages/rspack/src/config.ts#L94-L96 break the concatenation premise of modern-module. modern-module is now designed mainly to build compact ESM output and not tested to work with HMR now.

@lzxb
Copy link
Contributor Author

lzxb commented Nov 27, 2024

It's because of the https://github.com/dp-os/gez/blob/78da1962deea63a7e4efdf91873448984aea8e4e/packages/rspack/src/config.ts#L94-L96 break the concatenation premise of modern-module. modern-module is now designed mainly to build compact ESM output and not tested to work with HMR now.

I plan to use Rspack to build a pure ESM application, but it seems like I can't keep going now.

@lzxb
Copy link
Contributor Author

lzxb commented Nov 28, 2024

I have tested many and themodule is now stable, but it does not support export *

@lzxb
Copy link
Contributor Author

lzxb commented Nov 28, 2024

modern-module output is unstable,Built at different times, the output results are inconsistent. Sometimes normal, sometimes incorrect.

Image
Image

@lzxb
Copy link
Contributor Author

lzxb commented Nov 28, 2024

Provided new examples #8557

@chenjiahan chenjiahan removed the pending triage The issue/PR is currently untouched. label Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants