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

[Feature] SASS division without slash #3333

Closed
thebrownfox opened this issue May 21, 2021 · 22 comments
Closed

[Feature] SASS division without slash #3333

thebrownfox opened this issue May 21, 2021 · 22 comments

Comments

@thebrownfox
Copy link

thebrownfox commented May 21, 2021

This is about Bulma.

Overview of the problem

This is about the Bulma CSS framework
I'm using Bulma version [0.9.2]
This is a Sass issue: I'm using version [1.33.0]
I am sure this issue is not a duplicate

Description

Usage of slash division will be deprecated in sass 2.0.0 and now my console gets polluted with deprecation warnings.
https://sass-lang.com/documentation/breaking-changes/slash-div

Steps to Reproduce

  1. Update to latest sass 1.33.0
  2. Run project

Expected behavior

No warnings.

Actual behavior

Warning for every slash used for division.
DEPRECATION WARNING: Using / for division is deprecated and will be removed in Dart Sass 2.0.0.

@Niek
Copy link

Niek commented May 21, 2021

Same here, might be a good idea to run https://github.com/sass/migrator on the Sass files?

@tcitworld
Copy link

tcitworld commented May 21, 2021

It seems bulma still makes use of node-sass instead of dart-sass, and math:div is only supported in the latest version of dart-sass: https://sass-lang.com/documentation/modules/math

It's probably safer to downgrade sass to 1.32.0 for now, as asking people to use sass with the latest version if they want to use Bulma's sass source files is quite a requirement.

@francesco-loreti
Copy link

Recommendation: math.div($i, 12)

@robertmarney
Copy link

Full error example:

: Using / for division is deprecated and will be removed in Dart Sass 2.0.0.

Recommendation: math.div($button-padding-horizontal, 4)

More info and automated migrator: https://sass-lang.com/d/slash-div

   ╷
88 │       +ltr-property("margin", $button-padding-horizontal / 4)
   │                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   ╵
    node_modules\bulma\sass\elements\button.sass 88:31  @import
    node_modules\bulma\sass\elements\_all.sass 5:9      @import
    node_modules\bulma\bulma.sass 5:9                   @import
    resources\sass\buefy.scss 166:9                     @import
    stdin 1:9                                           root stylesheet

@lashchivskyi
Copy link

did you manage to resolve this error?

@coderberry
Copy link

coderberry commented May 25, 2021

It seems that this error is preventing anyone from using the latest Bulma via sass. Is there a release date for this? I've had to run sass-migrator division --migrate-deps bulma.sass and copy the modified sass into my project directly.

Also, I wonder if this issue should be flagged as a bug, not a feature.

@nextmat
Copy link

nextmat commented May 25, 2021

See @jgthms' comments in #3335 for context as to why this is not super straightforward to fix.

Anyone have insight into whether math.div() will be back-ported into node-sass or Ruby sass?

@tcitworld
Copy link

tcitworld commented May 25, 2021

This is explained in https://sass-lang.com/blog/libsass-is-deprecated. Libsass is depreciated and won't get anymore features (this one was one of the reasons for the depreciation).

@sajithneyo
Copy link

From your project's root run this

npx sass-migrator division --migrate-deps ./node_modules/bulma/bulma.sass
npx patch-package bulma

So patch-package will create a patch until bulma fixes this. Commit the patch file. Check patch-package documentation for it's setup.

@maxenz
Copy link

maxenz commented Jun 3, 2021

guys, any serious solution from bulma for this? thanks @sajithneyo for the patch option but it is not something I can use in my actual project.

@baileydoestech
Copy link

There is a similar discussion about this with Bootstrap with a range of suggestions: twbs/bootstrap#34051

97carmine pushed a commit to 97carmine/portfolio that referenced this issue Jun 4, 2021
@trezy
Copy link

trezy commented Jun 10, 2021

@sajithneyo's comment should work for now if you're using npm or Yarn 1. If you're using Yarn 2, you should use Yarn's built-in patch and patch-commit commands:

yarn patch bulma
yarn dlx sass-migrator division --migrate-deps {PATH TO PATCH FOLDER}
yarn patch-commit {PATH TO PATCH FOLDER}

@adamdehaven
Copy link

adamdehaven commented Jun 10, 2021

Can someone explain the implications of using @sajithneyo's solution? If Bulma rolls out an "official" fix, will it override the patch?

Also, I'm assuming this patch won't actually do anything if you're importing individual sass files from Bulma in order to compile in your project (i.e. customization of Bulma variables)?

@trezy
Copy link

trezy commented Jun 10, 2021

Can someone explain the implications of using @sajithneyo's solution? If Bulma rolls out an "official" fix, will it override the patch?

I imagine it'd be the same for Yarn's built in patch command. According to the patch-package readme, it will exit silently if it fails to apply the patch, which is likely to happen if you upgrade the version of the patched package. If the patch is still required after upgrading the patched package, you can follow the process again to recreate the patch. This is all just a guess, though. @ds300 or @arcanis might be able to give us more clarification on how they expect developers to handle fixed/upgraded packages, since I couldn't find any documentation about that.

Also, I'm assuming this patch won't actually do anything if you're importing individual sass files from Bulma in order to compile in your project (i.e. customization of Bulma variables)?

Actually, the patch only overrides the .sass files. It won't have any impact if you're using the compiled .css files, though.

@gandesc
Copy link

gandesc commented Jun 11, 2021

Can someone explain the implications of using @sajithneyo's solution? If Bulma rolls out an "official" fix, will it override the patch?

Also, I'm assuming this patch won't actually do anything if you're importing individual sass files from Bulma in order to compile in your project (i.e. customization of Bulma variables)?

Re patch-package:

When a new version of Bulma is released, patch-package will attempt to apply the patch same as before.

  • If the patch can be applied successfully, you'll get a warning that the package version has changed.
  • If the files to be patched have been changed in the new release and the patch can no longer be applied, you'll get a message explaining that the patch cannot be applied and you should check if the patch is still needed.

If the patch is not needed anymore, you can delete it (it won't be applied anyway). If a new patch is needed, you'd need to re-run the sass migrator and then recreate the patch (the old patch will be overwritten).

The whole process is pretty foolproof, we're using patches for a couple of other packages.

@Rainbowlemon
Copy link

Any other solutions for this? I'm compiling with parcel 2, and its transformer-sass package is reporting an error even after patching with @sajithneyo 's solution:

@parcel/transformer-sass: Undefined operation "divide(255, 255) < 0.03928".

71 │     @if $value < 0.03928

  node_modules/bulma/sass/utilities/functions.sass 71:9           colorLuminance()
  node_modules/bulma/sass/utilities/functions.sass 80:8           findColorInvert()
  node_modules/bulma/sass/utilities/derived-variables.sass 16:17  @import
  node_modules/bulma/sass/utilities/_all.sass 6:9                 @import
  node_modules/bulma/bulma.sass 3:9                               @import
  assets/sass/main.scss 7:9                                       root stylesheet

@tcitworld
Copy link

@Rainbowlemon According to https://v2.parceljs.org/languages/sass/ you can configure sass options into sass configuration files and add the quietDeps option from the recent sass versions.

@nogic1008
Copy link

If you use dart-sass via sass-loader, webpack.config.js like this:

module.exports = {
  module: {
    rules: [
      {
        test: /\.s[ac]ss$/i,
        use: [
          "style-loader",
          "css-loader",
          {
            loader: "sass-loader",
            options: {
              sassOptions: { quietDeps: true } // Add this
            }
          }
        ]
      }
    ]
  }
};

Or if you use it in nuxt, nuxt.config.js like this

export default {
  // ...
  build: {
    loaders: {
      scss: { sassOptions: { quietDeps: true } },
      sass: { sassOptions: { quietDeps: true } }
    }
  }
};

@m99coder
Copy link

Is there any solution for using Bulma SASS with Gatsby? So far I keep my SASS dependency pinned to 1.32.0 to avoid this error.

@jgthms
Copy link
Owner

jgthms commented Jun 18, 2021

I've just created a fix/divide branch. Will merge and release today.

@alexryabkov
Copy link

It works now! Thank you!

@jgthms jgthms closed this as completed Jun 18, 2021
@lesar
Copy link

lesar commented Jun 19, 2021

Great, work again.
Thanks you!

MartinRosenberg added a commit to Collabsalot/gatsby-starter-i18n-bulma that referenced this issue Sep 7, 2021
kalwalt pushed a commit to kalwalt/gatsby-starter-i18n-bulma that referenced this issue Sep 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.