All jobs

Fix "DEPRECATION WARNING [legacy-js-api]: The legacy JS API is deprecated and will be removed in Dart Sass 2.0.0"

Yes. An agent moves a build script from sass.renderSync to sass.compile, ports its custom Sass functions, and shows the CSS output is byte-identical.

Run this on RushOpens the console with this prompt ready to send, in a Project that has your repository.

What the agent does

The agent starts from the script that prints the warning, because the fix is a rewrite of that script and not a package bump. In a static site like iv-org/invidious-redirect, package.json has one build step, node src/build.js, and sass is a devDependency at ^1.26.10 that package-lock.json pins to 1.26.10. src/build.js walks a six-item spec list (two logo files, /main.sass, /main.js through Babel, and two Pug pages) and its addSass function calls sass.renderSync with a file, outputStyle: "compressed", and one custom function, static($name), written against the legacy value API: it checks name instanceof sass.types.String, reads name.getValue() and returns new sass.types.String(...). src/main.sass is 151 lines and calls that function twice, at lines 83 and 86, inside url() for the light and dark logo.

Next it works out which install prints the warning. npm install from the lock file gives sass 1.26.10 and a silent build. npm install sass@latest gives 1.108.1, whose engines field asks for Node 20.19.0 or newer, and npm run build then prints DEPRECATION WARNING [legacy-js-api]: The legacy JS API is deprecated and will be removed in Dart Sass 2.0.0. with the link https://sass-lang.com/d/legacy-js-api, once, before Build complete.. The legacy API still works on 1.108.1: its build/static/css/main.css is byte-for-byte the 2,386-byte file committed in the repository, which matters because .gitignore leaves build/static/ tracked.

The rewrite replaces renderSync with sass.compile(path, {style: "compressed", functions}). A modern-API function receives an array of arguments, so the body becomes args[0].assertString("name") and .text, and the return value is new sass.SassString(static.get(...), {quotes: false}). The quotes option is the one detail that bites: without it the two url(...) values come out as url("..."), four bytes longer and no longer identical to the committed file. compile also returns css as a string where renderSync returned a Buffer, so the agent wraps it in Buffer.from to keep the hash() call and fs.writeFile unchanged.

Proof is the build output and a checksum. With the modern API on sass 1.108.1 the build prints only Build complete., and main.css has the same MD5 as the committed file. The agent also reports what else a plain npm run build touches even before any change: Babel rewrites build/static/js/main.js, main.min.js and the source map from the lock file alone, so the pull request keeps those out unless the team wants the regenerated build committed too.

Start it with one API call

POST https://api.phoenix.so/o/{org}/sessions with this body:

{
  "agent": "claude",
  "input": "Our site build prints \"DEPRECATION WARNING [legacy-js-api]: The legacy JS API is deprecated and will be removed in Dart Sass 2.0.0\". Find every call to sass.render, sass.renderSync and sass.types in the build script, say which sass version the lock file installs and which version first prints the warning for us, and port the script to sass.compile with the modern function API. Keep the compiled CSS byte-identical: run the build before and after and compare checksums of every generated stylesheet, and note any other file the build rewrites. Open a pull request with the script change and the before-and-after build output; do not commit regenerated build artifacts unless they were already tracked and unchanged.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
  1. Get an API key. In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
  2. Send the request. POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
  3. Read what came back. Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

What comes back

A pull request that changes one function in src/build.js: renderSync becomes compile, outputStyle becomes style, and the static($name) helper is rewritten against assertString, .text and SassString with quotes: false. The description names the installed sass version, the version that prints the warning, the warning text, and the MD5 of main.css before and after.

A reviewer checks that the custom function keeps its contract, that the generated CSS is unchanged, and that the diff does not drag in the JavaScript files Babel rewrites on every build. If the team bumps sass in the same pull request, the lock file change and the Node 20.19 requirement from its engines field are called out so CI runners on older Node are not surprised.

The description names what the agent left alone: the @mixin and @media blocks in main.sass compile cleanly under 1.108.1, so no stylesheet change is needed, and sass.types disappears from the script entirely rather than being wrapped.

Run it on every Dependabot pull request that bumps sass

The warning arrives with the bump, so the trigger is the pull request that bumps it. An automation with a github trigger on pull_request.opened and pull_request.synchronize runs this prompt on each one, with the event appended after the prompt, and pushes the script rewrite onto the bump's branch when the build prints a Dart Sass deprecation.

For a fleet of sites that share the same build script, your server sends this request once per repository, each with its own UUID as request_id so a retry returns the run already started, and reads each run.completed webhook; a key starts at most max_concurrent runs at once and queues the rest.

The use case this job follows, with its automation and trigger: Fix a bug from an alert.

Why run it on Rush?

The legacy and modern APIs differ in small ways the docs do not shout about, and custom functions are where they bite: argument arrays instead of positional values, .text instead of getValue(), and a quotes default that changes url() output. In a Rush sandbox the agent runs the real build on both sass versions, keeps every warning line, and compares checksums, so the pull request argues from your stylesheet's output rather than from a migration guide.

A deprecation fix should not change what ships. The agent proves the CSS is identical and reports which other build outputs move on their own, so the reviewer reads a focused change and decides separately whether to regenerate and commit the build directory.

Frequently asked questions

Why does my build only warn after a dependency update?

The lock file pins the older sass, 1.26.10 in this repository, which has no warning. The ^1.26.10 range allows any 1.x, so the first npm update or Dependabot bump moves to a current 1.x release, where every call through the legacy render and renderSync API prints the warning.

Does the modern API produce the same CSS?

For this stylesheet, yes, once the custom function returns an unquoted string. new sass.SassString(value) is quoted by default, which turned two url(...) values into url("..."); passing {quotes: false} restores the exact bytes of the committed file.

Do I have to bump sass to fix the warning?

No. The modern compile API exists in the lock file's version too, so the script change can land first with no dependency bump. When the bump comes, it brings the engines requirement of Node 20.19.0 or newer, which the pull request names so CI runners can be checked.

What about the warning's Dart Sass 2.0.0 date?

The message says only that the legacy API will be removed in 2.0.0 and links to the deprecation page. The pull request quotes the message as printed and does not guess a release date.

More Sass jobs

More jobs like this: Fix a bug from an alert

Keep reading