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

fix: add defaultExport in empty export #1108

Merged
merged 2 commits into from
Aug 19, 2024

Conversation

houhongxu
Copy link
Contributor

This PR contains a:

  • bugfix
  • new feature
  • code refactor
  • test update
  • typo fix
  • metadata update

Motivation / Use-Case

if i have an empty less file
with config like this

 {
      test: /\.module\.less$/,
      use: [
        prodEnv
          ? {
              loader: MiniCssExtractPlugin.loader,
              options: {
                defaultExport: true,
              },
            }
          : require.resolve("style-loader"),
        {
          loader: require.resolve("css-loader"),
          options: {
            esModule: true,
            modules: {
              namedExport: true,
            },
          },
        },
        require.resolve("less-loader"),
      ],
}

i got an error

ModuleDependencyError: export 'default' (imported as 'styles') was not found in './index.module.less' (possible exports: container)

in mini-css-extract-plugin/loader.js function makeResult, when locals===undefined esModule===true defaultExport===true, only return export {}

this pr add the export {}; export default {}

Breaking Changes

Additional Info

Copy link

linux-foundation-easycla bot commented Aug 17, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: alexander-akait / name: Alexander Akait (1703161)
  • ✅ login: houhongxu / name: HHX (69a46dd)

Copy link
Member

@alexander-akait alexander-akait left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test case?

Copy link

codecov bot commented Aug 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.39%. Comparing base (c7ff30d) to head (1703161).
Report is 15 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1108      +/-   ##
==========================================
- Coverage   90.61%   85.39%   -5.22%     
==========================================
  Files           5        5              
  Lines         895     1041     +146     
  Branches      255      305      +50     
==========================================
+ Hits          811      889      +78     
- Misses         74      128      +54     
- Partials       10       24      +14     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@alexander-akait alexander-akait merged commit 8f77e19 into webpack-contrib:master Aug 19, 2024
40 of 41 checks passed
@alexander-akait
Copy link
Member

Thank you

@houhongxu
Copy link
Contributor Author

Thank you

Thank you 😝

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 this pull request may close these issues.

2 participants