Skip to content
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

Release a release candidate for the new JS API #1562

Merged
merged 1 commit into from Nov 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
37 changes: 37 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,40 @@
## 1.45.0-rc.1

### JS API

This release includes an entirely new JavaScript API, designed to be more
idiomatic, performant, and usable. The old API will continue to be supported
until Dart Sass 2.0.0, but it is now considered deprecated and should be avoided
for new code.

The new API includes:

* `compile()` and `compileAsync()` functions that take Sass file paths and
return the result of compiling them to CSS. The async function returns a
`Promise` rather than using a callback-based API.

* `compileString()` and `compileStringAsync()` functions that take a string of
Sass source and compiles it to CSS. As above, the async function returns a
`Promise`.

* A new importer API that more closely matches the Sass specification's logic
for resolving loads. This makes it much easier for Sass to cache information
across `@import` and `@use` rules, which substantially improves performance
for applications that rely heavily on repeated `@import`s.

* A new custom function API, including much more usable JS representations of
Sass value types complete with type-assertion functions, easy map and list
lookups, and compatibility with the [`immutable`] package. **Unlike in the
legacy API,** function callbacks now take one argument which contains an array
of Sass values (rather than taking a separate JS argument for each Sass
argument).

[`immutable`]: https://immutable-js.com/

For full documentation of this API, please see [the Sass website][js-api].

[js-api]: https://sass-lang.com/documentation/js-api

## 1.44.0

* Suggest `calc()` as an alternative in `/`-as-division deprecation messages.
Expand Down
48 changes: 23 additions & 25 deletions lib/src/node.dart
Expand Up @@ -18,31 +18,29 @@ import 'value.dart';
///
/// This sets up exports that can be called from JS.
void main() {
if (const bool.fromEnvironment("new-js-api")) {
exports.compile = allowInteropNamed('sass.compile', compile);
exports.compileString =
allowInteropNamed('sass.compileString', compileString);
exports.compileAsync = allowInteropNamed('sass.compileAsync', compileAsync);
exports.compileStringAsync =
allowInteropNamed('sass.compileStringAsync', compileStringAsync);
exports.Value = valueClass;
exports.SassBoolean = booleanClass;
exports.SassArgumentList = argumentListClass;
exports.SassColor = colorClass;
exports.SassFunction = functionClass;
exports.SassList = listClass;
exports.SassMap = mapClass;
exports.SassNumber = numberClass;
exports.SassString = stringClass;
exports.sassNull = sassNull;
exports.sassTrue = sassTrue;
exports.sassFalse = sassFalse;
exports.Exception = exceptionClass;
exports.Logger = LoggerNamespace(
silent: NodeLogger(
warn: allowInteropNamed('sass.Logger.silent.warn', (_, __) {}),
debug: allowInteropNamed('sass.Logger.silent.debug', (_, __) {})));
}
exports.compile = allowInteropNamed('sass.compile', compile);
exports.compileString =
allowInteropNamed('sass.compileString', compileString);
exports.compileAsync = allowInteropNamed('sass.compileAsync', compileAsync);
exports.compileStringAsync =
allowInteropNamed('sass.compileStringAsync', compileStringAsync);
exports.Value = valueClass;
exports.SassBoolean = booleanClass;
exports.SassArgumentList = argumentListClass;
exports.SassColor = colorClass;
exports.SassFunction = functionClass;
exports.SassList = listClass;
exports.SassMap = mapClass;
exports.SassNumber = numberClass;
exports.SassString = stringClass;
exports.sassNull = sassNull;
exports.sassTrue = sassTrue;
exports.sassFalse = sassFalse;
exports.Exception = exceptionClass;
exports.Logger = LoggerNamespace(
silent: NodeLogger(
warn: allowInteropNamed('sass.Logger.silent.warn', (_, __) {}),
debug: allowInteropNamed('sass.Logger.silent.debug', (_, __) {})));

exports.info =
"dart-sass\t${const String.fromEnvironment('version')}\t(Sass Compiler)\t"
Expand Down
4 changes: 4 additions & 0 deletions pkg/sass_api/CHANGELOG.md
@@ -1,3 +1,7 @@
## 1.0.0-beta.21

* No user-visible changes.

## 1.0.0-beta.20

* No user-visible changes.
Expand Down
4 changes: 2 additions & 2 deletions pkg/sass_api/pubspec.yaml
Expand Up @@ -2,15 +2,15 @@ name: sass_api
# Note: Every time we add a new Sass AST node, we need to bump the *major*
# version because it's a breaking change for anyone who's implementing the
# visitor interface(s).
version: 1.0.0-beta.20
version: 1.0.0-beta.21
description: Additional APIs for Dart Sass.
homepage: https://github.com/sass/dart-sass

environment:
sdk: '>=2.12.0 <3.0.0'

dependencies:
sass: 1.44.0
sass: 1.45.0-rc.1

dependency_overrides:
sass: {path: ../..}
2 changes: 1 addition & 1 deletion pubspec.yaml
@@ -1,5 +1,5 @@
name: sass
version: 1.44.0
version: 1.45.0-rc.1
description: A Sass implementation in Dart.
homepage: https://github.com/sass/dart-sass

Expand Down
1 change: 0 additions & 1 deletion tool/grind.dart
Expand Up @@ -35,7 +35,6 @@ void main(List<String> args) {
pkg.JSRequire("util", target: pkg.JSRequireTarget.all),
];
pkg.jsModuleMainLibrary.value = "lib/src/node.dart";
pkg.jsDevFlags.value.add("-Dnew-js-api=true");
pkg.npmPackageJson.fn = () =>
json.decode(File("package/package.json").readAsStringSync())
as Map<String, dynamic>;
Expand Down