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

postcss-preset-env throws TypeError starting with v8 #969

Closed
2 of 3 tasks
ERuseckas opened this issue May 18, 2023 · 3 comments
Closed
2 of 3 tasks

postcss-preset-env throws TypeError starting with v8 #969

ERuseckas opened this issue May 18, 2023 · 3 comments
Labels

Comments

@ERuseckas
Copy link

Reproduction link

No response

Bug description

v7.8.3 is working fine, but all the v8 versions are giving me the same error:

[!] (plugin postcss) TypeError: o is not a function
src/global.pcss
TypeError: o is not a function
    at /node_modules/postcss-preset-env/dist/index.cjs:1:17553
    at Array.forEach (<anonymous>)
    at pluginIdHelp (/node_modules/postcss-preset-env/dist/index.cjs:1:17429)
    at OnceExit (//node_modules/postcss-preset-env/dist/index.cjs:1:18705)
    at LazyResult.runAsync (/node_modules/postcss/lib/lazy-result.js:433:21)

This error is thrown even if my used src/global.pcss file is completely empty.

Actual Behavior

No response

Expected Behavior

No response

Can you reproduce it with npx @csstools/csstools-cli <plugin-name> minimal-example.css?

None

npx Output

No response

Extra config

my used postcss config

                require('postcss-discard-comments')(),
		require('stylelint')({
			files: 'src/**/*.pcss',
			cache: true,
			cacheLocation: path.resolve(__dirname, 'node_modules/.cache/.stylelintcache')
		}),
		require('postcss-mixins')({
			mixinsFiles: path.resolve(__dirname, 'src/common.pcss')
		}),
		require('postcss-preset-env')({
			stage: 2,
			preserve: false,
			features: {
				'custom-media-queries': true,
				'custom-properties': false,
				'custom-selectors': true,
				'environment-variables': true
			}
		}),
		require('postcss-nested')(),
		require('postcss-discard-empty')(),
		require('postcss-reporter')({ clearReportedMessages: true })

versions:

                "postcss": "^8.4.23",
		"postcss-discard-comments": "^6.0.0",
		"postcss-discard-empty": "^6.0.0",
		"postcss-mixins": "^9.0.4",
		"postcss-nested": "^6.0.1",
		"postcss-preset-env": "^8.3.2",
		"postcss-reporter": "^7.0.5",
		"stylelint": "^15.3.0"

it's running under rollup v2 by using latest rollup-plugin-postcss:

        postcss({
		extract: path.resolve('dist/main.min.css'),
		minimize: true
	})

What plugin are you experiencing this issue on?

PostCSS Preset Env

Plugin version

8..

What OS are you experiencing this on?

macOS

Node Version

18.3.0

Validations

  • Follow our Code of Conduct
  • Check that there isn't already an issue that request the same feature to avoid creating a duplicate.

Would you like to open a PR for this bug?

  • I'm willing to open a PR
@romainmenke
Copy link
Member

Hi @ERuseckas,

Thank you for reaching out about this!

Can you remove 'environment-variables': true from your config?
I think that should make the error go away.

https://github.com/csstools/postcss-plugins/blob/main/plugin-packs/postcss-preset-env/CHANGELOG.md#800-january-24-2023

From the changelog :

Removed postcss-env-function (breaking).

If you depend on this feature you must add it separately as a dependency in package.json and in your PostCSS config :

		require('postcss-mixins')({
			mixinsFiles: path.resolve(__dirname, 'src/common.pcss')
		}),
		require('postcss-env-function')(),
		require('postcss-preset-env')({
			stage: 2,
			preserve: false,
			features: {
				'custom-media-queries': true,
				'custom-properties': false,
				'custom-selectors': true,
				'environment-variables': true
			}
		}),
		require('postcss-nested')(),

We will roll out a patch shortly to ensure this exception doesn't happen.

@romainmenke romainmenke changed the title postcss-preset-env throws TS error starting with v8 postcss-preset-env throws TypeError starting with v8 May 18, 2023
@ERuseckas
Copy link
Author

Thank you @romainmenke
Removing that line helped

@romainmenke
Copy link
Member

@ERuseckas This exception has also been resolved in the latest release of postcss-preset-env. If you encounter a similar case the plugin will give you more useful feedback on what is going on.

Thank you again for reporting this!

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

No branches or pull requests

2 participants