Skip to content

Webpack omits exposed modules when sideEffects are enabled #120

Closed
@psimk

Description

@psimk

Reopening issue #89. The same problem still occurs on version 1.0.1 of expose-loader

  • Operating System:
  • Node Version: 12.8.3
  • NPM Version: 6.14.8
  • webpack Version: 4.35.0
  • expose-loader Version: 1.0.1

Preface

sideEffects is set to true when mode is production.

Expected Behavior

When mode is production, styled-components is bundled and exposed as a global styled variable.

Actual Behavior

When mode is production, neither styled-components or the exposed global styled are included into the bundled output.

Code

import "expose-loader?exposes=styled!styled-components";

webpack.config.js

How Do We Reproduce?

I have forked the reproduction branch from the previous issue and updated it to use 1.0.1 of expose-loader.
https://github.com/psimk/reproduction-expose-loader-optimization

Once again, the bug reproduction can be found in the with-expose-loader directory. There are also variants for but without expose-loader and one with sideEffects: false, both of which do produce the expected output. The build output is part of the repository, so you can inspect it without cloning. Additional information can be found in the repository readme.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions