web-infra-dev / rspack

The fast Rust-based web bundler with webpack-compatible API 🦀️
https://rspack.dev
MIT License
9.34k stars 544 forks source link

[Feature]: DefinePlugin support `__webpack_layer__` #7848

Open luhc228 opened 3 weeks ago

luhc228 commented 3 weeks ago

What problem does this feature solve?

Webpack supports __webpack_layer__ and it will be replaced with the value of entry.layer. But now Rspack doesn't support it.

What does the proposed API of configuration look like?

// webpack.config.js
module.exports = {
  entry: {
    catalog: {
      import: './catalog.js',
      layer: 'main'
    }
  },
  plugins: [
     new rspack.DefinePlugin({
      __RUNTIME_TYPE__: '__webpack_layer__'
    }) 
  ]
}
chenjiahan commented 2 weeks ago

@h-a-n-a Can you evaluate whether this feature can be supported?