Coder Social home page Coder Social logo

Comments (7)

ai avatar ai commented on June 1, 2024

Sorry, I can’t help with debugging Node.js. This is a question for Stack Overflow or Node.js community.

from postcss.

silverwind avatar silverwind commented on June 1, 2024

The question is: does postcss load it's plugins through regular import or some other nonstandard module loader? If the later, it is very much related to postcss. Have you even looked at the repro?

from postcss.

ai avatar ai commented on June 1, 2024

Mostly default require(), but there are a hack for TS https://github.com/postcss/postcss-load-config/blob/main/src/req.js

from postcss.

silverwind avatar silverwind commented on June 1, 2024

This here confirms that node can load both variants fine, but postcss cannot:

$ echo '{"type": "module", "exports": {".": "./index.js"}}' > config/package.json && node -e 'import("config").then(console.log)'
[Module: null prototype] { config: {} }
$ echo '{"type": "module", "exports": {".": {"import": "./index.js"}}}' > config/package.json && node -e 'import("config").then(console.log)'
[Module: null prototype] { config: {} }

from postcss.

silverwind avatar silverwind commented on June 1, 2024

I think the root problem is that you are using createRequire which will give you the legacy CJS loader instead of the ESM loader, and the CJS loader will not use the import entry point but the require one which does not. So in essense, postcss plugins can not be pure ESM.

from postcss.

ai avatar ai commented on June 1, 2024

Got it, what eactly you asked.

Yes, we do not suppor ESM plugins yet. You may try to create a PR to postcss-load-config if you have a good plan.

But I don’t think that it will be easy (this is why don’t have it).

from postcss.

silverwind avatar silverwind commented on June 1, 2024

Actually the bug is in the tailwindcss plugin because even after importing the plugin directly in the postcss config, the error persists. The error stack trace has no postcss in it, so I'm certain this is not a postcss bug.

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in node_modules/config/package.json
    at new NodeError (node:internal/errors:405:5)
    at exportsNotFound (node:internal/modules/esm/resolve:261:10)
    at packageExportsResolve (node:internal/modules/esm/resolve:535:13)
    at resolveExports (node:internal/modules/cjs/loader:547:36)
    at Module._findPath (node:internal/modules/cjs/loader:621:31)
    at Module._resolveFilename (node:internal/modules/cjs/loader:1034:27)
    at Function.resolve (node:internal/modules/helpers:136:19)
    at _resolve (node_modules/jiti/dist/jiti.js:1:250334)
    at jiti (node_modules/jiti/dist/jiti.js:1:252917)
    at tailwind.config.js:1:329 {
  code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'

from postcss.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.