diff --git a/examples/build-and-serve/duck.config.js b/examples/build-and-serve/duck.config.js index 6ed33caff..a54904571 100644 --- a/examples/build-and-serve/duck.config.js +++ b/examples/build-and-serve/duck.config.js @@ -3,7 +3,7 @@ module.exports = { inputsRoot: "js", depsJs: "build/deps.js", depsJsIgnoreDirs: ["node_modules", "build"], - entryConfigDir: "entry-config/entries" + entryConfigDir: "entry-config/entries", // http2: true, // https: { // keyPath: "./duck-key.pem", diff --git a/examples/build-and-serve/js/chunk1.js b/examples/build-and-serve/js/chunk1.js index 0a86331f9..5f26b1282 100644 --- a/examples/build-and-serve/js/chunk1.js +++ b/examples/build-and-serve/js/chunk1.js @@ -6,7 +6,7 @@ goog.require("goog.ui.Component"); /** * @return {string} */ -app.chunk1.getMessage = function() { +app.chunk1.getMessage = function () { return "from chunk1"; }; diff --git a/examples/build-and-serve/js/chunks.js b/examples/build-and-serve/js/chunks.js index 845100560..797f171cc 100644 --- a/examples/build-and-serve/js/chunks.js +++ b/examples/build-and-serve/js/chunks.js @@ -10,13 +10,13 @@ goog.scope(() => { // moduleLoader.setDebugMode(!!goog.global['PLOVR_MODULE_USE_DEBUG_MODE']); moduleLoader.setDebugMode(true); moduleManager.setLoader(moduleLoader); - moduleManager.setAllModuleInfo(goog.global["PLOVR_MODULE_INFO"]); + moduleManager.setAllModuleInfo(goog.global.PLOVR_MODULE_INFO); const trustedModuleUris = {}; - for (const id in goog.global["PLOVR_MODULE_URIS"]) { + for (const id in goog.global.PLOVR_MODULE_URIS) { trustedModuleUris[id] = [ goog.html.legacyconversions.trustedResourceUrlFromString( - goog.global["PLOVR_MODULE_URIS"][id] - ) + goog.global.PLOVR_MODULE_URIS[id] + ), ]; } moduleManager.setModuleTrustedUris(trustedModuleUris); diff --git a/examples/build-deps/duck.config.js b/examples/build-deps/duck.config.js index c5056e76c..c9b3e3585 100644 --- a/examples/build-deps/duck.config.js +++ b/examples/build-deps/duck.config.js @@ -2,5 +2,5 @@ module.exports = { closureLibraryDir: "node_modules/google-closure-library", inputsRoot: ".", depsJs: "build/duck.deps.js", - depsJsIgnoreDirs: ["node_modules", "build"] + depsJsIgnoreDirs: ["node_modules", "build"], }; diff --git a/examples/build-deps/script1.js b/examples/build-deps/script1.js index e912d0adf..05073e127 100644 --- a/examples/build-deps/script1.js +++ b/examples/build-deps/script1.js @@ -2,7 +2,7 @@ goog.provide("app.script1"); goog.require("app.module1"); -goog.scope(function() { +goog.scope(function () { const module1 = goog.module.get("app.module1"); app.script1 = `from app.script1 ${module1}`; }); diff --git a/package-lock.json b/package-lock.json index 95b6c9eb6..3f79a0f04 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1847,9 +1847,9 @@ } }, "cli-width": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-2.2.0.tgz", - "integrity": "sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk=", + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-2.2.1.tgz", + "integrity": "sha512-GRMWDxpOB6Dgk2E5Uo+3eEBvtOOlimMmpbFiKuLFnQzYDavtLFY3K5ona41jgN/WdRZtG7utuVSVTL4HbZHGkw==", "dev": true }, "cliui": { @@ -3240,22 +3240,22 @@ } }, "eslint": { - "version": "6.8.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-6.8.0.tgz", - "integrity": "sha512-K+Iayyo2LtyYhDSYwz5D5QdWw0hCacNzyq1Y821Xna2xSJj7cijoLLYmLxTQgcgZ9mC61nryMy9S7GRbYpI5Ig==", + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.1.0.tgz", + "integrity": "sha512-DfS3b8iHMK5z/YLSme8K5cge168I8j8o1uiVmFCgnnjxZQbCGyraF8bMl7Ju4yfBmCuxD7shOF7eqGkcuIHfsA==", "dev": true, "requires": { "@babel/code-frame": "^7.0.0", "ajv": "^6.10.0", - "chalk": "^2.1.0", - "cross-spawn": "^6.0.5", + "chalk": "^4.0.0", + "cross-spawn": "^7.0.2", "debug": "^4.0.1", "doctrine": "^3.0.0", "eslint-scope": "^5.0.0", - "eslint-utils": "^1.4.3", + "eslint-utils": "^2.0.0", "eslint-visitor-keys": "^1.1.0", - "espree": "^6.1.2", - "esquery": "^1.0.1", + "espree": "^7.0.0", + "esquery": "^1.2.0", "esutils": "^2.0.2", "file-entry-cache": "^5.0.1", "functional-red-black-tree": "^1.0.1", @@ -3268,67 +3268,71 @@ "is-glob": "^4.0.0", "js-yaml": "^3.13.1", "json-stable-stringify-without-jsonify": "^1.0.1", - "levn": "^0.3.0", + "levn": "^0.4.1", "lodash": "^4.17.14", "minimatch": "^3.0.4", - "mkdirp": "^0.5.1", "natural-compare": "^1.4.0", - "optionator": "^0.8.3", + "optionator": "^0.9.1", "progress": "^2.0.0", - "regexpp": "^2.0.1", - "semver": "^6.1.2", - "strip-ansi": "^5.2.0", - "strip-json-comments": "^3.0.1", + "regexpp": "^3.1.0", + "semver": "^7.2.1", + "strip-ansi": "^6.0.0", + "strip-json-comments": "^3.1.0", "table": "^5.2.3", "text-table": "^0.2.0", "v8-compile-cache": "^2.0.3" }, "dependencies": { "ansi-regex": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", - "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", + "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", "dev": true }, "ansi-styles": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", + "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", "dev": true, "requires": { - "color-convert": "^1.9.0" + "@types/color-name": "^1.1.1", + "color-convert": "^2.0.1" } }, "chalk": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", - "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.0.0.tgz", + "integrity": "sha512-N9oWFcegS0sFr9oh1oz2d7Npos6vNoWW9HvtCg5N1KRFpUhaAhvTv5Y58g880fZaEYSNm3qDz8SU1UrGvp+n7A==", "dev": true, "requires": { - "ansi-styles": "^3.2.1", - "escape-string-regexp": "^1.0.5", - "supports-color": "^5.3.0" + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" } }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, "cross-spawn": { - "version": "6.0.5", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", - "integrity": "sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==", + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", "dev": true, "requires": { - "nice-try": "^1.0.4", - "path-key": "^2.0.1", - "semver": "^5.5.0", - "shebang-command": "^1.2.0", - "which": "^1.2.9" - }, - "dependencies": { - "semver": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", - "dev": true - } + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" } }, "doctrine": { @@ -3350,15 +3354,6 @@ "estraverse": "^4.1.1" } }, - "eslint-utils": { - "version": "1.4.3", - "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-1.4.3.tgz", - "integrity": "sha512-fbBN5W2xdY45KulGXmLHZ3c3FHfVYmKg0IrAKGOkT/464PQsx2UeIzfz1RmEci+KLm1bBaAzZAh8+/E+XAeZ8Q==", - "dev": true, - "requires": { - "eslint-visitor-keys": "^1.1.0" - } - }, "globals": { "version": "12.4.0", "resolved": "https://registry.npmjs.org/globals/-/globals-12.4.0.tgz", @@ -3368,61 +3363,73 @@ "type-fest": "^0.8.1" } }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, "ignore": { "version": "4.0.6", "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==", "dev": true }, - "path-key": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", - "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=", - "dev": true - }, - "regexpp": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-2.0.1.tgz", - "integrity": "sha512-lv0M6+TkDVniA3aD1Eg0DVpfU/booSu7Eev3TDO/mZKHBfVjgCGTV4t4buppESEYDtkArYFOxTJWv6S5C+iaNw==", - "dev": true - }, - "semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", - "dev": true + "levn": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", + "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", + "dev": true, + "requires": { + "prelude-ls": "^1.2.1", + "type-check": "~0.4.0" + } }, - "shebang-command": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", - "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", + "optionator": { + "version": "0.9.1", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.1.tgz", + "integrity": "sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw==", "dev": true, "requires": { - "shebang-regex": "^1.0.0" + "deep-is": "^0.1.3", + "fast-levenshtein": "^2.0.6", + "levn": "^0.4.1", + "prelude-ls": "^1.2.1", + "type-check": "^0.4.0", + "word-wrap": "^1.2.3" } }, - "shebang-regex": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", - "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", + "prelude-ls": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", + "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", "dev": true }, "strip-ansi": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", - "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", + "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", "dev": true, "requires": { - "ansi-regex": "^4.1.0" + "ansi-regex": "^5.0.0" } }, "supports-color": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz", + "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==", "dev": true, "requires": { - "has-flag": "^3.0.0" + "has-flag": "^4.0.0" + } + }, + "type-check": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", + "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", + "dev": true, + "requires": { + "prelude-ls": "^1.2.1" } }, "type-fest": { @@ -3430,15 +3437,6 @@ "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz", "integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==", "dev": true - }, - "which": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", - "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", - "dev": true, - "requires": { - "isexe": "^2.0.0" - } } } }, @@ -3821,9 +3819,9 @@ } }, "espree": { - "version": "6.2.1", - "resolved": "https://registry.npmjs.org/espree/-/espree-6.2.1.tgz", - "integrity": "sha512-ysCxRQY3WaXJz9tdbWOwuWr5Y/XrPTGX9Kiz3yoUXwW0VZ4w30HTkQLaGx/+ttFjF8i+ACbArnB4ce68a9m5hw==", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-7.0.0.tgz", + "integrity": "sha512-/r2XEx5Mw4pgKdyb7GNLQNsu++asx/dltf/CI8RFi9oGHxmQFgvLbc5Op4U6i8Oaj+kdslhJtVlEZeAqH5qOTw==", "dev": true, "requires": { "acorn": "^7.1.1", @@ -3832,9 +3830,9 @@ }, "dependencies": { "acorn": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.1.1.tgz", - "integrity": "sha512-add7dgA5ppRPxCFJoAGfMDi7PIBXq1RtGo7BhbLaxwrXPOmw8gq48Y9ozT01hUKy9byMjlR20EJhu5zlkErEkg==", + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.2.0.tgz", + "integrity": "sha512-apwXVmYVpQ34m/i71vrApRrRKCWQnZZF1+npOD0WV5xZFfwWOmKGQ2RWlfdy9vWITsenisM8M0Qeq8agcFHNiQ==", "dev": true } } @@ -3855,18 +3853,18 @@ } }, "esquery": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.2.0.tgz", - "integrity": "sha512-weltsSqdeWIX9G2qQZz7KlTRJdkkOCTPgLYJUz1Hacf48R4YOwGPHO3+ORfWedqJKbq5WQmsgK90n+pFLIKt/Q==", + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.3.1.tgz", + "integrity": "sha512-olpvt9QG0vniUBZspVRN6lwB7hOZoTRtT+jzR+tS4ffYx2mzbw+z0XCOk44aaLYKApNX5nMm+E+P6o25ip/DHQ==", "dev": true, "requires": { - "estraverse": "^5.0.0" + "estraverse": "^5.1.0" }, "dependencies": { "estraverse": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.0.0.tgz", - "integrity": "sha512-j3acdrMzqrxmJTNj5dbr1YbjacrYgAxVMeF0gK16E3j494mOe7xygM/ZLIguEQ0ETwAg2hlJCtHRGav+y0Ny5A==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.1.0.tgz", + "integrity": "sha512-FyohXK+R0vE+y1nHLoBM7ZTyqRpqAlhdZHCWIWEviFLiGB8b04H6bQs8G+XTthacvT8VuwvteiP7RJSxMs8UEw==", "dev": true } } @@ -8587,9 +8585,9 @@ "dev": true }, "prettier": { - "version": "1.19.1", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.19.1.tgz", - "integrity": "sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==", + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.0.5.tgz", + "integrity": "sha512-7PtVymN48hGcO4fGjybyBSIWDsLU4H4XlvOHfq91pz9kkGlonzwTfYkaIEwiRg/dAJF9YlbsduBAgtYLi+8cFg==", "dev": true }, "prettier-linter-helpers": { @@ -9031,13 +9029,10 @@ } }, "run-async": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.4.0.tgz", - "integrity": "sha512-xJTbh/d7Lm7SBhc1tNvTpeCHaEzoyxPrqNlvSdMfBTYwaY++UJFyXUOxAtsRUXjlqOfj8luNaR9vjCh4KeV+pg==", - "dev": true, - "requires": { - "is-promise": "^2.1.0" - } + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.4.1.tgz", + "integrity": "sha512-tvVnVv01b8c1RrA6Ep7JkStj85Guv/YrMcwqYQnwjsAS2cTmmPGBBjAjpCW7RrSodNSoE2/qg9O4bceNvUuDgQ==", + "dev": true }, "run-queue": { "version": "1.0.3", diff --git a/package.json b/package.json index e136b9d13..adf1cb1ea 100644 --- a/package.json +++ b/package.json @@ -77,14 +77,14 @@ "@types/workerpool": "^5.0.1", "@types/yargs": "^15.0.5", "codecov": "^3.6.5", - "eslint": "^6.8.0", + "eslint": "^7.1.0", "espower-typescript": "^9.0.2", "google-closure-compiler": "^20200315.0.0", "mocha": "^7.1.2", "npm-run-all": "^4.1.5", "nyc": "^15.0.1", "power-assert": "^1.6.1", - "prettier": "^1.19.1", + "prettier": "^2.0.5", "rimraf": "^3.0.2", "standard-version": "^7.1.0", "typescript": "^3.8.3" diff --git a/src/batch.ts b/src/batch.ts index 1c995a18a..694ed224c 100644 --- a/src/batch.ts +++ b/src/batch.ts @@ -5,7 +5,7 @@ import { faastLocal, FaastModuleProxy, LocalOptions, - log + log, } from "faastjs"; import mergeOptions from "merge-options"; import semver from "semver"; @@ -57,8 +57,8 @@ function defaultBatchOptions(config: DuckConfig): AwsOptions { dependencies: { [`google-closure-compiler-${getOsForNativeImage( config - )}`]: `^${major}.0.0` - } + )}`]: `^${major}.0.0`, + }, }, webpackOptions: { externals: [ @@ -70,9 +70,9 @@ function defaultBatchOptions(config: DuckConfig): AwsOptions { "chalk", // used in google-closure-compiler/lib/gulp /^gulp($|-)/, - /^vinyl($|-)/ - ] - } + /^vinyl($|-)/, + ], + }, }; } diff --git a/src/cli.ts b/src/cli.ts index 386cb4b74..ed324a69d 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -10,7 +10,7 @@ import yargs from "yargs"; import { assertNodeVersionGte, assertNonNullable, - assertString + assertString, } from "./assert"; import { buildDeps } from "./commands/buildDeps"; import { buildJs, BuildJsCompilationError } from "./commands/buildJs"; @@ -41,7 +41,7 @@ function wrap(task: () => Promise): () => Observable { // Run the task in the next tick to register the observable to listr before the first logging. const await = Promise.resolve().then(task); return streamToObservable(logStream, { await, endEvent: false }).pipe( - map(obj => { + map((obj) => { if (obj.msg) { return String(obj.msg); } @@ -58,7 +58,7 @@ logStream.on("data", (data: any) => { resultInfos.push({ title: assertString(data.title), bodyString: data.bodyString, - bodyObject: data.bodyObject + bodyObject: data.bodyObject, }); } }); @@ -73,46 +73,46 @@ const nonTTY = { desc: "Output in nonTTY mode", type: "boolean", alias: ["noTTY", "n"], - default: false + default: false, } as const; const closureLibraryDir = { desc: "A root directory of Closure Library", type: "string", - coerce: path.resolve + coerce: path.resolve, } as const; const config = { desc: "A path to duck.config.js, the extension can be ommited", type: "string", - coerce: path.resolve + coerce: path.resolve, } as const; const entryConfigDir = { type: "string", // only for typing, the value is loaded from args hidden: true, - coerce: path.resolve + coerce: path.resolve, } as const; const printConfig = { desc: "Print effective configs for compilers", alias: "p", type: "boolean", - default: false + default: false, } as const; const depsJs = { desc: "A path to deps.js to save and load", type: "string", - coerce: path.resolve + coerce: path.resolve, } as const; const skipInitialBuild = { desc: "Skip initial building of Soy and deps.js", alias: "s", type: "boolean", - default: false + default: false, } as const; const buildJsOptions = { @@ -121,52 +121,52 @@ const buildJsOptions = { desc: "Entry config files (this option ignores entryConfigDir)", alias: "e", type: "array", - coerce: (arr: any[]) => arr.map(item => path.resolve(String(item))) + coerce: (arr: any[]) => arr.map((item) => path.resolve(String(item))), }, closureLibraryDir, config, concurrency: { desc: "Concurrency limit of Closure Compiler", alias: "c", - type: "number" + type: "number", }, batch: { desc: "Build in batch mode (on AWS or local for debug)", - choices: ["aws", "local"] + choices: ["aws", "local"], }, reporters: { desc: 'Test reporters ("text", "xunit" or "json")', type: "array", - default: ["text"] + default: ["text"], }, reporterOptions: { - desc: "Test reporter options" + desc: "Test reporter options", }, printConfig, depsJs, - nonTTY + nonTTY, } as const; const buildSoyOptions = { soyJarPath: { desc: "A path to Soy.jar", type: "string", - coerce: path.resolve + coerce: path.resolve, }, soyFileRoots: { desc: "Root directories of soy files", type: "array", - coerce: path.resolve + coerce: path.resolve, }, config, watch: { desc: "Re-compile incrementally when files change", alias: "w", type: "boolean", - default: false + default: false, }, printConfig, - nonTTY + nonTTY, } as const; const buildDepsOptions = { @@ -174,10 +174,10 @@ const buildDepsOptions = { depsWorkers: { desc: "The number of workers to analyze deps", type: "number", - default: Math.min(4, Math.max(os.cpus().length, 1)) + default: Math.min(4, Math.max(os.cpus().length, 1)), }, config, - nonTTY + nonTTY, } as const; export function run(processArgv: readonly string[]): void { @@ -190,7 +190,7 @@ export function run(processArgv: readonly string[]): void { inputsRoot: { desc: "A root directory to serve", type: "string", - coerce: path.resolve + coerce: path.resolve, }, closureLibraryDir, depsJs, @@ -199,17 +199,17 @@ export function run(processArgv: readonly string[]): void { port: { desc: "A port number to listen", type: "number", - default: 9810 + default: 9810, }, host: { desc: "A host to listen", type: "string", - default: "0.0.0.0" + default: "0.0.0.0", }, config, - nonTTY + nonTTY, }, - async argv => { + async (argv) => { const config = loadConfig(argv); const hasSoyConfig: boolean = Boolean( config.soyJarPath && config.soyFileRoots && config.soyOptions @@ -219,13 +219,13 @@ export function run(processArgv: readonly string[]): void { { title: `Compile Soy templates`, skip: () => !hasSoyConfig || argv.skipInitialBuild, - task: wrap(() => buildSoy(config as BuildSoyConfig)) + task: wrap(() => buildSoy(config as BuildSoyConfig)), }, { title: `Generate deps.js`, skip: () => !config.depsJs || argv.skipInitialBuild, - task: wrap(() => buildDeps(config)) - } + task: wrap(() => buildDeps(config)), + }, ], argv ); @@ -242,9 +242,9 @@ export function run(processArgv: readonly string[]): void { ...buildDepsOptions, skipInitialBuild, ...buildSoyOptions, - nonTTY + nonTTY, }, - async argv => { + async (argv) => { const config = loadConfig(argv); let warnings: ErrorReason[] = []; const tasks = listr( @@ -260,12 +260,12 @@ export function run(processArgv: readonly string[]): void { ), task: wrap(() => buildSoy(config as BuildSoyConfig, argv.printConfig) - ) + ), }, { title: `Generate deps.js`, skip: () => !config.depsJs || argv.skipInitialBuild, - task: wrap(() => buildDeps(config)) + task: wrap(() => buildDeps(config)), }, { title: `Compile JS files`, @@ -275,8 +275,8 @@ export function run(processArgv: readonly string[]): void { argv.entryConfigs as string[], argv.printConfig ); - }) - } + }), + }, ], argv ); @@ -291,7 +291,7 @@ export function run(processArgv: readonly string[]): void { "build:js [entryConfigDir]", "Compile JS files", buildJsOptions, - async argv => { + async (argv) => { const config = loadConfig(argv); let warnings: ErrorReason[] = []; const tasks = listr( @@ -304,8 +304,8 @@ export function run(processArgv: readonly string[]): void { argv.entryConfigs as string[], argv.printConfig ); - }) - } + }), + }, ], argv ); @@ -320,7 +320,7 @@ export function run(processArgv: readonly string[]): void { "build:soy", "Compile Soy templates", buildSoyOptions, - async argv => { + async (argv) => { const config = loadConfig(argv); assertString(config.soyJarPath); assertNonNullable(config.soyFileRoots); @@ -331,8 +331,27 @@ export function run(processArgv: readonly string[]): void { title: `Compile Soy templates`, task: wrap(() => buildSoy(config as BuildSoyConfig, argv.printConfig) - ) - } + ), + }, + ], + argv + ); + await tasks.run(); + printResultInfo(); + } + ) + .command( + "build:deps", + "Generate deps.js", + buildDepsOptions, + async (argv) => { + const config = loadConfig(argv); + const tasks = listr( + [ + { + title: `Generate deps.js`, + task: wrap(() => buildDeps(config)), + }, ], argv ); @@ -340,33 +359,19 @@ export function run(processArgv: readonly string[]): void { printResultInfo(); } ) - .command("build:deps", "Generate deps.js", buildDepsOptions, async argv => { - const config = loadConfig(argv); - const tasks = listr( - [ - { - title: `Generate deps.js`, - task: wrap(() => buildDeps(config)) - } - ], - argv - ); - await tasks.run(); - printResultInfo(); - }) .command( "clean:soy", "Remove all compiled .soy.js", buildSoyOptions, - async argv => { + async (argv) => { const config = loadConfig(argv); assertNonNullable(config.soyOptions); const tasks = listr( [ { title: `Clean up soy.js`, - task: wrap(() => cleanSoy(config as CleanSoyConfig)) - } + task: wrap(() => cleanSoy(config as CleanSoyConfig)), + }, ], argv ); @@ -377,14 +382,14 @@ export function run(processArgv: readonly string[]): void { "clean:deps", "Remove generated deps.js", buildDepsOptions, - async argv => { + async (argv) => { const config = loadConfig(argv); const tasks = listr( [ { title: `Clean up deps.js: ${config.depsJs}`, - task: wrap(() => cleanDeps(assertString(config.depsJs))) - } + task: wrap(() => cleanDeps(assertString(config.depsJs))), + }, ], argv ); @@ -413,7 +418,7 @@ function listr( ): Listr { return new Listr(tasks, { ...options, - renderer: argv.nonTTY ? "verbose" : "default" + renderer: argv.nonTTY ? "verbose" : "default", }); } @@ -430,7 +435,7 @@ function printOnlyCompilationError(config: DuckConfig) { function printResultInfo() { if (resultInfos.length > 0) { - resultInfos.forEach(info => { + resultInfos.forEach((info) => { console.log(`\n${info.title}:`); if (info.bodyString) { console.log(info.bodyString); diff --git a/src/commands/buildDeps.ts b/src/commands/buildDeps.ts index a88c7f08a..5e4539c9f 100644 --- a/src/commands/buildDeps.ts +++ b/src/commands/buildDeps.ts @@ -24,7 +24,7 @@ export async function buildDeps(config: DuckConfig): Promise { msg: "Generated to stdout", type: resultInfoLogType, title: "Generated deps.js", - bodyString: fileText + bodyString: fileText, }); } } diff --git a/src/commands/buildJs.ts b/src/commands/buildJs.ts index 2e59ec6d0..073acf025 100644 --- a/src/commands/buildJs.ts +++ b/src/commands/buildJs.ts @@ -9,7 +9,7 @@ import { CompilerError, compileToJson, createCompilerOptionsForChunks, - createCompilerOptionsForPage + createCompilerOptionsForPage, } from "../compiler"; import * as compilerCoreFunctions from "../compiler-core"; import { DuckConfig } from "../duckconfig"; @@ -42,7 +42,7 @@ export async function buildJs( const limit = pLimit(config.concurrency || 1); let runningJobCount = 1; let completedJobCount = 1; - const promises = entryConfigPaths.map(entryConfigPath => + const promises = entryConfigPaths.map((entryConfigPath) => limit(async () => { try { const entryConfig = await loadEntryConfig(entryConfigPath); @@ -67,14 +67,14 @@ export async function buildJs( msg: "Print config only", type: resultInfoLogType, title: "Compiler config", - bodyObject: options + bodyObject: options, }); return; } logWithCount(entryConfigPath, runningJobCount++, "Compiling"); const [outputs, warnings] = await compileFn(options); - const promises = outputs.map(async output => { + const promises = outputs.map(async (output) => { await fs.mkdir(path.dirname(output.path), { recursive: true }); return fs.writeFile(output.path, output.src); }); @@ -128,15 +128,15 @@ async function waitAllAndThrowIfAnyCompilationsFailed( const reasons: ErrorReason[] = results .map((result, idx) => ({ ...result, - entryConfigPath: entryConfigPaths[idx] + entryConfigPath: entryConfigPaths[idx], })) - .map(result => { + .map((result) => { if (result.isFulfilled) { // no errors, but it may contain warnings return { entryConfigPath: result.entryConfigPath, command: null, - items: result.value || [] + items: result.value || [], }; } // has some errors @@ -146,15 +146,15 @@ async function waitAllAndThrowIfAnyCompilationsFailed( return { entryConfigPath: result.entryConfigPath, command, - items + items, }; } catch { // for invalid compiler options errors throw new Error(`Unexpected non-JSON error: ${reason.message}`); } }) - .filter(result => result.items.length > 0); - if (results.filter(result => result.isRejected).length > 0) { + .filter((result) => result.items.length > 0); + if (results.filter((result) => result.isRejected).length > 0) { throw new BuildJsCompilationError(reasons, results.length); } return reasons; @@ -180,7 +180,7 @@ export class BuildJsCompilationError extends Error { async function findEntryConfigs(entryConfigDir: string): Promise { const files = await recursive(entryConfigDir); - return files.filter(file => /\.json$/.test(file)); + return files.filter((file) => /\.json$/.test(file)); } async function createCompilerOptionsForChunks_( diff --git a/src/commands/buildSoy.ts b/src/commands/buildSoy.ts index 73f4d5d17..7766bb6b0 100644 --- a/src/commands/buildSoy.ts +++ b/src/commands/buildSoy.ts @@ -24,9 +24,9 @@ export async function buildSoy( } async function findSoyFiles(config: BuildSoyConfig): Promise { - const soyFilePromises = config.soyFileRoots.map(async p => { + const soyFilePromises = config.soyFileRoots.map(async (p) => { const files = await recursive(p); - return files.filter(file => /\.soy$/.test(file)); + return files.filter((file) => /\.soy$/.test(file)); }); const soyFiles = flat(await Promise.all(soyFilePromises)); return soyFiles; diff --git a/src/commands/serve.ts b/src/commands/serve.ts index 05a5bd1ef..bad581cb6 100644 --- a/src/commands/serve.ts +++ b/src/commands/serve.ts @@ -13,19 +13,19 @@ import { compileToJson, convertModuleInfos, createCompilerOptionsForChunks, - createCompilerOptionsForPage + createCompilerOptionsForPage, } from "../compiler"; import { DuckConfig } from "../duckconfig"; import { createDag, EntryConfig, loadEntryConfigById, - PlovrMode + PlovrMode, } from "../entryconfig"; import { generateDepFileText, restoreDepsJs, - writeCachedDepsOnDisk + writeCachedDepsOnDisk, } from "../gendeps"; import { logger, setGlobalLogger } from "../logger"; import { @@ -33,7 +33,7 @@ import { compileUrlPath, depsUrlPath, googBaseUrlPath, - inputsUrlPath + inputsUrlPath, } from "../urls"; import { watchJsAndSoy } from "../watch"; @@ -64,7 +64,7 @@ function getDepsUrl(baseUrl: URL, entryConfigId: string): URL { export async function serve(config: DuckConfig, watch = true) { setGlobalLogger( pino({ - prettyPrint: { translateTime: "SYS:HH:MM:ss.l", ignore: "hostname,pid" } + prettyPrint: { translateTime: "SYS:HH:MM:ss.l", ignore: "hostname,pid" }, }) ); @@ -85,7 +85,7 @@ export async function serve(config: DuckConfig, watch = true) { closureLibraryUrlPath, serveStatic(config.closureLibraryDir, { maxAge: "1d", - immutable: true + immutable: true, }) as any ); server.use(inputsUrlPath, serveStatic(config.inputsRoot) as any); @@ -110,14 +110,14 @@ export async function serve(config: DuckConfig, watch = true) { id: { type: "string" }, mode: { type: "string", - enum: ["RAW", "WHITESPACE", "SIMPLE", "ADVANCED"] + enum: ["RAW", "WHITESPACE", "SIMPLE", "ADVANCED"], }, chunk: { type: "string" }, - parentRequest: { type: "string" } + parentRequest: { type: "string" }, }, - required: ["id"] - } - } + required: ["id"], + }, + }, }; server.get(compileUrlPath, opts, async (request, reply) => { @@ -150,8 +150,8 @@ export async function serve(config: DuckConfig, watch = true) { baseUrl: URL ): string[] { return inputs - .map(input => path.relative(config.inputsRoot, input)) - .map(input => new URL(`${inputsUrlPath}/${input}`, baseUrl).toString()); + .map((input) => path.relative(config.inputsRoot, input)) + .map((input) => new URL(`${inputsUrlPath}/${input}`, baseUrl).toString()); } function replyChunksRaw( @@ -160,13 +160,13 @@ export async function serve(config: DuckConfig, watch = true) { ) { const baseUrl = getScriptBaseUrl(reply, !!config.https); const modules = assertNonNullable(entryConfig.modules); - const { moduleInfo, moduleUris } = convertModuleInfos(entryConfig, id => { + const { moduleInfo, moduleUris } = convertModuleInfos(entryConfig, (id) => { return inputsToUrisForRaw(modules[id].inputs, baseUrl); }); // The root chunk loads all chunks in RAW mode const sortedChunkIds = createDag(entryConfig).getSortedIds(); const rootId = sortedChunkIds[0]; - moduleUris[rootId] = flat(sortedChunkIds.map(id => moduleUris[id])); + moduleUris[rootId] = flat(sortedChunkIds.map((id) => moduleUris[id])); for (const id in moduleUris) { if (id !== rootId) { moduleUris[id] = []; @@ -187,7 +187,9 @@ export async function serve(config: DuckConfig, watch = true) { )};'); document.write(''); ${rootModuleUris - .map(uri => `document.write('');`) + .map( + (uri) => `document.write('');` + ) .join("\n")} `); } @@ -224,7 +226,7 @@ export async function serve(config: DuckConfig, watch = true) { const { options, sortedChunkIds, - rootChunkId + rootChunkId, } = await createCompilerOptionsForChunks( entryConfig, config, @@ -259,7 +261,9 @@ export async function serve(config: DuckConfig, watch = true) { entryConfig.id )}">'); ${uris - .map(uri => `document.write('');`) + .map( + (uri) => `document.write('');` + ) .join("\n")} `); } @@ -280,10 +284,7 @@ export async function serve(config: DuckConfig, watch = true) { `Unexpectedly chunkOutputs.length must be 1, but actual ${compileOutputs.length}` ); } - reply - .code(200) - .type("application/javascript") - .send(compileOutputs[0].src); + reply.code(200).type("application/javascript").send(compileOutputs[0].src); } server.get(depsUrlPath, opts, async (request, reply) => { @@ -298,10 +299,7 @@ export async function serve(config: DuckConfig, watch = true) { config.depsJsIgnoreDirs.concat(config.closureLibraryDir), config.depsWorkers ); - reply - .code(200) - .type("application/javascript") - .send(depsContent); + reply.code(200).type("application/javascript").send(depsContent); updateDepsJsCache(config); }); @@ -327,7 +325,7 @@ function updateDepsJsCache(config: DuckConfig) { logger.debug( `[DEPSJS_UPDATED]: ${path.relative(process.cwd(), depsJs)}` ), - err => logger.error({ err }, "Fail to write deps.js") + (err) => logger.error({ err }, "Fail to write deps.js") ); } } @@ -337,7 +335,7 @@ async function createServer( ): Promise { const opts: fastify.ServerOptions = { logger, - disableRequestLogging: true + disableRequestLogging: true, }; const { http2, https } = config; // `req.originalUrl` is added by fastify but doesn't exist in the type definition. @@ -352,7 +350,7 @@ async function createServer( if (https) { const httpsOptions = { key: await fs.readFile(https.keyPath, "utf8"), - cert: await fs.readFile(https.certPath, "utf8") + cert: await fs.readFile(https.certPath, "utf8"), }; // Use `any` because the types of http, https and http2 modules in Node.js are not compatible. // But it is not a big deal. @@ -360,7 +358,7 @@ async function createServer( server = fastify({ ...opts, https: httpsOptions, - http2: true + http2: true, }) as fastify.FastifyInstance; } else { server = fastify({ ...opts, https: httpsOptions }) as any; @@ -391,7 +389,7 @@ async function createServer( { request: `${method} ${originalUrl || url || '"N/A"'}`, statusCode: reply.res.statusCode, - responseTime: `${Math.round(reply.getResponseTime())}ms` + responseTime: `${Math.round(reply.getResponseTime())}ms`, }, "request completed" ); diff --git a/src/compiler-core.ts b/src/compiler-core.ts index 6fdf8093a..3a37db211 100644 --- a/src/compiler-core.ts +++ b/src/compiler-core.ts @@ -75,7 +75,7 @@ export async function compileToJson( extendedOpts.compilerOptions = { ...extendedOpts.compilerOptions, json_streams: "OUT", - error_format: "JSON" + error_format: "JSON", }; const { stdout, stderr } = await compile(extendedOpts); const outputs: CompilerOutput[] = JSON.parse(stdout); @@ -147,7 +147,7 @@ function rewriteNodePathForAwsLambda(options: CompilerOptions): void { // eslint-disable-next-line no-eval eval("require.resolve")("google-closure-library/package.json") ); - options.js = options.js.map(js => + options.js = options.js.map((js) => js.replace(/^node_modules\/google-closure-library/, closureLibraryDir) ); } @@ -168,12 +168,12 @@ export class CompilerError extends Error { */ export function convertToFlagfile(opts: CompilerOptions): { flagfile: string } { const flagfile = tempy.file({ - name: `${new Date().toISOString().replace(/[^\w]/g, "")}.closure.conf` + name: `${new Date().toISOString().replace(/[^\w]/g, "")}.closure.conf`, }); const lines: string[] = []; Object.entries(opts).forEach(([key, value]) => { if (Array.isArray(value)) { - lines.push(...value.map(v => createKeyValue(key, v))); + lines.push(...value.map((v) => createKeyValue(key, v))); } else { lines.push(createKeyValue(key, value)); } diff --git a/src/compiler.ts b/src/compiler.ts index b658a04a1..81d3c8e9d 100644 --- a/src/compiler.ts +++ b/src/compiler.ts @@ -9,7 +9,7 @@ import { CompilationLevel, CompilerOptions, CompilerOptionsFormattingType, - ExtendedCompilerOptions + ExtendedCompilerOptions, } from "./compiler-core"; import { Dag } from "./dag"; import { DuckConfig } from "./duckconfig"; @@ -17,7 +17,7 @@ import { createDag, EntryConfig, PlovrMode, - WarningsWhitelistItem + WarningsWhitelistItem, } from "./entryconfig"; import { getClosureLibraryDependencies, getDependencies } from "./gendeps"; @@ -26,7 +26,7 @@ export { CompilerOptions, CompilerOutput, compileToJson, - convertToFlagfile + convertToFlagfile, } from "./compiler-core"; /** @@ -36,7 +36,7 @@ export { const GLOBAL_NAMESPACE = "z"; function snakeCase(key: string): string { - return key.replace(/[A-Z]/g, match => `_${match.toLowerCase()}`); + return key.replace(/[A-Z]/g, (match) => `_${match.toLowerCase()}`); } function createBaseOptions( @@ -105,7 +105,7 @@ function createBaseOptions( : "PRUNE"; const js = entryConfig.paths.slice(); if (entryConfig.externs) { - js.push(...entryConfig.externs.map(extern => `!${extern}`)); + js.push(...entryConfig.externs.map((extern) => `!${extern}`)); } opts.js = js; opts.entry_point = assertNonNullable(entryConfig.inputs).slice(); @@ -231,7 +231,7 @@ export async function createCompilerOptionsForChunks( const dependencies = flat( await Promise.all([ getDependencies(entryConfig, ignoreDirs, duckConfig.depsWorkers), - getClosureLibraryDependencies(duckConfig.closureLibraryDir) + getClosureLibraryDependencies(duckConfig.closureLibraryDir), ]) ); const dag = createDag(entryConfig); @@ -252,9 +252,9 @@ export async function createCompilerOptionsForChunks( outputToFile ); compilerOptions.js = flat( - [...chunkToInputPathSet.values()].map(inputs => [...inputs]) + [...chunkToInputPathSet.values()].map((inputs) => [...inputs]) ); - compilerOptions.module = sortedChunkIds.map(id => { + compilerOptions.module = sortedChunkIds.map((id) => { const numOfInputs = chunkToInputPathSet.get(id)!.size; return `${id}:${numOfInputs}:${modules[id].deps.join(",")}`; }); @@ -269,7 +269,7 @@ export async function createCompilerOptionsForChunks( } const options: ExtendedCompilerOptions = { - compilerOptions + compilerOptions, }; if (entryConfig.warningsWhitelist) { options.warningsWhitelist = createWarningsWhitelist( @@ -354,19 +354,19 @@ function findTransitiveDeps( } ): Map> { const pathToDep = new Map( - dependencies.map(dep => [dep.path, dep] as [string, depGraph.Dependency]) + dependencies.map((dep) => [dep.path, dep] as [string, depGraph.Dependency]) ); const graph = new depGraph.Graph(dependencies); const chunkToTransitiveDepPathSet: Map> = new Map(); - sortedChunkIds.forEach(chunkId => { + sortedChunkIds.forEach((chunkId) => { const chunkConfig = modules[chunkId]; - const entryPoints = chunkConfig.inputs.map(input => + const entryPoints = chunkConfig.inputs.map((input) => assertNonNullable( pathToDep.get(input), `entryConfig.paths does not include the inputs: ${input}` ) ); - const depPaths = graph.order(...entryPoints).map(dep => dep.path); + const depPaths = graph.order(...entryPoints).map((dep) => dep.path); chunkToTransitiveDepPathSet.set(chunkId, new Set(depPaths)); }); return chunkToTransitiveDepPathSet; @@ -381,7 +381,7 @@ function splitDepsIntoChunks( dag: Dag ): Map> { const chunkToInputPathSet: Map> = new Map(); - sortedChunkIds.forEach(chunk => { + sortedChunkIds.forEach((chunk) => { chunkToInputPathSet.set(chunk, new Set()); }); for (const targetDepPathSet of chunkToTransitiveDepPathSet.values()) { @@ -424,7 +424,7 @@ function createWarningsWhitelist( duckConfig: DuckConfig, basepath: string = process.cwd() ): WarningsWhitelistItem[] { - return warningsWhitelist.map(item => { + return warningsWhitelist.map((item) => { const newItem = { ...item }; if (duckConfig.batch === "aws") { newItem.file = path.relative(basepath, item.file); @@ -438,7 +438,7 @@ function convertCompilerOptionsToRelative( basepath: string = process.cwd() ): void { if (options.js) { - options.js = options.js.map(file => { + options.js = options.js.map((file) => { if (file.startsWith("!")) { return `!${path.relative(basepath, file.slice(1))}`; } @@ -446,12 +446,12 @@ function convertCompilerOptionsToRelative( }); } if (options.externs) { - options.externs = options.externs.map(file => + options.externs = options.externs.map((file) => path.relative(basepath, file) ); } if (options.entry_point) { - options.entry_point = options.entry_point.map(file => + options.entry_point = options.entry_point.map((file) => path.relative(basepath, file) ); } diff --git a/src/dag.ts b/src/dag.ts index 8d0d47b84..706a92b04 100644 --- a/src/dag.ts +++ b/src/dag.ts @@ -32,7 +32,7 @@ export class Dag { throw new Error("The `nodes` is empty"); } // populate idToNode - nodes.forEach(node => { + nodes.forEach((node) => { if (this.idToNode.has(node.id)) { throw new Error(`Same ID found: ${node.id}`); } @@ -51,13 +51,13 @@ export class Dag { } this.root = root; // populate children (inverting deps) - nodes.forEach(node => { - node.deps.forEach(dep => { + nodes.forEach((node) => { + node.deps.forEach((dep) => { this.idToNode.get(dep)!.children.add(node); }); }); this.populateDepth(); - this.idToNode.forEach(node => { + this.idToNode.forEach((node) => { node.ancestors = new Set(this.populateAncestors(node)); }); } @@ -73,7 +73,7 @@ export class Dag { throw new Error(`Circular dependencies found: ${ancestors}`); } ancestors.push(node.id); - node.deps.forEach(dep => { + node.deps.forEach((dep) => { this.populateAncestors(this.idToNode.get(dep)!, ancestors); }); return ancestors; @@ -190,6 +190,6 @@ export class Dag { * The result is cached and returned from the second time. */ getSortedIds(): string[] { - return this.getSortedNodes().map(node => node.id); + return this.getSortedNodes().map((node) => node.id); } } diff --git a/src/dependency-parser-worker.ts b/src/dependency-parser-worker.ts index e2f1ffa90..eb0bdb283 100644 --- a/src/dependency-parser-worker.ts +++ b/src/dependency-parser-worker.ts @@ -13,12 +13,12 @@ async function parse(filepath: string): Promise { type: dep.type, language: dep.language, // Don't copy `import.from` to avoid circular dependency in JSON.stringify. - imports: dep.imports.map(i => ({ + imports: dep.imports.map((i) => ({ symOrPath: i.symOrPath, // Convert getter methods to properties to transfer with postMessage() to workers. isGoogRequire: i.isGoogRequire(), - isEs6Import: i.isEs6Import() - })) + isEs6Import: i.isEs6Import(), + })), }; } diff --git a/src/dependency-parser-wrapper.ts b/src/dependency-parser-wrapper.ts index ef3c0b42d..7cff74135 100644 --- a/src/dependency-parser-wrapper.ts +++ b/src/dependency-parser-wrapper.ts @@ -14,7 +14,7 @@ export class DependencyParserWithWorkers { } this.pool = workerpool.pool(script, { minWorkers: "max", - maxWorkers: numOfWorkers + maxWorkers: numOfWorkers, }); } async parse(filepath: string): Promise { @@ -23,7 +23,7 @@ export class DependencyParserWithWorkers { } private deserialize(depData: DependencyTransferData): depGraph.Dependency { - const imports = depData.imports.map(i => { + const imports = depData.imports.map((i) => { if (i.isEs6Import && !i.isGoogRequire) { return new depGraph.Es6Import(i.symOrPath); } else if (!i.isEs6Import && i.isGoogRequire) { diff --git a/src/duckconfig.ts b/src/duckconfig.ts index f5c23723b..0fe58e85d 100644 --- a/src/duckconfig.ts +++ b/src/duckconfig.ts @@ -123,7 +123,7 @@ function toAbsPathArray( const values = config[key]; if (Array.isArray(values)) { // "as any": TypeScript can not handle conditional type - config[key] = values.map(value => path.resolve(baseDir, value)) as any; + config[key] = values.map((value) => path.resolve(baseDir, value)) as any; } } /** diff --git a/src/entryconfig.ts b/src/entryconfig.ts index 8c4ccc1e2..51468680d 100644 --- a/src/entryconfig.ts +++ b/src/entryconfig.ts @@ -52,7 +52,7 @@ export enum PlovrMode { RAW = "RAW", WHITESPACE = "WHITESPACE", SIMPLE = "SIMPLE", - ADVANCED = "ADVANCED" + ADVANCED = "ADVANCED", } /** * Load entry config JSON @@ -84,14 +84,14 @@ export async function loadEntryConfig( entryConfigPath ); // change relative paths to abs paths - entryConfig.paths = entryConfig.paths.map(p => path.resolve(basedir, p)); + entryConfig.paths = entryConfig.paths.map((p) => path.resolve(basedir, p)); if (entryConfig.inputs) { - entryConfig.inputs = entryConfig.inputs.map(input => + entryConfig.inputs = entryConfig.inputs.map((input) => path.resolve(basedir, input) ); } if (entryConfig.externs) { - entryConfig.externs = entryConfig.externs.map(extern => + entryConfig.externs = entryConfig.externs.map((extern) => path.resolve(basedir, extern) ); } @@ -102,17 +102,17 @@ export async function loadEntryConfig( ); } if (entryConfig.modules) { - Object.values(entryConfig.modules).forEach(mod => { - mod.inputs = mod.inputs.map(input => path.resolve(basedir, input)); + Object.values(entryConfig.modules).forEach((mod) => { + mod.inputs = mod.inputs.map((input) => path.resolve(basedir, input)); }); } if (entryConfig.warningsWhitelist) { - entryConfig.warningsWhitelist.forEach(item => { + entryConfig.warningsWhitelist.forEach((item) => { item.file = path.resolve(basedir, item.file); }); } if (entryConfig["test-excludes"]) { - entryConfig["test-excludes"] = entryConfig["test-excludes"].map(p => + entryConfig["test-excludes"] = entryConfig["test-excludes"].map((p) => path.resolve(basedir, p) ); } diff --git a/src/gendeps.ts b/src/gendeps.ts index 5d17c4b14..5a275f02f 100644 --- a/src/gendeps.ts +++ b/src/gendeps.ts @@ -39,14 +39,14 @@ export function generateDepFileTextFromDeps( // so change the type to CLOSURE_PROVIDE temporally. // TODO: fix upstream google-closure-deps and remove this const scriptDeps = dependencies.filter( - dep => dep.type === depGraph.DependencyType.SCRIPT + (dep) => dep.type === depGraph.DependencyType.SCRIPT ); - scriptDeps.forEach(dep => { + scriptDeps.forEach((dep) => { dep.type = depGraph.DependencyType.CLOSURE_PROVIDE; }); const depFileText = depFile.getDepFileText(googBaseDir, dependencies); // restore the type - scriptDeps.forEach(dep => { + scriptDeps.forEach((dep) => { dep.type = depGraph.DependencyType.SCRIPT; }); return depFileText; @@ -91,7 +91,7 @@ export async function restoreDepsJs( result.dependencies, path.join(closureLibraryDir, "closure", "goog") ); - result.dependencies.forEach(dep => { + result.dependencies.forEach((dep) => { pathToDependencyCache.set(dep.path, Promise.resolve(dep)); }); } @@ -105,30 +105,30 @@ export async function getDependencies( ignoreDirs: readonly string[] = [], numOfWorkers?: number ): Promise { - const ignoreDirPatterns = ignoreDirs.map(dir => path.join(dir, "**/*")); + const ignoreDirPatterns = ignoreDirs.map((dir) => path.join(dir, "**/*")); const parser = new DependencyParserWithWorkers(numOfWorkers); try { // TODO: uniq - const parseResultPromises = entryConfig.paths.map(async p => { + const parseResultPromises = entryConfig.paths.map(async (p) => { let testExcludes: readonly string[] = []; if (entryConfig["test-excludes"]) { testExcludes = entryConfig["test-excludes"]; } const files = await globPromise(path.join(p, "**/*.js"), { ignore: ignoreDirPatterns, - follow: true + follow: true, }); return Promise.all( files // TODO: load deps.js path from config - .filter(file => !/\bdeps\.js$/.test(file)) - .filter(file => { - if (testExcludes.some(exclude => file.startsWith(exclude))) { + .filter((file) => !/\bdeps\.js$/.test(file)) + .filter((file) => { + if (testExcludes.some((exclude) => file.startsWith(exclude))) { return !/_test\.js$/.test(file); } return true; }) - .map(async file => { + .map(async (file) => { if (pathToDependencyCache.has(file)) { return pathToDependencyCache.get(file)!; } @@ -179,11 +179,11 @@ function appendGoogImport( dependencies: readonly depGraph.Dependency[], googBaseDir: string ) { - dependencies.forEach(dep => { + dependencies.forEach((dep) => { dep.setClosurePath(googBaseDir); if ( dep.closureSymbols.length > 0 || - dep.imports.find(i => i.isGoogRequire()) + dep.imports.find((i) => i.isGoogRequire()) ) { const goog = new depGraph.GoogRequire("goog"); goog.from = dep; diff --git a/src/report.ts b/src/report.ts index 8f3b649ba..681973a03 100644 --- a/src/report.ts +++ b/src/report.ts @@ -30,7 +30,7 @@ export interface ErrorReason { const reporterClasses = { json: JsonReporter, text: TextReporter, - xunit: XUnitReporter + xunit: XUnitReporter, } as const; export async function reportTestResults( @@ -38,7 +38,7 @@ export async function reportTestResults( config: DuckConfig ): Promise { const reporters = config.reporters || ["text"]; - const promises = reporters.map(name => { + const promises = reporters.map((name) => { const options = (config.reporterOptions || {})[name]; const reporter = new reporterClasses[name](options); return reporter.output(reasons); diff --git a/src/reporters/base-reporter.ts b/src/reporters/base-reporter.ts index 17da19256..41671270d 100644 --- a/src/reporters/base-reporter.ts +++ b/src/reporters/base-reporter.ts @@ -9,7 +9,7 @@ export abstract class BaseReporter { constructor({ stderr, outputDir, - resultFilename + resultFilename, }: { stderr: boolean; outputDir: string | null; @@ -25,7 +25,7 @@ export abstract class BaseReporter { * @param reasons */ async output(reasons: readonly ErrorReason[]): Promise { - const promises = reasons.map(async reason => { + const promises = reasons.map(async (reason) => { const content = this.format(reason); if (this.stderr) { console.error(content); diff --git a/src/reporters/json-reporter.ts b/src/reporters/json-reporter.ts index 5d84d5612..bd08a642c 100644 --- a/src/reporters/json-reporter.ts +++ b/src/reporters/json-reporter.ts @@ -17,7 +17,7 @@ export class JsonReporter extends BaseReporter { options.outputDir === undefined ? DEFAULT_OUTPUT_DIR : options.outputDir, - resultFilename: "results.json" + resultFilename: "results.json", }); } diff --git a/src/reporters/text-reporter.ts b/src/reporters/text-reporter.ts index 9f6809577..5666f3b41 100644 --- a/src/reporters/text-reporter.ts +++ b/src/reporters/text-reporter.ts @@ -11,7 +11,7 @@ export class TextReporter extends BaseReporter { super({ stderr: options.stderr || true, outputDir: options.outputDir || null, - resultFilename: "results.txt" + resultFilename: "results.txt", }); } @@ -19,13 +19,13 @@ export class TextReporter extends BaseReporter { // if items doesn't include any errors or warnings, // we ignore "info" that includes the line of summary like: // "0 error(s), 0 warning(s), xx% typed" - if (items.filter(i => i.level !== "info").length === 0) { + if (items.filter((i) => i.level !== "info").length === 0) { return ""; } return `# ${entryConfigPath}: ${command ? `\n${command}\n` : ""} ${items - .map(item => + .map((item) => item.level === "info" ? item.description : this.formatErrorCase(item) ) .join("\n\n")}\n`; diff --git a/src/reporters/xunit-reporter.ts b/src/reporters/xunit-reporter.ts index e13b01447..c01caeb39 100644 --- a/src/reporters/xunit-reporter.ts +++ b/src/reporters/xunit-reporter.ts @@ -18,7 +18,7 @@ export class XUnitReporter extends BaseReporter { options.outputDir === undefined ? DEFAULT_OUTPUT_DIR : options.outputDir, - resultFilename: "results.xml" + resultFilename: "results.xml", }); } @@ -28,10 +28,10 @@ export class XUnitReporter extends BaseReporter { .element("testsuite") .attribute("name", entryConfigPath); const errors = items.filter( - item => item.level === "error" + (item) => item.level === "error" ) as CompileErrorCase[]; if (errors.length > 0) { - errors.forEach(error => { + errors.forEach((error) => { const testcase = testsuite .element("testcase") .attribute("classname", error.source) diff --git a/src/soy.ts b/src/soy.ts index b0be8dbae..f9671e470 100644 --- a/src/soy.ts +++ b/src/soy.ts @@ -27,7 +27,7 @@ export async function compileSoy( msg: "Print config only", type: resultInfoLogType, title: "Soy config", - bodyObject: soyArgs + bodyObject: soyArgs, }); return; } @@ -42,7 +42,7 @@ export function toSoyArgs( const args = [ "-classpath", soyJarPath, - "com.google.template.soy.SoyToJsSrcCompiler" + "com.google.template.soy.SoyToJsSrcCompiler", ]; Object.entries(soyOptions).forEach(([key, value]) => { if (typeof value === "boolean" && value) { @@ -57,7 +57,7 @@ export function toSoyArgs( }); if (soyOptions.inputPrefix) { const { inputPrefix } = soyOptions; - soyFiles = soyFiles.map(filepath => path.relative(inputPrefix, filepath)); + soyFiles = soyFiles.map((filepath) => path.relative(inputPrefix, filepath)); } args.push("--srcs", soyFiles.join(",")); return args; diff --git a/src/watch.ts b/src/watch.ts index 91a012904..cddcce475 100644 --- a/src/watch.ts +++ b/src/watch.ts @@ -16,7 +16,7 @@ export function watchJsAndSoy(config: DuckConfig) { let soyConfig: SoyConfig | null = null; if (soyJarPath && soyFileRoots && soyOptions) { soyConfig = { soyJarPath, soyOptions }; - paths.push(...soyFileRoots.map(p => `${p}/**/*.soy`)); + paths.push(...soyFileRoots.map((p) => `${p}/**/*.soy`)); target = "JS and Soy"; } const ignored = [...config.depsJsIgnoreDirs]; @@ -28,7 +28,7 @@ export function watchJsAndSoy(config: DuckConfig) { logger.info(`Watching for ${target} file changes...`) ); watcher.on("error", logger.error.bind(logger)); - chokidarEvents.forEach(event => { + chokidarEvents.forEach((event) => { watcher.on(event, handleChokidarEvent.bind(null, event, soyConfig)); }); } @@ -48,7 +48,7 @@ function handleChokidarEvent( const jsHandlers = { add: handleJsUpdated.bind(null, "ADDED"), change: handleJsUpdated.bind(null, "CHANGED"), - unlink: handleJsUpdated.bind(null, "DELETED") + unlink: handleJsUpdated.bind(null, "DELETED"), } as const; /** @@ -64,7 +64,7 @@ function handleJsUpdated(event: string, filepath: string) { const soyHandlers = { add: handleSoyUpdated.bind(null, "ADDED"), change: handleSoyUpdated.bind(null, "CHANGED"), - unlink: handleSoyDeleted + unlink: handleSoyDeleted, } as const; type SoyConfig = Required>; diff --git a/test/bin-test/bin.js b/test/bin-test/bin.js index 5cac486c4..7399f83c8 100644 --- a/test/bin-test/bin.js +++ b/test/bin-test/bin.js @@ -8,7 +8,7 @@ const bin = path.resolve(__dirname, "..", "..", "bin", "duck.js"); // Run this test after tsc describe("bin/duck.js", () => { - it("is executable", async function() { + it("is executable", async function () { this.timeout(5000); const { stderr } = await execFileP(bin, ["--help"]); assert.equal(stderr, ""); diff --git a/test/compiler.ts b/test/compiler.ts index 64d83fcb3..2f4fe19c5 100644 --- a/test/compiler.ts +++ b/test/compiler.ts @@ -4,7 +4,7 @@ import { readFileSync } from "fs"; import path from "path"; import { convertToFlagfile, - createCompilerOptionsForPage + createCompilerOptionsForPage, } from "../src/compiler"; import { ExtendedCompilerOptions } from "../src/compiler-core"; import { DuckConfig } from "../src/duckconfig"; @@ -32,7 +32,7 @@ describe("compiler", () => { id: "simple", mode: PlovrMode.RAW, paths: ["/path/to/path1"], - inputs: ["/input1.js"] + inputs: ["/input1.js"], }, emptyDuckConfig, false @@ -43,8 +43,8 @@ describe("compiler", () => { json_streams: "OUT", compilation_level: "WHITESPACE", js: ["/path/to/path1"], - entry_point: ["/input1.js"] - } + entry_point: ["/input1.js"], + }, }; assert.deepEqual(actual, expected); }); @@ -57,8 +57,8 @@ describe("compiler", () => { paths: ["/path/to/path1"], inputs: ["/input1.js"], "experimental-compiler-options": { - hideWarningsFor: ["foo/bar"] - } + hideWarningsFor: ["foo/bar"], + }, }, emptyDuckConfig, false @@ -70,8 +70,8 @@ describe("compiler", () => { compilation_level: "WHITESPACE", js: ["/path/to/path1"], entry_point: ["/input1.js"], - hide_warnings_for: ["foo/bar"] - } + hide_warnings_for: ["foo/bar"], + }, }; assert.deepEqual(actual, expected); }); @@ -84,15 +84,15 @@ describe("compiler", () => { inputs: ["/input1.js"], warningsWhitelist: [ { file: "/path/to/file1.js", line: 1, description: "Error1" }, - { file: "/path/to/file2.js", description: "Error2" } - ] + { file: "/path/to/file2.js", description: "Error2" }, + ], }, emptyDuckConfig, false ); assert.deepEqual(actual.warningsWhitelist, [ { file: "/path/to/file1.js", line: 1, description: "Error1" }, - { file: "/path/to/file2.js", description: "Error2" } + { file: "/path/to/file2.js", description: "Error2" }, ]); // const whitelist = readFileSync(actual.warnings_whitelist_file!, "utf8"); // assert.equal(whitelist, "/path/to/file1.js:1 Error1\n/path/to/file2.js: Error2"); @@ -117,14 +117,14 @@ describe("compiler", () => { define: { "goog.BOOLEAN": false, "goog.NUMBER": 100, - "goog.STRING": "single-quoted" + "goog.STRING": "single-quoted", }, checks: { checkRegExp: "ERROR", checkTypes: "OFF", checkVars: "WARNING", - deprecated: "ERROR" - } + deprecated: "ERROR", + }, }, emptyDuckConfig, true @@ -146,13 +146,13 @@ describe("compiler", () => { define: [ "goog.BOOLEAN=false", "goog.NUMBER=100", - "goog.STRING='single-quoted'" + "goog.STRING='single-quoted'", ], js_output_file: "/out.js", jscomp_error: ["checkRegExp", "deprecated"], jscomp_warning: ["checkVars"], - jscomp_off: ["checkTypes"] - } + jscomp_off: ["checkTypes"], + }, }; assert.deepEqual(actual, expected); }); @@ -167,8 +167,8 @@ describe("compiler", () => { inputs: ["/input1.js"], warningsWhitelist: [ { file: "/path/to/file1.js", line: 1, description: "Error1" }, - { file: "/path/to/file2.js", description: "Error2" } - ] + { file: "/path/to/file2.js", description: "Error2" }, + ], }, { batch: "aws" } as DuckConfig, false @@ -180,17 +180,17 @@ describe("compiler", () => { compilation_level: "WHITESPACE", externs: [relative("/path/to/extern1.js")], js: [relative("/path/to/path1"), `!${relative("/path/to/extern1.js")}`], - entry_point: [relative("/input1.js")] + entry_point: [relative("/input1.js")], }, batch: "aws", warningsWhitelist: [ { file: relative("/path/to/file1.js"), line: 1, - description: "Error1" + description: "Error1", }, - { file: relative("/path/to/file2.js"), description: "Error2" } - ] + { file: relative("/path/to/file2.js"), description: "Error2" }, + ], }; assert.deepEqual(actual, expected); }); @@ -212,7 +212,7 @@ describe("compiler", () => { const { flagfile } = convertToFlagfile({ compilation_level: "ADVANCED", js_output_file: '/a b".js', - js: ['/a b".js', '/c d".js'] + js: ['/a b".js', '/c d".js'], }); const content = readFileSync(flagfile, "utf8"); assert.equal( diff --git a/test/dag.ts b/test/dag.ts index b345bb810..4ffe7c088 100644 --- a/test/dag.ts +++ b/test/dag.ts @@ -56,7 +56,7 @@ describe("Dag", () => { new Node("a", []), new Node("b", ["a"]), new Node("c", ["a"]), - new Node("d", ["b"]) + new Node("d", ["b"]), ]); assert(dag.getLcaNode("a", "b").id === "a"); assert(dag.getLcaNode("b", "c").id === "a"); @@ -73,7 +73,7 @@ describe("Dag", () => { const dag = new Dag([ new Node("a", []), new Node("b", ["a", "c"]), - new Node("c", ["a"]) + new Node("c", ["a"]), ]); assert(dag.getLcaNode("a", "b").id === "a"); assert(dag.getLcaNode("a", "c").id === "a"); @@ -89,7 +89,7 @@ describe("Dag", () => { new Node("b", ["a"]), new Node("c", ["a"]), new Node("d", ["c"]), - new Node("e", ["b", "d"]) + new Node("e", ["b", "d"]), ]); assert(dag.getLcaNode("a", "b").id === "a"); assert(dag.getLcaNode("b", "c").id === "a"); @@ -108,7 +108,7 @@ describe("Dag", () => { new Node("b", ["a"]), new Node("c", ["a"]), new Node("d", ["b"]), - new Node("e", ["b"]) + new Node("e", ["b"]), ]); assert(dag.getLcaNode("a", "b", "c").id === "a"); assert(dag.getLcaNode("a", "b", "d").id === "a"); diff --git a/test/dependency-parser.ts b/test/dependency-parser.ts index 42903c313..5faa833d6 100644 --- a/test/dependency-parser.ts +++ b/test/dependency-parser.ts @@ -39,7 +39,7 @@ const expectedVariousModulesDeps = [ `${variousModulesFixturesDir}/script.js`, [], [new depGraph.GoogRequire("goog"), new depGraph.GoogRequire("goog.array")] - ) + ), ] as const; describe("DependencyParser()", () => { diff --git a/test/entryconfig.ts b/test/entryconfig.ts index 4efdfa453..c738148e7 100644 --- a/test/entryconfig.ts +++ b/test/entryconfig.ts @@ -15,7 +15,7 @@ describe("entryconfig", () => { inputs: [path.join(fixturesBaseDir, "js", "foo.js")], externs: [ path.join(fixturesBaseDir, "ext", "foo.js"), - path.join(fixturesDir, "ext", "bar.js") + path.join(fixturesDir, "ext", "bar.js"), ], paths: [path.join(fixturesBaseDir, "path1")], "output-file": path.join(fixturesDir, "out.js"), @@ -23,13 +23,13 @@ describe("entryconfig", () => { checkRegExp: "ERROR", checkTypes: "ERROR", checkVars: "WARNING", - deprecated: "OFF" - } + deprecated: "OFF", + }, }); }); it("overrides `mode`", async () => { const config = await loadEntryConfigById("simple", fixturesDir, { - mode: PlovrMode.ADVANCED + mode: PlovrMode.ADVANCED, }); assert(config.mode === PlovrMode.ADVANCED); }); @@ -42,15 +42,15 @@ describe("entryconfig", () => { modules: { base: { inputs: [path.join(fixturesBaseDir, "js", "base.js")], - deps: [] + deps: [], }, chunk1: { inputs: [path.join(fixturesDir, "js", "chunk1.js")], - deps: ["base"] - } + deps: ["base"], + }, }, "module-output-path": path.join(fixturesBaseDir, "chunks", "%s.js"), - "module-production-uri": "../output/%s.js" + "module-production-uri": "../output/%s.js", }); }); it("normalizes chunks config", async () => { @@ -63,13 +63,13 @@ describe("entryconfig", () => { modules: { base: { inputs: [path.join(fixturesBaseDir, "js", "base.js")], - deps: [] + deps: [], }, chunk1: { inputs: [path.join(fixturesDir, "js", "chunk1.js")], - deps: ["base"] - } - } + deps: ["base"], + }, + }, }); }); it("inherits parent configs", async () => { @@ -86,7 +86,7 @@ describe("entryconfig", () => { paths: [path.join(fixturesBaseDir, "path1")], debug: true, // resolve relative path and normalize in base.json - "test-excludes": [fixturesBaseDir] + "test-excludes": [fixturesBaseDir], }); }); it("warningsWhitelist", async () => { @@ -98,12 +98,12 @@ describe("entryconfig", () => { { file: `${fixturesDir}/path/to/file1.js`, line: 1, - description: "Error1" + description: "Error1", }, { file: `${fixturesDir}/path/to/file2.js`, - description: "Error2" - } + description: "Error2", + }, ]); }); }); diff --git a/test/gendeps.ts b/test/gendeps.ts index 61b30def2..439e8c613 100644 --- a/test/gendeps.ts +++ b/test/gendeps.ts @@ -11,7 +11,7 @@ import { getClosureLibraryDependencies, getDependencies, restoreDepsJs, - writeCachedDepsOnDisk + writeCachedDepsOnDisk, } from "../src/gendeps"; const fixturesBaseDir = path.join(__dirname, "fixtures"); @@ -53,7 +53,7 @@ const expectedVariousModulesDeps = [ `${variousModulesFixturesDir}/script.js`, [], [new depGraph.GoogRequire("goog"), new depGraph.GoogRequire("goog.array")] - ) + ), ] as const; describe("gendeps", () => { @@ -65,7 +65,7 @@ describe("gendeps", () => { const inputsRoot = path.join(fixturesBaseDir, "generateDepFileText"); const closureDir = path.join(inputsRoot, "closure"); const entryConfig = { - paths: [inputsRoot] + paths: [inputsRoot], }; assert.equal( await generateDepFileText(entryConfig, inputsRoot, [closureDir]), @@ -120,7 +120,7 @@ describe("gendeps", () => { const path1 = path.join(fixturesDir, "path1"); const path2 = path.join(fixturesDir, "path2"); const entryConfig = { - paths: [path1, path2] + paths: [path1, path2], }; const results = await getDependencies(entryConfig); assert.deepEqual( @@ -129,7 +129,7 @@ describe("gendeps", () => { createScriptDependency("path1/foo.js"), createScriptDependency("path1/foo_test.js"), createScriptDependency("path2/bar.js"), - createScriptDependency("path2/bar_test.js") + createScriptDependency("path2/bar_test.js"), ]) ); }); @@ -137,7 +137,7 @@ describe("gendeps", () => { const path1 = path.join(fixturesDir, "path1"); const path2 = path.join(fixturesDir, "path2"); const entryConfig = { - paths: [path1, path2] + paths: [path1, path2], }; const results = await getDependencies(entryConfig, [path2]); assert.equal(results.length, 2); @@ -145,7 +145,7 @@ describe("gendeps", () => { new Set(results), new Set([ createScriptDependency("path1/foo.js"), - createScriptDependency("path1/foo_test.js") + createScriptDependency("path1/foo_test.js"), ]) ); }); @@ -154,7 +154,7 @@ describe("gendeps", () => { const path2 = path.join(fixturesDir, "path2"); const entryConfig = { paths: [path1, path2], - "test-excludes": [path2] + "test-excludes": [path2], }; const results = await getDependencies(entryConfig); assert.equal(results.length, 3); @@ -163,13 +163,13 @@ describe("gendeps", () => { new Set([ createScriptDependency("path1/foo.js"), createScriptDependency("path1/foo_test.js"), - createScriptDependency("path2/bar.js") + createScriptDependency("path2/bar.js"), ]) ); }); it("loads various modules", async () => { const entryConfig = { - paths: [variousModulesFixturesDir] + paths: [variousModulesFixturesDir], }; const deps = await getDependencies(entryConfig); deps.sort((a, b) => a.path.localeCompare(b.path)); @@ -192,7 +192,7 @@ describe("gendeps", () => { const closureLibraryDir = path.join(fixturesDir, "closure"); await restoreDepsJs(originalDepsJs, closureLibraryDir); const actualDepsJsPath = tempy.file({ - name: "writeCachedDepsOnDisk-deps.js" + name: "writeCachedDepsOnDisk-deps.js", }); await writeCachedDepsOnDisk(actualDepsJsPath, closureLibraryDir); const actual = await fs.readFile(actualDepsJsPath, "utf8"); @@ -207,7 +207,7 @@ describe("gendeps", () => { assert.equal(countDepCache(), 5); const entryConfig = { - paths: [variousModulesFixturesDir] + paths: [variousModulesFixturesDir], }; const deps = await getDependencies(entryConfig); deps.sort((a, b) => a.path.localeCompare(b.path)); @@ -227,7 +227,7 @@ describe("gendeps", () => { ["goog.a11y.aria"], [ new depGraph.GoogRequire("goog"), - new depGraph.GoogRequire("goog.a11y.aria.Role") + new depGraph.GoogRequire("goog.a11y.aria.Role"), ] ), new depGraph.Dependency( @@ -236,7 +236,7 @@ describe("gendeps", () => { ["goog.collections.sets"], [new depGraph.GoogRequire("goog")], "es6" - ) + ), ]); }); }); diff --git a/test/json-reporter.ts b/test/json-reporter.ts index 4fa115aea..5f2c6efbb 100644 --- a/test/json-reporter.ts +++ b/test/json-reporter.ts @@ -30,10 +30,10 @@ describe("JsonReporter", () => { items: [ { level: "info", - description: "89 error(s), 5 warning(s), 98.4% typed" - } - ] - } + description: "89 error(s), 5 warning(s), 98.4% typed", + }, + ], + }, ] as const; const expected = JSON.stringify(reasons[0]); diff --git a/test/soy.ts b/test/soy.ts index f6b262a15..205c527fe 100644 --- a/test/soy.ts +++ b/test/soy.ts @@ -11,8 +11,8 @@ describe("soy", () => { outputPathFormat: "{INPUT_DIRECTORY}/{INPUT_FILE_NAME_NO_EXT}.soy.js", shouldProvideRequireSoyNamespaces: true, bidiGlobalDir: 1 as const, - pluginModules: ["com.example.Foo", "com.example.Bar"] - } + pluginModules: ["com.example.Foo", "com.example.Bar"], + }, }; assert.deepEqual(toSoyArgs(["/js/foo.soy", "/js/bar.soy"], config), [ "-classpath", @@ -26,7 +26,7 @@ describe("soy", () => { "--pluginModules", "com.example.Foo,com.example.Bar", "--srcs", - "/js/foo.soy,/js/bar.soy" + "/js/foo.soy,/js/bar.soy", ]); }); it("inputPrefix", () => { @@ -35,8 +35,8 @@ describe("soy", () => { soyJarPath: "/soy.jar", soyOptions: { outputPathFormat: "/out", - inputPrefix: "/path/to/js/" - } + inputPrefix: "/path/to/js/", + }, }; assert.deepEqual( toSoyArgs(["/path/to/js/foo.soy", "/path/to/js/bar/baz.soy"], config), @@ -49,7 +49,7 @@ describe("soy", () => { "--inputPrefix", "/path/to/js/", "--srcs", - "foo.soy,bar/baz.soy" + "foo.soy,bar/baz.soy", ] ); }); diff --git a/test/text-reporter.ts b/test/text-reporter.ts index 0fdb2316d..42eb1bde7 100644 --- a/test/text-reporter.ts +++ b/test/text-reporter.ts @@ -14,7 +14,7 @@ describe("TextReporter", () => { const actual = reporter.format({ entryConfigPath, command, - items: [] + items: [], }); assert.equal(actual, ""); }); @@ -26,9 +26,9 @@ describe("TextReporter", () => { items: [ { level: "info", - description: "0 error(s), 0 warning(s), 98.4% typed" - } - ] + description: "0 error(s), 0 warning(s), 98.4% typed", + }, + ], }); assert.equal(actual, ""); }); @@ -48,9 +48,9 @@ describe("TextReporter", () => { line: 57, column: 32, context: - " this.outstandingEvents_ = new goog.structs.Map();\n ^^^^^^^^^^^^^^^^" - } - ] + " this.outstandingEvents_ = new goog.structs.Map();\n ^^^^^^^^^^^^^^^^", + }, + ], }); assert.equal( actual, @@ -77,9 +77,9 @@ ${command} source: "/path/to/node_modules/google-closure-library/closure/goog/debug/tracer.js", line: 57, - column: 32 - } - ] + column: 32, + }, + ], }); assert.equal( actual, diff --git a/test/xunit-reporter.ts b/test/xunit-reporter.ts index df82e2c27..782fa0a08 100644 --- a/test/xunit-reporter.ts +++ b/test/xunit-reporter.ts @@ -31,10 +31,10 @@ describe("XUnitReporter", () => { items: [ { level: "info", - description: "89 error(s), 5 warning(s), 98.4% typed" - } - ] - } + description: "89 error(s), 5 warning(s), 98.4% typed", + }, + ], + }, ] as const; const expected = oneLineTrim` @@ -79,9 +79,9 @@ describe("XUnitReporter", () => { items: [ { level: "info", - description: "89 error(s), 5 warning(s), 98.4% typed" - } - ] + description: "89 error(s), 5 warning(s), 98.4% typed", + }, + ], }); assert.equal( actual, @@ -107,9 +107,9 @@ describe("XUnitReporter", () => { line: 57, column: 32, context: - " this.outstandingEvents_ = new goog.structs.Map();\n ^^^^^^^^^^^^^^^^" - } - ] + " this.outstandingEvents_ = new goog.structs.Map();\n ^^^^^^^^^^^^^^^^", + }, + ], }); assert.equal( actual, @@ -139,9 +139,9 @@ describe("XUnitReporter", () => { source: "/path/to/node_modules/google-closure-library/closure/goog/debug/tracer.js", line: 57, - column: 32 - } - ] + column: 32, + }, + ], }); assert.equal( actual, diff --git a/types/google-closure-deps.d.ts b/types/google-closure-deps.d.ts index 6d5d64956..795ca0768 100644 --- a/types/google-closure-deps.d.ts +++ b/types/google-closure-deps.d.ts @@ -30,7 +30,7 @@ export namespace parser { /** * A goog.addDependency statement. */ - GOOG_ADD_DEPENDENCY = "d" + GOOG_ADD_DEPENDENCY = "d", } } @@ -76,7 +76,7 @@ export namespace depGraph { /** An ES6 module file. */ ES6_MODULE = "es6 module", /** A JavaScript file that has no goog.provide/module and is not an ES6 module. */ - SCRIPT = "script" + SCRIPT = "script", } /**