embedded-host-node icon indicating copy to clipboard operation
embedded-host-node copied to clipboard

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

Open derrickb opened this issue 8 months ago • 2 comments

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
}),

derrickb avatar Apr 10 '25 16:04 derrickb

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 avatar Apr 10 '25 22:04 nex3

@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.

ntkme avatar Apr 10 '25 23:04 ntkme