Skip to content

[Rollup] Cannot read properties of undefined (reading 'url') -- with multiple @use #369

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

Open
derrickb opened this issue Apr 10, 2025 · 2 comments
Labels
bug Something isn't working needs info

Comments

@derrickb
Copy link

derrickb commented Apr 10, 2025

This may be an issue specific to the Rollup plugin, but if sass-embedded is meant to be a drop-in replacement for sass, then it may be an issue worth describing here.

I am using:

"rollup": "^4.39.0",
"rollup-plugin-scss": "^4.0.1",
"sass-embedded": "^1.86.3"

Like this:

import scss from "rollup-plugin-scss";
import * as sassEmbedded from "sass-embedded";
...
scss({
  fileName: "output.css",
  sass: sassEmbedded
}),

And a stripped down test case file that looks like:

@use 'module1';
@use 'module2';

Which results in Cannot read properties of undefined (reading 'url') but only if there is more than one @use statement.

If I swap out sass-embedded for sass, it works without the error, which leads me to think the error lies in this package.

import scss from "rollup-plugin-scss";
import sass from "sass";
...
scss({
  fileName: "output.css",
  sass: sass
}),
@nex3
Copy link
Contributor

nex3 commented Apr 10, 2025

This may be a bug, or it may be a case where the rollup plugin is relying on undefined behavior like passing in something that violates the TypeScript type constraints. Can you provide a reproduction that's just in terms of the importer API, without needing all of rollup to be installed as well?

@nex3 nex3 added bug Something isn't working needs info labels Apr 10, 2025
@ntkme
Copy link
Contributor

ntkme commented Apr 10, 2025

@derrickb It would be helpful if you can provide the error stack, in addition to the error message.

@nex3 I've quickly searched the code of rollup-plugin-scss and I don't see any where it's accessing a .url property of anything. Given it's running legacy API, I suspect something went wrong with prev.url in the emulated importer, that prev is somehow undefined.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs info
Projects
None yet
Development

No branches or pull requests

3 participants