@openuiai/next 16.2.0 → 16.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/next +2 -2
- package/dist/build/index.js +3 -3
- package/dist/build/webpack-config.js +2 -2
- package/dist/cache/cache-control.js +22 -0
- package/dist/cache/cache-control.js.map +1 -0
- package/dist/cache/clone-response.js +77 -0
- package/dist/cache/clone-response.js.map +1 -0
- package/dist/cache/dedupe-fetch.js +123 -0
- package/dist/cache/dedupe-fetch.js.map +1 -0
- package/dist/cache/lazy-result.js +46 -0
- package/dist/cache/lazy-result.js.map +1 -0
- package/dist/cache/lru-cache.js +177 -0
- package/dist/cache/lru-cache.js.map +1 -0
- package/dist/client/app-bootstrap.js +1 -1
- package/dist/client/index.js +1 -1
- package/dist/concurrency/batcher.js +65 -0
- package/dist/concurrency/batcher.js.map +1 -0
- package/dist/concurrency/coalesced-function.js +39 -0
- package/dist/concurrency/coalesced-function.js.map +1 -0
- package/dist/concurrency/scheduler.js +64 -0
- package/dist/concurrency/scheduler.js.map +1 -0
- package/dist/concurrency/wait.js +19 -0
- package/dist/concurrency/wait.js.map +1 -0
- package/dist/concurrency/with-promise-cache.js +24 -0
- package/dist/concurrency/with-promise-cache.js.map +1 -0
- package/dist/config/detect-typo.js +51 -0
- package/dist/config/detect-typo.js.map +1 -0
- package/dist/config/find-config.js +102 -0
- package/dist/config/find-config.js.map +1 -0
- package/dist/config/get-package-version.js +118 -0
- package/dist/config/get-package-version.js.map +1 -0
- package/dist/config/get-project-dir.js +51 -0
- package/dist/config/get-project-dir.js.map +1 -0
- package/dist/config/install-dependencies.js +40 -0
- package/dist/config/install-dependencies.js.map +1 -0
- package/dist/config/needs-experimental-react.js +16 -0
- package/dist/config/needs-experimental-react.js.map +1 -0
- package/dist/config/static-env.js +92 -0
- package/dist/config/static-env.js.map +1 -0
- package/dist/constants/constants.js +397 -0
- package/dist/constants/constants.js.map +1 -0
- package/dist/errors/compile-error.js +14 -0
- package/dist/errors/compile-error.js.map +1 -0
- package/dist/errors/error-source.js +36 -0
- package/dist/errors/error-source.js.map +1 -0
- package/dist/errors/error-telemetry-utils.js +42 -0
- package/dist/errors/error-telemetry-utils.js.map +1 -0
- package/dist/errors/fatal-error.js +14 -0
- package/dist/errors/fatal-error.js.map +1 -0
- package/dist/errors/format-server-error.js +74 -0
- package/dist/errors/format-server-error.js.map +1 -0
- package/dist/errors/invariant-error.js +18 -0
- package/dist/errors/invariant-error.js.map +1 -0
- package/dist/errors/is-error.js +65 -0
- package/dist/errors/is-error.js.map +1 -0
- package/dist/errors/no-fallback-error.js +18 -0
- package/dist/errors/no-fallback-error.js.map +1 -0
- package/dist/esm/build/index.js +3 -3
- package/dist/esm/build/webpack-config.js +2 -2
- package/dist/esm/client/app-bootstrap.js +1 -1
- package/dist/esm/client/index.js +1 -1
- package/dist/esm/server/dev/hot-reloader-webpack.js +1 -1
- package/dist/esm/server/lib/app-info-log.js +1 -1
- package/dist/esm/server/lib/start-server.js +1 -1
- package/dist/esm/shared/lib/errors/canary-only-config-error.js +1 -1
- package/dist/filesystem/file-exists.js +53 -0
- package/dist/filesystem/file-exists.js.map +1 -0
- package/dist/filesystem/find-pages-dir.js +65 -0
- package/dist/filesystem/find-pages-dir.js.map +1 -0
- package/dist/filesystem/find-root.js +118 -0
- package/dist/filesystem/find-root.js.map +1 -0
- package/dist/filesystem/get-files-in-dir.js +33 -0
- package/dist/filesystem/get-files-in-dir.js.map +1 -0
- package/dist/filesystem/multi-file-writer.js +75 -0
- package/dist/filesystem/multi-file-writer.js.map +1 -0
- package/dist/filesystem/realpath.js +20 -0
- package/dist/filesystem/realpath.js.map +1 -0
- package/dist/filesystem/recursive-copy.js +76 -0
- package/dist/filesystem/recursive-copy.js.map +1 -0
- package/dist/filesystem/recursive-delete.js +137 -0
- package/dist/filesystem/recursive-delete.js.map +1 -0
- package/dist/filesystem/recursive-readdir.js +124 -0
- package/dist/filesystem/recursive-readdir.js.map +1 -0
- package/dist/filesystem/rename.js +87 -0
- package/dist/filesystem/rename.js.map +1 -0
- package/dist/filesystem/write-atomic.js +28 -0
- package/dist/filesystem/write-atomic.js.map +1 -0
- package/dist/fonts/font-utils.js +43 -0
- package/dist/fonts/font-utils.js.map +1 -0
- package/dist/fonts/get-preloadable-fonts.js +39 -0
- package/dist/fonts/get-preloadable-fonts.js.map +1 -0
- package/dist/hash/bloom-filter.js +85 -0
- package/dist/hash/bloom-filter.js.map +1 -0
- package/dist/hash/etag.js +56 -0
- package/dist/hash/etag.js.map +1 -0
- package/dist/hash/fnv1a.js +56 -0
- package/dist/hash/fnv1a.js.map +1 -0
- package/dist/hash/hash.js +39 -0
- package/dist/hash/hash.js.map +1 -0
- package/dist/hostname/format-hostname.js +16 -0
- package/dist/hostname/format-hostname.js.map +1 -0
- package/dist/hostname/get-hostname.js +23 -0
- package/dist/hostname/get-hostname.js.map +1 -0
- package/dist/hostname/get-network-host.js +44 -0
- package/dist/hostname/get-network-host.js.map +1 -0
- package/dist/hostname/is-ipv6.js +41 -0
- package/dist/hostname/is-ipv6.js.map +1 -0
- package/dist/image/find-closest-quality.js +19 -0
- package/dist/image/find-closest-quality.js.map +1 -0
- package/dist/image/get-img-props.js +573 -0
- package/dist/image/get-img-props.js.map +1 -0
- package/dist/image/image-blur-svg.js +22 -0
- package/dist/image/image-blur-svg.js.map +1 -0
- package/dist/image/image-config-context.shared-runtime.js +19 -0
- package/dist/image/image-config-context.shared-runtime.js.map +1 -0
- package/dist/image/image-config.js +74 -0
- package/dist/image/image-config.js.map +1 -0
- package/dist/image/image-loader.js +91 -0
- package/dist/image/image-loader.js.map +1 -0
- package/dist/image/image-optimizer.js +1019 -0
- package/dist/image/image-optimizer.js.map +1 -0
- package/dist/image/match-local-pattern.js +46 -0
- package/dist/image/match-local-pattern.js.map +1 -0
- package/dist/image/match-remote-pattern.js +63 -0
- package/dist/image/match-remote-pattern.js.map +1 -0
- package/dist/image/mime-type.js +20 -0
- package/dist/image/mime-type.js.map +1 -0
- package/dist/memory/gc-observer.js +53 -0
- package/dist/memory/gc-observer.js.map +1 -0
- package/dist/memory/shutdown.js +29 -0
- package/dist/memory/shutdown.js.map +1 -0
- package/dist/memory/startup.js +47 -0
- package/dist/memory/startup.js.map +1 -0
- package/dist/memory/trace.js +109 -0
- package/dist/memory/trace.js.map +1 -0
- package/dist/module/client-and-server-references.js +54 -0
- package/dist/module/client-and-server-references.js.map +1 -0
- package/dist/module/format-dynamic-import-path.js +24 -0
- package/dist/module/format-dynamic-import-path.js.map +1 -0
- package/dist/module/interop-default.js +15 -0
- package/dist/module/interop-default.js.map +1 -0
- package/dist/module/resolve-from.js +79 -0
- package/dist/module/resolve-from.js.map +1 -0
- package/dist/module/semver-noop.js +18 -0
- package/dist/module/semver-noop.js.map +1 -0
- package/dist/object/deep-freeze.js +30 -0
- package/dist/object/deep-freeze.js.map +1 -0
- package/dist/object/deep-readonly.js +10 -0
- package/dist/object/deep-readonly.js.map +1 -0
- package/dist/object/is-plain-object.js +42 -0
- package/dist/object/is-plain-object.js.map +1 -0
- package/dist/object/non-nullable.js +15 -0
- package/dist/object/non-nullable.js.map +1 -0
- package/dist/object/pick.js +19 -0
- package/dist/object/pick.js.map +1 -0
- package/dist/process/setup-exception-listeners.js +11 -0
- package/dist/process/setup-exception-listeners.js.map +1 -0
- package/dist/promise/detached-promise.js +32 -0
- package/dist/promise/detached-promise.js.map +1 -0
- package/dist/promise/is-thenable.js +20 -0
- package/dist/promise/is-thenable.js.map +1 -0
- package/dist/promise/promise-with-resolvers.js +26 -0
- package/dist/promise/promise-with-resolvers.js.map +1 -0
- package/dist/server/dev/hot-reloader-webpack.js +1 -1
- package/dist/server/lib/app-info-log.js +1 -1
- package/dist/server/lib/start-server.js +1 -1
- package/dist/shared/lib/errors/canary-only-config-error.js +1 -1
- package/dist/string/encode-uri-path.js +15 -0
- package/dist/string/encode-uri-path.js.map +1 -0
- package/dist/string/escape-regexp.js +22 -0
- package/dist/string/escape-regexp.js.map +1 -0
- package/dist/string/normalize-path.js +21 -0
- package/dist/string/normalize-path.js.map +1 -0
- package/dist/string/oxford-comma-list.js +15 -0
- package/dist/string/oxford-comma-list.js.map +1 -0
- package/dist/string/pretty-bytes.js +74 -0
- package/dist/string/pretty-bytes.js.map +1 -0
- package/dist/telemetry/anonymous-meta.js +1 -1
- package/dist/telemetry/events/session-stopped.js +2 -2
- package/dist/telemetry/events/version.js +2 -2
- package/dist/typescript/diagnosticFormatter.js +240 -0
- package/dist/typescript/diagnosticFormatter.js.map +1 -0
- package/dist/typescript/getTypeScriptConfiguration.js +73 -0
- package/dist/typescript/getTypeScriptConfiguration.js.map +1 -0
- package/dist/typescript/getTypeScriptIntent.js +52 -0
- package/dist/typescript/getTypeScriptIntent.js.map +1 -0
- package/dist/typescript/missingDependencyError.js +27 -0
- package/dist/typescript/missingDependencyError.js.map +1 -0
- package/dist/typescript/runTypeCheck.js +95 -0
- package/dist/typescript/runTypeCheck.js.map +1 -0
- package/dist/typescript/writeAppTypeDeclarations.js +65 -0
- package/dist/typescript/writeAppTypeDeclarations.js.map +1 -0
- package/dist/typescript/writeConfigurationDefaults.js +403 -0
- package/dist/typescript/writeConfigurationDefaults.js.map +1 -0
- package/dist/validation/is-serializable-props.js +106 -0
- package/dist/validation/is-serializable-props.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../string/pretty-bytes.ts"],"sourcesContent":["/*\nMIT License\n\nCopyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n*/\n\nconst UNITS = ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']\n\n/*\nFormats the given number using `Number#toLocaleString`.\n- If locale is a string, the value is expected to be a locale-key (for example: `de`).\n- If locale is true, the system default locale is used for translation.\n- If no value for locale is specified, the number is returned unmodified.\n*/\nconst toLocaleString = (number: number, locale: any) => {\n let result: any = number\n if (typeof locale === 'string') {\n result = number.toLocaleString(locale)\n } else if (locale === true) {\n result = number.toLocaleString()\n }\n\n return result\n}\n\nexport default function prettyBytes(number: number, options?: any): string {\n if (!Number.isFinite(number)) {\n throw new TypeError(\n `Expected a finite number, got ${typeof number}: ${number}`\n )\n }\n\n options = Object.assign({}, options)\n\n if (options.signed && number === 0) {\n return ' 0 B'\n }\n\n const isNegative = number < 0\n const prefix = isNegative ? '-' : options.signed ? '+' : ''\n\n if (isNegative) {\n number = -number\n }\n\n if (number < 1) {\n const numberString = toLocaleString(number, options.locale)\n return prefix + numberString + ' B'\n }\n\n const exponent = Math.min(\n Math.floor(Math.log10(number) / 3),\n UNITS.length - 1\n )\n\n number = Number((number / Math.pow(1000, exponent)).toPrecision(3))\n const numberString = toLocaleString(number, options.locale)\n\n const unit = UNITS[exponent]\n\n return prefix + numberString + ' ' + unit\n}\n"],"names":["prettyBytes","UNITS","toLocaleString","number","locale","result","options","Number","isFinite","TypeError","Object","assign","signed","isNegative","prefix","numberString","exponent","Math","min","floor","log10","length","pow","toPrecision","unit"],"mappings":"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,SAASC,eAAe,MAAMS;AACvC","ignoreList":[0]}
|
|
@@ -11,11 +11,11 @@ Object.defineProperty(exports, "eventCliSessionStopped", {
|
|
|
11
11
|
const EVENT_VERSION = 'NEXT_CLI_SESSION_STOPPED';
|
|
12
12
|
function eventCliSessionStopped(event) {
|
|
13
13
|
// This should be an invariant, if it fails our build tooling is broken.
|
|
14
|
-
if (typeof "16.2.
|
|
14
|
+
if (typeof "16.2.1" !== 'string') {
|
|
15
15
|
return [];
|
|
16
16
|
}
|
|
17
17
|
const payload = {
|
|
18
|
-
nextVersion: "16.2.
|
|
18
|
+
nextVersion: "16.2.1",
|
|
19
19
|
nodeVersion: process.version,
|
|
20
20
|
cliCommand: event.cliCommand,
|
|
21
21
|
durationMilliseconds: event.durationMilliseconds,
|
|
@@ -12,12 +12,12 @@ const EVENT_VERSION = 'NEXT_CLI_SESSION_STARTED';
|
|
|
12
12
|
function eventCliSession(nextConfig, event) {
|
|
13
13
|
var _nextConfig_experimental_staleTimes, _nextConfig_experimental_staleTimes1, _nextConfig_reactCompiler, _nextConfig_reactCompiler1;
|
|
14
14
|
// This should be an invariant, if it fails our build tooling is broken.
|
|
15
|
-
if (typeof "16.2.
|
|
15
|
+
if (typeof "16.2.1" !== 'string') {
|
|
16
16
|
return [];
|
|
17
17
|
}
|
|
18
18
|
const { images, i18n } = nextConfig || {};
|
|
19
19
|
const payload = {
|
|
20
|
-
nextVersion: "16.2.
|
|
20
|
+
nextVersion: "16.2.1",
|
|
21
21
|
nodeVersion: process.version,
|
|
22
22
|
cliCommand: event.cliCommand,
|
|
23
23
|
isSrcDir: event.isSrcDir,
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "getFormattedDiagnostic", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return getFormattedDiagnostic;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _picocolors = require("../lib/picocolors");
|
|
12
|
+
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
13
|
+
function _interop_require_default(obj) {
|
|
14
|
+
return obj && obj.__esModule ? obj : {
|
|
15
|
+
default: obj
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function getFormattedLinkDiagnosticMessageText(diagnostic) {
|
|
19
|
+
const message = diagnostic.messageText;
|
|
20
|
+
if (typeof message === 'string' && diagnostic.code === 2322) {
|
|
21
|
+
const match = message.match(/Type '"(.+)"' is not assignable to type 'RouteImpl<.+> \| UrlObject'\./) || message.match(/Type '"(.+)"' is not assignable to type 'UrlObject \| RouteImpl<.+>'\./);
|
|
22
|
+
if (match) {
|
|
23
|
+
const [, href] = match;
|
|
24
|
+
return `"${(0, _picocolors.bold)(href)}" is not an existing route. If it is intentional, please type it explicitly with \`as Route\`.`;
|
|
25
|
+
} else if (message === "Type 'string' is not assignable to type 'UrlObject'.") {
|
|
26
|
+
var _diagnostic_relatedInformation_, _diagnostic_relatedInformation;
|
|
27
|
+
const relatedMessage = (_diagnostic_relatedInformation = diagnostic.relatedInformation) == null ? void 0 : (_diagnostic_relatedInformation_ = _diagnostic_relatedInformation[0]) == null ? void 0 : _diagnostic_relatedInformation_.messageText;
|
|
28
|
+
if (typeof relatedMessage === 'string' && relatedMessage.match(/The expected type comes from property 'href' which is declared here on type 'IntrinsicAttributes & /)) {
|
|
29
|
+
return `Invalid \`href\` property of \`Link\`: the route does not exist. If it is intentional, please type it explicitly with \`as Route\`.`;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
} else if (typeof message === 'string' && diagnostic.code === 2820) {
|
|
33
|
+
const match = message.match(/Type '"(.+)"' is not assignable to type 'RouteImpl<.+> \| UrlObject'\. Did you mean '"(.+)"'?/) || message.match(/Type '"(.+)"' is not assignable to type 'UrlObject \| RouteImpl<.+>'\. Did you mean '"(.+)"'?/);
|
|
34
|
+
if (match) {
|
|
35
|
+
const [, href, suggestion] = match;
|
|
36
|
+
return `"${(0, _picocolors.bold)(href)}" is not an existing route. Did you mean "${(0, _picocolors.bold)(suggestion)}" instead? If it is intentional, please type it explicitly with \`as Route\`.`;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function getFormattedLayoutAndPageDiagnosticMessageText(relativeSourceFilepath, diagnostic) {
|
|
41
|
+
const message = typeof diagnostic.messageText === 'string' ? diagnostic : diagnostic.messageText;
|
|
42
|
+
const messageText = message.messageText;
|
|
43
|
+
if (typeof messageText === 'string') {
|
|
44
|
+
const type = /page\.[^.]+$/.test(relativeSourceFilepath) ? 'Page' : /route\.[^.]+$/.test(relativeSourceFilepath) ? 'Route' : 'Layout';
|
|
45
|
+
// Reference of error codes:
|
|
46
|
+
// https://github.com/Microsoft/TypeScript/blob/main/src/compiler/diagnosticMessages.json
|
|
47
|
+
switch(message.code){
|
|
48
|
+
case 2344:
|
|
49
|
+
const filepathAndType = messageText.match(/typeof import\("(.+)"\)/);
|
|
50
|
+
if (filepathAndType) {
|
|
51
|
+
let main = `${type} "${(0, _picocolors.bold)(relativeSourceFilepath)}" does not match the required types of a Next.js ${type}.`;
|
|
52
|
+
function processNext(indent, next) {
|
|
53
|
+
if (!next) return;
|
|
54
|
+
for (const item of next){
|
|
55
|
+
switch(item.code){
|
|
56
|
+
case 2200:
|
|
57
|
+
const mismatchedField = item.messageText.match(/The types of '(.+)'/);
|
|
58
|
+
if (mismatchedField) {
|
|
59
|
+
main += '\n' + ' '.repeat(indent * 2);
|
|
60
|
+
main += `"${(0, _picocolors.bold)(mismatchedField[1])}" has the wrong type:`;
|
|
61
|
+
}
|
|
62
|
+
break;
|
|
63
|
+
case 2322:
|
|
64
|
+
const types = item.messageText.match(/Type '(.+)' is not assignable to type '(.+)'./);
|
|
65
|
+
if (types) {
|
|
66
|
+
main += '\n' + ' '.repeat(indent * 2);
|
|
67
|
+
if (types[2] === 'PageComponent' || types[2] === 'LayoutComponent') {
|
|
68
|
+
main += `The exported ${type} component isn't correctly typed.`;
|
|
69
|
+
} else {
|
|
70
|
+
main += `Expected "${(0, _picocolors.bold)(types[2].replace('"__invalid_negative_number__"', 'number (>= 0)'))}", got "${(0, _picocolors.bold)(types[1])}".`;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
break;
|
|
74
|
+
case 2326:
|
|
75
|
+
const invalidConfig = item.messageText.match(/Types of property '(.+)' are incompatible\./);
|
|
76
|
+
main += '\n' + ' '.repeat(indent * 2);
|
|
77
|
+
main += `Invalid configuration${invalidConfig ? ` "${(0, _picocolors.bold)(invalidConfig[1])}"` : ''}:`;
|
|
78
|
+
break;
|
|
79
|
+
case 2530:
|
|
80
|
+
const invalidField = item.messageText.match(/Property '(.+)' is incompatible with index signature/);
|
|
81
|
+
if (invalidField) {
|
|
82
|
+
main += '\n' + ' '.repeat(indent * 2);
|
|
83
|
+
main += `"${(0, _picocolors.bold)(invalidField[1])}" is not a valid ${type} export field.`;
|
|
84
|
+
}
|
|
85
|
+
return;
|
|
86
|
+
case 2739:
|
|
87
|
+
const invalidProp = item.messageText.match(/Type '(.+)' is missing the following properties from type '(.+)'/);
|
|
88
|
+
if (invalidProp) {
|
|
89
|
+
if (invalidProp[1] === 'LayoutProps' || invalidProp[1] === 'PageProps') {
|
|
90
|
+
main += '\n' + ' '.repeat(indent * 2);
|
|
91
|
+
main += `Prop "${invalidProp[2]}" is incompatible with the ${type}.`;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
break;
|
|
95
|
+
case 2559:
|
|
96
|
+
const invalid = item.messageText.match(/Type '(.+)' has/);
|
|
97
|
+
if (invalid) {
|
|
98
|
+
main += '\n' + ' '.repeat(indent * 2);
|
|
99
|
+
main += `Type "${(0, _picocolors.bold)(invalid[1])}" isn't allowed.`;
|
|
100
|
+
}
|
|
101
|
+
break;
|
|
102
|
+
case 2741:
|
|
103
|
+
const incompatPageProp = item.messageText.match(/Property '(.+)' is missing in type 'PageProps'/);
|
|
104
|
+
if (incompatPageProp) {
|
|
105
|
+
main += '\n' + ' '.repeat(indent * 2);
|
|
106
|
+
main += `Prop "${(0, _picocolors.bold)(incompatPageProp[1])}" will never be passed. Remove it from the component's props.`;
|
|
107
|
+
} else {
|
|
108
|
+
const extraLayoutProp = item.messageText.match(/Property '(.+)' is missing in type 'LayoutProps' but required in type '(.+)'/);
|
|
109
|
+
if (extraLayoutProp) {
|
|
110
|
+
main += '\n' + ' '.repeat(indent * 2);
|
|
111
|
+
main += `Prop "${(0, _picocolors.bold)(extraLayoutProp[1])}" is not valid for this Layout, remove it to fix.`;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
break;
|
|
115
|
+
default:
|
|
116
|
+
}
|
|
117
|
+
processNext(indent + 1, item.next);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
if ('next' in message) processNext(1, message.next);
|
|
121
|
+
return main;
|
|
122
|
+
}
|
|
123
|
+
const invalidExportFnArg = messageText.match(/Type 'OmitWithTag<(.+), .+, "(.+)">' does not satisfy the constraint/);
|
|
124
|
+
if (invalidExportFnArg) {
|
|
125
|
+
const main = `${type} "${(0, _picocolors.bold)(relativeSourceFilepath)}" has an invalid "${(0, _picocolors.bold)(invalidExportFnArg[2])}" export:\n Type "${(0, _picocolors.bold)(invalidExportFnArg[1])}" is not valid.`;
|
|
126
|
+
return main;
|
|
127
|
+
}
|
|
128
|
+
function processNextItems(indent, next) {
|
|
129
|
+
if (!next) return '';
|
|
130
|
+
let result = '';
|
|
131
|
+
for (const item of next){
|
|
132
|
+
switch(item.code){
|
|
133
|
+
case 2322:
|
|
134
|
+
const types = item.messageText.match(/Type '(.+)' is not assignable to type '(.+)'./);
|
|
135
|
+
if (types) {
|
|
136
|
+
result += '\n' + ' '.repeat(indent * 2);
|
|
137
|
+
result += `Expected "${(0, _picocolors.bold)(types[2])}", got "${(0, _picocolors.bold)(types[1])}".`;
|
|
138
|
+
}
|
|
139
|
+
break;
|
|
140
|
+
default:
|
|
141
|
+
}
|
|
142
|
+
result += processNextItems(indent + 1, item.next);
|
|
143
|
+
}
|
|
144
|
+
return result;
|
|
145
|
+
}
|
|
146
|
+
const invalidParamFn = messageText.match(/Type '{ __tag__: (.+); __param_position__: "(.*)"; __param_type__: (.+); }' does not satisfy/);
|
|
147
|
+
if (invalidParamFn) {
|
|
148
|
+
let main = `${type} "${(0, _picocolors.bold)(relativeSourceFilepath)}" has an invalid ${invalidParamFn[1]} export:\n Type "${(0, _picocolors.bold)(invalidParamFn[3])}" is not a valid type for the function's ${invalidParamFn[2]} argument.`;
|
|
149
|
+
if ('next' in message) main += processNextItems(1, message.next);
|
|
150
|
+
return main;
|
|
151
|
+
}
|
|
152
|
+
const invalidExportFnReturn = messageText.match(/Type '{ __tag__: "(.+)"; __return_type__: (.+); }' does not satisfy/);
|
|
153
|
+
if (invalidExportFnReturn) {
|
|
154
|
+
let main = `${type} "${(0, _picocolors.bold)(relativeSourceFilepath)}" has an invalid export:\n "${(0, _picocolors.bold)(invalidExportFnReturn[2])}" is not a valid ${invalidExportFnReturn[1]} return type:`;
|
|
155
|
+
if ('next' in message) main += processNextItems(1, message.next);
|
|
156
|
+
return main;
|
|
157
|
+
}
|
|
158
|
+
break;
|
|
159
|
+
case 2345:
|
|
160
|
+
const filepathAndInvalidExport = messageText.match(/'typeof import\("(.+)"\)'.+Impossible<"(.+)">/);
|
|
161
|
+
if (filepathAndInvalidExport) {
|
|
162
|
+
const main = `${type} "${(0, _picocolors.bold)(relativeSourceFilepath)}" exports an invalid "${(0, _picocolors.bold)(filepathAndInvalidExport[2])}" field. ${type} should only export a default React component and configuration options. Learn more: https://nextjs.org/docs/messages/invalid-segment-export`;
|
|
163
|
+
return main;
|
|
164
|
+
}
|
|
165
|
+
break;
|
|
166
|
+
case 2559:
|
|
167
|
+
const invalid = messageText.match(/Type '(.+)' has no properties in common with type '(.+)'/);
|
|
168
|
+
if (invalid) {
|
|
169
|
+
const main = `${type} "${(0, _picocolors.bold)(relativeSourceFilepath)}" contains an invalid type "${(0, _picocolors.bold)(invalid[1])}" as ${invalid[2]}.`;
|
|
170
|
+
return main;
|
|
171
|
+
}
|
|
172
|
+
break;
|
|
173
|
+
default:
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
function getAppEntrySourceFilePath(baseDir, diagnostic) {
|
|
178
|
+
var _diagnostic_file_text_trim_match, _diagnostic_file;
|
|
179
|
+
const sourceFilepath = ((_diagnostic_file = diagnostic.file) == null ? void 0 : (_diagnostic_file_text_trim_match = _diagnostic_file.text.trim().match(/^\/\/ File: (.+)\n/)) == null ? void 0 : _diagnostic_file_text_trim_match[1]) || '';
|
|
180
|
+
return _path.default.relative(baseDir, sourceFilepath);
|
|
181
|
+
}
|
|
182
|
+
function getFormattedDiagnostic(ts, baseDir, distDir, diagnostic, isAppDirEnabled) {
|
|
183
|
+
var _diagnostic_file;
|
|
184
|
+
// If the error comes from .next/types/, we handle it specially.
|
|
185
|
+
const isLayoutOrPageError = isAppDirEnabled && ((_diagnostic_file = diagnostic.file) == null ? void 0 : _diagnostic_file.fileName.startsWith(_path.default.join(baseDir, distDir, 'types')));
|
|
186
|
+
let message = '';
|
|
187
|
+
const appPath = isLayoutOrPageError ? getAppEntrySourceFilePath(baseDir, diagnostic) : null;
|
|
188
|
+
const linkReason = getFormattedLinkDiagnosticMessageText(diagnostic);
|
|
189
|
+
const appReason = !linkReason && isLayoutOrPageError && appPath ? getFormattedLayoutAndPageDiagnosticMessageText(appPath, diagnostic) : null;
|
|
190
|
+
const reason = linkReason || appReason || ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n');
|
|
191
|
+
const category = diagnostic.category;
|
|
192
|
+
switch(category){
|
|
193
|
+
// Warning
|
|
194
|
+
case ts.DiagnosticCategory.Warning:
|
|
195
|
+
{
|
|
196
|
+
message += (0, _picocolors.yellow)((0, _picocolors.bold)('Type warning')) + ': ';
|
|
197
|
+
break;
|
|
198
|
+
}
|
|
199
|
+
// Error
|
|
200
|
+
case ts.DiagnosticCategory.Error:
|
|
201
|
+
{
|
|
202
|
+
message += (0, _picocolors.red)((0, _picocolors.bold)('Type error')) + ': ';
|
|
203
|
+
break;
|
|
204
|
+
}
|
|
205
|
+
// 2 = Suggestion, 3 = Message
|
|
206
|
+
case ts.DiagnosticCategory.Suggestion:
|
|
207
|
+
case ts.DiagnosticCategory.Message:
|
|
208
|
+
message += (0, _picocolors.cyan)((0, _picocolors.bold)(category === 2 ? 'Suggestion' : 'Info')) + ': ';
|
|
209
|
+
break;
|
|
210
|
+
default:
|
|
211
|
+
{
|
|
212
|
+
category;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
message += reason + '\n';
|
|
216
|
+
if (!isLayoutOrPageError && diagnostic.file) {
|
|
217
|
+
const { codeFrameColumns } = require('next/dist/compiled/babel/code-frame');
|
|
218
|
+
const pos = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
|
|
219
|
+
const line = pos.line + 1;
|
|
220
|
+
const character = pos.character + 1;
|
|
221
|
+
let fileName = _path.default.posix.normalize(_path.default.relative(baseDir, diagnostic.file.fileName).replace(/\\/g, '/'));
|
|
222
|
+
if (!fileName.startsWith('.')) {
|
|
223
|
+
fileName = './' + fileName;
|
|
224
|
+
}
|
|
225
|
+
message = (0, _picocolors.cyan)(fileName) + ':' + (0, _picocolors.yellow)(line.toString()) + ':' + (0, _picocolors.yellow)(character.toString()) + '\n' + message;
|
|
226
|
+
message += '\n' + codeFrameColumns(diagnostic.file.getFullText(diagnostic.file.getSourceFile()), {
|
|
227
|
+
start: {
|
|
228
|
+
line: line,
|
|
229
|
+
column: character
|
|
230
|
+
}
|
|
231
|
+
}, {
|
|
232
|
+
forceColor: true
|
|
233
|
+
});
|
|
234
|
+
} else if (isLayoutOrPageError && appPath) {
|
|
235
|
+
message = (0, _picocolors.cyan)(appPath) + '\n' + message;
|
|
236
|
+
}
|
|
237
|
+
return message;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
//# sourceMappingURL=diagnosticFormatter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../typescript/diagnosticFormatter.ts"],"sourcesContent":["import { bold, cyan, red, yellow } from '../lib/picocolors'\nimport path from 'path'\n\nfunction getFormattedLinkDiagnosticMessageText(\n diagnostic: import('typescript').Diagnostic\n) {\n const message = diagnostic.messageText\n if (typeof message === 'string' && diagnostic.code === 2322) {\n const match =\n message.match(\n /Type '\"(.+)\"' is not assignable to type 'RouteImpl<.+> \\| UrlObject'\\./\n ) ||\n message.match(\n /Type '\"(.+)\"' is not assignable to type 'UrlObject \\| RouteImpl<.+>'\\./\n )\n\n if (match) {\n const [, href] = match\n return `\"${bold(\n href\n )}\" is not an existing route. If it is intentional, please type it explicitly with \\`as Route\\`.`\n } else if (\n message === \"Type 'string' is not assignable to type 'UrlObject'.\"\n ) {\n const relatedMessage = diagnostic.relatedInformation?.[0]?.messageText\n if (\n typeof relatedMessage === 'string' &&\n relatedMessage.match(\n /The expected type comes from property 'href' which is declared here on type 'IntrinsicAttributes & /\n )\n ) {\n return `Invalid \\`href\\` property of \\`Link\\`: the route does not exist. If it is intentional, please type it explicitly with \\`as Route\\`.`\n }\n }\n } else if (typeof message === 'string' && diagnostic.code === 2820) {\n const match =\n message.match(\n /Type '\"(.+)\"' is not assignable to type 'RouteImpl<.+> \\| UrlObject'\\. Did you mean '\"(.+)\"'?/\n ) ||\n message.match(\n /Type '\"(.+)\"' is not assignable to type 'UrlObject \\| RouteImpl<.+>'\\. Did you mean '\"(.+)\"'?/\n )\n\n if (match) {\n const [, href, suggestion] = match\n return `\"${bold(href)}\" is not an existing route. Did you mean \"${bold(\n suggestion\n )}\" instead? If it is intentional, please type it explicitly with \\`as Route\\`.`\n }\n }\n}\n\nfunction getFormattedLayoutAndPageDiagnosticMessageText(\n relativeSourceFilepath: string,\n diagnostic: import('typescript').Diagnostic\n) {\n const message =\n typeof diagnostic.messageText === 'string'\n ? diagnostic\n : diagnostic.messageText\n const messageText = message.messageText\n\n if (typeof messageText === 'string') {\n const type = /page\\.[^.]+$/.test(relativeSourceFilepath)\n ? 'Page'\n : /route\\.[^.]+$/.test(relativeSourceFilepath)\n ? 'Route'\n : 'Layout'\n\n // Reference of error codes:\n // https://github.com/Microsoft/TypeScript/blob/main/src/compiler/diagnosticMessages.json\n switch (message.code) {\n case 2344:\n const filepathAndType = messageText.match(/typeof import\\(\"(.+)\"\\)/)\n if (filepathAndType) {\n let main = `${type} \"${bold(\n relativeSourceFilepath\n )}\" does not match the required types of a Next.js ${type}.`\n\n function processNext(\n indent: number,\n next?: import('typescript').DiagnosticMessageChain[]\n ) {\n if (!next) return\n\n for (const item of next) {\n switch (item.code) {\n case 2200:\n const mismatchedField =\n item.messageText.match(/The types of '(.+)'/)\n if (mismatchedField) {\n main += '\\n' + ' '.repeat(indent * 2)\n main += `\"${bold(mismatchedField[1])}\" has the wrong type:`\n }\n break\n case 2322:\n const types = item.messageText.match(\n /Type '(.+)' is not assignable to type '(.+)'./\n )\n if (types) {\n main += '\\n' + ' '.repeat(indent * 2)\n\n if (\n types[2] === 'PageComponent' ||\n types[2] === 'LayoutComponent'\n ) {\n main += `The exported ${type} component isn't correctly typed.`\n } else {\n main += `Expected \"${bold(\n types[2].replace(\n '\"__invalid_negative_number__\"',\n 'number (>= 0)'\n )\n )}\", got \"${bold(types[1])}\".`\n }\n }\n break\n case 2326:\n const invalidConfig = item.messageText.match(\n /Types of property '(.+)' are incompatible\\./\n )\n main += '\\n' + ' '.repeat(indent * 2)\n main += `Invalid configuration${\n invalidConfig ? ` \"${bold(invalidConfig[1])}\"` : ''\n }:`\n break\n case 2530:\n const invalidField = item.messageText.match(\n /Property '(.+)' is incompatible with index signature/\n )\n if (invalidField) {\n main += '\\n' + ' '.repeat(indent * 2)\n main += `\"${bold(\n invalidField[1]\n )}\" is not a valid ${type} export field.`\n }\n return\n case 2739:\n const invalidProp = item.messageText.match(\n /Type '(.+)' is missing the following properties from type '(.+)'/\n )\n if (invalidProp) {\n if (\n invalidProp[1] === 'LayoutProps' ||\n invalidProp[1] === 'PageProps'\n ) {\n main += '\\n' + ' '.repeat(indent * 2)\n main += `Prop \"${invalidProp[2]}\" is incompatible with the ${type}.`\n }\n }\n break\n case 2559:\n const invalid = item.messageText.match(/Type '(.+)' has/)\n if (invalid) {\n main += '\\n' + ' '.repeat(indent * 2)\n main += `Type \"${bold(invalid[1])}\" isn't allowed.`\n }\n break\n case 2741:\n const incompatPageProp = item.messageText.match(\n /Property '(.+)' is missing in type 'PageProps'/\n )\n if (incompatPageProp) {\n main += '\\n' + ' '.repeat(indent * 2)\n main += `Prop \"${bold(\n incompatPageProp[1]\n )}\" will never be passed. Remove it from the component's props.`\n } else {\n const extraLayoutProp = item.messageText.match(\n /Property '(.+)' is missing in type 'LayoutProps' but required in type '(.+)'/\n )\n if (extraLayoutProp) {\n main += '\\n' + ' '.repeat(indent * 2)\n main += `Prop \"${bold(\n extraLayoutProp[1]\n )}\" is not valid for this Layout, remove it to fix.`\n }\n }\n break\n default:\n }\n\n processNext(indent + 1, item.next)\n }\n }\n\n if ('next' in message) processNext(1, message.next)\n return main\n }\n\n const invalidExportFnArg = messageText.match(\n /Type 'OmitWithTag<(.+), .+, \"(.+)\">' does not satisfy the constraint/\n )\n if (invalidExportFnArg) {\n const main = `${type} \"${bold(\n relativeSourceFilepath\n )}\" has an invalid \"${bold(\n invalidExportFnArg[2]\n )}\" export:\\n Type \"${bold(invalidExportFnArg[1])}\" is not valid.`\n return main\n }\n\n function processNextItems(\n indent: number,\n next?: import('typescript').DiagnosticMessageChain[]\n ) {\n if (!next) return ''\n\n let result = ''\n\n for (const item of next) {\n switch (item.code) {\n case 2322:\n const types = item.messageText.match(\n /Type '(.+)' is not assignable to type '(.+)'./\n )\n if (types) {\n result += '\\n' + ' '.repeat(indent * 2)\n result += `Expected \"${bold(types[2])}\", got \"${bold(\n types[1]\n )}\".`\n }\n break\n default:\n }\n\n result += processNextItems(indent + 1, item.next)\n }\n\n return result\n }\n\n const invalidParamFn = messageText.match(\n /Type '{ __tag__: (.+); __param_position__: \"(.*)\"; __param_type__: (.+); }' does not satisfy/\n )\n if (invalidParamFn) {\n let main = `${type} \"${bold(\n relativeSourceFilepath\n )}\" has an invalid ${invalidParamFn[1]} export:\\n Type \"${bold(\n invalidParamFn[3]\n )}\" is not a valid type for the function's ${\n invalidParamFn[2]\n } argument.`\n\n if ('next' in message) main += processNextItems(1, message.next)\n return main\n }\n\n const invalidExportFnReturn = messageText.match(\n /Type '{ __tag__: \"(.+)\"; __return_type__: (.+); }' does not satisfy/\n )\n if (invalidExportFnReturn) {\n let main = `${type} \"${bold(\n relativeSourceFilepath\n )}\" has an invalid export:\\n \"${bold(\n invalidExportFnReturn[2]\n )}\" is not a valid ${invalidExportFnReturn[1]} return type:`\n\n if ('next' in message) main += processNextItems(1, message.next)\n return main\n }\n\n break\n case 2345:\n const filepathAndInvalidExport = messageText.match(\n /'typeof import\\(\"(.+)\"\\)'.+Impossible<\"(.+)\">/\n )\n if (filepathAndInvalidExport) {\n const main = `${type} \"${bold(\n relativeSourceFilepath\n )}\" exports an invalid \"${bold(\n filepathAndInvalidExport[2]\n )}\" field. ${type} should only export a default React component and configuration options. Learn more: https://nextjs.org/docs/messages/invalid-segment-export`\n return main\n }\n break\n case 2559:\n const invalid = messageText.match(\n /Type '(.+)' has no properties in common with type '(.+)'/\n )\n if (invalid) {\n const main = `${type} \"${bold(\n relativeSourceFilepath\n )}\" contains an invalid type \"${bold(invalid[1])}\" as ${invalid[2]}.`\n return main\n }\n break\n default:\n }\n }\n}\n\nfunction getAppEntrySourceFilePath(\n baseDir: string,\n diagnostic: import('typescript').Diagnostic\n) {\n const sourceFilepath =\n diagnostic.file?.text.trim().match(/^\\/\\/ File: (.+)\\n/)?.[1] || ''\n\n return path.relative(baseDir, sourceFilepath)\n}\n\nexport function getFormattedDiagnostic(\n ts: typeof import('typescript'),\n baseDir: string,\n distDir: string,\n diagnostic: import('typescript').Diagnostic,\n isAppDirEnabled?: boolean\n): string {\n // If the error comes from .next/types/, we handle it specially.\n const isLayoutOrPageError =\n isAppDirEnabled &&\n diagnostic.file?.fileName.startsWith(path.join(baseDir, distDir, 'types'))\n\n let message = ''\n\n const appPath = isLayoutOrPageError\n ? getAppEntrySourceFilePath(baseDir, diagnostic)\n : null\n const linkReason = getFormattedLinkDiagnosticMessageText(diagnostic)\n const appReason =\n !linkReason && isLayoutOrPageError && appPath\n ? getFormattedLayoutAndPageDiagnosticMessageText(appPath, diagnostic)\n : null\n\n const reason =\n linkReason ||\n appReason ||\n ts.flattenDiagnosticMessageText(diagnostic.messageText, '\\n')\n const category = diagnostic.category\n switch (category) {\n // Warning\n case ts.DiagnosticCategory.Warning: {\n message += yellow(bold('Type warning')) + ': '\n break\n }\n // Error\n case ts.DiagnosticCategory.Error: {\n message += red(bold('Type error')) + ': '\n break\n }\n // 2 = Suggestion, 3 = Message\n case ts.DiagnosticCategory.Suggestion:\n case ts.DiagnosticCategory.Message:\n message += cyan(bold(category === 2 ? 'Suggestion' : 'Info')) + ': '\n break\n default: {\n category satisfies never\n }\n }\n\n message += reason + '\\n'\n\n if (!isLayoutOrPageError && diagnostic.file) {\n const { codeFrameColumns } =\n require('next/dist/compiled/babel/code-frame') as typeof import('next/dist/compiled/babel/code-frame')\n const pos = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start!)\n const line = pos.line + 1\n const character = pos.character + 1\n\n let fileName = path.posix.normalize(\n path.relative(baseDir, diagnostic.file.fileName).replace(/\\\\/g, '/')\n )\n if (!fileName.startsWith('.')) {\n fileName = './' + fileName\n }\n\n message =\n cyan(fileName) +\n ':' +\n yellow(line.toString()) +\n ':' +\n yellow(character.toString()) +\n '\\n' +\n message\n\n message +=\n '\\n' +\n codeFrameColumns(\n diagnostic.file.getFullText(diagnostic.file.getSourceFile()),\n {\n start: { line: line, column: character },\n },\n { forceColor: true }\n )\n } else if (isLayoutOrPageError && appPath) {\n message = cyan(appPath) + '\\n' + message\n }\n\n return message\n}\n"],"names":["getFormattedDiagnostic","getFormattedLinkDiagnosticMessageText","diagnostic","message","messageText","code","match","href","bold","relatedMessage","relatedInformation","suggestion","getFormattedLayoutAndPageDiagnosticMessageText","relativeSourceFilepath","type","test","filepathAndType","main","processNext","indent","next","item","mismatchedField","repeat","types","replace","invalidConfig","invalidField","invalidProp","invalid","incompatPageProp","extraLayoutProp","invalidExportFnArg","processNextItems","result","invalidParamFn","invalidExportFnReturn","filepathAndInvalidExport","getAppEntrySourceFilePath","baseDir","sourceFilepath","file","text","trim","path","relative","ts","distDir","isAppDirEnabled","isLayoutOrPageError","fileName","startsWith","join","appPath","linkReason","appReason","reason","flattenDiagnosticMessageText","category","DiagnosticCategory","Warning","yellow","Error","red","Suggestion","Message","cyan","codeFrameColumns","require","pos","getLineAndCharacterOfPosition","start","line","character","posix","normalize","toString","getFullText","getSourceFile","column","forceColor"],"mappings":";;;;+BA8SgBA;;;eAAAA;;;4BA9SwB;6DACvB;;;;;;AAEjB,SAASC,sCACPC,UAA2C;IAE3C,MAAMC,UAAUD,WAAWE,WAAW;IACtC,IAAI,OAAOD,YAAY,YAAYD,WAAWG,IAAI,KAAK,MAAM;QAC3D,MAAMC,QACJH,QAAQG,KAAK,CACX,6EAEFH,QAAQG,KAAK,CACX;QAGJ,IAAIA,OAAO;YACT,MAAM,GAAGC,KAAK,GAAGD;YACjB,OAAO,CAAC,CAAC,EAAEE,IAAAA,gBAAI,EACbD,MACA,8FAA8F,CAAC;QACnG,OAAO,IACLJ,YAAY,wDACZ;gBACuBD,iCAAAA;YAAvB,MAAMO,kBAAiBP,iCAAAA,WAAWQ,kBAAkB,sBAA7BR,kCAAAA,8BAA+B,CAAC,EAAE,qBAAlCA,gCAAoCE,WAAW;YACtE,IACE,OAAOK,mBAAmB,YAC1BA,eAAeH,KAAK,CAClB,wGAEF;gBACA,OAAO,CAAC,mIAAmI,CAAC;YAC9I;QACF;IACF,OAAO,IA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YAC7BD,WAAW,OAAOA;QACpB;QAEA/C,UACE+D,IAAAA,gBAAI,EAAChB,YACL,MACAW,IAAAA,kBAAM,EAACW,KAAKI,QAAQ,MACpB,MACAf,IAAAA,kBAAM,EAACY,UAAUG,QAAQ,MACzB,OACAzE;QAEFA,WACE,OACAgE,iBACEjE,WAAWuC,IAAI,CAACoC,WAAW,CAAC3E,WAAWuC,IAAI,CAACqC,aAAa,KACzD;YACEP,OAAO;gBAAEC,MAAMA;gBAAMO,QAAQN;YAAU;QACzC,GACA;YAAEO,YAAY;QAAK;IAEzB,OAAO,IAAI/B,uBAAuBI,SAAS;QACzClD,UAAU+D,IAAAA,gBAAI,EAACb,WAAW,OAAOlD;IACnC;IAEA,OAAOA;AACT","ignoreList":[0]}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "getTypeScriptConfiguration", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return getTypeScriptConfiguration;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _picocolors = require("../lib/picocolors");
|
|
12
|
+
const _os = /*#__PURE__*/ _interop_require_default(require("os"));
|
|
13
|
+
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
14
|
+
const _fatalerror = require("../errors/fatal-error");
|
|
15
|
+
const _iserror = /*#__PURE__*/ _interop_require_default(require("../errors/is-error"));
|
|
16
|
+
function _interop_require_default(obj) {
|
|
17
|
+
return obj && obj.__esModule ? obj : {
|
|
18
|
+
default: obj
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
async function getTypeScriptConfiguration(typescript, tsConfigPath, metaOnly) {
|
|
22
|
+
try {
|
|
23
|
+
var _result_errors;
|
|
24
|
+
const formatDiagnosticsHost = {
|
|
25
|
+
getCanonicalFileName: (fileName)=>fileName,
|
|
26
|
+
getCurrentDirectory: typescript.sys.getCurrentDirectory,
|
|
27
|
+
getNewLine: ()=>_os.default.EOL
|
|
28
|
+
};
|
|
29
|
+
const { config, error } = typescript.readConfigFile(tsConfigPath, typescript.sys.readFile);
|
|
30
|
+
if (error) {
|
|
31
|
+
throw Object.defineProperty(new _fatalerror.FatalError(typescript.formatDiagnostic(error, formatDiagnosticsHost)), "__NEXT_ERROR_CODE", {
|
|
32
|
+
value: "E394",
|
|
33
|
+
enumerable: false,
|
|
34
|
+
configurable: true
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
let configToParse = config;
|
|
38
|
+
const result = typescript.parseJsonConfigFileContent(configToParse, // When only interested in meta info,
|
|
39
|
+
// avoid enumerating all files (for performance reasons)
|
|
40
|
+
metaOnly ? {
|
|
41
|
+
...typescript.sys,
|
|
42
|
+
readDirectory (_path, extensions, _excludes, _includes, _depth) {
|
|
43
|
+
return [
|
|
44
|
+
extensions ? `file${extensions[0]}` : `file.ts`
|
|
45
|
+
];
|
|
46
|
+
}
|
|
47
|
+
} : typescript.sys, _path.default.dirname(tsConfigPath));
|
|
48
|
+
if (result.errors) {
|
|
49
|
+
result.errors = result.errors.filter(({ code })=>// No inputs were found in config file
|
|
50
|
+
code !== 18003);
|
|
51
|
+
}
|
|
52
|
+
if ((_result_errors = result.errors) == null ? void 0 : _result_errors.length) {
|
|
53
|
+
throw Object.defineProperty(new _fatalerror.FatalError(typescript.formatDiagnostic(result.errors[0], formatDiagnosticsHost)), "__NEXT_ERROR_CODE", {
|
|
54
|
+
value: "E394",
|
|
55
|
+
enumerable: false,
|
|
56
|
+
configurable: true
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
return result;
|
|
60
|
+
} catch (err) {
|
|
61
|
+
if ((0, _iserror.default)(err) && err.name === 'SyntaxError') {
|
|
62
|
+
const reason = '\n' + (err.message ?? '');
|
|
63
|
+
throw Object.defineProperty(new _fatalerror.FatalError((0, _picocolors.bold)('Could not parse' + (0, _picocolors.cyan)('tsconfig.json') + '.' + ' Please make sure it contains syntactically correct JSON.') + reason), "__NEXT_ERROR_CODE", {
|
|
64
|
+
value: "E339",
|
|
65
|
+
enumerable: false,
|
|
66
|
+
configurable: true
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
throw err;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
//# sourceMappingURL=getTypeScriptConfiguration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../typescript/getTypeScriptConfiguration.ts"],"sourcesContent":["import { bold, cyan } from '../lib/picocolors'\nimport os from 'os'\nimport path from 'path'\n\nimport { FatalError } from '../errors/fatal-error'\nimport isError from '../errors/is-error'\n\nexport async function getTypeScriptConfiguration(\n typescript: typeof import('typescript'),\n tsConfigPath: string,\n metaOnly?: boolean\n): Promise<import('typescript').ParsedCommandLine> {\n try {\n const formatDiagnosticsHost: import('typescript').FormatDiagnosticsHost = {\n getCanonicalFileName: (fileName: string) => fileName,\n getCurrentDirectory: typescript.sys.getCurrentDirectory,\n getNewLine: () => os.EOL,\n }\n\n const { config, error } = typescript.readConfigFile(\n tsConfigPath,\n typescript.sys.readFile\n )\n if (error) {\n throw new FatalError(\n typescript.formatDiagnostic(error, formatDiagnosticsHost)\n )\n }\n\n let configToParse: any = config\n\n const result = typescript.parseJsonConfigFileContent(\n configToParse,\n // When only interested in meta info,\n // avoid enumerating all files (for performance reasons)\n metaOnly\n ? {\n ...typescript.sys,\n readDirectory(_path, extensions, _excludes, _includes, _depth) {\n return [extensions ? `file${extensions[0]}` : `file.ts`]\n },\n }\n : typescript.sys,\n path.dirname(tsConfigPath)\n )\n\n if (result.errors) {\n result.errors = result.errors.filter(\n ({ code }) =>\n // No inputs were found in config file\n code !== 18003\n )\n }\n\n if (result.errors?.length) {\n throw new FatalError(\n typescript.formatDiagnostic(result.errors[0], formatDiagnosticsHost)\n )\n }\n\n return result\n } catch (err) {\n if (isError(err) && err.name === 'SyntaxError') {\n const reason = '\\n' + (err.message ?? '')\n throw new FatalError(\n bold(\n 'Could not parse' +\n cyan('tsconfig.json') +\n '.' +\n ' Please make sure it contains syntactically correct JSON.'\n ) + reason\n )\n }\n throw err\n }\n}\n"],"names":["getTypeScriptConfiguration","typescript","tsConfigPath","metaOnly","result","formatDiagnosticsHost","getCanonicalFileName","fileName","getCurrentDirectory","sys","getNewLine","os","EOL","config","error","readConfigFile","readFile","FatalError","formatDiagnostic","configToParse","parseJsonConfigFileContent","readDirectory","_path","extensions","_excludes","_includes","_depth","path","dirname","errors","filter","code","length","err","isError","name","reason","message","bold","cyan"],"mappings":";;;;+BAOsBA;;;eAAAA;;;4BAPK;2DACZ;6DACE;4BAEU;gEACP;;;;;;AAEb,eAAeA,2BACpBC,UAAuC,EACvCC,YAAoB,EACpBC,QAAkB;IAElB,IAAI;YA0CEC;QAzCJ,MAAMC,wBAAoE;YACxEC,sBAAsB,CAACC,WAAqBA;YAC5CC,qBAAqBP,WAAWQ,GAAG,CAACD,mBAAmB;YACvDE,YAAY,IAAMC,WAAE,CAACC,GAAG;QAC1B;QAEA,MAAM,EAAEC,MAAM,EAAEC,KAAK,EAAE,GAAGb,WAAWc,cAAc,CACjDb,cACAD,WAAWQ,GAAG,CAACO,QAAQ;QAEzB,IAAIF,OAAO;YACT,MAAM,qBAEL,CAFK,IAAIG,sBAAU,CAClBhB,WAAWiB,gBAAgB,CAACJ,OAAOT,yBAD/B,qBAAA;uBAAA;4BAAA;8BAAA;YAEN;QACF;QAEA,IAAIc,gBAAqBN;QAEzB,MAAMT,SAASH,WAAWmB,0BAA0B,CAClDD,eACA,qCAAqC;QACrC,wDAAwD;QACxDhB,WACI;YACE,GAAGF,WAAWQ,GAAG;YACjBY,eAAcC,KAAK,EAAEC,UAAU,EAAEC,SAAS,EAAEC,SAAS,EAAEC,MAAM;gBAC3D,OAAO;oBAACH,aAAa,CAAC,IAAI,EAAEA,UAAU,CAAC,EAAE,EAAE,GAAG,CAAC,OAAO,CAAC;iBAAC;YAC1D;QACF,IACAtB,WAAWQ,GAAG,EAClBkB,aAAI,CAACC,OAAO,CAAC1B;QAGf,IAAIE,OAAOyB,MAAM,EAAE;YACjBzB,OAAOyB,MAAM,GAAGzB,OAAOyB,MAAM,CAACC,MAAM,CAClC,CAAC,EAAEC,IAAI,EAAE,GACP,sCAAsC;gBACtCA,SAAS;QAEf;QAEA,KAAI3B,iBAAAA,OAAOyB,MAAM,qBAAbzB,eAAe4B,MAAM,EAAE;YACzB,MAAM,qBAEL,CAFK,IAAIf,sBAAU,CAClBhB,WAAWiB,gBAAgB,CAACd,OAAOyB,MAAM,CAAC,EAAE,EAAExB,yBAD1C,qBAAA;uBAAA;4BAAA;8BAAA;YAEN;QACF;QAEA,OAAOD;IACT,EAAE,OAAO6B,KAAK;QACZ,IAAIC,IAAAA,gBAAO,EAACD,QAAQA,IAAIE,IAAI,KAAK,eAAe;YAC9C,MAAMC,SAAS,OAAQH,CAAAA,IAAII,OAAO,IAAI,EAAC;YACvC,MAAM,qBAOL,CAPK,IAAIpB,sBAAU,CAClBqB,IAAAA,gBAAI,EACF,oBACEC,IAAAA,gBAAI,EAAC,mBACL,MACA,+DACAH,SANA,qBAAA;uBAAA;4BAAA;8BAAA;YAON;QACF;QACA,MAAMH;IACR;AACF","ignoreList":[0]}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "getTypeScriptIntent", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return getTypeScriptIntent;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _fs = require("fs");
|
|
12
|
+
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
13
|
+
const _recursivereaddir = require("../lib/recursive-readdir");
|
|
14
|
+
function _interop_require_default(obj) {
|
|
15
|
+
return obj && obj.__esModule ? obj : {
|
|
16
|
+
default: obj
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
async function getTypeScriptIntent(baseDir, intentDirs, tsconfigPath) {
|
|
20
|
+
const resolvedTsConfigPath = _path.default.join(baseDir, tsconfigPath);
|
|
21
|
+
// The integration turns on if we find a `tsconfig.json` in the user's
|
|
22
|
+
// project.
|
|
23
|
+
const hasTypeScriptConfiguration = (0, _fs.existsSync)(resolvedTsConfigPath);
|
|
24
|
+
if (hasTypeScriptConfiguration) {
|
|
25
|
+
const content = (0, _fs.readFileSync)(resolvedTsConfigPath, {
|
|
26
|
+
encoding: 'utf8'
|
|
27
|
+
}).trim();
|
|
28
|
+
return {
|
|
29
|
+
firstTimeSetup: content === '' || content === '{}'
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
// Next.js also offers a friendly setup mode that bootstraps a TypeScript
|
|
33
|
+
// project for the user when we detect TypeScript files. So, we need to check
|
|
34
|
+
// the `pages/` directory for a TypeScript file.
|
|
35
|
+
// Checking all directories is too slow, so this is a happy medium.
|
|
36
|
+
const tsFilesRegex = /.*\.(ts|tsx)$/;
|
|
37
|
+
const excludedRegex = /(node_modules|.*\.d\.ts$)/;
|
|
38
|
+
for (const dir of intentDirs){
|
|
39
|
+
const typescriptFiles = await (0, _recursivereaddir.recursiveReadDir)(dir, {
|
|
40
|
+
pathnameFilter: (name)=>tsFilesRegex.test(name),
|
|
41
|
+
ignoreFilter: (name)=>excludedRegex.test(name)
|
|
42
|
+
});
|
|
43
|
+
if (typescriptFiles.length) {
|
|
44
|
+
return {
|
|
45
|
+
firstTimeSetup: true
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
//# sourceMappingURL=getTypeScriptIntent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../typescript/getTypeScriptIntent.ts"],"sourcesContent":["import { existsSync, readFileSync } from 'fs'\nimport path from 'path'\nimport { recursiveReadDir } from '../lib/recursive-readdir'\n\nexport type TypeScriptIntent = { firstTimeSetup: boolean }\n\nexport async function getTypeScriptIntent(\n baseDir: string,\n intentDirs: string[],\n tsconfigPath: string\n): Promise<TypeScriptIntent | false> {\n const resolvedTsConfigPath = path.join(baseDir, tsconfigPath)\n\n // The integration turns on if we find a `tsconfig.json` in the user's\n // project.\n const hasTypeScriptConfiguration = existsSync(resolvedTsConfigPath)\n if (hasTypeScriptConfiguration) {\n const content = readFileSync(resolvedTsConfigPath, {\n encoding: 'utf8',\n }).trim()\n\n return { firstTimeSetup: content === '' || content === '{}' }\n }\n\n // Next.js also offers a friendly setup mode that bootstraps a TypeScript\n // project for the user when we detect TypeScript files. So, we need to check\n // the `pages/` directory for a TypeScript file.\n // Checking all directories is too slow, so this is a happy medium.\n const tsFilesRegex = /.*\\.(ts|tsx)$/\n const excludedRegex = /(node_modules|.*\\.d\\.ts$)/\n for (const dir of intentDirs) {\n const typescriptFiles = await recursiveReadDir(dir, {\n pathnameFilter: (name) => tsFilesRegex.test(name),\n ignoreFilter: (name) => excludedRegex.test(name),\n })\n if (typescriptFiles.length) {\n return { firstTimeSetup: true }\n }\n }\n\n return false\n}\n"],"names":["getTypeScriptIntent","baseDir","intentDirs","tsconfigPath","resolvedTsConfigPath","path","join","hasTypeScriptConfiguration","existsSync","content","readFileSync","encoding","trim","firstTimeSetup","tsFilesRegex","excludedRegex","dir","typescriptFiles","recursiveReadDir","pathnameFilter","name","test","ignoreFilter","length"],"mappings":";;;;+BAMsBA;;;eAAAA;;;oBANmB;6DACxB;kCACgB;;;;;;AAI1B,eAAeA,oBACpBC,OAAe,EACfC,UAAoB,EACpBC,YAAoB;IAEpB,MAAMC,uBAAuBC,aAAI,CAACC,IAAI,CAACL,SAASE;IAEhD,sEAAsE;IACtE,WAAW;IACX,MAAMI,6BAA6BC,IAAAA,cAAU,EAACJ;IAC9C,IAAIG,4BAA4B;QAC9B,MAAME,UAAUC,IAAAA,gBAAY,EAACN,sBAAsB;YACjDO,UAAU;QACZ,GAAGC,IAAI;QAEP,OAAO;YAAEC,gBAAgBJ,YAAY,MAAMA,YAAY;QAAK;IAC9D;IAEA,yEAAyE;IACzE,6EAA6E;IAC7E,gDAAgD;IAChD,mEAAmE;IACnE,MAAMK,eAAe;IACrB,MAAMC,gBAAgB;IACtB,KAAK,MAAMC,OAAOd,WAAY;QAC5B,MAAMe,kBAAkB,MAAMC,IAAAA,kCAAgB,EAACF,KAAK;YAClDG,gBAAgB,CAACC,OAASN,aAAaO,IAAI,CAACD;YAC5CE,cAAc,CAACF,OAASL,cAAcM,IAAI,CAACD;QAC7C;QACA,IAAIH,gBAAgBM,MAAM,EAAE;YAC1B,OAAO;gBAAEV,gBAAgB;YAAK;QAChC;IACF;IAEA,OAAO;AACT","ignoreList":[0]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "missingDepsError", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return missingDepsError;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _picocolors = require("../lib/picocolors");
|
|
12
|
+
const _oxfordcommalist = require("../lib/oxford-comma-list");
|
|
13
|
+
const _fatalerror = require("../errors/fatal-error");
|
|
14
|
+
const _getpkgmanager = require("../lib/helpers/get-pkg-manager");
|
|
15
|
+
function missingDepsError(dir, missingPackages) {
|
|
16
|
+
const packagesHuman = (0, _oxfordcommalist.getOxfordCommaList)(missingPackages.map((p)=>p.pkg));
|
|
17
|
+
const packagesCli = missingPackages.map((p)=>p.pkg).join(' ');
|
|
18
|
+
const packageManager = (0, _getpkgmanager.getPkgManager)(dir);
|
|
19
|
+
const removalMsg = '\n\n' + (0, _picocolors.bold)('If you are not trying to use TypeScript, please remove the ' + (0, _picocolors.cyan)('tsconfig.json') + ' file from your package root (and any TypeScript files in your app and pages directories).');
|
|
20
|
+
throw Object.defineProperty(new _fatalerror.FatalError((0, _picocolors.bold)((0, _picocolors.red)(`It looks like you're trying to use TypeScript but do not have the required package(s) installed.`)) + '\n\n' + (0, _picocolors.bold)(`Please install ${(0, _picocolors.bold)(packagesHuman)} by running:`) + '\n\n' + `\t${(0, _picocolors.bold)((0, _picocolors.cyan)((packageManager === 'yarn' ? 'yarn add --dev' : packageManager === 'pnpm' ? 'pnpm install --save-dev' : 'npm install --save-dev') + ' ' + packagesCli))}` + removalMsg + '\n'), "__NEXT_ERROR_CODE", {
|
|
21
|
+
value: "E532",
|
|
22
|
+
enumerable: false,
|
|
23
|
+
configurable: true
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=missingDependencyError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../typescript/missingDependencyError.ts"],"sourcesContent":["import { bold, cyan, red } from '../lib/picocolors'\n\nimport { getOxfordCommaList } from '../lib/oxford-comma-list'\nimport type { MissingDependency } from '../lib/has-necessary-dependencies'\nimport { FatalError } from '../errors/fatal-error'\nimport { getPkgManager } from '../lib/helpers/get-pkg-manager'\n\nexport function missingDepsError(\n dir: string,\n missingPackages: MissingDependency[]\n): never {\n const packagesHuman = getOxfordCommaList(missingPackages.map((p) => p.pkg))\n const packagesCli = missingPackages.map((p) => p.pkg).join(' ')\n const packageManager = getPkgManager(dir)\n\n const removalMsg =\n '\\n\\n' +\n bold(\n 'If you are not trying to use TypeScript, please remove the ' +\n cyan('tsconfig.json') +\n ' file from your package root (and any TypeScript files in your app and pages directories).'\n )\n\n throw new FatalError(\n bold(\n red(\n `It looks like you're trying to use TypeScript but do not have the required package(s) installed.`\n )\n ) +\n '\\n\\n' +\n bold(`Please install ${bold(packagesHuman)} by running:`) +\n '\\n\\n' +\n `\\t${bold(\n cyan(\n (packageManager === 'yarn'\n ? 'yarn add --dev'\n : packageManager === 'pnpm'\n ? 'pnpm install --save-dev'\n : 'npm install --save-dev') +\n ' ' +\n packagesCli\n )\n )}` +\n removalMsg +\n '\\n'\n )\n}\n"],"names":["missingDepsError","dir","missingPackages","packagesHuman","getOxfordCommaList","map","p","pkg","packagesCli","join","packageManager","getPkgManager","removalMsg","bold","cyan","FatalError","red"],"mappings":";;;;+BAOgBA;;;eAAAA;;;4BAPgB;iCAEG;4BAER;+BACG;AAEvB,SAASA,iBACdC,GAAW,EACXC,eAAoC;IAEpC,MAAMC,gBAAgBC,IAAAA,mCAAkB,EAACF,gBAAgBG,GAAG,CAAC,CAACC,IAAMA,EAAEC,GAAG;IACzE,MAAMC,cAAcN,gBAAgBG,GAAG,CAAC,CAACC,IAAMA,EAAEC,GAAG,EAAEE,IAAI,CAAC;IAC3D,MAAMC,iBAAiBC,IAAAA,4BAAa,EAACV;IAErC,MAAMW,aACJ,SACAC,IAAAA,gBAAI,EACF,gEACEC,IAAAA,gBAAI,EAAC,mBACL;IAGN,MAAM,qBAsBL,CAtBK,IAAIC,sBAAU,CAClBF,IAAAA,gBAAI,EACFG,IAAAA,eAAG,EACD,CAAC,gGAAgG,CAAC,KAGpG,SACAH,IAAAA,gBAAI,EAAC,CAAC,eAAe,EAAEA,IAAAA,gBAAI,EAACV,eAAe,YAAY,CAAC,IACxD,SACA,CAAC,EAAE,EAAEU,IAAAA,gBAAI,EACPC,IAAAA,gBAAI,EACF,AAACJ,CAAAA,mBAAmB,SAChB,mBACAA,mBAAmB,SACjB,4BACA,wBAAuB,IAC3B,MACAF,eAEH,GACHI,aACA,OArBE,qBAAA;eAAA;oBAAA;sBAAA;IAsBN;AACF","ignoreList":[0]}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "runTypeCheck", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return runTypeCheck;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
12
|
+
const _diagnosticFormatter = require("./diagnosticFormatter");
|
|
13
|
+
const _getTypeScriptConfiguration = require("./getTypeScriptConfiguration");
|
|
14
|
+
const _writeConfigurationDefaults = require("./writeConfigurationDefaults");
|
|
15
|
+
const _compileerror = require("../errors/compile-error");
|
|
16
|
+
const _log = require("../build/output/log");
|
|
17
|
+
function _interop_require_default(obj) {
|
|
18
|
+
return obj && obj.__esModule ? obj : {
|
|
19
|
+
default: obj
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
async function runTypeCheck(typescript, baseDir, distDir, tsConfigPath, cacheDir, isAppDirEnabled) {
|
|
23
|
+
const effectiveConfiguration = await (0, _getTypeScriptConfiguration.getTypeScriptConfiguration)(typescript, tsConfigPath);
|
|
24
|
+
if (effectiveConfiguration.fileNames.length < 1) {
|
|
25
|
+
return {
|
|
26
|
+
hasWarnings: false,
|
|
27
|
+
inputFilesCount: 0,
|
|
28
|
+
totalFilesCount: 0,
|
|
29
|
+
incremental: false
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
const requiredConfig = (0, _writeConfigurationDefaults.getRequiredConfiguration)(typescript);
|
|
33
|
+
const options = {
|
|
34
|
+
...requiredConfig,
|
|
35
|
+
...effectiveConfiguration.options,
|
|
36
|
+
declarationMap: false,
|
|
37
|
+
emitDeclarationOnly: false,
|
|
38
|
+
noEmit: true
|
|
39
|
+
};
|
|
40
|
+
let program;
|
|
41
|
+
let incremental = false;
|
|
42
|
+
if ((options.incremental || options.composite) && cacheDir) {
|
|
43
|
+
if (options.composite) {
|
|
44
|
+
(0, _log.warn)('TypeScript project references are not fully supported. Attempting to build in incremental mode.');
|
|
45
|
+
}
|
|
46
|
+
incremental = true;
|
|
47
|
+
program = typescript.createIncrementalProgram({
|
|
48
|
+
rootNames: effectiveConfiguration.fileNames,
|
|
49
|
+
options: {
|
|
50
|
+
...options,
|
|
51
|
+
composite: false,
|
|
52
|
+
incremental: true,
|
|
53
|
+
tsBuildInfoFile: _path.default.join(cacheDir, '.tsbuildinfo')
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
} else {
|
|
57
|
+
program = typescript.createProgram(effectiveConfiguration.fileNames, options);
|
|
58
|
+
}
|
|
59
|
+
const result = program.emit();
|
|
60
|
+
const ignoreRegex = [
|
|
61
|
+
// matches **/__(tests|mocks)__/**
|
|
62
|
+
/[\\/]__(?:tests|mocks)__[\\/]/,
|
|
63
|
+
// matches **/*.(spec|test).*
|
|
64
|
+
/(?<=[\\/.])(?:spec|test)\.[^\\/]+$/
|
|
65
|
+
];
|
|
66
|
+
const regexIgnoredFile = new RegExp(ignoreRegex.map((r)=>r.source).join('|'));
|
|
67
|
+
const allDiagnostics = typescript.getPreEmitDiagnostics(program).concat(result.diagnostics).filter((d)=>!(d.file && regexIgnoredFile.test(d.file.fileName)));
|
|
68
|
+
const firstError = allDiagnostics.find((d)=>d.category === typescript.DiagnosticCategory.Error && Boolean(d.file)) ?? allDiagnostics.find((d)=>d.category === typescript.DiagnosticCategory.Error);
|
|
69
|
+
// In test mode, we want to check all diagnostics, not just the first one.
|
|
70
|
+
if (process.env.__NEXT_TEST_MODE) {
|
|
71
|
+
if (firstError) {
|
|
72
|
+
const allErrors = allDiagnostics.filter((d)=>d.category === typescript.DiagnosticCategory.Error).map((d)=>'[Test Mode] ' + (0, _diagnosticFormatter.getFormattedDiagnostic)(typescript, baseDir, distDir, d, isAppDirEnabled));
|
|
73
|
+
console.error('\n\n===== TS errors =====\n\n' + allErrors.join('\n\n') + '\n\n===== TS errors =====\n\n');
|
|
74
|
+
// Make sure all stdout is flushed before we exit.
|
|
75
|
+
await new Promise((resolve)=>setTimeout(resolve, 100));
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
if (firstError) {
|
|
79
|
+
throw Object.defineProperty(new _compileerror.CompileError((0, _diagnosticFormatter.getFormattedDiagnostic)(typescript, baseDir, distDir, firstError, isAppDirEnabled)), "__NEXT_ERROR_CODE", {
|
|
80
|
+
value: "E394",
|
|
81
|
+
enumerable: false,
|
|
82
|
+
configurable: true
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
const warnings = allDiagnostics.filter((d)=>d.category === typescript.DiagnosticCategory.Warning).map((d)=>(0, _diagnosticFormatter.getFormattedDiagnostic)(typescript, baseDir, distDir, d, isAppDirEnabled));
|
|
86
|
+
return {
|
|
87
|
+
hasWarnings: true,
|
|
88
|
+
warnings,
|
|
89
|
+
inputFilesCount: effectiveConfiguration.fileNames.length,
|
|
90
|
+
totalFilesCount: program.getSourceFiles().length,
|
|
91
|
+
incremental
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
//# sourceMappingURL=runTypeCheck.js.map
|