Skip to content
This repository was archived by the owner on Oct 24, 2023. It is now read-only.

place-content/items issue #229

Closed
nevolgograd opened this issue Nov 26, 2021 · 21 comments
Closed

place-content/items issue #229

nevolgograd opened this issue Nov 26, 2021 · 21 comments
Assignees

Comments

@nevolgograd
Copy link

I have simple webpack/postcss stack and my build is failing each time I use place-content or place-items properties

Here’s the error:

Module build failed (from ./node_modules/postcss-loader/dist/cjs.js):
TypeError: Cannot read properties of undefined (reading 'includes')

I'm using latest version of the package:

"postcss-preset-env": "^7.0.1",

PostCSS config:

module.exports = {
  plugins: [
    require('postcss-import'),
    require('postcss-normalize'),
    require('postcss-color-mod-function'),
    require('postcss-preset-env')
  ]
};

Webpack config:

{
  test: /\.(scss|css)$/,
  use: [
    {
      loader: 'css-loader',
      options: {
        modules: true,
        importLoaders: 1
      }
    },
    {
      loader: 'postcss-loader'
    },
    {
      loader: 'sass-loader'
    }
  ]
}

I will be grateful for any advice!

@Antonio-Laguna
Copy link
Member

Does any minimal code fail with that?

@nevolgograd
Copy link
Author

nevolgograd commented Nov 26, 2021

@Antonio-Laguna

I can have only css file which I import in my entry and still getting same error

import 'styles/main.css';

:global {
  body {
    place-content: center;
  }
}

@Antonio-Laguna
Copy link
Member

Thanks! Can you tell me your node version? @nevolgograd

@nevolgograd
Copy link
Author

@Antonio-Laguna v16.13.0

@Antonio-Laguna
Copy link
Member

@nevolgograd would it be possible to have access to your repo? This issue is similar as #225 but I'm having a hard time reproducing this.

I've created two files: index.css and main.css, within main.css I've put

:global {
  body {
    place-content: center;
  }
}

Then on index.css this is the only thing @import 'main.css';

The postcss.config.js file is like this:

module.exports = {
  plugins: [
    require('postcss-import'),
    require('postcss-normalize'),
    require('postcss-color-mod-function'),
    require('postcss-preset-env')
  ]
};

Ran with postcss-cli like npx postcss src/index.css -o dist/output.css and had a successful output so I'm not sure what I'm missing.

@nevolgograd
Copy link
Author

nevolgograd commented Nov 26, 2021

@Antonio-Laguna thanks! My repo is private, but I'll create a copy in a moment.

@nevolgograd
Copy link
Author

nevolgograd commented Nov 26, 2021

@Antonio-Laguna https://github.com/nevolgograd/postcss-config-hell

@Antonio-Laguna Antonio-Laguna self-assigned this Nov 26, 2021
@Antonio-Laguna
Copy link
Member

Thanks for preparing this @nevolgograd ! I'll take a look soon and update you on this.

@Antonio-Laguna
Copy link
Member

Antonio-Laguna commented Nov 26, 2021

Can reproduce here at least. What I can see is that this is mixing some postcss versions which isn't fine.

All of our plugins use postcss 8 but we got postcss@7.0.39 and postcss@6.0.23 too. This all seems to come from typescript-plugin-css-modules which uses things such as postcss-filter-plugins which are not upgraded to use PostCSS 8. This last plugin seems to be 4 years old without much further changes.

I'll dig a bit more to see if this is coming from our code and if it's something we could prevent.

@armano2
Copy link

armano2 commented Nov 26, 2021

issue is somewhere else, it seem that enabling postcss-lab-function after postcss-place leads to

  align-content: undefined;
  justify-content: undefined;
  place-content: center;

and crash comes from autoprefixer


repro

// postcss.config.js
module.exports = {
  plugins: [
    require('autoprefixer'),
    require('postcss-lab-function'),
    require('postcss-place')({}),
  ]
};
/* index.css */
body {
  place-content: center;
}
// package.json
{
  "scripts": {
    "test": "postcss index.css -o output.css"
  },
  "devDependencies": {
    "postcss": "^8.4.1",
    "postcss-cli": "^9.0.2",
    "postcss-preset-env": "^7.0.1"
  }
}

@Antonio-Laguna
Copy link
Member

@armano2 can't seem to repro with your use case. Seems to output just fine for me, no undefined :/

@armano2
Copy link

armano2 commented Nov 26, 2021

@armano2 can't seem to repro with your use case. Seems to output just fine for me, no undefined :/

@Antonio-Laguna i pushed it as fork
https://github.com/armano2/postcss-config-hell/actions/runs/1507597183

@Antonio-Laguna
Copy link
Member

Thanks! Will check what was different but can repro on your fork!

@armano2
Copy link

armano2 commented Nov 26, 2021

  • npm dedupe seem to be solving this issue
  • his seem to be related to postcss-values-parser being incorrectly hoisted
  • adding "postcss-values-parser": "^6.0.1" also seem to solve this issue

in oriignal repo postcss-color-mod-function as its uses postcss-values-parse v2 and npm dosn't resolve it correctly

@Antonio-Laguna
Copy link
Member

Antonio-Laguna commented Nov 26, 2021

Thanks for investigating. That's probably why I don't get the error on my test case but happens here

Probably related to #228

@evenfrost
Copy link

FYI, Tailwind CSS build fails because of that as well, due to @tailwind utilities; using this declaration internally. Looking forward to a fix, but for now npm i postcss-preset-env@6.

@Antonio-Laguna
Copy link
Member

@evenfrost what package is using @tailwind utilities? Could you point me at that?

@evenfrost
Copy link

@Antonio-Laguna sorry for the late reply. It's Tailwind CSS.

@Antonio-Laguna
Copy link
Member

This should now be fixed as of csstools/postcss-plugins@b1c4d27

@nevolgograd I'd appreciate a lot if you could bump to 7.0.2 and see if it goes well

@nevolgograd
Copy link
Author

@Antonio-Laguna since then i've changed a lot in my code, basically i removed postcss-color-mod-function plugin and it worked for me even on prev version.
v7.1.0 works good as well.

@Antonio-Laguna
Copy link
Member

Great! Thanks! Closing this issue then!

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

No branches or pull requests

4 participants