Initial boiler plate project

This commit is contained in:
2024-09-24 03:52:46 +00:00
parent 6120b2d6c3
commit 154b93e267
10034 changed files with 2079352 additions and 2 deletions

5
node_modules/next/dist/trace/index.d.ts generated vendored Normal file
View File

@ -0,0 +1,5 @@
import { trace, exportTraceState, flushAllTraces, getTraceEvents, initializeTraceState, recordTraceEvents, Span, SpanStatus } from './trace';
import { setGlobal } from './shared';
import type { SpanId, TraceEvent, TraceState } from './types';
export { trace, exportTraceState, flushAllTraces, getTraceEvents, initializeTraceState, recordTraceEvents, Span, setGlobal, SpanStatus, };
export type { SpanId, TraceEvent, TraceState };

54
node_modules/next/dist/trace/index.js generated vendored Normal file
View File

@ -0,0 +1,54 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
Span: null,
SpanStatus: null,
exportTraceState: null,
flushAllTraces: null,
getTraceEvents: null,
initializeTraceState: null,
recordTraceEvents: null,
setGlobal: null,
trace: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
Span: function() {
return _trace.Span;
},
SpanStatus: function() {
return _trace.SpanStatus;
},
exportTraceState: function() {
return _trace.exportTraceState;
},
flushAllTraces: function() {
return _trace.flushAllTraces;
},
getTraceEvents: function() {
return _trace.getTraceEvents;
},
initializeTraceState: function() {
return _trace.initializeTraceState;
},
recordTraceEvents: function() {
return _trace.recordTraceEvents;
},
setGlobal: function() {
return _shared.setGlobal;
},
trace: function() {
return _trace.trace;
}
});
const _trace = require("./trace");
const _shared = require("./shared");
//# sourceMappingURL=index.js.map

1
node_modules/next/dist/trace/index.js.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"sources":["../../src/trace/index.ts"],"names":["Span","SpanStatus","exportTraceState","flushAllTraces","getTraceEvents","initializeTraceState","recordTraceEvents","setGlobal","trace"],"mappings":";;;;;;;;;;;;;;;;;;;;;;IAoBEA,IAAI;eAAJA,WAAI;;IAEJC,UAAU;eAAVA,iBAAU;;IAPVC,gBAAgB;eAAhBA,uBAAgB;;IAChBC,cAAc;eAAdA,qBAAc;;IACdC,cAAc;eAAdA,qBAAc;;IACdC,oBAAoB;eAApBA,2BAAoB;;IACpBC,iBAAiB;eAAjBA,wBAAiB;;IAEjBC,SAAS;eAATA,iBAAS;;IAPTC,KAAK;eAALA,YAAK;;;uBALA;wBACmB"}

10
node_modules/next/dist/trace/report/index.d.ts generated vendored Normal file
View File

@ -0,0 +1,10 @@
import type { TraceEvent } from '../types';
import type { Reporter } from './types';
declare class MultiReporter implements Reporter {
private reporters;
constructor(reporters: Reporter[]);
flushAll(): Promise<void>;
report(event: TraceEvent): void;
}
export declare const reporter: MultiReporter;
export {};

35
node_modules/next/dist/trace/report/index.js generated vendored Normal file
View File

@ -0,0 +1,35 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "reporter", {
enumerable: true,
get: function() {
return reporter;
}
});
const _totelemetry = /*#__PURE__*/ _interop_require_default(require("./to-telemetry"));
const _tojson = /*#__PURE__*/ _interop_require_default(require("./to-json"));
function _interop_require_default(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
class MultiReporter {
constructor(reporters){
this.reporters = [];
this.reporters = reporters;
}
async flushAll() {
await Promise.all(this.reporters.map((reporter)=>reporter.flushAll()));
}
report(event) {
this.reporters.forEach((reporter)=>reporter.report(event));
}
}
const reporter = new MultiReporter([
_tojson.default,
_totelemetry.default
]);
//# sourceMappingURL=index.js.map

1
node_modules/next/dist/trace/report/index.js.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"sources":["../../../src/trace/report/index.ts"],"names":["reporter","MultiReporter","constructor","reporters","flushAll","Promise","all","map","report","event","forEach","reportToJson","reportToTelemetry"],"mappings":";;;;+BAsBaA;;;eAAAA;;;oEArBiB;+DACL;;;;;;AAGzB,MAAMC;IAGJC,YAAYC,SAAqB,CAAE;aAF3BA,YAAwB,EAAE;QAGhC,IAAI,CAACA,SAAS,GAAGA;IACnB;IAEA,MAAMC,WAAW;QACf,MAAMC,QAAQC,GAAG,CAAC,IAAI,CAACH,SAAS,CAACI,GAAG,CAAC,CAACP,WAAaA,SAASI,QAAQ;IACtE;IAEAI,OAAOC,KAAiB,EAAE;QACxB,IAAI,CAACN,SAAS,CAACO,OAAO,CAAC,CAACV,WAAaA,SAASQ,MAAM,CAACC;IACvD;AACF;AAGO,MAAMT,WAAW,IAAIC,cAAc;IAACU,eAAY;IAAEC,oBAAiB;CAAC"}

1
node_modules/next/dist/trace/report/index.test.d.ts generated vendored Normal file
View File

@ -0,0 +1 @@
export {};

63
node_modules/next/dist/trace/report/index.test.js generated vendored Normal file
View File

@ -0,0 +1,63 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
const _promises = require("fs/promises");
const _ = require(".");
const _shared = require("../shared");
const _path = require("path");
const _os = require("os");
const TRACE_EVENT = {
name: "test-span",
duration: 321,
timestamp: Date.now(),
id: 127,
startTime: Date.now()
};
const WEBPACK_INVALIDATED_EVENT = {
name: "webpack-invalidated",
duration: 100,
timestamp: Date.now(),
id: 112,
startTime: Date.now()
};
describe("Trace Reporter", ()=>{
describe("JSON reporter", ()=>{
it("should write the trace events to JSON file", async ()=>{
const tmpDir = await (0, _promises.mkdtemp)((0, _path.join)((0, _os.tmpdir)(), "json-reporter"));
(0, _shared.setGlobal)("distDir", tmpDir);
(0, _shared.setGlobal)("phase", "anything");
_.reporter.report(TRACE_EVENT);
await _.reporter.flushAll();
const traceFilename = (0, _path.join)(tmpDir, "trace");
const traces = JSON.parse(await (0, _promises.readFile)(traceFilename, "utf-8"));
expect(traces.length).toEqual(1);
expect(traces[0].name).toEqual("test-span");
expect(traces[0].id).toEqual(127);
expect(traces[0].duration).toEqual(321);
expect(traces[0].traceId).toBeDefined();
});
});
describe("Telemetry reporter", ()=>{
it("should record telemetry event", async ()=>{
const recordMock = jest.fn();
const telemetryMock = {
record: recordMock
};
(0, _shared.setGlobal)("telemetry", telemetryMock);
// This should be ignored.
_.reporter.report(TRACE_EVENT);
expect(recordMock).toHaveBeenCalledTimes(0);
_.reporter.report(WEBPACK_INVALIDATED_EVENT);
expect(recordMock).toHaveBeenCalledTimes(1);
expect(recordMock).toHaveBeenCalledWith({
eventName: "WEBPACK_INVALIDATED",
payload: {
durationInMicroseconds: 100
}
});
});
});
});
//# sourceMappingURL=index.test.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../../src/trace/report/index.test.ts"],"names":["TRACE_EVENT","name","duration","timestamp","Date","now","id","startTime","WEBPACK_INVALIDATED_EVENT","describe","it","tmpDir","mkdtemp","join","tmpdir","setGlobal","reporter","report","flushAll","traceFilename","traces","JSON","parse","readFile","expect","length","toEqual","traceId","toBeDefined","recordMock","jest","fn","telemetryMock","record","toHaveBeenCalledTimes","toHaveBeenCalledWith","eventName","payload","durationInMicroseconds"],"mappings":";;;;0BAAkC;kBACT;wBACC;sBACL;oBACE;AAEvB,MAAMA,cAAc;IAClBC,MAAM;IACNC,UAAU;IACVC,WAAWC,KAAKC,GAAG;IACnBC,IAAI;IACJC,WAAWH,KAAKC,GAAG;AACrB;AACA,MAAMG,4BAA4B;IAChCP,MAAM;IACNC,UAAU;IACVC,WAAWC,KAAKC,GAAG;IACnBC,IAAI;IACJC,WAAWH,KAAKC,GAAG;AACrB;AAEAI,SAAS,kBAAkB;IACzBA,SAAS,iBAAiB;QACxBC,GAAG,8CAA8C;YAC/C,MAAMC,SAAS,MAAMC,IAAAA,iBAAO,EAACC,IAAAA,UAAI,EAACC,IAAAA,UAAM,KAAI;YAC5CC,IAAAA,iBAAS,EAAC,WAAWJ;YACrBI,IAAAA,iBAAS,EAAC,SAAS;YACnBC,UAAQ,CAACC,MAAM,CAACjB;YAChB,MAAMgB,UAAQ,CAACE,QAAQ;YACvB,MAAMC,gBAAgBN,IAAAA,UAAI,EAACF,QAAQ;YACnC,MAAMS,SAASC,KAAKC,KAAK,CAAC,MAAMC,IAAAA,kBAAQ,EAACJ,eAAe;YACxDK,OAAOJ,OAAOK,MAAM,EAAEC,OAAO,CAAC;YAC9BF,OAAOJ,MAAM,CAAC,EAAE,CAACnB,IAAI,EAAEyB,OAAO,CAAC;YAC/BF,OAAOJ,MAAM,CAAC,EAAE,CAACd,EAAE,EAAEoB,OAAO,CAAC;YAC7BF,OAAOJ,MAAM,CAAC,EAAE,CAAClB,QAAQ,EAAEwB,OAAO,CAAC;YACnCF,OAAOJ,MAAM,CAAC,EAAE,CAACO,OAAO,EAAEC,WAAW;QACvC;IACF;IAEAnB,SAAS,sBAAsB;QAC7BC,GAAG,iCAAiC;YAClC,MAAMmB,aAAaC,KAAKC,EAAE;YAC1B,MAAMC,gBAAgB;gBACpBC,QAAQJ;YACV;YACAd,IAAAA,iBAAS,EAAC,aAAaiB;YACvB,0BAA0B;YAC1BhB,UAAQ,CAACC,MAAM,CAACjB;YAChBwB,OAAOK,YAAYK,qBAAqB,CAAC;YACzClB,UAAQ,CAACC,MAAM,CAACT;YAChBgB,OAAOK,YAAYK,qBAAqB,CAAC;YACzCV,OAAOK,YAAYM,oBAAoB,CAAC;gBACtCC,WAAW;gBACXC,SAAS;oBACPC,wBAAwB;gBAC1B;YACF;QACF;IACF;AACF"}

18
node_modules/next/dist/trace/report/to-json.d.ts generated vendored Normal file
View File

@ -0,0 +1,18 @@
import type { TraceEvent } from '../types';
declare const localEndpoint: {
serviceName: string;
ipv4: string;
port: number;
};
type Event = TraceEvent & {
localEndpoint?: typeof localEndpoint;
};
export declare function batcher(reportEvents: (evts: Event[]) => Promise<void>): {
flushAll: () => Promise<void>;
report: (event: Event) => void;
};
declare const _default: {
flushAll: () => Promise<void | undefined> | undefined;
report: (event: TraceEvent) => void;
};
export default _default;

161
node_modules/next/dist/trace/report/to-json.js generated vendored Normal file
View File

@ -0,0 +1,161 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
batcher: null,
default: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
batcher: function() {
return batcher;
},
default: function() {
return _default;
}
});
const _crypto = require("crypto");
const _shared = require("../shared");
const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
const _constants = require("../../shared/lib/constants");
function _interop_require_default(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
const localEndpoint = {
serviceName: "nextjs",
ipv4: "127.0.0.1",
port: 9411
};
function batcher(reportEvents) {
const events = [];
// Promise queue to ensure events are always sent on flushAll
const queue = new Set();
return {
flushAll: async ()=>{
await Promise.all(queue);
if (events.length > 0) {
await reportEvents(events);
events.length = 0;
}
},
report: (event)=>{
events.push(event);
if (events.length > 100) {
const evts = events.slice();
events.length = 0;
const report = reportEvents(evts);
queue.add(report);
report.then(()=>queue.delete(report));
}
}
};
}
let writeStream;
let traceId;
let batch;
const writeStreamOptions = {
flags: "a",
encoding: "utf8"
};
class RotatingWriteStream {
constructor(file, sizeLimit){
this.file = file;
this.size = 0;
this.sizeLimit = sizeLimit;
this.createWriteStream();
}
createWriteStream() {
this.writeStream = _fs.default.createWriteStream(this.file, writeStreamOptions);
}
// Recreate the file
async rotate() {
await this.end();
try {
_fs.default.unlinkSync(this.file);
} catch (err) {
// It's fine if the file does not exist yet
if (err.code !== "ENOENT") {
throw err;
}
}
this.size = 0;
this.createWriteStream();
this.rotatePromise = undefined;
}
async write(data) {
if (this.rotatePromise) await this.rotatePromise;
this.size += data.length;
if (this.size > this.sizeLimit) {
await (this.rotatePromise = this.rotate());
}
if (!this.writeStream.write(data, "utf8")) {
if (this.drainPromise === undefined) {
this.drainPromise = new Promise((resolve, _reject)=>{
this.writeStream.once("drain", ()=>{
this.drainPromise = undefined;
resolve();
});
});
}
await this.drainPromise;
}
}
end() {
return new Promise((resolve)=>{
this.writeStream.end(resolve);
});
}
}
const reportToLocalHost = (event)=>{
const distDir = _shared.traceGlobals.get("distDir");
const phase = _shared.traceGlobals.get("phase");
if (!distDir || !phase) {
return;
}
if (!traceId) {
traceId = process.env.TRACE_ID || (0, _crypto.randomBytes)(8).toString("hex");
}
if (!batch) {
batch = batcher(async (events)=>{
if (!writeStream) {
await _fs.default.promises.mkdir(distDir, {
recursive: true
});
const file = _path.default.join(distDir, "trace");
writeStream = new RotatingWriteStream(file, // Development is limited to 50MB, production is unlimited
phase === _constants.PHASE_DEVELOPMENT_SERVER ? 52428800 : Infinity);
}
const eventsJson = JSON.stringify(events);
try {
await writeStream.write(eventsJson + "\n");
} catch (err) {
console.log(err);
}
});
}
batch.report({
...event,
traceId
});
};
const _default = {
flushAll: ()=>batch ? batch.flushAll().then(()=>{
const phase = _shared.traceGlobals.get("phase");
// Only end writeStream when manually flushing in production
if (phase !== _constants.PHASE_DEVELOPMENT_SERVER) {
return writeStream.end();
}
}) : undefined,
report: reportToLocalHost
};
//# sourceMappingURL=to-json.js.map

1
node_modules/next/dist/trace/report/to-json.js.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"sources":["../../../src/trace/report/to-json.ts"],"names":["batcher","localEndpoint","serviceName","ipv4","port","reportEvents","events","queue","Set","flushAll","Promise","all","length","report","event","push","evts","slice","add","then","delete","writeStream","traceId","batch","writeStreamOptions","flags","encoding","RotatingWriteStream","constructor","file","sizeLimit","size","createWriteStream","fs","rotate","end","unlinkSync","err","code","rotatePromise","undefined","write","data","drainPromise","resolve","_reject","once","reportToLocalHost","distDir","traceGlobals","get","phase","process","env","TRACE_ID","randomBytes","toString","promises","mkdir","recursive","path","join","PHASE_DEVELOPMENT_SERVER","Infinity","eventsJson","JSON","stringify","console","log"],"mappings":";;;;;;;;;;;;;;;IAkBgBA,OAAO;eAAPA;;IAkIhB,OAYC;eAZD;;;wBApJ4B;wBACC;2DACd;6DACE;2BACwB;;;;;;AAGzC,MAAMC,gBAAgB;IACpBC,aAAa;IACbC,MAAM;IACNC,MAAM;AACR;AAOO,SAASJ,QAAQK,YAA8C;IACpE,MAAMC,SAAkB,EAAE;IAC1B,6DAA6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ACA,MAAMC,aAAaC,KAAKC,SAAS,CAAC5D;YAClC,IAAI;gBACF,MAAMe,YAAYoB,KAAK,CAACuB,aAAa;YACvC,EAAE,OAAO3B,KAAK;gBACZ8B,QAAQC,GAAG,CAAC/B;YACd;QACF;IACF;IAEAd,MAAMV,MAAM,CAAC;QACX,GAAGC,KAAK;QACRQ;IACF;AACF;MAEA,WAAe;IACbb,UAAU,IACRc,QACIA,MAAMd,QAAQ,GAAGU,IAAI,CAAC;YACpB,MAAMgC,QAAQF,oBAAY,CAACC,GAAG,CAAC;YAC/B,4DAA4D;YAC5D,IAAIC,UAAUW,mCAAwB,EAAE;gBACtC,OAAOzC,YAAYc,GAAG;YACxB;QACF,KACAK;IACN3B,QAAQkC;AACV"}

View File

@ -0,0 +1,6 @@
import type { TraceEvent } from '../types';
declare const _default: {
flushAll: () => void;
report: ({ name, duration }: TraceEvent) => void;
};
export default _default;

36
node_modules/next/dist/trace/report/to-telemetry.js generated vendored Normal file
View File

@ -0,0 +1,36 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "default", {
enumerable: true,
get: function() {
return _default;
}
});
const _shared = require("../shared");
const TRACE_EVENT_ACCESSLIST = new Map(Object.entries({
"webpack-invalidated": "WEBPACK_INVALIDATED"
}));
const reportToTelemetry = ({ name, duration })=>{
const eventName = TRACE_EVENT_ACCESSLIST.get(name);
if (!eventName) {
return;
}
const telemetry = _shared.traceGlobals.get("telemetry");
if (!telemetry) {
return;
}
telemetry.record({
eventName,
payload: {
durationInMicroseconds: duration
}
});
};
const _default = {
flushAll: ()=>{},
report: reportToTelemetry
};
//# sourceMappingURL=to-telemetry.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../../src/trace/report/to-telemetry.ts"],"names":["TRACE_EVENT_ACCESSLIST","Map","Object","entries","reportToTelemetry","name","duration","eventName","get","telemetry","traceGlobals","record","payload","durationInMicroseconds","flushAll","report"],"mappings":";;;;+BA4BA;;;eAAA;;;wBA3B6B;AAG7B,MAAMA,yBAAyB,IAAIC,IACjCC,OAAOC,OAAO,CAAC;IACb,uBAAuB;AACzB;AAGF,MAAMC,oBAAoB,CAAC,EAAEC,IAAI,EAAEC,QAAQ,EAAc;IACvD,MAAMC,YAAYP,uBAAuBQ,GAAG,CAACH;IAC7C,IAAI,CAACE,WAAW;QACd;IACF;IACA,MAAME,YAAmCC,oBAAY,CAACF,GAAG,CAAC;IAC1D,IAAI,CAACC,WAAW;QACd;IACF;IAEAA,UAAUE,MAAM,CAAC;QACfJ;QACAK,SAAS;YACPC,wBAAwBP;QAC1B;IACF;AACF;MAEA,WAAe;IACbQ,UAAU,KAAO;IACjBC,QAAQX;AACV"}

5
node_modules/next/dist/trace/report/types.d.ts generated vendored Normal file
View File

@ -0,0 +1,5 @@
import type { TraceEvent } from '../types';
export type Reporter = {
flushAll: () => Promise<void> | void;
report: (event: TraceEvent) => void;
};

6
node_modules/next/dist/trace/report/types.js generated vendored Normal file
View File

@ -0,0 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
//# sourceMappingURL=types.js.map

1
node_modules/next/dist/trace/report/types.js.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"sources":[],"names":[],"mappings":""}

2
node_modules/next/dist/trace/shared.d.ts generated vendored Normal file
View File

@ -0,0 +1,2 @@
export declare const traceGlobals: Map<any, any>;
export declare const setGlobal: (key: any, val: any) => void;

33
node_modules/next/dist/trace/shared.js generated vendored Normal file
View File

@ -0,0 +1,33 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
setGlobal: null,
traceGlobals: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
setGlobal: function() {
return setGlobal;
},
traceGlobals: function() {
return traceGlobals;
}
});
let _traceGlobals = global._traceGlobals;
if (!_traceGlobals) {
_traceGlobals = new Map();
}
global._traceGlobals = _traceGlobals;
const traceGlobals = _traceGlobals;
const setGlobal = (key, val)=>{
traceGlobals.set(key, val);
};
//# sourceMappingURL=shared.js.map

1
node_modules/next/dist/trace/shared.js.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"sources":["../../src/trace/shared.ts"],"names":["setGlobal","traceGlobals","_traceGlobals","global","Map","key","val","set"],"mappings":";;;;;;;;;;;;;;;IAQaA,SAAS;eAATA;;IADAC,YAAY;eAAZA;;;AAPb,IAAIC,gBAA+B,AAACC,OAAeD,aAAa;AAEhE,IAAI,CAACA,eAAe;IAClBA,gBAAgB,IAAIE;AACtB;AACED,OAAeD,aAAa,GAAGA;AAE1B,MAAMD,eAA8BC;AACpC,MAAMF,YAAY,CAACK,KAAUC;IAClCL,aAAaM,GAAG,CAACF,KAAKC;AACxB"}

1
node_modules/next/dist/trace/trace-uploader.d.ts generated vendored Normal file
View File

@ -0,0 +1 @@
export {};

112
node_modules/next/dist/trace/trace-uploader.js generated vendored Normal file
View File

@ -0,0 +1,112 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
const _findup = /*#__PURE__*/ _interop_require_default(require("next/dist/compiled/find-up"));
const _promises = /*#__PURE__*/ _interop_require_default(require("fs/promises"));
const _child_process = /*#__PURE__*/ _interop_require_default(require("child_process"));
const _assert = /*#__PURE__*/ _interop_require_default(require("assert"));
const _nodefetch = /*#__PURE__*/ _interop_require_default(require("next/dist/compiled/node-fetch"));
const _os = /*#__PURE__*/ _interop_require_default(require("os"));
const _readline = require("readline");
const _fs = require("fs");
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
const _storage = require("../telemetry/storage");
function _interop_require_default(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
// Predefined set of the event names to be included in the trace.
// If the trace span's name matches to one of the event names in the set,
// it'll up uploaded to the trace server.
const EVENT_FILTER = new Set([
"client-hmr-latency",
"hot-reloader",
"webpack-invalid-client",
"webpack-invalidated-server",
"navigation-to-hydration",
"start-dev-server",
"compile-path",
"memory-usage",
"server-restart-close-to-memory-threshold"
]);
const { NEXT_TRACE_UPLOAD_DEBUG, // An external env to allow to upload full trace without picking up the relavant spans.
// This is mainly for the debugging purpose, to allwo manual audit for full trace for the given build.
// [NOTE] This may fail if build is large and generated trace is excessively large.
NEXT_TRACE_UPLOAD_FULL } = process.env;
const isDebugEnabled = !!NEXT_TRACE_UPLOAD_DEBUG || !!NEXT_TRACE_UPLOAD_FULL;
const shouldUploadFullTrace = !!NEXT_TRACE_UPLOAD_FULL;
const [, , traceUploadUrl, mode, projectDir, distDir] = process.argv;
(async function upload() {
const nextVersion = JSON.parse(await _promises.default.readFile(_path.default.resolve(__dirname, "../../package.json"), "utf8")).version;
const telemetry = new _storage.Telemetry({
distDir
});
const projectPkgJsonPath = await (0, _findup.default)("package.json");
(0, _assert.default)(projectPkgJsonPath);
const projectPkgJson = JSON.parse(await _promises.default.readFile(projectPkgJsonPath, "utf-8"));
const pkgName = projectPkgJson.name;
const commit = _child_process.default.spawnSync(_os.default.platform() === "win32" ? "git.exe" : "git", [
"rev-parse",
"HEAD"
], {
shell: true
}).stdout.toString().trimEnd();
const readLineInterface = (0, _readline.createInterface)({
input: (0, _fs.createReadStream)(_path.default.join(projectDir, distDir, "trace")),
crlfDelay: Infinity
});
let isTurboSession = false;
const traces = new Map();
for await (const line of readLineInterface){
const lineEvents = JSON.parse(line);
for (const event of lineEvents){
if (// Always include root spans
event.parentId === undefined || shouldUploadFullTrace || EVENT_FILTER.has(event.name)) {
let trace = traces.get(event.traceId);
if (trace === undefined) {
trace = [];
traces.set(event.traceId, trace);
}
if (typeof event.tags.isTurbopack === "boolean") {
isTurboSession = event.tags.isTurbopack;
}
trace.push(event);
}
}
}
const body = {
metadata: {
anonymousId: telemetry.anonymousId,
arch: _os.default.arch(),
commit,
cpus: _os.default.cpus().length,
isTurboSession,
mode,
nextVersion,
pkgName,
platform: _os.default.platform(),
sessionId: telemetry.sessionId
},
traces: [
...traces.values()
]
};
if (isDebugEnabled) {
console.log("Sending request with body", JSON.stringify(body, null, 2));
}
let res = await (0, _nodefetch.default)(traceUploadUrl, {
method: "POST",
headers: {
"Content-Type": "application/json",
"x-trace-transfer-mode": shouldUploadFullTrace ? "full" : "default"
},
body: JSON.stringify(body)
});
if (isDebugEnabled) {
console.log("Received response", res.status, await res.json());
}
})();
//# sourceMappingURL=trace-uploader.js.map

1
node_modules/next/dist/trace/trace-uploader.js.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"sources":["../../src/trace/trace-uploader.ts"],"names":["EVENT_FILTER","Set","NEXT_TRACE_UPLOAD_DEBUG","NEXT_TRACE_UPLOAD_FULL","process","env","isDebugEnabled","shouldUploadFullTrace","traceUploadUrl","mode","projectDir","distDir","argv","upload","nextVersion","JSON","parse","fsPromise","readFile","path","resolve","__dirname","version","telemetry","Telemetry","projectPkgJsonPath","findUp","assert","projectPkgJson","pkgName","name","commit","child_process","spawnSync","os","platform","shell","stdout","toString","trimEnd","readLineInterface","createInterface","input","createReadStream","join","crlfDelay","Infinity","isTurboSession","traces","Map","line","lineEvents","event","parentId","undefined","has","trace","get","traceId","set","tags","isTurbopack","push","body","metadata","anonymousId","arch","cpus","length","sessionId","values","console","log","stringify","res","fetch","method","headers","status","json"],"mappings":";;;;+DAAmB;iEACG;sEACI;+DACP;kEACD;2DACH;0BACiB;oBACC;6DAChB;yBACS;;;;;;AAE1B,iEAAiE;AACjE,yEAAyE;AACzE,yCAAyC;AACzC,MAAMA,eAAe,IAAIC,IAAI;IAC3B;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD;AAED,MAAM,EACJC,uBAAuB,EACvB,uFAAuF;AACvF,sGAAsG;AACtG,mFAAmF;AACnFC,sBAAsB,EACvB,GAAGC,QAAQC,GAAG;AAEf,MAAMC,iBAAiB,CAAC,CAACJ,2BAA2B,CAAC,CAACC;AACtD,MAAMI,wBAAwB,CAAC,CAACJ;AAEhC,MAAM,KAAKK,gBAAgBC,MAAMC,YAAYC,QAAQ,GAAGP,QAAQQ,IAAI;AA+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AW;gBACzC;gBACAL,MAAMM,IAAI,CAACV;YACb;QACF;IACF;IAEA,MAAMW,OAAyB;QAC7BC,UAAU;YACRC,aAAa1C,UAAU0C,WAAW;YAClCC,MAAMhC,WAAE,CAACgC,IAAI;YACbnC;YACAoC,MAAMjC,WAAE,CAACiC,IAAI,GAAGC,MAAM;YACtBrB;YACAtC;YACAK;YACAe;YACAM,UAAUD,WAAE,CAACC,QAAQ;YACrBkC,WAAW9C,UAAU8C,SAAS;QAChC;QACArB,QAAQ;eAAIA,OAAOsB,MAAM;SAAG;IAC9B;IAEA,IAAIhE,gBAAgB;QAClBiE,QAAQC,GAAG,CAAC,6BAA6BzD,KAAK0D,SAAS,CAACV,MAAM,MAAM;IACtE;IAEA,IAAIW,MAAM,MAAMC,IAAAA,kBAAK,EAACnE,gBAAgB;QACpCoE,QAAQ;QACRC,SAAS;YACP,gBAAgB;YAChB,yBAAyBtE,wBAAwB,SAAS;QAC5D;QACAwD,MAAMhD,KAAK0D,SAAS,CAACV;IACvB;IAEA,IAAIzD,gBAAgB;QAClBiE,QAAQC,GAAG,CAAC,qBAAqBE,IAAII,MAAM,EAAE,MAAMJ,IAAIK,IAAI;IAC7D;AACF,CAAA"}

40
node_modules/next/dist/trace/trace.d.ts generated vendored Normal file
View File

@ -0,0 +1,40 @@
import type { SpanId, TraceEvent, TraceState } from './types';
export declare enum SpanStatus {
Started = "started",
Stopped = "stopped"
}
interface Attributes {
[key: string]: string;
}
export declare class Span {
private name;
private id;
private parentId?;
private attrs;
private status;
private now;
private _start;
constructor({ name, parentId, attrs, startTime, }: {
name: string;
parentId?: SpanId;
startTime?: bigint;
attrs?: Attributes;
});
stop(stopTime?: bigint): void;
traceChild(name: string, attrs?: Attributes): Span;
manualTraceChild(name: string, startTime?: bigint, stopTime?: bigint, attrs?: Attributes): void;
getId(): number;
setAttribute(key: string, value: string): void;
traceFn<T>(fn: (span: Span) => T): T;
traceAsyncFn<T>(fn: (span: Span) => T | Promise<T>): Promise<T>;
}
export declare const trace: (name: string, parentId?: SpanId, attrs?: {
[key: string]: string;
} | undefined) => Span;
export declare const flushAllTraces: () => Promise<void>;
export declare const exportTraceState: () => TraceState;
export declare const initializeTraceState: (state: TraceState) => void;
export declare function getTraceEvents(): TraceEvent[];
export declare function recordTraceEvents(events: TraceEvent[]): void;
export declare const clearTraceEvents: () => never[];
export {};

194
node_modules/next/dist/trace/trace.js generated vendored Normal file
View File

@ -0,0 +1,194 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
Span: null,
SpanStatus: null,
clearTraceEvents: null,
exportTraceState: null,
flushAllTraces: null,
getTraceEvents: null,
initializeTraceState: null,
recordTraceEvents: null,
trace: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
Span: function() {
return Span;
},
SpanStatus: function() {
return SpanStatus;
},
clearTraceEvents: function() {
return clearTraceEvents;
},
exportTraceState: function() {
return exportTraceState;
},
flushAllTraces: function() {
return flushAllTraces;
},
getTraceEvents: function() {
return getTraceEvents;
},
initializeTraceState: function() {
return initializeTraceState;
},
recordTraceEvents: function() {
return recordTraceEvents;
},
trace: function() {
return trace;
}
});
const _report = require("./report");
const NUM_OF_MICROSEC_IN_NANOSEC = BigInt("1000");
const NUM_OF_MILLISEC_IN_NANOSEC = BigInt("1000000");
let count = 0;
const getId = ()=>{
count++;
return count;
};
let defaultParentSpanId;
let shouldSaveTraceEvents;
let savedTraceEvents = [];
var SpanStatus;
(function(SpanStatus) {
SpanStatus["Started"] = "started";
SpanStatus["Stopped"] = "stopped";
})(SpanStatus || (SpanStatus = {}));
class Span {
constructor({ name, parentId, attrs, startTime }){
this.name = name;
this.parentId = parentId ?? defaultParentSpanId;
this.attrs = attrs ? {
...attrs
} : {};
if (this.parentId === undefined) {
// Attach additional information to root spans
this.attrs.isTurbopack = Boolean(process.env.TURBOPACK);
}
this.status = "started";
this.id = getId();
this._start = startTime || process.hrtime.bigint();
// hrtime cannot be used to reconstruct tracing span's actual start time
// since it does not have relation to clock time:
// `These times are relative to an arbitrary time in the past, and not related to the time of day and therefore not subject to clock drift`
// https://nodejs.org/api/process.html#processhrtimetime
// Capturing current datetime as additional metadata for external reconstruction.
this.now = Date.now();
}
// Durations are reported as microseconds. This gives 1000x the precision
// of something like Date.now(), which reports in milliseconds.
// Additionally, ~285 years can be safely represented as microseconds as
// a float64 in both JSON and JavaScript.
stop(stopTime) {
if (this.status === "stopped") {
// Don't report the same span twice.
// TODO: In the future this should throw as `.stop()` shouldn't be called multiple times.
return;
}
const end = stopTime || process.hrtime.bigint();
const duration = (end - this._start) / NUM_OF_MICROSEC_IN_NANOSEC;
this.status = "stopped";
if (duration > Number.MAX_SAFE_INTEGER) {
throw new Error(`Duration is too long to express as float64: ${duration}`);
}
const timestamp = this._start / NUM_OF_MICROSEC_IN_NANOSEC;
const traceEvent = {
name: this.name,
duration: Number(duration),
timestamp: Number(timestamp),
id: this.id,
parentId: this.parentId,
tags: this.attrs,
startTime: this.now
};
_report.reporter.report(traceEvent);
if (shouldSaveTraceEvents) {
savedTraceEvents.push(traceEvent);
}
}
traceChild(name, attrs) {
return new Span({
name,
parentId: this.id,
attrs
});
}
manualTraceChild(name, // Start time in nanoseconds since epoch.
startTime, // Stop time in nanoseconds since epoch.
stopTime, attrs) {
// We need to convert the time info to the same base as hrtime since that is used usually.
const correction = process.hrtime.bigint() - BigInt(Date.now()) * NUM_OF_MILLISEC_IN_NANOSEC;
const span = new Span({
name,
parentId: this.id,
attrs,
startTime: startTime ? startTime + correction : process.hrtime.bigint()
});
span.stop(stopTime ? stopTime + correction : process.hrtime.bigint());
}
getId() {
return this.id;
}
setAttribute(key, value) {
this.attrs[key] = value;
}
traceFn(fn) {
try {
return fn(this);
} finally{
this.stop();
}
}
async traceAsyncFn(fn) {
try {
return await fn(this);
} finally{
this.stop();
}
}
}
const trace = (name, parentId, attrs)=>{
return new Span({
name,
parentId,
attrs
});
};
const flushAllTraces = ()=>_report.reporter.flushAll();
const exportTraceState = ()=>({
defaultParentSpanId,
lastId: count,
shouldSaveTraceEvents
});
const initializeTraceState = (state)=>{
count = state.lastId;
defaultParentSpanId = state.defaultParentSpanId;
shouldSaveTraceEvents = state.shouldSaveTraceEvents;
};
function getTraceEvents() {
return savedTraceEvents;
}
function recordTraceEvents(events) {
for (const traceEvent of events){
_report.reporter.report(traceEvent);
if (traceEvent.id > count) {
count = traceEvent.id + 1;
}
}
if (shouldSaveTraceEvents) {
savedTraceEvents.push(...events);
}
}
const clearTraceEvents = ()=>savedTraceEvents = [];
//# sourceMappingURL=trace.js.map

1
node_modules/next/dist/trace/trace.js.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"sources":["../../src/trace/trace.ts"],"names":["Span","clearTraceEvents","exportTraceState","flushAllTraces","getTraceEvents","initializeTraceState","recordTraceEvents","trace","NUM_OF_MICROSEC_IN_NANOSEC","BigInt","NUM_OF_MILLISEC_IN_NANOSEC","count","getId","defaultParentSpanId","shouldSaveTraceEvents","savedTraceEvents","SpanStatus","constructor","name","parentId","attrs","startTime","undefined","isTurbopack","Boolean","process","env","TURBOPACK","status","id","_start","hrtime","bigint","now","Date","stop","stopTime","end","duration","Number","MAX_SAFE_INTEGER","Error","timestamp","traceEvent","tags","reporter","report","push","traceChild","manualTraceChild","correction","span","setAttribute","key","value","traceFn","fn","traceAsyncFn","flushAll","lastId","state","events"],"mappings":";;;;;;;;;;;;;;;;;;;;;;IAyBaA,IAAI;eAAJA;;;;;IAkKAC,gBAAgB;eAAhBA;;IA3BAC,gBAAgB;eAAhBA;;IALAC,cAAc;eAAdA;;IAgBGC,cAAc;eAAdA;;IANHC,oBAAoB;eAApBA;;IAUGC,iBAAiB;eAAjBA;;IA5BHC,KAAK;eAALA;;;wBAnJY;AAGzB,MAAMC,6BAA6BC,OAAO;AAC1C,MAAMC,6BAA6BD,OAAO;AAC1C,IAAIE,QAAQ;AACZ,MAAMC,QAAQ;IACZD;IACA,OAAOA;AAC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,MACAC,UACAC;IAEA,OAAO,IAAIpB,KAAK;QAAEkB;QAAMC;QAAUC;IAAM;AAC1C;AAEO,MAAMjB,iBAAiB,IAAM0C,gBAAQ,CAACa,QAAQ;AAK9C,MAAMxD,mBAAmB,IAAmB,CAAA;QACjDW;QACA8C,QAAQhD;QACRG;IACF,CAAA;AACO,MAAMT,uBAAuB,CAACuD;IACnCjD,QAAQiD,MAAMD,MAAM;IACpB9C,sBAAsB+C,MAAM/C,mBAAmB;IAC/CC,wBAAwB8C,MAAM9C,qBAAqB;AACrD;AAEO,SAASV;IACd,OAAOW;AACT;AAEO,SAAST,kBAAkBuD,MAAoB;IACpD,KAAK,MAAMlB,cAAckB,OAAQ;QAC/BhB,gBAAQ,CAACC,MAAM,CAACH;QAChB,IAAIA,WAAWd,EAAE,GAAGlB,OAAO;YACzBA,QAAQgC,WAAWd,EAAE,GAAG;QAC1B;IACF;IACA,IAAIf,uBAAuB;QACzBC,iBAAiBgC,IAAI,IAAIc;IAC3B;AACF;AAEO,MAAM5D,mBAAmB,IAAOc,mBAAmB,EAAE"}

1
node_modules/next/dist/trace/trace.test.d.ts generated vendored Normal file
View File

@ -0,0 +1 @@
export {};

175
node_modules/next/dist/trace/trace.test.js generated vendored Normal file
View File

@ -0,0 +1,175 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
const _promises = require("fs/promises");
const _path = require("path");
const _os = require("os");
const _shared = require("./shared");
const _trace = require("./trace");
describe("Trace", ()=>{
beforeEach(()=>{
(0, _trace.initializeTraceState)({
lastId: 0,
shouldSaveTraceEvents: true
});
(0, _trace.clearTraceEvents)();
});
describe("Tracer", ()=>{
it("traces a block of code", async ()=>{
const tmpDir = await (0, _promises.mkdtemp)((0, _path.join)((0, _os.tmpdir)(), "json-reporter"));
(0, _shared.setGlobal)("distDir", tmpDir);
(0, _shared.setGlobal)("phase", "anything");
const root = (0, _trace.trace)("root-span", undefined, {
"some-tag": "some-value"
});
root.traceChild("child-span").traceFn(()=>null);
await root.traceChild("async-child-span").traceAsyncFn(async ()=>{
const delayedPromise = new Promise((resolve)=>{
setTimeout(resolve, 100);
});
await delayedPromise;
});
root.stop();
const traceEvents = (0, _trace.getTraceEvents)();
expect(traceEvents.length).toEqual(3);
expect(traceEvents[0].name).toEqual("child-span");
expect(traceEvents[1].name).toEqual("async-child-span");
expect(traceEvents[2].name).toEqual("root-span");
// Check that the serialized .next/trace file looks correct.
await (0, _trace.flushAllTraces)();
const traceFilename = (0, _path.join)(tmpDir, "trace");
const serializedTraces = JSON.parse(await (0, _promises.readFile)(traceFilename, "utf-8"));
expect(serializedTraces).toMatchObject([
{
id: 2,
name: "child-span",
parentId: 1,
startTime: expect.any(Number),
timestamp: expect.any(Number),
duration: expect.any(Number),
tags: {}
},
{
id: 3,
name: "async-child-span",
parentId: 1,
startTime: expect.any(Number),
timestamp: expect.any(Number),
duration: expect.any(Number),
tags: {}
},
{
id: 1,
name: "root-span",
startTime: expect.any(Number),
timestamp: expect.any(Number),
duration: expect.any(Number),
tags: {
"some-tag": "some-value"
}
}
]);
});
});
describe("Worker", ()=>{
it("exports and initializes trace state", ()=>{
const root = (0, _trace.trace)("root-span");
expect(root.getId()).toEqual(1);
const traceState = (0, _trace.exportTraceState)();
expect(traceState.lastId).toEqual(1);
(0, _trace.initializeTraceState)({
lastId: 101
});
const span = (0, _trace.trace)("another-span");
expect(span.getId()).toEqual(102);
});
it("trace data is serializable to a worker", async ()=>{
const root = (0, _trace.trace)("root-span");
root.traceChild("child-span").traceFn(()=>null);
root.stop();
const traceEvents = (0, _trace.getTraceEvents)();
expect(traceEvents.length).toEqual(2);
// This is a proxy check to make sure the object would be serializable
// to a worker. It will fail if the data contains some unserializable
// objects like BigInt.
const clone = JSON.parse(JSON.stringify(traceEvents));
expect(clone).toEqual(traceEvents);
});
it("correctly reports trace data from multiple workers", ()=>{
// This test simulates workers creating traces and propagating them
// back to the main process for recording. It doesn't use
// actual workers since they are more difficult to set up in tests.
(0, _trace.initializeTraceState)({
lastId: 5,
defaultParentSpanId: 1,
shouldSaveTraceEvents: true
});
const worker1Span = (0, _trace.trace)("worker1");
worker1Span.traceChild("webpack-compilation1").traceFn(()=>null);
worker1Span.stop();
const worker1Traces = (0, _trace.getTraceEvents)();
expect(worker1Traces.length).toEqual(2);
// Repeat for a second worker.
(0, _trace.clearTraceEvents)();
(0, _trace.initializeTraceState)({
lastId: 10,
defaultParentSpanId: 1,
shouldSaveTraceEvents: true
});
const worker2Span = (0, _trace.trace)("worker2");
worker2Span.traceChild("webpack-compilation2").traceFn(()=>null);
worker2Span.stop();
const worker2Traces = (0, _trace.getTraceEvents)();
expect(worker2Traces.length).toEqual(2);
// Now simulate the traces in the main process and record the traces
// from each worker.
(0, _trace.clearTraceEvents)();
(0, _trace.initializeTraceState)({
lastId: 0,
shouldSaveTraceEvents: true
});
const root = (0, _trace.trace)("next-build");
root.traceChild("some-child-span").traceFn(()=>null);
(0, _trace.recordTraceEvents)(worker1Traces);
expect((0, _trace.exportTraceState)().lastId).toEqual(8);
(0, _trace.recordTraceEvents)(worker2Traces);
expect((0, _trace.exportTraceState)().lastId).toEqual(13);
root.traceChild("another-child-span").traceFn(()=>null);
root.stop();
// Check that the final output looks correct.
const allTraces = (0, _trace.getTraceEvents)();
expect(allTraces.length).toEqual(7);
const firstSpan = allTraces[0];
expect(firstSpan.name).toEqual("some-child-span");
expect(firstSpan.id).toEqual(2);
expect(firstSpan.parentId).toEqual(1);
const worker1Child = allTraces[1];
expect(worker1Child.name).toEqual("webpack-compilation1");
expect(worker1Child.id).toEqual(7);
expect(worker1Child.parentId).toEqual(6);
const worker1Root = allTraces[2];
expect(worker1Root.name).toEqual("worker1");
expect(worker1Root.id).toEqual(6);
expect(worker1Root.parentId).toEqual(1);
const worker2Child = allTraces[3];
expect(worker2Child.name).toEqual("webpack-compilation2");
expect(worker2Child.id).toEqual(12);
expect(worker2Child.parentId).toEqual(11);
const worker2Root = allTraces[4];
expect(worker2Root.name).toEqual("worker2");
expect(worker2Root.id).toEqual(11);
expect(worker2Root.parentId).toEqual(1);
const lastChildSpan = allTraces[5];
expect(lastChildSpan.name).toEqual("another-child-span");
expect(lastChildSpan.id).toEqual(14);
expect(lastChildSpan.parentId).toEqual(1);
const rootSpan = allTraces[6];
expect(rootSpan.name).toEqual("next-build");
expect(rootSpan.id).toEqual(1);
expect(rootSpan.parentId).toBeUndefined();
});
});
});
//# sourceMappingURL=trace.test.js.map

1
node_modules/next/dist/trace/trace.test.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

16
node_modules/next/dist/trace/types.d.ts generated vendored Normal file
View File

@ -0,0 +1,16 @@
export type SpanId = number;
export interface TraceState {
lastId: number;
defaultParentSpanId?: SpanId;
shouldSaveTraceEvents?: boolean;
}
export type TraceEvent = {
traceId?: string;
parentId?: SpanId;
name: string;
id: SpanId;
timestamp: number;
duration: number;
tags?: Object;
startTime?: number;
};

6
node_modules/next/dist/trace/types.js generated vendored Normal file
View File

@ -0,0 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
//# sourceMappingURL=types.js.map

1
node_modules/next/dist/trace/types.js.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"sources":[],"names":[],"mappings":""}

7
node_modules/next/dist/trace/upload-trace.d.ts generated vendored Normal file
View File

@ -0,0 +1,7 @@
export default function uploadTrace({ traceUploadUrl, mode, projectDir, distDir, sync, }: {
traceUploadUrl: string;
mode: 'dev';
projectDir: string;
distDir: string;
sync?: boolean;
}): void;

35
node_modules/next/dist/trace/upload-trace.js generated vendored Normal file
View File

@ -0,0 +1,35 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "default", {
enumerable: true,
get: function() {
return uploadTrace;
}
});
function uploadTrace({ traceUploadUrl, mode, projectDir, distDir, sync }) {
const { NEXT_TRACE_UPLOAD_DEBUG } = process.env;
// Note: cross-spawn is not used here as it causes
// a new command window to appear when we don't want it to
const child_process = require("child_process");
// we use spawnSync when debugging to ensure logs are piped
// correctly to stdout/stderr
const spawn = NEXT_TRACE_UPLOAD_DEBUG || sync ? child_process.spawnSync : child_process.spawn;
spawn(process.execPath, [
require.resolve("./trace-uploader"),
traceUploadUrl,
mode,
projectDir,
distDir
], {
detached: !NEXT_TRACE_UPLOAD_DEBUG,
windowsHide: true,
shell: false,
...NEXT_TRACE_UPLOAD_DEBUG ? {
stdio: "inherit"
} : {}
});
}
//# sourceMappingURL=upload-trace.js.map

1
node_modules/next/dist/trace/upload-trace.js.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"sources":["../../src/trace/upload-trace.ts"],"names":["uploadTrace","traceUploadUrl","mode","projectDir","distDir","sync","NEXT_TRACE_UPLOAD_DEBUG","process","env","child_process","require","spawn","spawnSync","execPath","resolve","detached","windowsHide","shell","stdio"],"mappings":";;;;+BAAA;;;eAAwBA;;;AAAT,SAASA,YAAY,EAClCC,cAAc,EACdC,IAAI,EACJC,UAAU,EACVC,OAAO,EACPC,IAAI,EAOL;IACC,MAAM,EAAEC,uBAAuB,EAAE,GAAGC,QAAQC,GAAG;IAE/C,kDAAkD;IAClD,0DAA0D;IAC1D,MAAMC,gBACJC,QAAQ;IAEV,2DAA2D;IAC3D,6BAA6B;IAC7B,MAAMC,QACJL,2BAA2BD,OACvBI,cAAcG,SAAS,GACvBH,cAAcE,KAAK;IAEzBA,MACEJ,QAAQM,QAAQ,EAChB;QACEH,QAAQI,OAAO,CAAC;QAChBb;QACAC;QACAC;QACAC;KACD,EACD;QACEW,UAAU,CAACT;QACXU,aAAa;QACbC,OAAO;QACP,GAAIX,0BACA;YACEY,OAAO;QACT,IACA,CAAC,CAAC;IACR;AAEJ"}