diff --git a/WORKSPACE b/WORKSPACE index baef7e2f1de5..f8400a4aeee1 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -283,7 +283,7 @@ rules_browsers_setup_2() git_repository( name = "rules_sass", - commit = "a32f75ce6fa0c5370bd3f29a5306478c681ad124", + commit = "3cd198e291caf21ba8f7105d53963dd3df62ef6d", remote = "https://github.com/devversion/rules_sass.git", ) diff --git a/package.json b/package.json index ef5bb250e5b9..61f6f196d699 100644 --- a/package.json +++ b/package.json @@ -86,7 +86,6 @@ "@bazel/buildifier": "6.1.2", "@bazel/ibazel": "^0.25.0", "@bazel/runfiles": "5.8.1", - "@bazel/worker": "^5.8.1", "@firebase/app-types": "^0.7.0", "@material/material-color-utilities": "^0.3.0", "@octokit/rest": "18.3.5", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 726c2123ae40..b98c6189bf9c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -169,9 +169,6 @@ importers: '@bazel/runfiles': specifier: 5.8.1 version: 5.8.1 - '@bazel/worker': - specifier: ^5.8.1 - version: 5.8.1 '@firebase/app-types': specifier: ^0.7.0 version: 0.7.0 @@ -1579,9 +1576,6 @@ packages: '@bazel/runfiles@5.8.1': resolution: {integrity: sha512-NDdfpdQ6rZlylgv++iMn5FkObC/QlBQvipinGLSOguTYpRywmieOyJ29XHvUilspwTFSILWpoE9CqMGkHXug1g==} - '@bazel/worker@5.8.1': - resolution: {integrity: sha512-GMyZSNW3F34f9GjbJqvs1aHyed5BNrNeiDzNJhC1fIizo/UeBM21oBBONIYLBDoBtq936U85VyPZ76JaP/83hw==} - '@colors/colors@1.5.0': resolution: {integrity: sha512-ooWCrlZP11i8GImSjTHYHLkvFDP48nS4+204nGb1RiX/WXYHmJA2III9/e2DWVabCESdW7hBAEzHRqUn9OUVvQ==} engines: {node: '>=0.1.90'} @@ -5461,9 +5455,6 @@ packages: deprecated: Package is no longer maintained hasBin: true - google-protobuf@3.21.4: - resolution: {integrity: sha512-MnG7N936zcKTco4Jd2PX2U96Kf9PxygAPKBug+74LHzmHXmceN16MmRcdgZv+DGef/S9YvQAfRsNCn4cjf9yyQ==} - gopd@1.2.0: resolution: {integrity: sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==} engines: {node: '>= 0.4'} @@ -10713,10 +10704,6 @@ snapshots: '@bazel/runfiles@5.8.1': {} - '@bazel/worker@5.8.1': - dependencies: - google-protobuf: 3.21.4 - '@colors/colors@1.5.0': {} '@colors/colors@1.6.0': {} @@ -15223,8 +15210,6 @@ snapshots: dependencies: node-forge: 1.3.1 - google-protobuf@3.21.4: {} - gopd@1.2.0: {} got@9.6.0: diff --git a/tools/sass/BUILD.bazel b/tools/sass/BUILD.bazel index ea60997d9905..b1da3e20bf0f 100644 --- a/tools/sass/BUILD.bazel +++ b/tools/sass/BUILD.bazel @@ -1,4 +1,3 @@ -load("@aspect_rules_js//js:defs.bzl", "js_binary") load("//tools:defaults2.bzl", "ts_project") package(default_visibility = ["//visibility:public"]) @@ -6,26 +5,11 @@ package(default_visibility = ["//visibility:public"]) ts_project( name = "sass_lib", srcs = [ - "compiler-main.ts", "local-sass-importer.ts", ], tsconfig = "//tools:tsconfig", deps = [ - "//:node_modules/@bazel/worker", "//:node_modules/@types/node", - "//:node_modules/@types/yargs", "//:node_modules/sass", - "//:node_modules/yargs", ], ) - -js_binary( - name = "compiler", - data = [":sass_lib"], - entry_point = "compiler-main.js", - env = { - # TODO(devversion): Replace `rules_sass` with modernized standalone ruleset. - # e.g. https://github.com/devversion/rules_sass. - "BAZEL_BINDIR": ".", - }, -) diff --git a/tools/sass/compiler-main.ts b/tools/sass/compiler-main.ts deleted file mode 100644 index 85fe89753351..000000000000 --- a/tools/sass/compiler-main.ts +++ /dev/null @@ -1,72 +0,0 @@ -import * as worker from '@bazel/worker'; -import * as fs from 'fs'; -import * as path from 'path'; -import yargs from 'yargs'; -import {OutputStyle, compile} from 'sass'; - -import {createLocalAngularPackageImporter} from './local-sass-importer'; - -const workerArgs = process.argv.slice(2); - -// Note: This path is relative to the current working directory as build actions -// are always spawned in the execroot (which is exactly what we want). -const execrootProjectDir = path.resolve('./src/'); -const localPackageSassImporter = createLocalAngularPackageImporter(execrootProjectDir); - -if (require.main === module) { - main().catch(e => { - console.error(e); - process.exitCode = 1; - }); -} - -async function main() { - if (worker.runAsWorker(workerArgs)) { - await worker.runWorkerLoop(args => - processBuildAction(args) - .then(() => true) - .catch(error => { - worker.log(error); - return false; - }), - ); - } else { - // For non-worker mode, we parse the flag/params file ourselves. The Sass rule - // uses a multi-line params file (with `\n` used as separator). - const configFile = workerArgs[0].replace(/^@+/, ''); - const configContent = fs.readFileSync(configFile, 'utf8').trim(); - const args = configContent.split('\n'); - - await processBuildAction(args); - } -} - -/** - * Processes a build action expressed through command line arguments - * as composed by the `sass_binary` rule. - */ -async function processBuildAction(args: string[]) { - const {loadPath, style, sourceMap, embedSources, inputExecpath, outExecpath} = await yargs(args) - .showHelpOnFail(false) - .strict() - .parserConfiguration({'greedy-arrays': false}) - .command('$0 ', 'Compiles a Sass file') - .positional('inputExecpath', {type: 'string', demandOption: true}) - .positional('outExecpath', {type: 'string', demandOption: true}) - .option('embedSources', {type: 'boolean'}) - .option('errorCss', {type: 'boolean'}) - .option('sourceMap', {type: 'boolean'}) - .option('loadPath', {type: 'array', string: true}) - .option('style', {type: 'string'}) - .parseAsync(); - - const result = compile(inputExecpath, { - style: style as OutputStyle, - sourceMap, - sourceMapIncludeSources: embedSources, - loadPaths: loadPath, - importers: [localPackageSassImporter], - }); - - await fs.promises.writeFile(outExecpath, result.css); -}