webpackPrefetch always creates `link rel` , does not matter if the `if statement` is `true` or `false`

Bug report

Do you want to request a feature or report a bug?
I want to report a bug

What is the current behavior?
If use the dynamic import with webpackPrefetch like here

 componentDidMount() {
    if(this.props.getcomponent){
      import(/* webpackChunkName: "Component", webpackPrefetch: -999 */'../components/Component').then(Component => {
        this.setState({ Component });
      })
    }
  }

webpack always creates the link rel with this component created – it happens also if make

 componentDidMount() {
    if(undefined){
      import(/* webpackChunkName: "Component", webpackPrefetch: -999 */'../components/Component').then(Component => {
        this.setState({ Component });
      })
    }
  }

so any if statement- false or true does not matter – creates link rel

What is the expected behavior?
Expected behavior is that if the if statement is false – it should not create the link rel for component prefetch.
Webpack should create link rel – only if the if statement is true

webpack version: ^4.16.2
Node.js version: v8.11.3
Operating System: macOs High Sierra

Author: Fantashit

1 thought on “webpackPrefetch always creates `link rel` , does not matter if the `if statement` is `true` or `false`

Comments are closed.