Repository: next.js
Issue: postcss.config.js not work with type module
Labels: bug

### Link to the code that reproduces this issue

https://github.com/alkorlos/nextjs-issue-bug-postcssconfig

### To Reproduce

1. Start the application in development (next dev)
2. Error in console and browser

### Current vs. Expected behavior

I expected `postcss.config.js` work with type module to happen, but I observed error.

### Provide environment information

```bash
Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 10 Enterprise
  Available memory (MB): 16228
  Available CPU cores: 4
Binaries:
  Node: 20.10.0
  npm: N/A
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 15.0.0-canary.115 // Latest available version is detected (15.0.0-canary.115).
  eslint-config-next: N/A
  react: 19.0.0-rc-187dd6a7-20240806
  react-dom: 19.0.0-rc-187dd6a7-20240806
  typescript: 5.3.3
Next.js Config:
  output: N/A
```


### Which area(s) are affected? (Select all that apply)

Instrumentation

### Which stage(s) are affected? (Select all that apply)

next dev (local), next build (local)

### Additional context

Next.js 14.2.5 also have this issue.

In reproduce new project with `type module` in `package.json` and `postcss.config.js`:
```js
import postcssPresetEnv from 'postcss-preset-env';

const config = {
	plugins: [
		postcssPresetEnv({
			stage: 2,
			features: {
				'nesting-rules': false
			}
		})
	]
};

export default config;
```

When starting the project, there is an error in the console:
```console
 ○ Compiling /_not-found ...                                                                                                                                                                      
Error: An unknown PostCSS plugin was provided ([object Object]).                                                                                                                                  
Read more: https://nextjs.org/docs/messages/postcss-shape                                                                                                                                         
 ⨯ ./app/layout.module.css.webpack[javascript/auto]!=!./node_modules/next/dist/build/webpack/loaders/css-loader/src/index.js??ruleSet[1].rules[12].oneOf[5].use[2]!./node_modules/next/dist/build/
webpack/loaders/postcss-loader/src/index.js??ruleSet[1].rules[12].oneOf[5].use[3]!./app/layout.module.css                                                                                         
Error: Malformed PostCSS Configuration                                                                                                                                                            
    at Array.forEach (<anonymous>)                                                                                                                                                                
Import trace for requested module:                                                                                                                                                                
./app/layout.module.css.webpack[javascript/auto]!=!./node_modules/next/dist/build/webpack/loaders/css-loader/src/index.js??ruleSet[1].rules[12].oneOf[5].use[2]!./node_modules/next/dist/build/web
pack/loaders/postcss-loader/src/index.js??ruleSet[1].rules[12].oneOf[5].use[3]!./app/layout.module.css                                                                                            
./app/layout.module.css                                                                                                                                                                           
 ⨯ ./app/layout.module.css.webpack[javascript/auto]!=!./node_modules/next/dist/build/webpack/loaders/css-loader/src/index.js??ruleSet[1].rules[12].oneOf[5].use[2]!./node_modules/next/dist/build/
webpack/loaders/postcss-loader/src/index.js??ruleSet[1].rules[12].oneOf[5].use[3]!./app/layout.module.css                                                                                         
Error: Malformed PostCSS Configuration                                                                                                                                                            
    at Array.forEach (<anonymous>)                                                                                                                                                                
Import trace for requested module:                                                                                                                                                                
./app/layout.module.css.webpack[javascript/auto]!=!./node_modules/next/dist/build/webpack/loaders/css-loader/src/index.js??ruleSet[1].rules[12].oneOf[5].use[2]!./node_modules/next/dist/build/web
pack/loaders/postcss-loader/src/index.js??ruleSet[1].rules[12].oneOf[5].use[3]!./app/layout.module.css                                                                                            
./app/layout.module.css                                                                                                                                                                           
 ⨯ ./app/layout.module.css.webpack[javascript/auto]!=!./node_modules/next/dist/build/webpack/loaders/css-loader/src/index.js??ruleSet[1].rules[12].oneOf[5].use[2]!./node_modules/next/dist/build/
webpack/loaders/postcss-loader/src/index.js??ruleSet[1].rules[12].oneOf[5].use[3]!./app/layout.module.css                                                                                         
Error: Malformed PostCSS Configuration                                                                                                                                                            
    at Array.forEach (<anonymous>)                                                                                                                                                                
Import trace for requested module:                                                                                                                                                                
./app/layout.module.css.webpack[javascript/auto]!=!./node_modules/next/dist/build/webpack/loaders/css-loader/src/index.js??ruleSet[1].rules[12].oneOf[5].use[2]!./node_modules/next/dist/build/web
pack/loaders/postcss-loader/src/index.js??ruleSet[1].rules[12].oneOf[5].use[3]!./app/layout.module.css                                                                                            
./app/layout.module.css                                                                                                                                                                           
 GET /_next/static/webpack/8aa696ba82e7cf46.webpack.hot-update.json 500 in 6127ms                                                                                                                 
 ⚠ Fast Refresh had to perform a full reload due to a runtime error.                                                                                                                              
 GET / 500 in 1203ms                                                                                                                                                                              
 GET / 500 in 20ms                                                                                                                                                                                
 ⨯ ./app/layout.module.css                                                                                                                                                                        
Error: Malformed PostCSS Configuration                                                                                                                                                            
    at Array.forEach (<anonymous>)                                                                                                                                                                
Import trace for requested module:                                                                                                                                                                
./app/layout.module.css                                                                                                                                                                           
./app/layout.tsx                                                                                                                                                                                  
```

Error in the browser:
```console
Build Error
Failed to compile

./app/layout.module.css
Error: Malformed PostCSS Configuration
    at Array.forEach (<anonymous>)
Import trace for requested module:
./app/layout.module.css
./app/layout.tsx
```

This configuration works with other tools.
The error occurs not only with `postcss-preset-env`, but also with other libraries.