node-sass deprecation background

Background note
This change was concluded after a lot of discussion by the Sass core team. It is now time to officially announce the deprecation of LibSass and the packages built on it (including Node Sass). Over the years, LibSass has obviously not had enough engineering bandwidth to keep up with the latest developments in the Sass language (for example, the most recent language features were added in November 2018). Although we very much hope to see this situation improve, even the excellent work of long-term LibSass contributors Michael Mifsud and Marcel Greter cannot keep up with the rapid pace of CSS and Sass language development.
Mainly include the following four points

  1. It is no longer recommended to use LibSass for new Sass projects, use Dart Sass instead. It is recommended that all existing LibSass
    users make plans to migrate to Dart Sass, and all Sass libraries make plans to finally give up support for LibSass. There are no plans to
    add any new features to LibSass, including compatibility with new CSS features. LibSass and Node Sass
    will be maintained indefinitely on a best-effort basis, including fixing major bugs and security issues and being compatible with the latest Node version. Why is it deprecated?
  2. For several years, Sass has been in a state of ambiguity. LibSass is officially supported in theory, but in fact it is static from the perspective of its functional performance.
    Over time, it became clear that this state of affairs has caused real problems for Sass users. For example, users are often confused about why the
    min() and max() of the native CSS do not work properly. You may think that there is a problem with Sass as a whole, but it is actually because LibSass does not support this feature.
  3. The officially supported LibSass will not only cause pain to individual users. Since LibSass does not support the Sass module system launched last year, the main related Sass
    library cannot use it due to concerns about incompatibility with downstream users. It is clearly pointed out that all Sass users should abandon using LibSass. , We hope that
    the authors of these libraries can use more modern features more effectively.
  4. LibSass even suppressed the development of the Sass language itself. We cannot proceed
    with the proposal of treating / as a separator because any code they write will generate a deprecation warning in Dart Sass or fail to compile in LibSass. By
    marking LibSass as deprecated, things will get better, and Sass will get better at supporting the latest version of CSS.

What does "deprecated" mean?
We chose to use the term "deprecated" because it has a lot of weight in the programming community and strongly suggests that users should start planning to abandon LibSass. However, this does not mean that the project is completely dead. The lead maintainer of LibSass and Node Sass, Michael Mifsud, confirmed that he plans to continue the same level of maintenance as in the past few years. This means that although no more features will be added (and thus LibSass will gradually deviate from compatibility with the latest CSS and Sass syntax), maintenance versions will continue to be released indefinitely.

Portability and performance
LibSass has two main advantages over DartSass:

  • Portability : Since it is written in C++, LibSass can be easily embedded in other programming languages ​​and provide native-feeling APIs.
  • Performance : Calling LibSass through C++ API is very fast compared to using scripting language to write code directly. In particular, this means that LibSass is much faster in JavaScript than Dart Sass compiled to JS libraries (although it is comparable to Dart Sass
    's command line executable). We are using the Sass embedded protocol to solve these two problems. The protocol
    runs the Sass compiler as a child process and can communicate with any host language through message passing. The embedded protocol supports all the functions of the native Sass API, including
    the ability to define custom importers and Sass functions, while also providing high-performance CLI applications. Dart Sass has implemented the compiler side of the embedded protocol and is actively developing the
    JavaScript side.

Dart Sass

  • Dart Sass can be compiled into a sass package written in pure JavaScript and uploaded to npm. The pure JS
    version is slower than a standalone executable, but is easy to integrate into existing workflows, and allows you to define custom functions and importers in JavaScript.
  • When installed via npm, Dart Sass aims to implement a JavaScript API
    library compatible with Node Sass . Full compatibility is still under development, but Dart Sass currently supports render() and renderSync()
    functions. Note, however, that by default, due to the overhead of asynchronous callbacks, the speed of renderSync() is more than twice that of render().

Guess you like

Origin blog.csdn.net/weixin_46476460/article/details/112312929