rspack icon indicating copy to clipboard operation
rspack copied to clipboard

[Feature]: Improve `DataCloneError` when invoking loaders in worker

Open h-a-n-a opened this issue 1 year ago • 2 comments

What problem does this feature solve?

Improve DataCloneError when invoking loaders in worker.

What does the proposed API of configuration look like?

N/A

h-a-n-a avatar Apr 24 '25 09:04 h-a-n-a

Current error when loader parallel is enabled and the options include a function:

Image

chenjiahan avatar Apr 24 '25 09:04 chenjiahan

a practical example of parallel loaders in the docs would also be appreciated

such as style-loader -> css-loader -> postcss-loader -> sass-loader sort of chain

which loaders are the current parallel feature compatible with?

I'm seeing errors with no description at all

edit: im also open to the idea that I don't know how to configure this properly, given the documentation

    let cssLoaderLoaders = [
        process.env.NODE_ENV === 'production' && {
            loader: rspack.CssExtractRspackPlugin.loader,
            options: {},
            // parallel: true,
        },
        process.env.NODE_ENV !== 'production' &&
            !isServer && {
                loader: 'style-loader',
                options: {},
                // parallel: true,
            },
        {
            loader: 'css-loader',
            options: {},
            // parallel: true,
        },
        {
            loader: 'postcss-loader',
            options: {
                config: {
                    path: path.resolve(__dirname, '../../postcss.config.js'),
                },
            },
            // parallel: true,
        },
        {
            loader: 'sass-loader',
            options: {
                api: 'modern-compiler',
                implementation: require.resolve('sass-embedded'),
                outputStyle: 'compressed',
            },
            // parallel: true,
        },
    ].filter(Boolean);

    const cssLoader = {
        test: /\.s?css$/,
        type: 'javascript/auto',
        use: cssLoaderLoaders,
    };

If I only set parallel: true on postcss-loader, I'll see things like

Image

Only enable on sass-loader

Image

tim-soft avatar Apr 24 '25 18:04 tim-soft

@tim-soft parallel has same limitation as thread-loader which only supports cloneable options, if you use some cloneable options, consider disable parallel for this loader or consider remove non-cloneable props

hardfist avatar Jul 09 '25 07:07 hardfist