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]: Unable to recognize the less variable in the third-party library (like component library) #6439

Closed
Sunny-117 opened this issue May 5, 2024 · 4 comments

Comments

@Sunny-117
Copy link
Contributor

System Info

macOS
node:v16.14.2
pnpm: 6.32.3

Details

webpack can operate normally:
img_v3_02ai_1fb756d7-f27c-428b-815d-20f2be8317bg

rspack:
img_v3_02ai_2b5bd3bd-0514-449e-af5f-9a80824b502g
img_v3_02ai_a865a334-6836-4584-acdd-41b9ba692eag

I can directly use the less variable in the project. The less variable used inside the third-party component library will report an error.

Reproduce link

https://github.com/op-sources/rspack-bug-playground

Reproduce Steps

There is no need to install node_modules, because the reproduce link is already included.

Run project:
start webpack server: cd packages/active: pnpm dev
start rspack server: cd packages/home: pnpm dev

@Sunny-117 Sunny-117 added bug Something isn't working pending triage The issue/PR is currently untouched. labels May 5, 2024
@LingyuCoder
Copy link
Collaborator

Fail to build because node_modules of packages/* are lost.

@LingyuCoder LingyuCoder removed the pending triage The issue/PR is currently untouched. label May 6, 2024
@Sunny-117
Copy link
Contributor Author

Fail to build because node_modules of packages/* are lost.

It has been updated. Please take a look

node_modules download address and project start method: https://jzq422bol5.feishu.cn/wiki/Pe7pwcmdaitTBNk18vKcXuQjnth?from=from_copylink

@xc2
Copy link
Collaborator

xc2 commented May 7, 2024

this file is a css file other than a less file and the highlighted variable is a css variable as well.

min(1 * var(--dls-transition-from-y, 0), 0) is not valid in less by default.

please separate rules for less and css. e.g.,

[
    {
        test: /\.css$/,
        use: [
            {
              loader: 'style-resources-loader',
              options: {
                 // ...
              }
          }
        ],
        type: 'css'
    },
    {
        test: /\.less$/,
        use: [
            'less-loader',
            {
              loader: 'style-resources-loader',
              options: {
                 // ...
              }
          }
        ],
        type: 'css'
    },
]

or setting the math option of less.js to parens

    {
        test: lessRule,
        use: [
            {
                loader: 'less-loader',options: {lessOptions: {math: 'parens'}}
            },
            {
              loader: 'style-resources-loader',
              options: {
                 // ...
              }
          }
        ],
        type: 'css'
    },

@xc2 xc2 removed the bug Something isn't working label May 7, 2024
@Sunny-117
Copy link
Contributor Author

this file is a css file other than a less file and the highlighted variable is a css variable as well.

min(1 * var(--dls-transition-from-y, 0), 0) is not valid in less by default.

please separate rules for less and css. e.g.,

[
    {
        test: /\.css$/,
        use: [
            {
              loader: 'style-resources-loader',
              options: {
                 // ...
              }
          }
        ],
        type: 'css'
    },
    {
        test: /\.less$/,
        use: [
            'less-loader',
            {
              loader: 'style-resources-loader',
              options: {
                 // ...
              }
          }
        ],
        type: 'css'
    },
]

or setting the math option of less.js to parens

    {
        test: lessRule,
        use: [
            {
                loader: 'less-loader',options: {lessOptions: {math: 'parens'}}
            },
            {
              loader: 'style-resources-loader',
              options: {
                 // ...
              }
          }
        ],
        type: 'css'
    },

Thanks a lot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants