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]: using concatenateModules with experiments.css and results in no CSS in output #5593

Closed
colinaaa opened this issue Feb 3, 2024 · 2 comments · Fixed by #5635
Closed
Assignees
Labels
bug Something isn't working pending triage The issue/PR is currently untouched. urgent Fix build-breaking bugs affecting most users, should be released ASAP (priority)

Comments

@colinaaa
Copy link
Contributor

colinaaa commented Feb 3, 2024

System Info

  Binaries:
    Node: 18.17.1 - ~/Library/Caches/fnm_multishells/3027_1706874775530/bin/node
    Yarn: 1.22.19 - ~/Library/Caches/fnm_multishells/3027_1706874775530/bin/yarn
    npm: 9.6.7 - ~/Library/Caches/fnm_multishells/3027_1706874775530/bin/npm
    pnpm: 7.33.6 - ~/Library/Caches/fnm_multishells/3027_1706874775530/bin/pnpm
  Browsers:
    Chrome: 121.0.6167.85
    Firefox Nightly: 115.0
    Safari: 17.0
  npmPackages:
    @rspack/cli: ^0.5.1 => 0.5.1 
    @rspack/core: 0.5.3-canary-c9f8d78-20240201071306 => 0.5.3-canary-c9f8d78-20240201071306 

Details

I'm using the concatenateModules from #5415. It is great that the bundle size reduced significantly!

But it seems that there is no CSS in the output :(

And if I add @import './bar.css'; in the CSS, the imported CSS will be emitted to the output. Seems like only the CSS directly imported by JS is not emitted correctly.

Reproduce link

No response

Reproduce Steps

Using the following example:

// index.js
import styles from './foo.css'

console.log(styles)
/** foo.css */
.foo {
    background-color: red;
}
// rspack.config.js
export default {
  mode: "production",
  entry: {
    main: "./index.js",
  },
  optimization: {
    concatenateModules: true,
    minimize: false,
  },
  module: {
    rules: [
      {
        test: /\.css$/,
        type: "css/module",
      },
    ],
  },
  experiments: {
    css: true,
    rspackFuture: {
      newTreeshaking: true,
    },
  },
};
@colinaaa colinaaa added bug Something isn't working pending triage The issue/PR is currently untouched. labels Feb 3, 2024
@IWANABETHATGUY
Copy link
Contributor

https://github.com/IWANABETHATGUY/rspack-concate-css-module
looks like the output is already different from webpack so there is no way to align with webpack concatenateModules, can you have a look @JSerFeng

@hardfist hardfist added the urgent Fix build-breaking bugs affecting most users, should be released ASAP (priority) label Feb 7, 2024
@JSerFeng JSerFeng self-assigned this Feb 7, 2024
@JSerFeng
Copy link
Collaborator

JSerFeng commented Feb 7, 2024

Though the runtime is different, we should still generate correct CSS output.
The reason of this issue is that, concate module will remove module from original chunk, but only if the module's sourceType === javascript. For CSS module, it can have 2 sourceType, it should delete the javascript sourceType, and do not disconnect module from that chunk

See webpack/webpack#15515

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pending triage The issue/PR is currently untouched. urgent Fix build-breaking bugs affecting most users, should be released ASAP (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants