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]: Incorrect parsing of webpackInclude #7356

Open
elsassph opened this issue Jul 29, 2024 · 2 comments
Open

[Bug]: Incorrect parsing of webpackInclude #7356

elsassph opened this issue Jul 29, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@elsassph
Copy link

elsassph commented Jul 29, 2024

System Info

  System:
    OS: macOS 14.5
    CPU: (10) arm64 Apple M1 Pro
    Memory: 1.06 GB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.17.1 - ~/.nvm/versions/node/v18.17.1/bin/node
    npm: 9.6.7 - ~/.nvm/versions/node/v18.17.1/bin/npm
    pnpm: 9.4.0 - ~/.nvm/versions/node/v18.17.1/bin/pnpm
    bun: 1.0.15 - ~/.bun/bin/bun
  Browsers:
    Chrome: 126.0.6478.183
    Safari: 17.5
  npmPackages:
    @rspack/cli: 1.0.0-beta.0 => 1.0.0-beta.0 
    @rspack/core: 1.0.0-beta.0 => 1.0.0-beta.0 

Details

rspack

PR #7055 added support for some Webpack "magic comments", but but webpackInclude is incorrect:

/* webpackInclude: /^.{2,}$/ */

Results in an error which seem to suggest the regex has been incorrectly extracted:

Magic comments parse failed: `webpackInclude` expected a regular expression, but received: /^.{2.

Looking at the PR it seems the extraction logic stops at ,: https://github.com/web-infra-dev/rspack/pull/7055/files#diff-d53d879b548a6442e88215394f482df179f48e7f98e20f401f84051fef5bd63cR132

Reproduce link

N/A

Reproduce Steps

N/A

@elsassph elsassph added bug Something isn't working pending triage The issue/PR is currently untouched. labels Jul 29, 2024
@LingyuCoder
Copy link
Collaborator

Looking at the PR it seems the extraction logic stops at ,

Yes, this is an known issue. Webpack uses vm to eval the magic comments. But Rspack parses magic comments in rust, so we can only try to extract them with regular expressions. And also the rust std::regexp does not support (?!) so the extraction logic stops at , to get the regular expression of webpackInclude and webpackExclude.

You can just avoid to use ,. We are trying to find a better way to parse the magic comments.

@LingyuCoder LingyuCoder self-assigned this Jul 30, 2024
@elsassph
Copy link
Author

Good that you're aware, we'll work around the limitation.

FWIW it seems to me that Webpack parses those comments like JSON
/* webpackInclude: /^.{2,}$/ */ would be parsed as { webpackInclude: /^.{2,}$/ }.

@jerrykingxyz jerrykingxyz removed the pending triage The issue/PR is currently untouched. label Sep 2, 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