Can sass-loader understand package.json "exports" field? #17990
-
Hi, in my UI library i have some scss files. This library build from TS and SCSS files:
In package.json of my library i have: {
"name": "@my-org/my-library",
"exports": {
"./utils.scss": "./build/utils.scss"
},
} In the project in which I use my library I tried imports: @use "@my-org/my-library/utils";
// or
@use "@my-org/my-library/utils.scss";
// or
@use "node_modules/@my-org/my-library/utils";
// or
@use "node_modules/@my-org/my-library/utils.scss"; But it is not working, in this project i use sass-loader with rspack but it crashes with error:
Can sass-loader understand package.json "exports" field? |
Beta Was this translation helpful? Give feedback.
Answered by
alexander-akait
Feb 3, 2024
Replies: 1 comment 10 replies
-
Did you try it using webpack? Because yes, it should works |
Beta Was this translation helpful? Give feedback.
10 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sorry for delay, there is an intresting problem...
exports
works fine, you have:// @use "my-library/utils.scss"; // also not working
But it works fine, just uncomment it and check out.
Because
import * as mod from "something.js"
requires an extension, you need to writescss
extension too for sass, i.e.@use "my-library/utils.scss";
, theoretically you can make a small plugin that allow to use it without thescss
extensions, but I don't feel it is a right solution,import ... from "something.js"
and theexports
field were originally designed to have an extension at the end and I have strong feel if sass wants to be align with javascript and don't create potential misunderstanding for devel…