Replace grunt with npm scripts (post BS5)#4591
Conversation
demiankatz
left a comment
There was a problem hiding this comment.
Thanks for getting this started, @crhallberg! See below for a couple of comments.
Also, should we go ahead and close #2624 at this point? Looks like most of what's there is obsolete at this stage, though I do notice that you added Typescript type checking. Do we still want to add that? If so, maybe we should put a TODO here to address that as a follow-up PR after we've refactored the existing Grunt functionality.
|
|
||
| // Bootstrap 5 | ||
| await cp('node_modules/bootstrap/scss/.', 'scss/vendor/bootstrap/', { recursive: true }); | ||
| await cp('node_modules/bootstrap/scss/.', 'scss/vendor/bootstrap/scss/', { recursive: true }); |
There was a problem hiding this comment.
Do we really need the double scss in the path?
There was a problem hiding this comment.
Yes, for the new scss compiler which tries to resolve the Bootstrap dependencies in this folder. I can try without again with updated loadPaths. Nope that didn't work.
There was a problem hiding this comment.
If we can't avoid this change, I imagine we'll need to commit the result of moving those files, won't we?
demiankatz
left a comment
There was a problem hiding this comment.
Thanks for the progress, @crhallberg -- see below for a few new thoughts.
|
|
||
| // Bootstrap 5 | ||
| await cp('node_modules/bootstrap/scss/.', 'scss/vendor/bootstrap/', { recursive: true }); | ||
| await cp('node_modules/bootstrap/scss/.', 'scss/vendor/bootstrap/scss/', { recursive: true }); |
There was a problem hiding this comment.
If we can't avoid this change, I imagine we'll need to commit the result of moving those files, won't we?
| "scripts": { | ||
| "build": "npm run build:css", | ||
| "watch": "npm run watch:css", | ||
| "build": "npm-run-all install:scss-dependencies build:scss", |
There was a problem hiding this comment.
If we're not using wildcards, could we just revert to npm run install:scss-dependencies ; npm run build:scss so we can eliminate the npm-run-all2 dependency? If you strongly feel that it's useful, I don't mind having it, but if it's not essential, it's always nice to minimize dependencies.
|
I would like feedback on 00035b1. I think this will allow new themes and mixins to automatically install and update dependencies. For example, #4031 will need to install Font Awesome this way. It does remove the build only option. I might be able to bring it back by checking for devDependencies or adding try/catches. |
demiankatz
left a comment
There was a problem hiding this comment.
@crhallberg, I just did another general review of all the changes, without specifically focusing on 00035b1 -- I'd have to find time to research npm workspaces to fully understand all the implications there. But for now, my review really focuses on the public interface and our current practices; I think some of the changes here could significantly impact those things. Some of those changes might be for the best, but they could also have some fairly broad-reaching implications -- I want to be sure we don't pull the rug out from under anyone.
Maybe a broader question to help get this PR done: what exactly is the overall goal of the work here, and can we constrain the scope? My preference would be to eliminate Grunt with as few changes to behavior as possible, just to move us forward an incremental step without a lot of side effects. We could then follow on from there with more strategic changes, and they might be easier to understand if planned in stages. Maybe it's not possible to do this incrementally, in which case we may have to take the consequences of making several changes at once. But my preference is to always keep things as simple and non-disruptive as possible, when possible.
| console.log("- minifying..."); | ||
|
|
||
| // @link https://github.com/twbs/bootstrap/blob/main/package.json | ||
| // cleancss -O1 --format breakWith=lf --with-rebase --source-map --source-map-inline-sources |
There was a problem hiding this comment.
This comment says --with-rebase but I don't see an equivalent option in the code below. Is that a default, or is something out of sync?
| console.log("- compiling SCSS to CSS..."); | ||
|
|
||
| // @link https://github.com/twbs/bootstrap/blob/main/package.json | ||
| // sass --style expanded --source-map --embed-sources --no-error-css scss/:dist/css/ |
There was a problem hiding this comment.
This comment also seems a little bit out of sync with the code below. Is it meaningful, or an old reference?
demiankatz
left a comment
There was a problem hiding this comment.
Thanks for the progress here, @crhallberg. Before I do another review, do you mind browsing through my previous comments and resolving the items that have been addressed? It looks to me like there are still some outstanding ones that need addressing (e.g. regarding outdated/out-of-sync comments in build-css.js). It would be good to clear up as much as possible of past reviews before I invest time in writing a new one, just to be sure I don't repeat myself. There also seem to be some minor eslint style issues that can be easily addressed and will hopefully reduce noise in the files tab once fixed.
|
@crhallberg, I've gone ahead and resolved merge conflicts here, though most of my outstanding review comments are still relevant; I think there's still quite a bit of work needed here. We should discuss today whether it's realistic to aim for 11.1, or if we should resign ourselves to 12.0. |
|
The build is currently broken because something is trying to call |
demiankatz
left a comment
There was a problem hiding this comment.
Thanks, @crhallberg, this is looking a lot cleaner now... see below for a comment about further simplification/separation, though.
I've also taken care of resolving conflicts introduced by merging your language check tool. I think I incorporated workspace functionality correctly, but please double-check my work.
I've also cleaned up a few eslint indentation warnings to reduce noise in the PR.
Unfortunately, the CSS compilation isn't actually working for me. I'm getting this:
bootstrap5
- compiling SCSS to CSS...
sass.Exception [Error]: Can't find stylesheet to import.
╷
14 │ @import "vendor/bootstrap/scss/functions";
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
╵
themes/bootstrap5/scss/bootstrap.scss 14:9 @import
themes/bootstrap5/scss/compiled.scss 1:9 root stylesheet
at Object.wrapException (/usr/local/vufind/node_modules/sass/sass.dart.js:2166:43)
at _EvaluateVisitor1._evaluate0$_loadStylesheet$4$baseUrl$forImport (/usr/local/vufind/node_modules/sass/sass.dart.js:94280:19)
at _EvaluateVisitor1._evaluate0$_loadStylesheet$3$forImport (/usr/local/vufind/node_modules/sass/sass.dart.js:94309:19)
at _EvaluateVisitor__visitDynamicImport_closure1.call$0 (/usr/local/vufind/node_modules/sass/sass.dart.js:96589:17)
at _EvaluateVisitor1._evaluate0$_withStackFrame$1$3 (/usr/local/vufind/node_modules/sass/sass.dart.js:95729:25)
at _EvaluateVisitor1._evaluate0$_withStackFrame$3 (/usr/local/vufind/node_modules/sass/sass.dart.js:95735:19)
at _EvaluateVisitor1._evaluate0$_visitDynamicImport$1 (/usr/local/vufind/node_modules/sass/sass.dart.js:94227:19)
at _EvaluateVisitor1.visitImportRule$1 (/usr/local/vufind/node_modules/sass/sass.dart.js:94201:17)
at ImportRule0.accept$1$1 (/usr/local/vufind/node_modules/sass/sass.dart.js:100089:22)
at ImportRule0.accept$1 (/usr/local/vufind/node_modules/sass/sass.dart.js:100092:19)
Is it working for you?
| # Vim temporary files | ||
| .*.sw[po] | ||
|
|
||
| # local config |
There was a problem hiding this comment.
Might make sense to move this reorganization of .gitignore to a separate PR, and just focus on removing the obsolete lines in this one. I think it's useful, but it obscures what is actually changing here. I also think some of the lines currently under the "QA files" comment really belong elsewhere -- but I don't want to distract from the work at hand sorting all that out here. :-)
|
I've also resolved some comment threads for issues that have been addressed. However, there are still a couple of outstanding questions about comments in build-css.js (from my September review) that I believe still need attention. |
This reverts commit 077f5ea.
Target Node v20 (older LTS).
From #2624