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

[node-build-scripts] feat: use non-legacy Sass compiler, remove node-sass #5904

Merged
merged 14 commits into from
Feb 24, 2023

Conversation

adidahiya
Copy link
Contributor

@adidahiya adidahiya commented Jan 30, 2023

Fixes #5334

Changes proposed in this pull request:

This PR completely revamps the sass-compile script in @blueprintjs/node-build-scripts:

  • We now use the standard async compiler instead of the legacy sync compiler API
  • The dependency on legacy node-sass custom Sass functions has been removed
    • @vgrid/sass-inline-svg (which doesn't work well with dart-sass and fails to run in Node v19.x) has been removed in favor of our own custom SVG inliner implementation
  • We no longer use the deprecated "node-sass-package-importer"
  • Instead of the special ~ syntax for importing node modules (which seems to be webpack-specific via sass-loader), we now specify dart-sass includePaths to include nodes_modules paths
    • I've implemented this in a way that should work with both Yarn and PNPM, but for now it only has to work with Yarn in this repo

This will unblock upgrading to Node v19.x 🎉

Implementation notes

Not done in this PR

This PR does not migrate from Sass @import to @use. That will happen in another PR.

Reviewers should focus on:

No regressions in CSS APIs for the following components:

  • Breadcrumbs
  • Checkbox
  • Radio

Screenshot

image

@adidahiya adidahiya changed the title [DRAFT] use our own sass-inline-svg implementation [node-build-scripts] feat(sass-compile): use non-legacy compiler, completely remove node-sass Feb 24, 2023
@adidahiya adidahiya changed the title [node-build-scripts] feat(sass-compile): use non-legacy compiler, completely remove node-sass [node-build-scripts] feat: use non-legacy Sass compiler, completely remove node-sass Feb 24, 2023
@adidahiya adidahiya marked this pull request as ready for review February 24, 2023 18:16
@adidahiya
Copy link
Contributor Author

export svg inliner, remove math from variables

Build artifact links for this commit: documentation | landing | table | demo

This is an automated comment from the deploy-preview CircleCI job.

@@ -46,11 +55,13 @@ $pt-font-size-large: $pt-grid-size * 1.6 !default;
$pt-font-size-small: $pt-grid-size * 1.2 !default;

// a little bit extra to ensure the height comes out to just over 18px (and browser rounds to 18px)
$pt-line-height: math.div($pt-grid-size * 1.8, $pt-font-size) + 0.0001 !default;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ooc why did you have to drop the math.div ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get-sass-vars actually interprets and evaluates math for us (kind of surprising when you think about it). when I switched to postcss-simple-vars, we lost that evaluation step. But I think I can actually move back to get-sass-vars; see my other comment

@@ -2,7 +2,7 @@
// Licensed under the Apache License, Version 2.0.

@import "../../common/variables";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ooc should these change to @use at some point?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, at some point...

@@ -54,7 +54,7 @@ Blueprint provides variables for colors in Sass, Less, and JavaScript.
Example in Sass:

```scss
@import "~@blueprintjs/core/lib/scss/variables";
@import "@blueprintjs/core/lib/scss/variables";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we be recommending @use "@blueprintjs/core/lib/scss/variables" as bp instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will change the recommendation once we switch to @use in this repo

export const DEFAULT_FLAG = "!default";

/**
* Parses Sass source file contents for variables using "postcss-simple-vars"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on second thought, we might be able to stick with get-sass-vars instead of switching to this custom implementation. I think at some point during the long history of this PR, I got convinced that we had to migrate away from that library because of our custom functions, but I think it can continue to work for us. and it seems to be maintained well enough (last update was Jan 2023).

@@ -46,11 +55,13 @@ $pt-font-size-large: $pt-grid-size * 1.6 !default;
$pt-font-size-small: $pt-grid-size * 1.2 !default;

// a little bit extra to ensure the height comes out to just over 18px (and browser rounds to 18px)
$pt-line-height: math.div($pt-grid-size * 1.8, $pt-font-size) + 0.0001 !default;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get-sass-vars actually interprets and evaluates math for us (kind of surprising when you think about it). when I switched to postcss-simple-vars, we lost that evaluation step. But I think I can actually move back to get-sass-vars; see my other comment

@adidahiya
Copy link
Contributor Author

Fix math reference

Build artifact links for this commit: documentation | landing | table | demo

This is an automated comment from the deploy-preview CircleCI job.

@adidahiya adidahiya changed the title [node-build-scripts] feat: use non-legacy Sass compiler, completely remove node-sass [node-build-scripts] feat: use non-legacy Sass compiler, remove node-sass Feb 24, 2023
@adidahiya adidahiya merged commit 1ff4cc5 into develop Feb 24, 2023
@adidahiya adidahiya deleted the ad/remove-sass-inline-svg branch February 24, 2023 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

svg-icon - (path: (fill: #5f6b7c)) isn't a valid CSS value
2 participants