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

feat: allow importing sass/package.json #2030

Closed
AviVahl opened this issue Jun 28, 2023 · 3 comments
Closed

feat: allow importing sass/package.json #2030

AviVahl opened this issue Jun 28, 2023 · 3 comments

Comments

@AviVahl
Copy link

AviVahl commented Jun 28, 2023

I'm trying to import { version as sassVersion } from 'sass/package.json'; and noticed it wasn't exposed in current "exports".

Current (1.63.6) package.json:

{
  "exports": {
    "types": "./types/index.d.ts",
    "node": { "require": "./sass.node.js", "default": "./sass.node.mjs" },
    "default": {
      "require": "./sass.default.cjs",
      "default": "./sass.default.js"
    }
  }
}

I wonder if it could be adjusted to:

{
  "exports": {
    "./package.json": "./package.json",
    ".": {
      "types": "./types/index.d.ts",
      "node": { "require": "./sass.node.js", "default": "./sass.node.mjs" },
      "default": {
        "require": "./sass.default.cjs",
        "default": "./sass.default.js"
      }
    }
  }
}
@nex3
Copy link
Contributor

nex3 commented Jun 28, 2023

If you're trying to get the version, it's better to parse it from the info field, which is guaranteed to be set for all Sass implementations.

@nex3 nex3 closed this as not planned Won't fix, can't repro, duplicate, stale Jun 28, 2023
@AviVahl
Copy link
Author

AviVahl commented Jun 28, 2023

Not sure why I would want to parse the version from that string when the version is already available in the package.json, which my case is guaranteed to have. I'd also like to avoid evaluating the entire sass library just to get the version. Exposing the package.json is a pretty common practice, so I'd ask you to please reconcider.

@nex3
Copy link
Contributor

nex3 commented Jul 5, 2023

The Sass package isn't just an API in itself, it's an interface that multiple implementations can implement. We want to be very clear what's an expected part of that interface, and exporting the entire package.json—most of which is fundamentally an implementation detail—risks having users over-index on the specific implementation they're testing against rather than the general shape of "a Sass API" that can be supported by multiple implementations. That's why we want to encourage users to go through the official, JS API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants