Breaking Change: Default Exports

By default, Node.js allows CommonJS modules to be loaded from ECMAScript modules using the syntax import sass from 'sass'. This is now deprecated; ESM users should use import * as sass from 'sass' instead.

Historically, Dart Sass was only available as a CommonJS module. This meant that anyone using it from a project that used Node.js’s native ECMAScript module support was able to load it as though it provided a default export:

import sass from 'sass'; // Don't do this anymore

This was never intended by the Sass team, and it didn’t match the type declarations provided with the package, but it did work. We have decided to remove this support in Dart Sass 2.0.0 and require that ECMAScript module users only use the package’s named exports:

import * as sass from 'sass'; // Do this

Transition PeriodTransition Period permalink

Compatibility:
Dart Sass
since 1.54.0
LibSass
Ruby Sass

Until Dart Sass 2.0.0, we will continue to support users loading Sass’s default export. The first time any properties on the default export are accessed, it will emit a deprecation warning to console.error(). To avoid this error, use import * as sass from 'sass' instead.