uswds / uswds-compile

Simple Gulp 4 functions for copying USWDS static assets and transforming USWDS Sass into browser-readable CSS.
Other
21 stars 12 forks source link

USWDS-Compile - Bug: "0px and 1 are incompatible" #69

Closed ryandwalker closed 11 months ago

ryandwalker commented 1 year ago

Describe the bug

When I run npx gulp, I see errors like the following:

Message:
    assets/scss/lib/functions/_strip-units.scss
Error: 0px and 1 are incompatible.
   ╷
16 │   @return (calc($value / ($value * 0 + 1)));
   │                           ^^^^^^^^^^^^^^
   ╵

Steps to reproduce the bug

  1. Run npx gulp
  2. See error:
    Message:
    assets/scss/lib/functions/_strip-units.scss
    Error: 0px and 1 are incompatible.
    ╷
    16 │   @return (calc($value / ($value * 0 + 1)));
    │                           ^^^^^^^^^^^^^^
    ╵

Expected Behavior

I expect it to run without errors.

Related code

No response

Screenshots

No response

System setup

Debian GNU/Linux 11 (bullseye) NPM 7.5.2

Additional context

I'm not sure what the intent is with this expression: ($value * 0 + 1)

Code of Conduct

mahoneycm commented 1 year ago

Hello Ryan,

The function in question appears to belong to USWDS, rather than USWDS-Compile.

Can you provide any more insight into your repo that may have caused this error to pop up? Is there anywhere you are setting a value to 0px or a unitless 1 ?

By default, when I run npx gulp on a project with USWDS-Compile, I do not see the error. Any help to recreate the bug or even a test repo would be appreciated!

mahoneycm commented 1 year ago

Hello again @ryandwalker,

Following up on my previous question. Can you provide any more detail on your repo or how to recreate this bug? With default USWDS settings, I do not receive this error when running npx gulp.

To clarify, is this happening on a project with USWDS and USWDS-compile installed? Which version of USWDS are you using? Have you updated any values to 0px or a unitless 1?

If you can provide more information, we'll be happy to dive deeper!

Thanks!

mejiaj commented 1 year ago

This doesn't seem like a USWDS specific bug, system uses strip-unit() & there's USWDS version tied.

For reference, this name hasn't changed. You can see a 2x example here.


@ryandwalker can you provide:

ryandwalker commented 1 year ago

I've been away from this project, but I believe my aim was to get to first base with gulp and a sub-theme of USWDS. Here is my package.json:

{ "name": "uswds-gulp-subtheme", "version": "1.0.0", "devDependencies": { "@uswds/compile": "^1.0.0", "autoprefixer": "^10.4.13", "del": "^6.0.0", "gulp": "^4.0.2", "gulp-postcss": "^9.0.1", "gulp-rename": "^2.0.0", "gulp-replace": "^1.1.3", "gulp-sass": "^5.1.0", "gulp-sourcemaps": "^3.0.0", "gulp-svg-sprite": "^1.5.0", "postcss": "^8.4.19", "postcss-csso": "^5.0.1", "sass": "^1.64.1", "uswds": "^2.14.0", "uswds-gulp": "github:uswds/uswds-gulp" } }

I copied the uswds_gulp_subtheme from USWDS/examples to create my subtheme. Subsequently, I was trying to follow the instructions in the README for uswds-compile.

If I remember correctly, I arrived at this uswds-compile project via a link from some other project that indicated it was deprecated, and I should use uswds-compile instead.

As you can see from my package.json, I installed uswds-compile and was then trying to run npx gulp to see if I was on the right track with my setup. When I run npx gulp watch or npx gulp, I see the output in my bug report above. image

mahoneycm commented 1 year ago

@ryandwalker The error could be coming from bourbon scss. The error path tracks back to that file and I can see their strip-unit() function used to be named strip-units() (plural) as it is in your error message, where ours has always been without the s.

It looks like we removed our bourbon dependency for the 2.0 release but your error message mentions it is referenced on uswds.scss 4:9.

You also have uswds-gulp installed, which is deprecated and was replaced by @uswds/compile. I wonder if that is causing any conflict with the gulp commands.

Is the project you mentioned still in development? It may be a good idea to checkout our 2.0 migration guides and make sure your USWDS implementation is up to date, or consider upgrading to the latest 3.6.0.

If you are using a USWDS Drupal theme, you may also want to reach out to reach out to the team maintaining that implementation since this doesn’t look like a USWDS specific issue.

mahoneycm commented 11 months ago

Closing because this doesn't seem like a uswds-compile issue.

Please don't hesitate to reach out if you have any more questions about getting your USWDS package up to date!