Giter Club home page Giter Club logo

Comments (17)

pmmmwh avatar pmmmwh commented on May 19, 2024 2

I reproduced this by adding the Webpack conf, in webpack.config, in resolve.plugins section, not in plugins section

resolve: {
  plugins: [
    new ReactRefreshWebpackPlugin(),
  ],
}

It's working by putting the configuration in webpack plugins section.

Well I don't think this is something that we have to deal with ... ? All plugins could fail if you use them as resolver plugins?

from react-refresh-webpack-plugin.

paaacman avatar paaacman commented on May 19, 2024 1

I reproduced this by adding the Webpack conf, in webpack.config, in resolve.plugins section, not in plugins section

resolve: {
  plugins: [
    new ReactRefreshWebpackPlugin(),
  ],
}

It's working by putting the configuration in webpack plugins section.

from react-refresh-webpack-plugin.

paaacman avatar paaacman commented on May 19, 2024 1

Well I don't think this is something that we have to deal with ... ? All plugins could fail if you use them as resolver plugins?

I totally agree with you, you should not handle this case, it's a configuration error made by us.
I added this comment to help anybody who, like me, made this mistake and look for a solution here :)

from react-refresh-webpack-plugin.

drather19 avatar drather19 commented on May 19, 2024

That's odd... I also tried it on a brand new CRA project using the instructions in the README, but didn't encounter the same error. I did the following:

npx create-react-app . --typescript
npm run eject
npm install react-refresh-webpack-plugin react-refresh

from react-refresh-webpack-plugin.

gaearon avatar gaearon commented on May 19, 2024

I tried this on ejected “todomvc” app from Redux repo examples folder.

from react-refresh-webpack-plugin.

pmmmwh avatar pmmmwh commented on May 19, 2024

After adding this plugin to an ejected CRA project I get:

Cannot read property 'mode' of undefined

Are we assuming some particular webpack version?

That's my bad - I did some sniffing on webpack mode but did not add a check for its existence.

Edit: That's actually strange. mode of undefined means that the Webpack compiler did not receive any options (compiler.options.mode) ...

from react-refresh-webpack-plugin.

gaearon avatar gaearon commented on May 19, 2024

I did some sniffing on webpack mode but did not add a check for its existence.

Maybe you’re checking it incorrectly? It sounds weird you’d have to sniff for it.

What does TerserPlugin do to only turn on in production mode? We need to do the opposite of that.

from react-refresh-webpack-plugin.

pmmmwh avatar pmmmwh commented on May 19, 2024

I did some sniffing on webpack mode but did not add a check for its existence.

Maybe you’re checking it incorrectly? It sounds weird you’d have to sniff for it.

What does TerserPlugin do to only turn on in production mode? We need to do the opposite of that.

I worded it inappropriately. I edited my comment above to reflect what is actually happening.

I'll check how TerserPlugin does it.

Edit: TerserPlugin actually don't seem to contain any code related to dev/prod checking, I will see if I can reference elsewhere.

from react-refresh-webpack-plugin.

MasterCassim avatar MasterCassim commented on May 19, 2024

Webpack automatically adds the TerserPlugin for production builds since v4:

Sets process.env.NODE_ENV on DefinePlugin to value production . Enables FlagDependencyUsagePlugin , FlagIncludedChunksPlugin , ModuleConcatenationPlugin , NoEmitOnErrorsPlugin , OccurrenceOrderPlugin , SideEffectsFlagPlugin and TerserPlugin .

-> https://webpack.js.org/configuration/mode/

from react-refresh-webpack-plugin.

pmmmwh avatar pmmmwh commented on May 19, 2024

I tried this on ejected “todomvc” app from Redux repo examples folder.

@gaearon I couldn't reproduce this. I just cloned the Redux repo and ejected the same app (todomvc), adding in only the babel plugin and the webpack plugin and I didn't hit this issue. (I hit the issue with #8 / #11 , but they are unrelated to mode checking)

from react-refresh-webpack-plugin.

luisgrases avatar luisgrases commented on May 19, 2024

I believe it requires webpack 5

from react-refresh-webpack-plugin.

pmmmwh avatar pmmmwh commented on May 19, 2024

I believe it requires webpack 5

Can you explain a bit more? You mean the error only triggers in Webpack 5 or the repo only works in Webpack 5?

from react-refresh-webpack-plugin.

luisgrases avatar luisgrases commented on May 19, 2024

I believe the repo only works in webpack 5

from react-refresh-webpack-plugin.

pmmmwh avatar pmmmwh commented on May 19, 2024

I believe the repo only works in webpack 5

No, the repo does not work with Webpack 5. All testing I've done and all examples provided here all uses Webpack 4.41.2. So if the plugin does not work for you on webpack 4, please file an issue and provide a reproduce-able case.

from react-refresh-webpack-plugin.

pmmmwh avatar pmmmwh commented on May 19, 2024

I don't think this is still valid (and I am unable to reproduce it), so I'll close this for now.

from react-refresh-webpack-plugin.

Bec-k avatar Bec-k commented on May 19, 2024

Same here, i guess that is something related to versions inconsistencies.

from react-refresh-webpack-plugin.

Bec-k avatar Bec-k commented on May 19, 2024

Here what is forwarded into apply method:

  apply(compiler) {
    console.log(util.inspect(compiler, false, null))
    process.exit()

https://gist.github.com/denissabramovs/6946875e786ea37c096928e77ff51f8a

It doesn't have mode, logger and others properties.

from react-refresh-webpack-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.