Comments (40)
Can confirm. Exactly the same errors with same package versions.
from gulp-postcss.
Hi @simbo and @waldemarfm, thanks for reporting this! Recent change was only PostCSS version bump.
It seems that the problem is due to version mistmach between PostCSS and plugins. I checked autoprefixer-core 4.0.2 and found that it depends on PostCSS ~3.0.7
cc @ai
from gulp-postcss.
Yeap. Should we use peerDependencies
in Autoprefixer and other plugins?
from gulp-postcss.
Yeah, seems to be the right way to solve this problem. I will make this change to gulp-postcss as well so users will have more control over which version of PostCSS to use.
from gulp-postcss.
@MoOx are you agree to add peerDependencies
to all plugins? Also I add this recommendation to plugin developer How To (it is in progress right now).
from gulp-postcss.
gulp-postcss now lists postcss in peerDependencies.
from gulp-postcss.
Sorry to bother, but any idea when this will be finished? :)
from gulp-postcss.
peerDep will be deprecated, so not sure it's a good idea.
npm/npm#6565
from gulp-postcss.
The why you should not use dep is overthere npm/npm#5080
from gulp-postcss.
@MoOx any suggestions on how to prevent version mismatch?
from gulp-postcss.
Don't know any magic method. I just too many undesired issues with peerDep too.
Developers should take care of that. When someone upgrade a tool with some plugins, this person should ensure all plugins have versions that work with the new version of the tool. IMO, it's that simple.
Each plugins might specify minimal version they require in their README.
from gulp-postcss.
Note that all the plugins I published for example have tests with a specific postcss version (cf devDep). Developers can also take a look to that. Version in README seems a good idea tho.
from gulp-postcss.
Maybe we can set some special flag to plugin with PostCSS AST version they required? I do not really like this idea, only as brainstorm.
from gulp-postcss.
Like:
module.export = {
postcss: function () {},
ast: '4.0.0'
}
And PostCSS will throw error if plugins expect different AST versions.
from gulp-postcss.
Maybe more
module.export = {
postcss: function () {},
postcssVersion: require("./package.json").devDependencies.postcss
}
?
Note sure we should handle this in the core tho.
We all get this kind of issue with all tool/plugins things, this is not likely easy to solve.
from gulp-postcss.
If each plugin exposed its postcss version from package.json, then postcss itself could check it with smth like https://github.com/npm/node-semver and throw an error
from gulp-postcss.
Main problems:
- Does API check is a part of PostCSS?
- What we will suggest to user? Downgrade plugin version?
- I think short plugin syntax (just a function) is important on debug. Should we allow it and miss API check it this case?
from gulp-postcss.
This suggestion seems to be the way how this should be solved npm/npm#5080 (comment)
from gulp-postcss.
It is certainly a headache problem.
from gulp-postcss.
I like the way isaac explains. So this can be handled in plugin like this:
var plugin = function () {}
plugin.supportedVersion = require("./package.json").dependencies.postcss || require("./package.json").devDependencies.postcss
module.export = plugin
It would be could to directly add a supportedVersion
property to the plugin itself.
This way, postcss can check for this without having to rely on a object that contains function+supported version.
What do you think guys?
Btw, this should only show a warning because for example a plugin done for v3 can totally work for v4 (the otherwise is not likely to work all the time).
from gulp-postcss.
I found the best solution. We dont necessarily have to use one AST version in every plugin. If plugin uses old AST we can stringify current one and then reparse it with old PostCSS for this plugin.
Every plugin should have own PostCSS version in dependencies
and will use special mathod to wrap plugin function:
var postcss = require('postcss');
module.exports = postcss.plugin(function (css) {
// css will be in plugin’s PostCSS version
});
postcss.plugin
will be like:
postcss.plugin = function (plugin) {
return function (ast) {
// here will be smarter semver check
if ( ast.postcss.version == postcss.version ) {
return plugin(ast);
} else {
var old = postcss.parse( ast.toResult() );
var result = plugin(old);
return ast.postcss.parse( result.toResult() );
}
};
});
from gulp-postcss.
Overkill !
We should not take care of this. It's up to the developer to know which version of the tool he use, & so which version of plugin to use too.
Your solution might create slow result if several postcss plugins use severals versions of postcss.
Sound like over-engineering to me.
We don't have to handle this kind of issue...
from gulp-postcss.
@MoOx but slow plugin is better, that broken plugin :)
from gulp-postcss.
Also, you will have to face a new problem cause a new version might parse something a previous version fails to. You don't want user to want an report issue about that.
Plugin is not broken, just no compatible (yet?).
from gulp-postcss.
Sooo,
What steps does one need to take to get the documented example in the README to work without error?
Thanks :)
from gulp-postcss.
Autoprefixer 5.0 was released with PostCSS 4.0 support. Please update.
from gulp-postcss.
@MoOx @ai should I revert commit that made postcss into peerDepency or is it fine for gulp plugin?
from gulp-postcss.
@kristoferjoseph PR for the README is very welcome!
from gulp-postcss.
@w0rm I am not so familiar with npm :(. @MoOx knows better.
from gulp-postcss.
Note: I don't use gulp anymore so I don't care =)
Since npm plan to deprecate this feature, I think you should not use this.
And it brings the exact same kind of issue as normal dep: webpack/webpack#570 (comment)
from gulp-postcss.
If somebody needs old plugin, let use old versions of other plugins and postcss. Without peerDep
from gulp-postcss.
@MoOx so webpack loaders are the new hype thing =)
@TrySound to use with previous version of postcss simply pick corresponding version of gulp-postcss from the change log.
from gulp-postcss.
Yes, I am about it.
from gulp-postcss.
(@Worm my build process is more based on npm itself (npm scripts) than on webpack. Check it out https://github.com/MoOx/frontend-hot-starterkit)
Maybe we should close this issue for now (and encourage people to read CHANGELOG & README & package.json).
from gulp-postcss.
Maybe an issue should be created to postcss directly.
from gulp-postcss.
I created this issue postcss/postcss#163
from gulp-postcss.
Perfect.
from gulp-postcss.
Put PostCSS back into simple dependency and republished on npm (commit)
from gulp-postcss.
Next PostCSS 4.1 will print warning if plugin throwed a error and was based on different PostCSS version: postcss/postcss@3d48436
from gulp-postcss.
The same issues can occur when you make a mistake in an array of processors and undefined item appear in a row:
[processor1,, processor2]
from gulp-postcss.
Related Issues (20)
- Error in plugin "gulp-postcss" HOT 1
- PostCSS 8 support HOT 9
- Extension css for output HOT 2
- PostCSS plugin autoprefixer requires PostCSS 8. Update PostCSS or downgrade this plugin HOT 6
- Use postcss-load-config 3.0
- Error: [object Object] is not a PostCSS plugin HOT 1
- CSS Syntax Error, alien script, and ELIFECYCLE error on build HOT 9
- Sourcemaps always shows parent line for nested SASS HOT 1
- Support "watch" mode (equivalent to -w switch in postcss-cli) HOT 6
- PostCSS dependency messages are not respected HOT 2
- Error: PostCSS plugin autoprefixer requires PostCSS 8. HOT 3
- Outputing multi-level folders HOT 1
- Error plugin is not a function HOT 2
- Not working with TailwindCSS >=3.0 HOT 1
- CssSyntaxError in plugin "gulp-postcss" / You tried to parse SCSS with the standard CSS parser; try again with the postcss-scss parser HOT 1
- TypeError in plugin "gulp-postcss" plugin is not a function HOT 1
- ENOENT: No such file or directory (sass/postcss/tailwind)
- s.default.isPseudoElement is not a function HOT 1
- Update `postcss-load-config` HOT 1
- Why does the new version 9.1.0 not comply with semver about engines.node? HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gulp-postcss.