Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions app/javascript/packages/build-sass/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## Unreleased

### Breaking Changes

- Requires Node.js v18 or newer

## 2.0.0

### Breaking Changes
Expand Down
11 changes: 7 additions & 4 deletions app/javascript/packages/build-sass/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
/* eslint-disable no-console */

import { mkdir } from 'node:fs/promises';
import { parseArgs } from 'node:util';
import { watch } from 'chokidar';
import { fileURLToPath } from 'url';
import { parseArgs } from '@pkgjs/parseargs'; // Note: Use native util.parseArgs after Node v18
import { buildFile } from './index.js';
import getDefaultLoadPaths from './get-default-load-paths.js';
import getErrorSassStackPaths from './get-error-sass-stack-paths.js';
Expand All @@ -26,9 +26,12 @@ const { values: flags, positionals: fileArgs } = parseArgs({
},
});

const isWatching = flags.watch;
const outDir = flags['out-dir'];
const loadPaths = [...flags['load-path'], ...getDefaultLoadPaths()];
const { watch: isWatching, 'out-dir': outDir, 'load-path': loadPaths = [] } = flags;
loadPaths.push(...getDefaultLoadPaths());
Comment on lines -29 to +30
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The polyfill doesn't reflect that flags['load-path'] may be undefined, which TypeScript flagged as not being possible to splat into an array from the prior logic:

app/javascript/packages/build-sass/cli.js:31:23 - error TS2488: Type 'string[] | undefined' must have a '[Symbol.iterator]()' method that returns an iterator.

31 const loadPaths = [...flags['load-path'], ...getDefaultLoadPaths()];
                         ~~~~~~~~~~~~~~~~~~

So effectively this is adding a default empty array. I could have inlined it, though I chose a bit of a rewrite to destructure the entire flags object and use that as the point at which to assign the default values.


if (!outDir) {
throw new TypeError('Output directory must be provided using the `--out-dir` option.');
}

/** @type {BuildOptions & SyncSassOptions} */
const options = { outDir, loadPaths, optimize: isProduction };
Expand Down
4 changes: 3 additions & 1 deletion app/javascript/packages/build-sass/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
"private": false,
"description": "Stylesheet compilation utility with reasonable defaults and fast performance.",
"type": "module",
"engines": {
"node": ">= 18"
},
"bin": {
"build-sass": "./cli.js"
},
Expand All @@ -25,7 +28,6 @@
"homepage": "https://github.com/18f/identity-idp",
"dependencies": {
"@aduth/is-dependency": "^1.0.0",
"@pkgjs/parseargs": "^0.11.0",
"browserslist": "^4.22.1",
"chokidar": "^3.5.3",
"lightningcss": "^1.22.0",
Expand Down
5 changes: 0 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1216,11 +1216,6 @@
resolved "https://registry.yarnpkg.com/@open-draft/until/-/until-1.0.3.tgz#db9cc719191a62e7d9200f6e7bab21c5b848adca"
integrity sha512-Aq58f5HiWdyDlFffbbSjAlv596h/cOnt2DO1w3DOC7OJ5EHs0hd/nycJfiu9RJbT6Yk6F1knnRRXNSpxoIVZ9Q==

"@pkgjs/parseargs@^0.11.0":
version "0.11.0"
resolved "https://registry.yarnpkg.com/@pkgjs/parseargs/-/parseargs-0.11.0.tgz#a77ea742fab25775145434eb1d2328cf5013ac33"
integrity sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==

"@pkgr/utils@^2.3.1":
version "2.4.2"
resolved "https://registry.yarnpkg.com/@pkgr/utils/-/utils-2.4.2.tgz#9e638bbe9a6a6f165580dc943f138fd3309a2cbc"
Expand Down