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

Failed to import - postcss-nested #411

Closed
kidonng opened this issue Aug 26, 2022 · 2 comments
Closed

Failed to import - postcss-nested #411

kidonng opened this issue Aug 26, 2022 · 2 comments
Labels
deno Not working in Deno

Comments

@kidonng
Copy link
Contributor

kidonng commented Aug 26, 2022

Failing module

import postcss from 'https://esm.sh/[email protected]'
import nested from 'https://esm.sh/[email protected]'

const {css} = postcss([nested]).process(`
.a {
	color: blue;

	& .b {
		color: red;
	}
}
`)

console.log(css)

Error message

After running deno run I got this:

error: Uncaught TypeError: _ is not a function
    at v (https://esm.sh/v92/[email protected]/deno/postcss-nested.js:2:998)
    at https://esm.sh/v92/[email protected]/deno/postcss-nested.js:2:1397
    at Array.forEach (<anonymous>)
    at x (https://esm.sh/v92/[email protected]/deno/postcss-nested.js:2:1379)
    at https://esm.sh/v92/[email protected]/deno/postcss-nested.js:2:2454
    at https://esm.sh/v92/[email protected]/deno/postcss.js:24:5129
    at M.each (https://esm.sh/v92/[email protected]/deno/postcss.js:24:1199)
    at Proxy.<anonymous> (https://esm.sh/v92/[email protected]/deno/postcss.js:24:5088)
    at Rule (https://esm.sh/v92/[email protected]/deno/postcss-nested.js:2:2365)
    at C.visitSync (https://esm.sh/v92/[email protected]/deno/postcss.js:26:11276)

Additional info

  • esm.sh version: v92
  • Deno version: 1.25.0

I noticed the following code:

let parser = require('postcss-selector-parser')

...is transformed into:

import * as __postcss_selector_parser$ from "/v92/[email protected]/deno/postcss-selector-parser.js";

Which is not correct all the time, for example when the default export is a function with properties. postcss-nested uses both of them:

  // This is where error happens
  let saver = parser(parsed => {
    nodes = parsed
  })

// ...

node.prepend(parser.combinator({ value: ' ' }))

In comparison, Skypack is transforming is correctly:

// https://cdn.skypack.dev/-/[email protected]/dist=es2019,mode=imports/optimized/postcss-nested.js
import parser from "/-/[email protected]/dist=es2019,mode=imports/optimized/postcss-selector-parser.js";
@kidonng kidonng added the deno Not working in Deno label Aug 26, 2022
@kidonng
Copy link
Contributor Author

kidonng commented Aug 26, 2022

@ije Kindly ping because I feel this is a serious issue. I also tried past versions, and got the same error since v72 (well, v71 does give the same transformed import, but a new error also appeared).

@ije ije closed this as completed in 5bbbe5e Aug 29, 2022
@kidonng
Copy link
Contributor Author

kidonng commented Aug 29, 2022

I see, so there's a hard-coded list fixing these errors. I wish we can have a better solution in the future.

In the meantime, you may want to also add conf into the list, which is reported in #410.

ije added a commit that referenced this issue Oct 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deno Not working in Deno
Projects
None yet
Development

No branches or pull requests

1 participant