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

css-loader produces invalid es5 code #1033

Closed
timocov opened this issue Dec 30, 2019 · 5 comments · Fixed by #1035
Closed

css-loader produces invalid es5 code #1033

timocov opened this issue Dec 30, 2019 · 5 comments · Fixed by #1035

Comments

@timocov
Copy link

timocov commented Dec 30, 2019

  • Operating System: windows 10
  • Node Version: 12.4
  • NPM Version: 6.13.4
  • webpack Version: 4.41.5
  • css-loader Version: 3.4.0

Expected Behavior

No JS code produced.

Actual Behavior

css-loader produces

// Exports
module.exports = {
undefined
};

what is incorrect es5 code (also I don't think that having exported undefined key with undefined value is good here).

Code

I'll fill code later if it's really needed, but just looking into the code you're able to see difference between 3.3 and 3.4 versions.

Just look at https://github.com/webpack-contrib/css-loader/blob/v3.3.2/src/utils.js#L387-L389 and https://github.com/webpack-contrib/css-loader/blob/v3.4.0/src/utils.js#L417-L479. Previously (in 3.3.2) if exports length is 0 then it returns empty string. Now it doesn't check it and after if (exports.length > 0) { variable exportLocalsCode is undefined so that's why it produces incorrect output.

How Do We Reproduce?

I don't have working example right now, but it looks like that it fails if css module exports nothing (e.g. :global expression only).

@timocov
Copy link
Author

timocov commented Dec 30, 2019

Broken in 23bc1e9.

@alexander-akait
Copy link
Member

Can you create reproducible test repo?

@alexander-akait
Copy link
Member

Looks like bug, agree

@timocov
Copy link
Author

timocov commented Dec 30, 2019

I'll try. It isn't so easy to extract repro from huge project :)

@alexander-akait
Copy link
Member

Reproduced, WIP

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

Successfully merging a pull request may close this issue.

2 participants