inital commit

This commit is contained in:
2026-01-01 15:25:19 +05:30
commit f0ae49465a
36361 changed files with 4894111 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
import type { webpack } from 'next/dist/compiled/webpack/webpack';
export declare function formatModuleTrace(compiler: webpack.Compiler, moduleTrace: any[]): {
lastInternalFileName: string;
invalidImportMessage: string;
formattedModuleTrace: string;
};
export declare function getModuleTrace(module: any, compilation: webpack.Compilation, compiler: webpack.Compiler): {
moduleTrace: any[];
isPagesDir: boolean;
};

View File

@@ -0,0 +1,89 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
formatModuleTrace: null,
getModuleTrace: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
formatModuleTrace: function() {
return formatModuleTrace;
},
getModuleTrace: function() {
return getModuleTrace;
}
});
const _loaderutils3 = /*#__PURE__*/ _interop_require_default(require("next/dist/compiled/loader-utils3"));
const _path = require("path");
function _interop_require_default(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
function formatModule(compiler, module1) {
const relativePath = (0, _path.relative)(compiler.context, module1.resource).replace(/\?.+$/, '');
return _loaderutils3.default.isUrlRequest(relativePath) ? _loaderutils3.default.urlToRequest(relativePath) : relativePath;
}
function formatModuleTrace(compiler, moduleTrace) {
let importTrace = [];
let firstExternalModule;
for(let i = moduleTrace.length - 1; i >= 0; i--){
const mod = moduleTrace[i];
if (!mod.resource) continue;
if (!mod.resource.includes('node_modules/')) {
importTrace.unshift(formatModule(compiler, mod));
} else {
firstExternalModule = mod;
break;
}
}
let invalidImportMessage = '';
if (firstExternalModule) {
var _firstExternalModule_resourceResolveData_descriptionFileData, _firstExternalModule_resourceResolveData;
const firstExternalPackageName = (_firstExternalModule_resourceResolveData = firstExternalModule.resourceResolveData) == null ? void 0 : (_firstExternalModule_resourceResolveData_descriptionFileData = _firstExternalModule_resourceResolveData.descriptionFileData) == null ? void 0 : _firstExternalModule_resourceResolveData_descriptionFileData.name;
if (firstExternalPackageName === 'styled-jsx') {
invalidImportMessage += `\n\nThe error was caused by using 'styled-jsx' in '${importTrace[0]}'. It only works in a Client Component but none of its parents are marked with "use client", so they're Server Components by default.`;
} else {
let formattedExternalFile = firstExternalModule.resource.split('node_modules');
formattedExternalFile = formattedExternalFile[formattedExternalFile.length - 1];
invalidImportMessage += `\n\nThe error was caused by importing '${formattedExternalFile.slice(1)}' in '${importTrace[0]}'.`;
}
}
return {
lastInternalFileName: importTrace[0],
invalidImportMessage,
formattedModuleTrace: importTrace.map((mod)=>' ' + mod).join('\n')
};
}
function getModuleTrace(module1, compilation, compiler) {
// Get the module trace:
// https://cs.github.com/webpack/webpack/blob/9fcaa243573005d6fdece9a3f8d89a0e8b399613/lib/stats/DefaultStatsFactoryPlugin.js#L414
const visitedModules = new Set();
const moduleTrace = [];
let current = module1;
let isPagesDir = false;
while(current){
if (visitedModules.has(current)) break;
if (/[\\/]pages/.test(current.resource.replace(compiler.context, ''))) {
isPagesDir = true;
}
visitedModules.add(current);
moduleTrace.push(current);
const origin = compilation.moduleGraph.getIssuer(current);
if (!origin) break;
current = origin;
}
return {
moduleTrace,
isPagesDir
};
}
//# sourceMappingURL=getModuleTrace.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,4 @@
import type { webpack } from 'next/dist/compiled/webpack/webpack';
export declare class WellKnownErrorsPlugin {
apply(compiler: webpack.Compiler): void;
}

View File

@@ -0,0 +1,43 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "WellKnownErrorsPlugin", {
enumerable: true,
get: function() {
return WellKnownErrorsPlugin;
}
});
const _webpackModuleError = require("./webpackModuleError");
const NAME = 'WellKnownErrorsPlugin';
class WellKnownErrorsPlugin {
apply(compiler) {
compiler.hooks.compilation.tap(NAME, (compilation)=>{
compilation.hooks.afterSeal.tapPromise(NAME, async ()=>{
var _compilation_warnings, _compilation_errors;
if ((_compilation_warnings = compilation.warnings) == null ? void 0 : _compilation_warnings.length) {
await Promise.all(compilation.warnings.map(async (warn, i)=>{
var _warn_module_context, _warn_module;
if (warn.name === 'ModuleDependencyWarning' && ((_warn_module = warn.module) == null ? void 0 : (_warn_module_context = _warn_module.context) == null ? void 0 : _warn_module_context.includes('node_modules'))) {
compilation.warnings.splice(i, 1);
}
}));
}
if ((_compilation_errors = compilation.errors) == null ? void 0 : _compilation_errors.length) {
await Promise.all(compilation.errors.map(async (err, i)=>{
try {
const moduleError = await (0, _webpackModuleError.getModuleBuildError)(compiler, compilation, err);
if (moduleError !== false) {
compilation.errors[i] = moduleError;
}
} catch (e) {
console.log(e);
}
}));
}
});
});
}
}
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../src/build/webpack/plugins/wellknown-errors-plugin/index.ts"],"sourcesContent":["import type { webpack } from 'next/dist/compiled/webpack/webpack'\n\nimport { getModuleBuildError } from './webpackModuleError'\n\nconst NAME = 'WellKnownErrorsPlugin'\nexport class WellKnownErrorsPlugin {\n apply(compiler: webpack.Compiler) {\n compiler.hooks.compilation.tap(NAME, (compilation) => {\n compilation.hooks.afterSeal.tapPromise(NAME, async () => {\n if (compilation.warnings?.length) {\n await Promise.all(\n compilation.warnings.map(async (warn, i) => {\n if (\n warn.name === 'ModuleDependencyWarning' &&\n warn.module?.context?.includes('node_modules')\n ) {\n compilation.warnings.splice(i, 1)\n }\n })\n )\n }\n\n if (compilation.errors?.length) {\n await Promise.all(\n compilation.errors.map(async (err, i) => {\n try {\n const moduleError = await getModuleBuildError(\n compiler,\n compilation,\n err\n )\n if (moduleError !== false) {\n compilation.errors[i] = moduleError\n }\n } catch (e) {\n console.log(e)\n }\n })\n )\n }\n })\n })\n }\n}\n"],"names":["WellKnownErrorsPlugin","NAME","apply","compiler","hooks","compilation","tap","afterSeal","tapPromise","warnings","length","Promise","all","map","warn","i","name","module","context","includes","splice","errors","err","moduleError","getModuleBuildError","e","console","log"],"mappings":";;;;+BAKaA;;;eAAAA;;;oCAHuB;AAEpC,MAAMC,OAAO;AACN,MAAMD;IACXE,MAAMC,QAA0B,EAAE;QAChCA,SAASC,KAAK,CAACC,WAAW,CAACC,GAAG,CAACL,MAAM,CAACI;YACpCA,YAAYD,KAAK,CAACG,SAAS,CAACC,UAAU,CAACP,MAAM;oBACvCI,uBAaAA;gBAbJ,KAAIA,wBAAAA,YAAYI,QAAQ,qBAApBJ,sBAAsBK,MAAM,EAAE;oBAChC,MAAMC,QAAQC,GAAG,CACfP,YAAYI,QAAQ,CAACI,GAAG,CAAC,OAAOC,MAAMC;4BAGlCD,sBAAAA;wBAFF,IACEA,KAAKE,IAAI,KAAK,+BACdF,eAAAA,KAAKG,MAAM,sBAAXH,uBAAAA,aAAaI,OAAO,qBAApBJ,qBAAsBK,QAAQ,CAAC,kBAC/B;4BACAd,YAAYI,QAAQ,CAACW,MAAM,CAACL,GAAG;wBACjC;oBACF;gBAEJ;gBAEA,KAAIV,sBAAAA,YAAYgB,MAAM,qBAAlBhB,oBAAoBK,MAAM,EAAE;oBAC9B,MAAMC,QAAQC,GAAG,CACfP,YAAYgB,MAAM,CAACR,GAAG,CAAC,OAAOS,KAAKP;wBACjC,IAAI;4BACF,MAAMQ,cAAc,MAAMC,IAAAA,uCAAmB,EAC3CrB,UACAE,aACAiB;4BAEF,IAAIC,gBAAgB,OAAO;gCACzBlB,YAAYgB,MAAM,CAACN,EAAE,GAAGQ;4BAC1B;wBACF,EAAE,OAAOE,GAAG;4BACVC,QAAQC,GAAG,CAACF;wBACd;oBACF;gBAEJ;YACF;QACF;IACF;AACF"}

View File

@@ -0,0 +1,3 @@
import type { webpack } from 'next/dist/compiled/webpack/webpack';
import { SimpleWebpackError } from './simpleWebpackError';
export declare function getDynamicCodeEvaluationError(message: string, module: webpack.NormalModule, compilation: webpack.Compilation, compiler: webpack.Compiler): SimpleWebpackError;

View File

@@ -0,0 +1,19 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "getDynamicCodeEvaluationError", {
enumerable: true,
get: function() {
return getDynamicCodeEvaluationError;
}
});
const _getModuleTrace = require("./getModuleTrace");
const _simpleWebpackError = require("./simpleWebpackError");
function getDynamicCodeEvaluationError(message, module, compilation, compiler) {
const { moduleTrace } = (0, _getModuleTrace.getModuleTrace)(module, compilation, compiler);
const { formattedModuleTrace, lastInternalFileName, invalidImportMessage } = (0, _getModuleTrace.formatModuleTrace)(compiler, moduleTrace);
return new _simpleWebpackError.SimpleWebpackError(lastInternalFileName, message + invalidImportMessage + '\n\nImport trace for requested module:\n' + formattedModuleTrace);
}
//# sourceMappingURL=parse-dynamic-code-evaluation-error.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../src/build/webpack/plugins/wellknown-errors-plugin/parse-dynamic-code-evaluation-error.ts"],"sourcesContent":["import type { webpack } from 'next/dist/compiled/webpack/webpack'\nimport { formatModuleTrace, getModuleTrace } from './getModuleTrace'\nimport { SimpleWebpackError } from './simpleWebpackError'\n\nexport function getDynamicCodeEvaluationError(\n message: string,\n module: webpack.NormalModule,\n compilation: webpack.Compilation,\n compiler: webpack.Compiler\n): SimpleWebpackError {\n const { moduleTrace } = getModuleTrace(module, compilation, compiler)\n const { formattedModuleTrace, lastInternalFileName, invalidImportMessage } =\n formatModuleTrace(compiler, moduleTrace)\n\n return new SimpleWebpackError(\n lastInternalFileName,\n message +\n invalidImportMessage +\n '\\n\\nImport trace for requested module:\\n' +\n formattedModuleTrace\n )\n}\n"],"names":["getDynamicCodeEvaluationError","message","module","compilation","compiler","moduleTrace","getModuleTrace","formattedModuleTrace","lastInternalFileName","invalidImportMessage","formatModuleTrace","SimpleWebpackError"],"mappings":";;;;+BAIgBA;;;eAAAA;;;gCAHkC;oCACf;AAE5B,SAASA,8BACdC,OAAe,EACfC,MAA4B,EAC5BC,WAAgC,EAChCC,QAA0B;IAE1B,MAAM,EAAEC,WAAW,EAAE,GAAGC,IAAAA,8BAAc,EAACJ,QAAQC,aAAaC;IAC5D,MAAM,EAAEG,oBAAoB,EAAEC,oBAAoB,EAAEC,oBAAoB,EAAE,GACxEC,IAAAA,iCAAiB,EAACN,UAAUC;IAE9B,OAAO,IAAIM,sCAAkB,CAC3BH,sBACAP,UACEQ,uBACA,6CACAF;AAEN"}

View File

@@ -0,0 +1,8 @@
import { SimpleWebpackError } from './simpleWebpackError';
export declare function getBabelError(fileName: string, err: Error & {
code?: string | number;
loc?: {
line: number;
column: number;
};
}): SimpleWebpackError | false;

View File

@@ -0,0 +1,29 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "getBabelError", {
enumerable: true,
get: function() {
return getBabelError;
}
});
const _picocolors = require("../../../../lib/picocolors");
const _simpleWebpackError = require("./simpleWebpackError");
function getBabelError(fileName, err) {
if (err.code !== 'BABEL_PARSE_ERROR') {
return false;
}
// https://github.com/babel/babel/blob/34693d6024da3f026534dd8d569f97ac0109602e/packages/babel-core/src/parser/index.js
if (err.loc) {
const lineNumber = Math.max(1, err.loc.line);
const column = Math.max(1, err.loc.column);
let message = err.message// Remove file information, which instead is provided by webpack.
.replace(/^.+?: /, '')// Remove column information from message
.replace(new RegExp(`[^\\S\\r\\n]*\\(${lineNumber}:${column}\\)[^\\S\\r\\n]*`), '');
return new _simpleWebpackError.SimpleWebpackError(`${(0, _picocolors.cyan)(fileName)}:${(0, _picocolors.yellow)(lineNumber.toString())}:${(0, _picocolors.yellow)(column.toString())}`, (0, _picocolors.red)((0, _picocolors.bold)('Syntax error')).concat(`: ${message}`));
}
return false;
}
//# sourceMappingURL=parseBabel.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../src/build/webpack/plugins/wellknown-errors-plugin/parseBabel.ts"],"sourcesContent":["import { bold, cyan, red, yellow } from '../../../../lib/picocolors'\nimport { SimpleWebpackError } from './simpleWebpackError'\n\nexport function getBabelError(\n fileName: string,\n err: Error & {\n code?: string | number\n loc?: { line: number; column: number }\n }\n): SimpleWebpackError | false {\n if (err.code !== 'BABEL_PARSE_ERROR') {\n return false\n }\n\n // https://github.com/babel/babel/blob/34693d6024da3f026534dd8d569f97ac0109602e/packages/babel-core/src/parser/index.js\n if (err.loc) {\n const lineNumber = Math.max(1, err.loc.line)\n const column = Math.max(1, err.loc.column)\n\n let message = err.message\n // Remove file information, which instead is provided by webpack.\n .replace(/^.+?: /, '')\n // Remove column information from message\n .replace(\n new RegExp(`[^\\\\S\\\\r\\\\n]*\\\\(${lineNumber}:${column}\\\\)[^\\\\S\\\\r\\\\n]*`),\n ''\n )\n\n return new SimpleWebpackError(\n `${cyan(fileName)}:${yellow(lineNumber.toString())}:${yellow(\n column.toString()\n )}`,\n red(bold('Syntax error')).concat(`: ${message}`)\n )\n }\n\n return false\n}\n"],"names":["getBabelError","fileName","err","code","loc","lineNumber","Math","max","line","column","message","replace","RegExp","SimpleWebpackError","cyan","yellow","toString","red","bold","concat"],"mappings":";;;;+BAGgBA;;;eAAAA;;;4BAHwB;oCACL;AAE5B,SAASA,cACdC,QAAgB,EAChBC,GAGC;IAED,IAAIA,IAAIC,IAAI,KAAK,qBAAqB;QACpC,OAAO;IACT;IAEA,uHAAuH;IACvH,IAAID,IAAIE,GAAG,EAAE;QACX,MAAMC,aAAaC,KAAKC,GAAG,CAAC,GAAGL,IAAIE,GAAG,CAACI,IAAI;QAC3C,MAAMC,SAASH,KAAKC,GAAG,CAAC,GAAGL,IAAIE,GAAG,CAACK,MAAM;QAEzC,IAAIC,UAAUR,IAAIQ,OAAO,AACvB,iEAAiE;SAChEC,OAAO,CAAC,UAAU,GACnB,yCAAyC;SACxCA,OAAO,CACN,IAAIC,OAAO,CAAC,gBAAgB,EAAEP,WAAW,CAAC,EAAEI,OAAO,gBAAgB,CAAC,GACpE;QAGJ,OAAO,IAAII,sCAAkB,CAC3B,GAAGC,IAAAA,gBAAI,EAACb,UAAU,CAAC,EAAEc,IAAAA,kBAAM,EAACV,WAAWW,QAAQ,IAAI,CAAC,EAAED,IAAAA,kBAAM,EAC1DN,OAAOO,QAAQ,KACd,EACHC,IAAAA,eAAG,EAACC,IAAAA,gBAAI,EAAC,iBAAiBC,MAAM,CAAC,CAAC,EAAE,EAAET,SAAS;IAEnD;IAEA,OAAO;AACT"}

View File

@@ -0,0 +1,2 @@
import { SimpleWebpackError } from './simpleWebpackError';
export declare function getCssError(fileName: string, err: Error): SimpleWebpackError | false;

View File

@@ -0,0 +1,29 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "getCssError", {
enumerable: true,
get: function() {
return getCssError;
}
});
const _picocolors = require("../../../../lib/picocolors");
const _simpleWebpackError = require("./simpleWebpackError");
const regexCssError = /^(?:CssSyntaxError|SyntaxError)\n\n\((\d+):(\d*)\) (.*)$/s;
function getCssError(fileName, err) {
if (!((err.name === 'CssSyntaxError' || err.name === 'SyntaxError') && err.stack === false && !(err instanceof SyntaxError))) {
return false;
}
// https://github.com/postcss/postcss-loader/blob/d6931da177ac79707bd758436e476036a55e4f59/src/Error.js
const res = regexCssError.exec(err.message);
if (res) {
const [, _lineNumber, _column, reason] = res;
const lineNumber = Math.max(1, parseInt(_lineNumber, 10));
const column = Math.max(1, parseInt(_column, 10));
return new _simpleWebpackError.SimpleWebpackError(`${(0, _picocolors.cyan)(fileName)}:${(0, _picocolors.yellow)(lineNumber.toString())}:${(0, _picocolors.yellow)(column.toString())}`, (0, _picocolors.red)((0, _picocolors.bold)('Syntax error')).concat(`: ${reason}`));
}
return false;
}
//# sourceMappingURL=parseCss.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../src/build/webpack/plugins/wellknown-errors-plugin/parseCss.ts"],"sourcesContent":["import { bold, cyan, red, yellow } from '../../../../lib/picocolors'\nimport { SimpleWebpackError } from './simpleWebpackError'\n\nconst regexCssError =\n /^(?:CssSyntaxError|SyntaxError)\\n\\n\\((\\d+):(\\d*)\\) (.*)$/s\n\nexport function getCssError(\n fileName: string,\n err: Error\n): SimpleWebpackError | false {\n if (\n !(\n (err.name === 'CssSyntaxError' || err.name === 'SyntaxError') &&\n (err as any).stack === false &&\n !(err instanceof SyntaxError)\n )\n ) {\n return false\n }\n\n // https://github.com/postcss/postcss-loader/blob/d6931da177ac79707bd758436e476036a55e4f59/src/Error.js\n\n const res = regexCssError.exec(err.message)\n if (res) {\n const [, _lineNumber, _column, reason] = res\n const lineNumber = Math.max(1, parseInt(_lineNumber, 10))\n const column = Math.max(1, parseInt(_column, 10))\n\n return new SimpleWebpackError(\n `${cyan(fileName)}:${yellow(lineNumber.toString())}:${yellow(\n column.toString()\n )}`,\n red(bold('Syntax error')).concat(`: ${reason}`)\n )\n }\n\n return false\n}\n"],"names":["getCssError","regexCssError","fileName","err","name","stack","SyntaxError","res","exec","message","_lineNumber","_column","reason","lineNumber","Math","max","parseInt","column","SimpleWebpackError","cyan","yellow","toString","red","bold","concat"],"mappings":";;;;+BAMgBA;;;eAAAA;;;4BANwB;oCACL;AAEnC,MAAMC,gBACJ;AAEK,SAASD,YACdE,QAAgB,EAChBC,GAAU;IAEV,IACE,CACE,CAAA,AAACA,CAAAA,IAAIC,IAAI,KAAK,oBAAoBD,IAAIC,IAAI,KAAK,aAAY,KAC3D,AAACD,IAAYE,KAAK,KAAK,SACvB,CAAEF,CAAAA,eAAeG,WAAU,CAAC,GAE9B;QACA,OAAO;IACT;IAEA,uGAAuG;IAEvG,MAAMC,MAAMN,cAAcO,IAAI,CAACL,IAAIM,OAAO;IAC1C,IAAIF,KAAK;QACP,MAAM,GAAGG,aAAaC,SAASC,OAAO,GAAGL;QACzC,MAAMM,aAAaC,KAAKC,GAAG,CAAC,GAAGC,SAASN,aAAa;QACrD,MAAMO,SAASH,KAAKC,GAAG,CAAC,GAAGC,SAASL,SAAS;QAE7C,OAAO,IAAIO,sCAAkB,CAC3B,GAAGC,IAAAA,gBAAI,EAACjB,UAAU,CAAC,EAAEkB,IAAAA,kBAAM,EAACP,WAAWQ,QAAQ,IAAI,CAAC,EAAED,IAAAA,kBAAM,EAC1DH,OAAOI,QAAQ,KACd,EACHC,IAAAA,eAAG,EAACC,IAAAA,gBAAI,EAAC,iBAAiBC,MAAM,CAAC,CAAC,EAAE,EAAEZ,QAAQ;IAElD;IAEA,OAAO;AACT"}

View File

@@ -0,0 +1,3 @@
import type { webpack } from 'next/dist/compiled/webpack/webpack';
import { SimpleWebpackError } from './simpleWebpackError';
export declare function getNextAppLoaderError(err: Error, module: any, compiler: webpack.Compiler): SimpleWebpackError | false;

View File

@@ -0,0 +1,26 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "getNextAppLoaderError", {
enumerable: true,
get: function() {
return getNextAppLoaderError;
}
});
const _path = require("path");
const _simpleWebpackError = require("./simpleWebpackError");
const _entries = require("../../../entries");
function getNextAppLoaderError(err, module, compiler) {
try {
if (!module.loaders[0].loader.includes((0, _entries.getAppLoader)())) {
return false;
}
const file = (0, _path.relative)(compiler.context, module.buildInfo.route.absolutePagePath);
return new _simpleWebpackError.SimpleWebpackError(file, err.message);
} catch {
return false;
}
}
//# sourceMappingURL=parseNextAppLoaderError.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../src/build/webpack/plugins/wellknown-errors-plugin/parseNextAppLoaderError.ts"],"sourcesContent":["import type { webpack } from 'next/dist/compiled/webpack/webpack'\nimport { relative } from 'path'\nimport { SimpleWebpackError } from './simpleWebpackError'\nimport { getAppLoader } from '../../../entries'\n\nexport function getNextAppLoaderError(\n err: Error,\n module: any,\n compiler: webpack.Compiler\n): SimpleWebpackError | false {\n try {\n if (!module.loaders[0].loader.includes(getAppLoader())) {\n return false\n }\n\n const file = relative(\n compiler.context,\n module.buildInfo.route.absolutePagePath\n )\n\n return new SimpleWebpackError(file, err.message)\n } catch {\n return false\n }\n}\n"],"names":["getNextAppLoaderError","err","module","compiler","loaders","loader","includes","getAppLoader","file","relative","context","buildInfo","route","absolutePagePath","SimpleWebpackError","message"],"mappings":";;;;+BAKgBA;;;eAAAA;;;sBAJS;oCACU;yBACN;AAEtB,SAASA,sBACdC,GAAU,EACVC,MAAW,EACXC,QAA0B;IAE1B,IAAI;QACF,IAAI,CAACD,OAAOE,OAAO,CAAC,EAAE,CAACC,MAAM,CAACC,QAAQ,CAACC,IAAAA,qBAAY,MAAK;YACtD,OAAO;QACT;QAEA,MAAMC,OAAOC,IAAAA,cAAQ,EACnBN,SAASO,OAAO,EAChBR,OAAOS,SAAS,CAACC,KAAK,CAACC,gBAAgB;QAGzC,OAAO,IAAIC,sCAAkB,CAACN,MAAMP,IAAIc,OAAO;IACjD,EAAE,OAAM;QACN,OAAO;IACT;AACF"}

View File

@@ -0,0 +1,2 @@
import { SimpleWebpackError } from './simpleWebpackError';
export declare function getNextFontError(err: Error, module: any): SimpleWebpackError | false;

View File

@@ -0,0 +1,33 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "getNextFontError", {
enumerable: true,
get: function() {
return getNextFontError;
}
});
const _simpleWebpackError = require("./simpleWebpackError");
function getNextFontError(err, module) {
try {
const resourceResolveData = module.resourceResolveData;
if (!module.loaders.find((loader)=>/next-font-loader[/\\]index.js/.test(loader.loader))) {
return false;
}
// Parse the query and get the path of the file where the font function was called.
// provided by next-swc next-transform-font
const file = JSON.parse(resourceResolveData.query.slice(1)).path;
if (err.name === 'NextFontError') {
// Known error thrown by @next/font, display the error message
return new _simpleWebpackError.SimpleWebpackError(file, `\`next/font\` error:\n${err.message}`);
} else {
// Unknown error thrown by @next/font
return new _simpleWebpackError.SimpleWebpackError(file, `An error occurred in \`next/font\`.\n\n${err.stack}`);
}
} catch {
return false;
}
}
//# sourceMappingURL=parseNextFontError.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../src/build/webpack/plugins/wellknown-errors-plugin/parseNextFontError.ts"],"sourcesContent":["import { SimpleWebpackError } from './simpleWebpackError'\n\nexport function getNextFontError(\n err: Error,\n module: any\n): SimpleWebpackError | false {\n try {\n const resourceResolveData = module.resourceResolveData\n if (\n !module.loaders.find((loader: any) =>\n /next-font-loader[/\\\\]index.js/.test(loader.loader)\n )\n ) {\n return false\n }\n\n // Parse the query and get the path of the file where the font function was called.\n // provided by next-swc next-transform-font\n const file = JSON.parse(resourceResolveData.query.slice(1)).path\n\n if (err.name === 'NextFontError') {\n // Known error thrown by @next/font, display the error message\n return new SimpleWebpackError(\n file,\n `\\`next/font\\` error:\\n${err.message}`\n )\n } else {\n // Unknown error thrown by @next/font\n return new SimpleWebpackError(\n file,\n `An error occurred in \\`next/font\\`.\\n\\n${err.stack}`\n )\n }\n } catch {\n return false\n }\n}\n"],"names":["getNextFontError","err","module","resourceResolveData","loaders","find","loader","test","file","JSON","parse","query","slice","path","name","SimpleWebpackError","message","stack"],"mappings":";;;;+BAEgBA;;;eAAAA;;;oCAFmB;AAE5B,SAASA,iBACdC,GAAU,EACVC,MAAW;IAEX,IAAI;QACF,MAAMC,sBAAsBD,OAAOC,mBAAmB;QACtD,IACE,CAACD,OAAOE,OAAO,CAACC,IAAI,CAAC,CAACC,SACpB,gCAAgCC,IAAI,CAACD,OAAOA,MAAM,IAEpD;YACA,OAAO;QACT;QAEA,mFAAmF;QACnF,2CAA2C;QAC3C,MAAME,OAAOC,KAAKC,KAAK,CAACP,oBAAoBQ,KAAK,CAACC,KAAK,CAAC,IAAIC,IAAI;QAEhE,IAAIZ,IAAIa,IAAI,KAAK,iBAAiB;YAChC,8DAA8D;YAC9D,OAAO,IAAIC,sCAAkB,CAC3BP,MACA,CAAC,sBAAsB,EAAEP,IAAIe,OAAO,EAAE;QAE1C,OAAO;YACL,qCAAqC;YACrC,OAAO,IAAID,sCAAkB,CAC3BP,MACA,CAAC,uCAAuC,EAAEP,IAAIgB,KAAK,EAAE;QAEzD;IACF,EAAE,OAAM;QACN,OAAO;IACT;AACF"}

View File

@@ -0,0 +1,3 @@
import type { webpack } from 'next/dist/compiled/webpack/webpack';
import { SimpleWebpackError } from './simpleWebpackError';
export declare function getNextInvalidImportError(err: Error, module: any, compilation: webpack.Compilation, compiler: webpack.Compiler): SimpleWebpackError | false;

View File

@@ -0,0 +1,26 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "getNextInvalidImportError", {
enumerable: true,
get: function() {
return getNextInvalidImportError;
}
});
const _getModuleTrace = require("./getModuleTrace");
const _simpleWebpackError = require("./simpleWebpackError");
function getNextInvalidImportError(err, module, compilation, compiler) {
try {
if (!module.loaders.find((loader)=>loader.loader.includes('next-invalid-import-error-loader.js'))) {
return false;
}
const { moduleTrace } = (0, _getModuleTrace.getModuleTrace)(module, compilation, compiler);
const { formattedModuleTrace, lastInternalFileName, invalidImportMessage } = (0, _getModuleTrace.formatModuleTrace)(compiler, moduleTrace);
return new _simpleWebpackError.SimpleWebpackError(lastInternalFileName, err.message + invalidImportMessage + '\n\nImport trace for requested module:\n' + formattedModuleTrace);
} catch {
return false;
}
}
//# sourceMappingURL=parseNextInvalidImportError.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../src/build/webpack/plugins/wellknown-errors-plugin/parseNextInvalidImportError.ts"],"sourcesContent":["import type { webpack } from 'next/dist/compiled/webpack/webpack'\nimport { formatModuleTrace, getModuleTrace } from './getModuleTrace'\nimport { SimpleWebpackError } from './simpleWebpackError'\n\nexport function getNextInvalidImportError(\n err: Error,\n module: any,\n compilation: webpack.Compilation,\n compiler: webpack.Compiler\n): SimpleWebpackError | false {\n try {\n if (\n !module.loaders.find((loader: any) =>\n loader.loader.includes('next-invalid-import-error-loader.js')\n )\n ) {\n return false\n }\n\n const { moduleTrace } = getModuleTrace(module, compilation, compiler)\n const { formattedModuleTrace, lastInternalFileName, invalidImportMessage } =\n formatModuleTrace(compiler, moduleTrace)\n\n return new SimpleWebpackError(\n lastInternalFileName,\n err.message +\n invalidImportMessage +\n '\\n\\nImport trace for requested module:\\n' +\n formattedModuleTrace\n )\n } catch {\n return false\n }\n}\n"],"names":["getNextInvalidImportError","err","module","compilation","compiler","loaders","find","loader","includes","moduleTrace","getModuleTrace","formattedModuleTrace","lastInternalFileName","invalidImportMessage","formatModuleTrace","SimpleWebpackError","message"],"mappings":";;;;+BAIgBA;;;eAAAA;;;gCAHkC;oCACf;AAE5B,SAASA,0BACdC,GAAU,EACVC,MAAW,EACXC,WAAgC,EAChCC,QAA0B;IAE1B,IAAI;QACF,IACE,CAACF,OAAOG,OAAO,CAACC,IAAI,CAAC,CAACC,SACpBA,OAAOA,MAAM,CAACC,QAAQ,CAAC,yCAEzB;YACA,OAAO;QACT;QAEA,MAAM,EAAEC,WAAW,EAAE,GAAGC,IAAAA,8BAAc,EAACR,QAAQC,aAAaC;QAC5D,MAAM,EAAEO,oBAAoB,EAAEC,oBAAoB,EAAEC,oBAAoB,EAAE,GACxEC,IAAAA,iCAAiB,EAACV,UAAUK;QAE9B,OAAO,IAAIM,sCAAkB,CAC3BH,sBACAX,IAAIe,OAAO,GACTH,uBACA,6CACAF;IAEN,EAAE,OAAM;QACN,OAAO;IACT;AACF"}

View File

@@ -0,0 +1,4 @@
import { SimpleWebpackError } from './simpleWebpackError';
import type { webpack } from 'next/dist/compiled/webpack/webpack';
export declare function getNotFoundError(compilation: webpack.Compilation, input: any, fileName: string, module: any): Promise<any>;
export declare function getImageError(compilation: any, input: any, err: Error): Promise<SimpleWebpackError | false>;

View File

@@ -0,0 +1,161 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
getImageError: null,
getNotFoundError: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
getImageError: function() {
return getImageError;
},
getNotFoundError: function() {
return getNotFoundError;
}
});
const _picocolors = require("../../../../lib/picocolors");
const _simpleWebpackError = require("./simpleWebpackError");
const _middlewarewebpack = require("../../../../client/components/react-dev-overlay/server/middleware-webpack");
// Based on https://github.com/webpack/webpack/blob/fcdd04a833943394bbb0a9eeb54a962a24cc7e41/lib/stats/DefaultStatsFactoryPlugin.js#L422-L431
/*
Copyright JS Foundation and other contributors
Permission 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:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE 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.
*/ function getModuleTrace(input, compilation) {
const visitedModules = new Set();
const moduleTrace = [];
let current = input.module;
while(current){
if (visitedModules.has(current)) break; // circular (technically impossible, but who knows)
visitedModules.add(current);
const origin = compilation.moduleGraph.getIssuer(current);
if (!origin) break;
moduleTrace.push({
origin,
module: current
});
current = origin;
}
return moduleTrace;
}
async function getSourceFrame(input, fileName, compilation) {
try {
const loc = input.loc || input.dependencies.map((d)=>d.loc).filter(Boolean)[0];
const module1 = input.module;
const originalSource = module1.originalSource();
const sourceMap = (originalSource == null ? void 0 : originalSource.map()) ?? undefined;
if (sourceMap) {
var _result_originalStackFrame_lineNumber, _result_originalStackFrame, _result_originalStackFrame_column, _result_originalStackFrame1;
const moduleId = compilation.chunkGraph.getModuleId(module1);
const result = await (0, _middlewarewebpack.createOriginalStackFrame)({
source: {
type: 'bundle',
sourceMap,
ignoredSources: (0, _middlewarewebpack.getIgnoredSources)(sourceMap),
compilation,
moduleId,
moduleURL: fileName
},
rootDirectory: compilation.options.context,
frame: {
arguments: [],
file: fileName,
methodName: '',
lineNumber: loc.start.line,
// loc is 0-based but columns in stack frames are 1-based.
column: (loc.start.column ?? 0) + 1
}
});
return {
frame: (result == null ? void 0 : result.originalCodeFrame) ?? '',
lineNumber: (result == null ? void 0 : (_result_originalStackFrame = result.originalStackFrame) == null ? void 0 : (_result_originalStackFrame_lineNumber = _result_originalStackFrame.lineNumber) == null ? void 0 : _result_originalStackFrame_lineNumber.toString()) ?? '',
column: (result == null ? void 0 : (_result_originalStackFrame1 = result.originalStackFrame) == null ? void 0 : (_result_originalStackFrame_column = _result_originalStackFrame1.column) == null ? void 0 : _result_originalStackFrame_column.toString()) ?? ''
};
}
} catch {}
return {
frame: '',
lineNumber: '',
column: ''
};
}
function getFormattedFileName(fileName, module1, lineNumber, column) {
var _module_loaders;
if ((_module_loaders = module1.loaders) == null ? void 0 : _module_loaders.find((loader)=>/next-font-loader[/\\]index.js/.test(loader.loader))) {
// Parse the query and get the path of the file where the font function was called.
// provided by next-swc next-transform-font
return JSON.parse(module1.resourceResolveData.query.slice(1)).path;
} else {
let formattedFileName = (0, _picocolors.cyan)(fileName);
if (lineNumber && column) {
formattedFileName += `:${(0, _picocolors.yellow)(lineNumber)}:${(0, _picocolors.yellow)(column)}`;
}
return formattedFileName;
}
}
async function getNotFoundError(compilation, input, fileName, module1) {
if (input.name !== 'ModuleNotFoundError' && !(input.name === 'ModuleBuildError' && /Error: Can't resolve '.+' in /.test(input.message))) {
return false;
}
try {
const { frame, lineNumber, column } = await getSourceFrame(input, fileName, compilation);
const errorMessage = input.error.message.replace(/ in '.*?'/, '').replace(/Can't resolve '(.*)'/, `Can't resolve '${(0, _picocolors.green)('$1')}'`);
const importTrace = ()=>{
const moduleTrace = getModuleTrace(input, compilation).map(({ origin })=>origin.readableIdentifier(compilation.requestShortener)).filter((name)=>name && !/next-(app|middleware|client-pages|route|flight-(client|server|client-entry))-loader/.test(name) && !/css-loader.+\.js/.test(name));
if (moduleTrace.length === 0) return '';
return `\nImport trace for requested module:\n${moduleTrace.join('\n')}`;
};
let message = (0, _picocolors.red)((0, _picocolors.bold)('Module not found')) + `: ${errorMessage}` + '\n' + frame + (frame !== '' ? '\n' : '') + '\nhttps://nextjs.org/docs/messages/module-not-found\n' + importTrace();
const formattedFileName = getFormattedFileName(fileName, module1, lineNumber, column);
return new _simpleWebpackError.SimpleWebpackError(formattedFileName, message);
} catch (err) {
// Don't fail on failure to resolve sourcemaps
return input;
}
}
async function getImageError(compilation, input, err) {
if (err.name !== 'InvalidImageFormatError') {
return false;
}
const moduleTrace = getModuleTrace(input, compilation);
const { origin, module: module1 } = moduleTrace[0] || {};
if (!origin || !module1) {
return false;
}
const page = origin.rawRequest.replace(/^private-next-pages/, './pages');
const importedFile = module1.rawRequest;
const source = origin.originalSource().buffer().toString('utf8');
let lineNumber = -1;
source.split('\n').some((line)=>{
lineNumber++;
return line.includes(importedFile);
});
return new _simpleWebpackError.SimpleWebpackError(`${(0, _picocolors.cyan)(page)}:${(0, _picocolors.yellow)(lineNumber.toString())}`, (0, _picocolors.red)((0, _picocolors.bold)('Error')).concat(`: Image import "${importedFile}" is not a valid image file. The image may be corrupted or an unsupported format.`));
}
//# sourceMappingURL=parseNotFoundError.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,2 @@
import { SimpleWebpackError } from './simpleWebpackError';
export declare function getScssError(fileName: string, fileContent: string | null, err: Error): SimpleWebpackError | false;

View File

@@ -0,0 +1,42 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "getScssError", {
enumerable: true,
get: function() {
return getScssError;
}
});
const _picocolors = require("../../../../lib/picocolors");
const _simpleWebpackError = require("./simpleWebpackError");
const regexScssError = /SassError: (.+)\n\s+on line (\d+) [\s\S]*?>> (.+)\n\s*(-+)\^$/m;
function getScssError(fileName, fileContent, err) {
if (err.name !== 'SassError') {
return false;
}
const res = regexScssError.exec(err.message);
if (res) {
const [, reason, _lineNumer, backupFrame, columnString] = res;
const lineNumber = Math.max(1, parseInt(_lineNumer, 10));
const column = (columnString == null ? void 0 : columnString.length) ?? 1;
let frame;
if (fileContent) {
try {
const { codeFrameColumns } = require('next/dist/compiled/babel/code-frame');
frame = codeFrameColumns(fileContent, {
start: {
line: lineNumber,
column
}
}, {
forceColor: true
});
} catch {}
}
return new _simpleWebpackError.SimpleWebpackError(`${(0, _picocolors.cyan)(fileName)}:${(0, _picocolors.yellow)(lineNumber.toString())}:${(0, _picocolors.yellow)(column.toString())}`, (0, _picocolors.red)((0, _picocolors.bold)('Syntax error')).concat(`: ${reason}\n\n${frame ?? backupFrame}`));
}
return false;
}
//# sourceMappingURL=parseScss.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../src/build/webpack/plugins/wellknown-errors-plugin/parseScss.ts"],"sourcesContent":["import { bold, cyan, red, yellow } from '../../../../lib/picocolors'\nimport { SimpleWebpackError } from './simpleWebpackError'\n\nconst regexScssError =\n /SassError: (.+)\\n\\s+on line (\\d+) [\\s\\S]*?>> (.+)\\n\\s*(-+)\\^$/m\n\nexport function getScssError(\n fileName: string,\n fileContent: string | null,\n err: Error\n): SimpleWebpackError | false {\n if (err.name !== 'SassError') {\n return false\n }\n\n const res = regexScssError.exec(err.message)\n if (res) {\n const [, reason, _lineNumer, backupFrame, columnString] = res\n const lineNumber = Math.max(1, parseInt(_lineNumer, 10))\n const column = columnString?.length ?? 1\n\n let frame: string | undefined\n if (fileContent) {\n try {\n const {\n codeFrameColumns,\n } = require('next/dist/compiled/babel/code-frame')\n frame = codeFrameColumns(\n fileContent,\n { start: { line: lineNumber, column } },\n { forceColor: true }\n ) as string\n } catch {}\n }\n\n return new SimpleWebpackError(\n `${cyan(fileName)}:${yellow(lineNumber.toString())}:${yellow(\n column.toString()\n )}`,\n red(bold('Syntax error')).concat(`: ${reason}\\n\\n${frame ?? backupFrame}`)\n )\n }\n\n return false\n}\n"],"names":["getScssError","regexScssError","fileName","fileContent","err","name","res","exec","message","reason","_lineNumer","backupFrame","columnString","lineNumber","Math","max","parseInt","column","length","frame","codeFrameColumns","require","start","line","forceColor","SimpleWebpackError","cyan","yellow","toString","red","bold","concat"],"mappings":";;;;+BAMgBA;;;eAAAA;;;4BANwB;oCACL;AAEnC,MAAMC,iBACJ;AAEK,SAASD,aACdE,QAAgB,EAChBC,WAA0B,EAC1BC,GAAU;IAEV,IAAIA,IAAIC,IAAI,KAAK,aAAa;QAC5B,OAAO;IACT;IAEA,MAAMC,MAAML,eAAeM,IAAI,CAACH,IAAII,OAAO;IAC3C,IAAIF,KAAK;QACP,MAAM,GAAGG,QAAQC,YAAYC,aAAaC,aAAa,GAAGN;QAC1D,MAAMO,aAAaC,KAAKC,GAAG,CAAC,GAAGC,SAASN,YAAY;QACpD,MAAMO,SAASL,CAAAA,gCAAAA,aAAcM,MAAM,KAAI;QAEvC,IAAIC;QACJ,IAAIhB,aAAa;YACf,IAAI;gBACF,MAAM,EACJiB,gBAAgB,EACjB,GAAGC,QAAQ;gBACZF,QAAQC,iBACNjB,aACA;oBAAEmB,OAAO;wBAAEC,MAAMV;wBAAYI;oBAAO;gBAAE,GACtC;oBAAEO,YAAY;gBAAK;YAEvB,EAAE,OAAM,CAAC;QACX;QAEA,OAAO,IAAIC,sCAAkB,CAC3B,GAAGC,IAAAA,gBAAI,EAACxB,UAAU,CAAC,EAAEyB,IAAAA,kBAAM,EAACd,WAAWe,QAAQ,IAAI,CAAC,EAAED,IAAAA,kBAAM,EAC1DV,OAAOW,QAAQ,KACd,EACHC,IAAAA,eAAG,EAACC,IAAAA,gBAAI,EAAC,iBAAiBC,MAAM,CAAC,CAAC,EAAE,EAAEtB,OAAO,IAAI,EAAEU,SAASR,aAAa;IAE7E;IAEA,OAAO;AACT"}

View File

@@ -0,0 +1,7 @@
import type { webpack } from 'next/dist/compiled/webpack/webpack';
declare const SimpleWebpackError_base: typeof webpack.WebpackError;
export declare class SimpleWebpackError extends SimpleWebpackError_base {
file: string;
constructor(file: string, message: string);
}
export {};

View File

@@ -0,0 +1,18 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "SimpleWebpackError", {
enumerable: true,
get: function() {
return SimpleWebpackError;
}
});
class SimpleWebpackError extends Error {
constructor(file, message){
super(message);
this.file = file;
}
}
//# sourceMappingURL=simpleWebpackError.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../src/build/webpack/plugins/wellknown-errors-plugin/simpleWebpackError.ts"],"sourcesContent":["import type { webpack } from 'next/dist/compiled/webpack/webpack'\n\n// This class creates a simplified webpack error that formats nicely based on\n// webpack's build in serializer.\n// https://github.com/webpack/webpack/blob/c9d4ff7b054fc581c96ce0e53432d44f9dd8ca72/lib/Stats.js#L294-L356\nexport class SimpleWebpackError extends (Error as unknown as typeof webpack.WebpackError) {\n file: string\n\n constructor(file: string, message: string) {\n super(message)\n this.file = file\n }\n}\n"],"names":["SimpleWebpackError","Error","constructor","file","message"],"mappings":";;;;+BAKaA;;;eAAAA;;;AAAN,MAAMA,2BAA4BC;IAGvCC,YAAYC,IAAY,EAAEC,OAAe,CAAE;QACzC,KAAK,CAACA;QACN,IAAI,CAACD,IAAI,GAAGA;IACd;AACF"}

View File

@@ -0,0 +1,3 @@
import type { webpack } from 'next/dist/compiled/webpack/webpack';
import type { SimpleWebpackError } from './simpleWebpackError';
export declare function getModuleBuildError(compiler: webpack.Compiler, compilation: webpack.Compilation, input: any): Promise<SimpleWebpackError | false>;

View File

@@ -0,0 +1,138 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "getModuleBuildError", {
enumerable: true,
get: function() {
return getModuleBuildError;
}
});
const _fs = require("fs");
const _path = /*#__PURE__*/ _interop_require_wildcard(require("path"));
const _parseBabel = require("./parseBabel");
const _parseCss = require("./parseCss");
const _parseScss = require("./parseScss");
const _parseNotFoundError = require("./parseNotFoundError");
const _iserror = /*#__PURE__*/ _interop_require_default(require("../../../../lib/is-error"));
const _parseNextFontError = require("./parseNextFontError");
const _parseNextAppLoaderError = require("./parseNextAppLoaderError");
const _parseNextInvalidImportError = require("./parseNextInvalidImportError");
function _interop_require_default(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
function _getRequireWildcardCache(nodeInterop) {
if (typeof WeakMap !== "function") return null;
var cacheBabelInterop = new WeakMap();
var cacheNodeInterop = new WeakMap();
return (_getRequireWildcardCache = function(nodeInterop) {
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
})(nodeInterop);
}
function _interop_require_wildcard(obj, nodeInterop) {
if (!nodeInterop && obj && obj.__esModule) {
return obj;
}
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
return {
default: obj
};
}
var cache = _getRequireWildcardCache(nodeInterop);
if (cache && cache.has(obj)) {
return cache.get(obj);
}
var newObj = {
__proto__: null
};
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
for(var key in obj){
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
if (desc && (desc.get || desc.set)) {
Object.defineProperty(newObj, key, desc);
} else {
newObj[key] = obj[key];
}
}
}
newObj.default = obj;
if (cache) {
cache.set(obj, newObj);
}
return newObj;
}
function getFileData(compilation, m) {
var _compilation_compiler;
let resolved;
let ctx = ((_compilation_compiler = compilation.compiler) == null ? void 0 : _compilation_compiler.context) ?? null;
if (ctx !== null && typeof m.resource === 'string') {
const res = _path.relative(ctx, m.resource).replace(/\\/g, _path.posix.sep);
resolved = res.startsWith('.') ? res : `.${_path.posix.sep}${res}`;
} else {
const requestShortener = compilation.requestShortener;
if (typeof (m == null ? void 0 : m.readableIdentifier) === 'function') {
resolved = m.readableIdentifier(requestShortener);
} else {
resolved = m.request ?? m.userRequest;
}
}
if (resolved) {
let content = null;
try {
content = (0, _fs.readFileSync)(ctx ? _path.resolve(ctx, resolved) : resolved, 'utf8');
} catch {}
return [
resolved,
content
];
}
return [
'<unknown>',
null
];
}
async function getModuleBuildError(compiler, compilation, input) {
if (!(typeof input === 'object' && ((input == null ? void 0 : input.name) === 'ModuleBuildError' || (input == null ? void 0 : input.name) === 'ModuleNotFoundError') && Boolean(input.module) && (0, _iserror.default)(input.error))) {
return false;
}
const err = input.error;
const [sourceFilename, sourceContent] = getFileData(compilation, input.module);
const notFoundError = await (0, _parseNotFoundError.getNotFoundError)(compilation, input, sourceFilename, input.module);
if (notFoundError !== false) {
return notFoundError;
}
const imageError = await (0, _parseNotFoundError.getImageError)(compilation, input, err);
if (imageError !== false) {
return imageError;
}
const babel = (0, _parseBabel.getBabelError)(sourceFilename, err);
if (babel !== false) {
return babel;
}
const css = (0, _parseCss.getCssError)(sourceFilename, err);
if (css !== false) {
return css;
}
const scss = (0, _parseScss.getScssError)(sourceFilename, sourceContent, err);
if (scss !== false) {
return scss;
}
const nextFont = (0, _parseNextFontError.getNextFontError)(err, input.module);
if (nextFont !== false) {
return nextFont;
}
const nextAppLoader = (0, _parseNextAppLoaderError.getNextAppLoaderError)(err, input.module, compiler);
if (nextAppLoader !== false) {
return nextAppLoader;
}
const invalidImportError = (0, _parseNextInvalidImportError.getNextInvalidImportError)(err, input.module, compilation, compiler);
if (invalidImportError !== false) {
return invalidImportError;
}
return false;
}
//# sourceMappingURL=webpackModuleError.js.map

File diff suppressed because one or more lines are too long