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

New version 0.4.2 capture lot of warnings #250

Closed
nuintun opened this issue Aug 22, 2018 · 86 comments
Closed

New version 0.4.2 capture lot of warnings #250

nuintun opened this issue Aug 22, 2018 · 86 comments

Comments

@nuintun
Copy link

nuintun commented Aug 22, 2018

_20180822095000

Lot of conflicting order warning, but this css files not care about their order!

@nuintun nuintun changed the title New version 0.4.2 capture many warnings New version 0.4.2 capture lot of warnings Aug 22, 2018
@luqimin
Copy link

luqimin commented Aug 22, 2018

experiencing the same issue

@alexander-akait
Copy link
Member

Due https://github.com/webpack-contrib/mini-css-extract-plugin/blob/master/src/index.js#L459

@jsg2021
Copy link

jsg2021 commented Aug 22, 2018

What does this warning mean? How do we resolve it?

@sokra
Copy link
Member

sokra commented Aug 23, 2018

We are trying to generate a CSS file but your codebase has multiple possible orderings for these modules.

In this case you used table before button in one location and button before table in another location. We need to generate a single CSS file for these and can't decide which one should be first. In this case we put table before button. But this is chosen without reason. In future build we may decide the other way. But since CSS cares for rule order this can lead to issue when CSS changes without reason.

So not defining a clear order can lead to fragile builds, that's why we display a warning here.

There are two things that you can do:

Sort your imports to create a consistent order. I must admit that the warning could be improved to point to the locations that need to be changed.

Ignore the warning with stats.warningFilter when the order of these styles doesn't matter. Maybe the eventually add an option to mark order-independent styles directly.

@wende60
Copy link

wende60 commented Aug 23, 2018

also got these "conflicting order between " while compiling and a rollback to 0.4.1 solved the problem...

@alexander-akait
Copy link
Member

@wende60 you should solve order problem, not downgrade

@wende60
Copy link

wende60 commented Aug 23, 2018

@evilebottnawi unfortunally i do not even understand what i have to order here... the loaders? Maybe you can give me a hint...

@alexander-akait
Copy link
Member

@wende60 looks above and read post #250 (comment)

@wende60
Copy link

wende60 commented Aug 23, 2018

@evilebottnawi do i understand it right: i should play around with the order of imports in the file that is - maybe - the location? Ok, will tryout... thanks

@timothywisdom
Copy link

We used the sort-import plugin for VS Code to insure our entire team is importing modules in the same order.
https://marketplace.visualstudio.com/items?itemName=amatiasq.sort-imports

Unfortunately, even after insuring the order is the same, we still see these warnings from the mini-css-extract-plugin

@michael-ciniawsky
Copy link
Member

@timothywisdom Sorting imports/modules per file (within) !== Import/Module Order in the Import/Module Tree/Graph (in relation to other files)

@jsg2021
Copy link

jsg2021 commented Aug 28, 2018

This seems like an unreasonable request (to ensure order within our graph)... we need a way to turn this off for projects that don't care. For example, in my projects each component's styles are self contained so order is only important within each component. (each component has a very unique class name root and all selectors are scoped to them)

@timothywisdom
Copy link

I'm confused - how do I sort "Import/Module Order in the Import/Module Tree/Graph"?

@jsg2021
Copy link

jsg2021 commented Aug 28, 2018

I think you would have to layout all your imports and make sure to always import things in the same order following the tree traversal order. (Not ideal)

@timothywisdom
Copy link

timothywisdom commented Aug 28, 2018

I believe I have done that via the sort-imports plugin for VS Code.
This insures all imported modules are imported via the same order logic in every file. But according to @michael-ciniawsky, that's not good enough so I'm not sure how to proceed.

Edit: actually, I'm sorting them alphabetically, not by tree-traversal order. That would be a nightmare to figure out for every file

@michael-ciniawsky
Copy link
Member

It's very inconvenient at best and realistically unmanagable at a certain project size. That's what CSS Module (automatically) or a CSS naming convention (e.g BEM/ITCSS(Namspace + BEM)) (manually) are for. Nevertheless if one uses CSS without particular care on the matter he/she likely runs into issue with the CSS Cascade and there should be a warning at least (optional)

@timothywisdom It's always hard to tell why you get these warnings and where within your project. I'm not saying sorting them for every file doesn't eventually help, but it definitely will not solve all issues.

See #250 (comment)

We are trying to generate a CSS file but your codebase has multiple possible orderings for these modules.

In this case you used table before button in one location and button before table in another location. We need to generate a single CSS file for these and can't decide which one should be first. In this case we put table before button. But this is chosen without reason. In future build we may decide the other way. But since CSS cares for rule order this can lead to issue when CSS changes without reason.

@ulivz
Copy link

ulivz commented Sep 4, 2018

This was truly a bug I think. I have following structure:

├── ActionSheetCard
│   ├── index.js
│   └── index.less
├── CardWrap
│   └── index.js
├── ImageView
│   └── index.js
├── Request
│   ├── index.js
│   └── index.less
├── ToAlipay
│   ├── index.js
│   └── index.less
├── ToNewUrl
│   ├── index.js
│   └── index.less
├── color.less
└── index.js

Each index.less was imported by its adjacent index.js, but this warning was still here:

chunk vendors [mini-css-extract-plugin]
Conflicting order between:
 * css ./node_modules/_css-loader@1.0.0@css-loader??ref--18-2!./node_modules/_postcss-loader@3.0.0@postcss-loader/src??postcss!./node_modules/_less-loader@4.1.0@less-loader/dist/cjs.js??ref--18-4!./node_modules/_antd-mobile@2.2.3@antd-mobile/lib/style/index.less
 * css ./node_modules/_css-loader@1.0.0@css-loader??ref--18-2!./node_modules/_postcss-loader@3.0.0@postcss-loader/src??postcss!./node_modules/_less-loader@4.1.0@less-loader/dist/cjs.js??ref--18-4!./node_modules/_antd-mobile@2.2.3@antd-mobile/es/action-sheet/style/index.less
 * css ./node_modules/_css-loader@1.0.0@css-loader??ref--18-2!./node_modules/_postcss-loader@3.0.0@postcss-loader/src??postcss!./node_modules/_less-loader@4.1.0@less-loader/dist/cjs.js??ref--18-4!./node_modules/_antd-mobile@2.2.3@antd-mobile/es/toast/style/index.less
 * css ./node_modules/_css-loader@1.0.0@css-loader??ref--18-2!./node_modules/_postcss-loader@3.0.0@postcss-loader/src??postcss!./node_modules/_less-loader@4.1.0@less-loader/dist/cjs.js??ref--18-4!./node_modules/_antd-mobile@2.2.3@antd-mobile/es/button/style/index.less
 * css ./node_modules/_css-loader@1.0.0@css-loader??ref--18-2!./node_modules/_postcss-loader@3.0.0@postcss-loader/src??postcss!./node_modules/_less-loader@4.1.0@less-loader/dist/cjs.js??ref--18-4!./node_modules/_antd-mobile@2.2.3@antd-mobile/es/white-space/style/index.less

@jsg2021
Copy link

jsg2021 commented Sep 4, 2018

@ulivz the warning output you gave doesn't line up with your example structure.

@webylb
Copy link

webylb commented Dec 3, 2019

并没有解决我遇到的的问题

@nicooprat
Copy link

Tried to add ignoreOrder: true but I'm getting some Cannot read property 'createChildCompiler' of undefined errors, has anyone encountered the same issue? Looks like it's coming from the thread-loader plugin but I couldn't find any solution there.

@Hypnosphi
Copy link

Sort your imports to create a consistent order.

@sokra do you know any practical way to do that? As pointed out above, alphabetical order doesn't always work:

// a.entry.js
import './a.css'
import './b.css'
// b.entry.js
import './b.css'
import './c.js'
// c.js
import './a.css'

Here, all the imports are sorted alphabetically, but a.entry.js and b.entry.js have different order of CSS files

@julpat
Copy link

julpat commented May 23, 2020

Still waitting for this 😇 🙏

Sort your imports to create a consistent order. I must admit that the warning could be improved to point to the locations that need to be changed.

Solving this warnings by disable them globaly is wrong. The messages are useful when you have nested use of same components and then the order is important!

// Some.vue
import Decor from 'Decor.vue';
import SomethingDifferent from 'SomethingDifferent';

// SomethingDifferent.vue
import Decor from 'Decor.vue'; // completely different use of the same component

So the solution here is "lazy" loading (getting this from Webpack doc (?) not sure now)

// SomethingDifferent.vue
const Decor = () => import('Decor.vue');

@steveswork
Copy link

steveswork commented Dec 22, 2020

There is now an NPM package named @webkrafters/ordercss which tackles this issue.

Full disclosure: I initially created it to solve this very problem in one of my apps but decided to expand it and share it with everyone.

If this package helps anyone, please share it with others.

Thanks and good luck!

@cdll
Copy link

cdll commented Feb 25, 2021

same issue here💔

@Nsandomeno
Copy link

same issue here💔

@cdll working on this too... will get back here if I find anything. Any luck for you?

@eyedean
Copy link

eyedean commented May 18, 2021

I wrote a detailed explanation of why this happens and what are the solutions at: https://stackoverflow.com/a/67579319

@9mm
Copy link

9mm commented Aug 17, 2021

So how do we fix this when everything is ordered and the error still occurs, yet we don't just want to disable the warnings?

@benomatis
Copy link

benomatis commented May 22, 2024

NOTE FOR FUTURE READERS: See #250 (comment) for a more up-to-date comment

It felt easier to us to use a plugin called webpack-filter-warnings-plugin for this, so if anyone's curios, this is how this warning can be ignored:

const FilterWarningsPlugin = require('webpack-filter-warnings-plugin'); 

const config = {
  plugins: [
    // Silence mini-css-extract-plugin generating lots of warnings for CSS ordering.
    // We use CSS modules that should not care for the order of CSS imports, so we
    // should be safe to ignore these.
    //
    // See: https://github.com/webpack-contrib/mini-css-extract-plugin/issues/250
    new FilterWarningsPlugin({
      exclude: /mini-css-extract-plugin[^]*Conflicting order between:/
    })
  ]
}

As you can see from our comment, we're not 100% sure we're safe but at least we try to document why this warning can be ignored. I suggest others filtering these warnings do something similar ☺️

This works, except the warning doesn't show Conflicting order between: anymore, it's just Conflicting order, so just remove the between: from the end before the last slash of the exclude property, and you should be good to go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests