postcss_nesting doesn't work on Deno
oscarotero opened this issue · comments
I have this error importing the plugin in this way:
import postcssNesting from "https://cdn.jsdelivr.net/gh/csstools/postcss-nesting@10.0.1/mod.js";
It works fine in 9.0.0
.
In adddition to that, the README says that it can be imported from deno.land/x (import postcssNesting from "https://deno.land/x/postcss_nesting/mod.js";
), but the module is not registered there
https://cdn.jsdelivr.net/gh/csstools/postcss-nesting@**9.0.0**/mod.js
/* Deno entry point */
export { default } from './src/postcss-8-nesting.js'
https://cdn.jsdelivr.net/gh/csstools/postcss-nesting@**10.0.1**/mod.js
/* Deno entry point */
export { default } from './dist/index.deno.mjs'
I totally missed the nuance that this is served via jsdeliver and read from github.
The /dist/
folder doesn't exist in github.
Don't have an immediate fix for this as we need the build process to bundle the plugin.
@oscarotero thanks for flagging this. There's a nested dependency that uses Node internals (util) which would make this not work with Deno as it is which why we're packing it.
We don't want to add to git the disted files. However I've included the mod.js into the packed files which means you should be able to import it like this:
https://cdn.jsdelivr.net/npm/postcss-nesting@10/mod.js
It has been released and it's been also updated on the README so it's clearer. I'd be happy to know your experience with this.
Thanks @Antonio-Laguna for the quick reply.
Unfortunately, this issue is not fixed yet. I continue getting the same error:
error: Import 'https://cdn.jsdelivr.net/gh/csstools/postcss-nesting@10.0.2/dist/index.deno.mjs' failed, not found.
at https://cdn.jsdelivr.net/gh/csstools/postcss-nesting@10.0.2/mod.js:3:25
I see that you have registered the plugin in deno.land (https://deno.land/x/postcss_nesting@10.0.2) but it won't work either because the mod.js
file is importing the missing dist
folder (https://deno.land/x/postcss_nesting@10.0.2/mod.js)
The version 9.0 doesn't use any dependency so it works fine with Deno without any build process because the code uses regular es modules. To provide Deno compatiblity for version 10, it's needed to do more changes.
- The official postcss library has a different repository for deno (https://github.com/postcss/postcss-deno) to save the built code for Deno.
- Other option is using a different branch, but I understand that you're not interested in keep the dist files in the repo.
- Deno has a package to convert Deno to npm (https://github.com/denoland/dnt) so another solution is make this repository Deno first, and use the build process to convert to npm.
- FYI, there's a deno version of postcss_selector_parser, maybe the Deno version could use it (https://deno.land/x/postcss_selector_parser@v6.0.2).
@oscarotero can you use the one that's on README?
import postcssNesting from "https://cdn.jsdelivr.net/npm/postcss-nesting@10/mod.js";
Ah, sorry @Antonio-Laguna, I didn't see that.
Yes, this url seems to work fine on Deno. Thanks!