From 9e174d815c90bc56849ebdf2f43a75f632b4191f Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Tue, 30 Nov 2021 15:04:32 -0800 Subject: [PATCH] Release a release candidate for the new JS API --- CHANGELOG.md | 37 ++++++++++++++++++++++++++++++ lib/src/node.dart | 48 +++++++++++++++++++-------------------- pkg/sass_api/CHANGELOG.md | 4 ++++ pkg/sass_api/pubspec.yaml | 4 ++-- pubspec.yaml | 2 +- tool/grind.dart | 1 - 6 files changed, 67 insertions(+), 29 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 11c5fd78a..5cb263336 100644 --- a/CHANGELOG.md +++ b/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. diff --git a/lib/src/node.dart b/lib/src/node.dart index 04f8947cb..41513da75 100644 --- a/lib/src/node.dart +++ b/lib/src/node.dart @@ -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" diff --git a/pkg/sass_api/CHANGELOG.md b/pkg/sass_api/CHANGELOG.md index d8d76f1a5..43aae1641 100644 --- a/pkg/sass_api/CHANGELOG.md +++ b/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. diff --git a/pkg/sass_api/pubspec.yaml b/pkg/sass_api/pubspec.yaml index c838ec8f6..503488212 100644 --- a/pkg/sass_api/pubspec.yaml +++ b/pkg/sass_api/pubspec.yaml @@ -2,7 +2,7 @@ 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 @@ -10,7 +10,7 @@ environment: sdk: '>=2.12.0 <3.0.0' dependencies: - sass: 1.44.0 + sass: 1.45.0-rc.1 dependency_overrides: sass: {path: ../..} diff --git a/pubspec.yaml b/pubspec.yaml index a71486686..aa59a16c8 100644 --- a/pubspec.yaml +++ b/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 diff --git a/tool/grind.dart b/tool/grind.dart index d79a3ef1c..dbd890bf3 100644 --- a/tool/grind.dart +++ b/tool/grind.dart @@ -35,7 +35,6 @@ void main(List 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;