Open vdboor opened 3 years ago
Hello @vdboor could you please try to use this branch and report if it works fine with PostCss 8? Thanks
good to know you're working on this! 😃
Pardon for asking, how do I install that branch?
I've tried npm install 'leodido/postcss-clean#release/2.x'
but that only installs a index.m.js
, not an index.js
(I'm not that familiar with build tools here)
It works from branch for me
Hey @leodido ,
using the release/2.x branch and then using rollup gives me this:
[!] (plugin postcss) Error: Loading PostCSS Plugin failed: Cannot find module 'path/to/dir/node_modules/postcss-clean/index.js'. Please verify that the package.json has a valid "main" entry
Just to let you know.
Problem is with how the module is indexed within package.json via main field, rollup users will most likely get complaints.
Install clean-css and postcss as deps, eg:
pnpm i clean-css postcss --save-dev
Use the source and simply create a build script.
@leodido
Do you still need Bublé for transpilation? the code will suffice for the vast majority of node versions in circulation, esp in v8 of post-css. Couple if suggestions:
Change the main
and module
fields in the package.json file
to:
{
"main": "./package/index.js",
"module": "package/index.es.js"
}
You can lean on Rollup for watching and setting environment variables. Another approach you could take in your scripts
instead of setting a DEV environment variable (which works), you could maybe set prod
environment variables, eg:
{
"scripts": {
"develop": "rollup -c -w",
"distrib": "rollup -c --environment prod",
}
}
This approach will let rollup compose the cjs and es bundles. Changing the current main index.m.js
to index.js
and use a rollup build config like:
import { terser } from 'rollup-plugin-terser'
import json from '@rollup/plugin-json'
import pkg from './package.json'
export default {
input: 'index.js',
output: [
{
format: 'cjs',
file: pkg.main,
exports: 'named',
sourcemap: process.env.prod ? false : 'inline'
},
{
format: 'es',
file: pkg.module,
sourcemap: process.env.prod ? false : 'inline'
}
],
external: [ ...Object.keys(pkg.dependencies), 'path' ],
plugins: [
json({
preferConst: true
}),
terser({
warnings: 'verbose'
, compress: { passes: 2 }
})
]
}
I would submit a PR but I don't want to intrude on your code styling or preferred approaches.
I am getting the same error, "node.getIterator is not a function" after upgrading to postcss 8. Is there some workaround that can be implemented? I am not sure how to use the workaround @panoply mentioned. I installed clean-css and postcss as dependencies but don't know how to go forward from there. Any help would be very much appreciated.
I am experiencing the same problem, is there any chance to get it fixed? Seems a bit similar to https://github.com/leodido/postcss-clean/pull/41, or is it not?
I'll fork and provide a solution for you guys this week sometime.
I happened to notice 1.2.0 is missing from the changelog on master, but 1.2.1 and 1.2.2 are present. It seems @leodido released 1.2.0 on npm from the release/2.x branch, but 1.2.1 and 1.2.2 from master, reverting what was in the 1.2.0 release.
Workaround for postcss 8 support for now: Downgrade to postcss-clean@1.2.0
.
@kirb thanks for the solution, i can confirm that it works with the latest version of postcss (8.3.5 at the time of writing).
The same error for me. Downgrading to postcss-clean@1.2.0
helped me a lot, so thanks to @kirb !
Any motion on this?
@leodido - facing the same issue.. Could you please suggest a way to fix this
Facing the same issue when postcss-clean is enabled
When running this module against the latest postcss config, I get
node.getIterator() is not a function
:This issue disappears when postcss-clean is removed from the postcss plugins.
Running both on node v14.16 and v15.9.
This is my package.json: