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

RSPack support and compatibility #55

Open
KrzysztofZawisla opened this issue Nov 27, 2023 · 6 comments
Open

RSPack support and compatibility #55

KrzysztofZawisla opened this issue Nov 27, 2023 · 6 comments
Labels
enhancement New feature or request help wanted Extra attention is needed
Milestone

Comments

@KrzysztofZawisla
Copy link

KrzysztofZawisla commented Nov 27, 2023

Feature request

What is motivation or use case for adding/changing the behavior?
Would be nice to add compatibility with rspack ecosystem as many other webpack plugins are already compatible with rspack. In my project, it's the only plugin that is incompatible with rspack and doesn't have any other equivalent

Useful links: https://www.rspack.dev/

Describe the solution you'd like
Resolve the error on the attached screenshot

rspack

Describe alternatives you've considered
None

@KrzysztofZawisla
Copy link
Author

By the fact that there's no alternative in the ecosystem I mean no alternative which is able to preload assets (CSS, scripts, fonts, etc.)

@webdiscus
Copy link
Owner

Hello @KrzysztofZawisla,

thanks for the feature request!
I don't use rspack (yet), but I'm thinking of using it in the future (next year) and I will optimize the plugin for rspack.

@webdiscus webdiscus added this to the backlog milestone Nov 27, 2023
@webdiscus
Copy link
Owner

@KrzysztofZawisla

can you please create a repo with reproducible issue. I'll see whether the problem is difficult. Perhaps this is not such complex and I can quickly fix it.

@webdiscus webdiscus added enhancement New feature or request help wanted Extra attention is needed labels Nov 27, 2023
@davidmurdoch
Copy link

I think RSPack will need to catch up on webpack features and internal hooks. I doubt there is anything html-bundler-webpack-plugin can do.

Rspack chokes on this simple config:

// 1. create `./src/index.html` with an empty, but valid, HTML5 document
// 2. create `./webpack.config.js`
// 3. run `npx -y @rspack/cli --config webpack.config.js`

const HtmlBundlerPlugin = require('html-bundler-webpack-plugin');

const config = {
    mode: "development",
    entry: {
        index: './src/index.html'
    },
    plugins: [
        new HtmlBundlerPlugin()
    ]
};
module.exports = config;

The error I get is:

Error: Napi Error: Failed to convert JavaScript value `function anonymous(..) ` into rust type `String`

    at Compiler._Compiler_getInstance (/home/david/.npm/_npx/89e5cd2d45bac79e/node_modules/@rspack/core/dist/Compiler.js:516:55)
    at Compiler.build (/home/david/.npm/_npx/89e5cd2d45bac79e/node_modules/@rspack/core/dist/Compiler.js:380:87)
    at /home/david/.npm/_npx/89e5cd2d45bac79e/node_modules/@rspack/core/dist/Compiler.js:347:26
    at Hook.eval [as callAsync] (eval at create (/home/david/.npm/_npx/89e5cd2d45bac79e/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
    at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/home/david/.npm/_npx/89e5cd2d45bac79e/node_modules/tapable/lib/Hook.js:18:14)
    at /home/david/.npm/_npx/89e5cd2d45bac79e/node_modules/@rspack/core/dist/Compiler.js:343:32
    at Hook.eval [as callAsync] (eval at create (/home/david/.npm/_npx/89e5cd2d45bac79e/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:15:1)
    at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/home/david/.npm/_npx/89e5cd2d45bac79e/node_modules/tapable/lib/Hook.js:18:14)
    at doRun (/home/david/.npm/_npx/89e5cd2d45bac79e/node_modules/@rspack/core/dist/Compiler.js:339:34)
    at Compiler.run (/home/david/.npm/_npx/89e5cd2d45bac79e/node_modules/@rspack/core/dist/Compiler.js:375:13) {
  code: 'GenericFailure'
}

But even if you remove HtmlBundlerPlugin, switch to a JavaScript entry, and start adding webpack config options, like cache: object, it will error, as it expects cache to be a Boolean. There are many other options it doesn't support (optimization.moduleIds = "size", output.chunkFilename = function, symlinks: false, and more.

@exocornet
Copy link

exocornet commented Mar 9, 2024

Hello. I'm also trying to switch to RSPack and have the same problem with the plugin. I would like to see support in the near future. Essentially he is complaining about pug-plugin joining the RSPack ecosystem. Thank you.

P.S. - I'm trying to do it myself for pug-plugin.

@webdiscus
Copy link
Owner

webdiscus commented Mar 9, 2024

@KrzysztofZawisla, @davidmurdoch, @exocornet

Currently, RSPack v0.5.6 is yet not 100% compatible with the Webpack.

Using the html-bundler-webpack-plugin with RSPack occurs the issue:

/Users/xxxx/html-bundler-webpack-plugin/experiments/rspack/node_modules/@rspack/core/dist/Compiler.js:518
    __classPrivateFieldSet(this, _Compiler_instance, new instanceBinding.Rspack(rawOptions, this.builtinPlugins, {
                                                     ^

Error: Failed to convert JavaScript value `function filenameFn(..) ` into rust type `String`

    at Compiler._Compiler_getInstance (/Users/xxxx/html-bundler-webpack-plugin/experiments/rspack/node_modules/@rspack/core/dist/Compiler.js:518:54)
    at Compiler.build (/Users/xxxx/html-bundler-webpack-plugin/experiments/rspack/node_modules/@rspack/core/dist/Compiler.js:384:87)
    at /Users/xxxx/html-bundler-webpack-plugin/experiments/rspack/node_modules/@rspack/core/dist/Watching.js:263:23
    at Hook.eval [as callAsync] (eval at create (/Users/xxxx/html-bundler-webpack-plugin/experiments/rspack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:24:1)
    at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/Users/xxxx/html-bundler-webpack-plugin/experiments/rspack/node_modules/tapable/lib/Hook.js:18:14)
    at Watching._Watching_go (/Users/xxxx/html-bundler-webpack-plugin/experiments/rspack/node_modules/@rspack/core/dist/Watching.js:253:34)
    at Watching._Watching_invalidate (/Users/xxxx/html-bundler-webpack-plugin/experiments/rspack/node_modules/@rspack/core/dist/Watching.js:217:74)
    at /Users/xxxx/html-bundler-webpack-plugin/experiments/rspack/node_modules/@rspack/core/dist/Watching.js:51:94
    at process.processTicksAndRejections (node:internal/process/task_queues:77:11) {
  code: 'GenericFailure'
}

This is a BUG on the RSPack side.

Here is the minimal usage example rspack-html-bundler.

rspack.config.js

const path = require('path');
const HtmlBundlerPlugin = require('html-bundler-webpack-plugin');

module.exports = {
  output: {
    path: path.join(__dirname, 'dist/'),
    publicPath: '',
  },

  entry: {},

  plugins: [
    // TODO: fix rspack issue
    new HtmlBundlerPlugin({
      entry: {
        index: './src/template.html',
      },
    }),
  ],
};

How to reproduce

git clone https://github.com/webdiscus/html-bundler-webpack-plugin.git
cd html-bundler-webpack-plugin/experiments/rspack
npm i
npm run dev

Please, can you create an issue by the RSPack to add the compatibility with this plugin.

📌 Note
A symbiosis of the fast RSPack and the powerful html-bundler-webpack-plugin could be a Vite killer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants