@ms-cloudpack/api-server 0.65.9 → 0.65.11
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/lib/utilities/TaskRunner.d.ts.map +1 -1
- package/lib/utilities/TaskRunner.js +1 -4
- package/lib/utilities/TaskRunner.js.map +1 -1
- package/lib/utilities/bundleTask.d.ts.map +1 -1
- package/lib/utilities/bundleTask.js +3 -1
- package/lib/utilities/bundleTask.js.map +1 -1
- package/lib/utilities/getEntriesMapFromPackage.d.ts +14 -0
- package/lib/utilities/getEntriesMapFromPackage.d.ts.map +1 -0
- package/lib/utilities/getEntriesMapFromPackage.js +50 -0
- package/lib/utilities/getEntriesMapFromPackage.js.map +1 -0
- package/lib/utilities/getExternalsFromPackage.d.ts +14 -0
- package/lib/utilities/getExternalsFromPackage.d.ts.map +1 -0
- package/lib/utilities/getExternalsFromPackage.js +25 -0
- package/lib/utilities/getExternalsFromPackage.js.map +1 -0
- package/lib/utilities/isValidBundleEntry.d.ts +9 -0
- package/lib/utilities/isValidBundleEntry.d.ts.map +1 -0
- package/lib/utilities/isValidBundleEntry.js +24 -0
- package/lib/utilities/isValidBundleEntry.js.map +1 -0
- package/lib/utilities/toNormalizedEntryKey.d.ts +6 -0
- package/lib/utilities/toNormalizedEntryKey.d.ts.map +1 -0
- package/lib/utilities/toNormalizedEntryKey.js +9 -0
- package/lib/utilities/toNormalizedEntryKey.js.map +1 -0
- package/lib/utilities/writeStubForDensityEntries.js +1 -1
- package/lib/utilities/writeStubForDensityEntries.js.map +1 -1
- package/package.json +17 -17
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TaskRunner.d.ts","sourceRoot":"","sources":["../../src/utilities/TaskRunner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAGtD,OAAO,KAAK,EAAE,IAAI,EAAsB,MAAM,kBAAkB,CAAC;AAGjE,OAAO,KAAK,E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AC,QAAQ,CAAC,aAAa,CAAgC;IAC9D,gCAAgC;IAChC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAuB;IACvD;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAc;IAC7C,sDAAsD;IACtD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA6B;;IAWvD;;;OAGG;IACH,IAAI,UAAU,IAAI,QAAQ,CAAC,SAAS,CAAC,CAQpC;IAED;;;;OAIG;IACI,YAAY,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI;IAIvC;;;;;;;;;OASG;IACH,GAAG,CAAC,OAAO,EACT,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,EACnB,OAAO,CAAC,EAAE;QACR,KAAK,CAAC,EAAE,OAAO,CAAC;QAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,GACA,OAAO,CAAC,OAAO,CAAC;IAoEnB;;OAEG;IAGH,OAAO,IAAI,IAAI;IAYf;;;OAGG;IACG,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAoB5C;;;;;OAKG;IACG,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;IActC;;;OAGG;IACH,MAAM,IAAI,IAAI;IAId;;;OAGG;IACH,MAAM,IAAI,IAAI;IAId,2EAA2E;IAC3E,OAAO,CAAC,iBAAiB;IAOzB;;OAEG;IACH,OAAO,CAAC,YAAY;IAqBpB;;OAEG;IACH,OAAO,CAAC,UAAU;IA2ClB,sEAAsE;IACtE,OAAO,CAAC,iBAAiB;IAMzB;;OAEG;IACH,OAAO,CAAC,eAAe;CAMxB"}
|
|
@@ -92,10 +92,7 @@ export class TaskRunner {
|
|
|
92
92
|
do {
|
|
93
93
|
// Delete from rerun list (if present).
|
|
94
94
|
this._requiresRerun.delete(id);
|
|
95
|
-
taskResult = await this._queue.add(execute,
|
|
96
|
-
// Removes void from return type.
|
|
97
|
-
// Read more on: https://github.com/sindresorhus/p-queue/issues/175
|
|
98
|
-
{ throwOnTimeout: true, priority });
|
|
95
|
+
taskResult = await this._queue.add(execute, { priority });
|
|
99
96
|
} while (this._requiresRerun.has(id));
|
|
100
97
|
}
|
|
101
98
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TaskRunner.js","sourceRoot":"","sources":["../../src/utilities/TaskRunner.ts"],"names":[],"mappings":"AACA,OAAO,MAAM,MAAM,SAAS,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAaxE;;;;;;;GAOG;AACH,MAAM,OAAO,UAAU;IACb,IAAI,CAAsB;IACjB,MAAM,CAAS;IAChC,2EAA2E;IACnE,WAAW,CAAiB;IACpC;;;OAGG;IACc,aAAa,CAAgC;IAC9D,gCAAgC;IACf,eAAe,CAAuB;IACvD;;;OAGG;IACc,cAAc,CAAc;IAC7C,sDAAsD;IACrC,SAAS,CAA6B;IAEvD;QACE,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC,CAAC;QAC9C,IAAI,CAAC,WAAW,GAAG,EAAE,WAAW,EAAE,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,YAAY,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC;QAC1F,IAAI,CAAC,aAAa,GAAG,IAAI,GAAG,EAAE,CAAC;QAC/B,IAAI,CAAC,eAAe,GAAG,IAAI,GAAG,EAAE,CAAC;QACjC,IAAI,CAAC,cAAc,GAAG,IAAI,GAAG,EAAE,CAAC;QAChC,IAAI,CAAC,SAAS,GAAG,IAAI,GAAG,EAAE,CAAC;IAC7B,CAAC;IAED;;;OAGG;IACH,IAAI,UAAU;QACZ,OAAO;YACL,MAAM,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM;YACpD,cAAc,EAAE,IAAI,CAAC,aAAa,C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KAAK,IAAI,EAAE,CAAC;QAC7E,MAAM,KAAK,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QAClD,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;IAC1B,CAAC;IAED;;OAEG;IACK,eAAe,CAAC,MAAsD;QAC5E,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;QAChC,yCAAyC;QACzC,KAAK,IAAI,IAAI,CAAC,IAAI,EAAE,OAAO,CAAY,eAAe,CAAC,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QAC9E,KAAK,IAAI,IAAI,CAAC,IAAI,EAAE,OAAO,CAAW,cAAc,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IACxE,CAAC;CACF","sourcesContent":["import type { DataBus } from '@ms-cloudpack/data-bus';\nimport PQueue from 'p-queue';\nimport { taskListSource, taskStatsSource } from '../data/busSources.js';\nimport type { Task, TaskEndDescription } from '../types/Task.js';\nimport type { TaskDescription } from '../types/TaskDescription.js';\nimport type { TaskList } from '../types/TaskList.js';\nimport type { TaskStats } from '../types/TaskStats.js';\n\ninterface TaskIssueStats extends Pick<TaskStats, 'totalErrors' | 'totalWarnings'> {\n /** Mapping from ID to count */\n taskWarnings: Record<string, number>;\n /** Mapping from ID to count */\n taskErrors: Record<string, number>;\n}\n\n/**\n * TaskRunner tracks the status of tasks, manages concurrency, allows reusing task results,\n * and sends notifications about task status to the data bus (currently just used for `start`).\n *\n * NOTE: To enable data bus notifications, you must call `connectToBus()`.\n * `createApiContext` does this with the `taskRunner` passed in.\n * (`createPartialApiContext` does not create or connect a data bus.)\n */\nexport class TaskRunner {\n private _bus: DataBus | undefined;\n private readonly _queue: PQueue;\n /** Stats about task errors/warnings, only updated if a bus is connected */\n private _taskIssues: TaskIssueStats;\n /**\n * Tasks that are currently either running or waiting. (Note that `PQeueue`'s definition of\n * \"pending\" is slightly different: it only counts tasks that are currently running.)\n */\n private readonly _pendingTasks: Map<string, Promise<unknown>>;\n /** Tasks that have completed */\n private readonly _completedTasks: Map<string, unknown>;\n /**\n * Task IDs where a re-run was requested while the task was running.\n * We let the current task finish, and then re-run it.\n */\n private readonly _requiresRerun: Set<string>;\n /** All previously-seen tasks (regardless of state) */\n private readonly _allTasks: Map<string, Task<unknown>>;\n\n constructor() {\n this._queue = new PQueue({ concurrency: 10 });\n this._taskIssues = { totalErrors: 0, totalWarnings: 0, taskWarnings: {}, taskErrors: {} };\n this._pendingTasks = new Map();\n this._completedTasks = new Map();\n this._requiresRerun = new Set();\n this._allTasks = new Map();\n }\n\n /**\n * Get current task stats. Public for testing.\n * @internal\n */\n get _taskStats(): Readonly<TaskStats> {\n return {\n status: this._pendingTasks.size ? 'pending' : 'idle',\n remainingTasks: this._pendingTasks.size,\n totalTasks: this._allTasks.size,\n totalErrors: this._taskIssues.totalErrors,\n totalWarnings: this._taskIssues.totalWarnings,\n };\n }\n\n /**\n * Connects the TaskRunner to the data bus. Tasks will still run without this, but they won't\n * send any notifications to a client (which only matters if a client is listening, e.g.\n * the browser while running `start`).\n */\n public connectToBus(bus: DataBus): void {\n this._bus = bus;\n }\n\n /**\n * Enqueue a task and return its result promise.\n *\n * If a task with the same `id` was already added, it returns either the previous result\n * (if completed) or the promise (if pending). Pass `options.rerun` to force re-running.\n *\n * (Note that any re-runs will use the *original* task function, not the new one.\n * If something has changed that requires a new task function, you should incorporate this\n * into the `id`.)\n */\n add<TReturn>(\n task: Task<TReturn>,\n options?: {\n rerun?: boolean;\n priority?: number;\n },\n ): Promise<TReturn> {\n const { name, id, execute } = task;\n const { rerun, priority } = options || {};\n\n if (!this._allTasks.has(id)) {\n this._allTasks.set(id, task as Task<unknown>);\n }\n\n // Check if we are already completed the task with that id.\n const action = this._completedTasks.get(id) as TReturn | undefined;\n if (action !== undefined && !rerun) {\n return Promise.resolve(action);\n }\n\n // Check if we are already running the task with that id.\n const pending = this._pendingTasks.get(id) as Promise<TReturn> | undefined;\n if (pending !== undefined) {\n if (rerun) {\n this._requiresRerun.add(id);\n }\n return pending;\n }\n\n const resultPromise: Promise<TReturn> = (async () => {\n let taskResult: TReturn | undefined;\n let taskError: unknown;\n\n try {\n do {\n // Delete from rerun list (if present).\n this._requiresRerun.delete(id);\n\n taskResult = await this._queue.add(\n execute,\n // Removes void from return type.\n // Read more on: https://github.com/sindresorhus/p-queue/issues/175\n { throwOnTimeout: true, priority },\n );\n } while (this._requiresRerun.has(id));\n } catch (error) {\n taskError = error;\n // Re-throw the error, but `finally` will handle completion\n throw error;\n } finally {\n // Delete from pending list.\n this._pendingTasks.delete(id);\n\n this._reportEnd(task, taskResult, taskError);\n }\n\n // Extra check to ensure that the task returned a value.\n // It should never throw, if it does we have a bug.\n if (taskResult === undefined) {\n throw new Error(`Task \"${name}:${id}\" returned undefined, without throwing an error, which was unexpected.`);\n }\n\n // Update finished Tasks.\n this._completedTasks.set(id, taskResult);\n\n return taskResult;\n })();\n\n this._pendingTasks.set(id, resultPromise);\n const wasCompleted = this._completedTasks.delete(id);\n if (wasCompleted) {\n this._removeTaskIssues(task.id);\n }\n\n this._reportStart<TReturn>(task);\n\n return resultPromise;\n }\n\n /**\n * Dispose in-memory resources of all tasks and clear the TaskRunner's state.\n */\n // NOTE: This is also used by clearAllResults(), so if it's updated to do anything that\n // renders the TaskRunner unusable/finished, the common parts should be refactored out.\n dispose(): void {\n this._queue.clear();\n for (const task of this._allTasks.values()) {\n task.dispose?.();\n }\n this._allTasks.clear();\n this._pendingTasks.clear();\n this._completedTasks.clear();\n this._requiresRerun.clear();\n this._taskIssues = { totalErrors: 0, totalWarnings: 0, taskWarnings: {}, taskErrors: {} };\n }\n\n /**\n * Clear the result of a specific task (could involve deleting files from disk) and remove\n * it from the TaskRunner's task records.\n */\n async clearResult(id: string): Promise<void> {\n const task = this._allTasks.get(id);\n task?.dispose?.();\n await task?.clear?.();\n\n this._allTasks.delete(id);\n this._requiresRerun.delete(id);\n this._pendingTasks.delete(id);\n this._completedTasks.delete(id);\n this._removeTaskIssues(id);\n\n if (this._bus) {\n const { tasks, index } = this._findFromTaskList(id);\n if (index !== -1) {\n tasks.splice(index, 1);\n this._publishUpdates({ tasks, stats: true });\n }\n }\n }\n\n /**\n * Clear the results of all tasks (might include deleting files on disk) and clear the\n * TaskRunner's task records.\n *\n * (To only dispose in-memory resources, use `dispose()`.)\n */\n async clearAllResults(): Promise<void> {\n // Publish the empty task list first since deleting things might take awhile.\n this._publishUpdates({ tasks: [] });\n\n for (const task of this._allTasks.values()) {\n task.dispose?.();\n await task.clear?.();\n }\n this.dispose();\n\n // Publish new stats after clearing everything (otherwise the calculated values will be wrong)\n this._publishUpdates({ stats: true });\n }\n\n /**\n * Pauses the TaskRunner (for testing).\n * @internal\n */\n _pause(): void {\n this._queue.pause();\n }\n\n /**\n * Starts or resumes the TaskRunner (for testing).\n * @internal\n */\n _start(): void {\n this._queue.start();\n }\n\n /** Remove any records of previous issues with this task from the totals */\n private _removeTaskIssues(id: string): void {\n this._taskIssues.totalErrors -= this._taskIssues.taskErrors[id] || 0;\n this._taskIssues.totalWarnings -= this._taskIssues.taskWarnings[id] || 0;\n delete this._taskIssues.taskErrors[id];\n delete this._taskIssues.taskWarnings[id];\n }\n\n /**\n * Internal method to report the start of a task to the bus.\n */\n private _reportStart<TReturn>(task: Task<TReturn>): void {\n if (!this._bus || !task.getStartDescription) return;\n\n const { tasks, index } = this._findFromTaskList(task.id);\n\n const taskDesc: TaskDescription = {\n id: task.id,\n name: task.name,\n ...task.getStartDescription(),\n status: 'pending',\n startTime: Date.now(),\n };\n if (index === -1) {\n tasks.push(taskDesc);\n } else {\n tasks[index] = taskDesc;\n }\n\n this._publishUpdates({ tasks, stats: true });\n }\n\n /**\n * Internal method to report the end of a task to the bus.\n */\n private _reportEnd<TReturn>(task: Task<TReturn>, taskResult: TReturn | undefined, taskError: unknown): void {\n if (!this._bus || !task.getEndDescription) return;\n\n // Replace the usual description with an error if relevant\n const description: TaskEndDescription = taskError\n ? {\n errors: [\n {\n source: 'running task',\n // eslint-disable-next-line @typescript-eslint/no-base-to-string\n text: taskError instanceof Error ? taskError.stack || taskError.message : String(taskError),\n },\n ],\n }\n : task.getEndDescription(taskResult);\n const errorCount = description.errors?.length || 0;\n const warningCount = description.warnings?.length || 0;\n if (errorCount) {\n this._taskIssues.taskErrors[task.id] = errorCount;\n this._taskIssues.totalErrors += errorCount;\n }\n if (warningCount) {\n this._taskIssues.taskWarnings[task.id] = warningCount;\n this._taskIssues.totalWarnings += warningCount;\n }\n\n const { tasks, index } = this._findFromTaskList(task.id);\n const startDescription = tasks[index];\n\n if (startDescription) {\n const now = Date.now();\n tasks[index] = {\n ...startDescription,\n ...description,\n status: 'complete',\n duration: now - startDescription.startTime,\n lastUpdated: now,\n };\n\n this._publishUpdates({ tasks, stats: true });\n }\n }\n\n /** Get the task list from the data bus, and find the task's index. */\n private _findFromTaskList(id: string): { tasks: TaskDescription[]; index: number } {\n const tasks = this._bus?.getData<TaskList>(taskListSource.path)?.tasks || [];\n const index = tasks.findIndex((t) => t.id === id);\n return { tasks, index };\n }\n\n /**\n * Publish tasks and/or stats to the data bus.\n */\n private _publishUpdates(params: { tasks?: TaskDescription[]; stats?: boolean }): void {\n const { tasks, stats } = params;\n // Publish using .path for easier testing\n stats && this._bus?.publish<TaskStats>(taskStatsSource.path, this._taskStats);\n tasks && this._bus?.publish<TaskList>(taskListSource.path, { tasks });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"TaskRunner.js","sourceRoot":"","sources":["../../src/utilities/TaskRunner.ts"],"names":[],"mappings":"AACA,OAAO,MAAM,MAAM,SAAS,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAaxE;;;;;;;GAOG;AACH,MAAM,OAAO,UAAU;IACb,IAAI,CAAsB;IACjB,MAAM,CAAS;IAChC,2EAA2E;IACnE,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I,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IACxE,CAAC;CACF","sourcesContent":["import type { DataBus } from '@ms-cloudpack/data-bus';\nimport PQueue from 'p-queue';\nimport { taskListSource, taskStatsSource } from '../data/busSources.js';\nimport type { Task, TaskEndDescription } from '../types/Task.js';\nimport type { TaskDescription } from '../types/TaskDescription.js';\nimport type { TaskList } from '../types/TaskList.js';\nimport type { TaskStats } from '../types/TaskStats.js';\n\ninterface TaskIssueStats extends Pick<TaskStats, 'totalErrors' | 'totalWarnings'> {\n /** Mapping from ID to count */\n taskWarnings: Record<string, number>;\n /** Mapping from ID to count */\n taskErrors: Record<string, number>;\n}\n\n/**\n * TaskRunner tracks the status of tasks, manages concurrency, allows reusing task results,\n * and sends notifications about task status to the data bus (currently just used for `start`).\n *\n * NOTE: To enable data bus notifications, you must call `connectToBus()`.\n * `createApiContext` does this with the `taskRunner` passed in.\n * (`createPartialApiContext` does not create or connect a data bus.)\n */\nexport class TaskRunner {\n private _bus: DataBus | undefined;\n private readonly _queue: PQueue;\n /** Stats about task errors/warnings, only updated if a bus is connected */\n private _taskIssues: TaskIssueStats;\n /**\n * Tasks that are currently either running or waiting. (Note that `PQeueue`'s definition of\n * \"pending\" is slightly different: it only counts tasks that are currently running.)\n */\n private readonly _pendingTasks: Map<string, Promise<unknown>>;\n /** Tasks that have completed */\n private readonly _completedTasks: Map<string, unknown>;\n /**\n * Task IDs where a re-run was requested while the task was running.\n * We let the current task finish, and then re-run it.\n */\n private readonly _requiresRerun: Set<string>;\n /** All previously-seen tasks (regardless of state) */\n private readonly _allTasks: Map<string, Task<unknown>>;\n\n constructor() {\n this._queue = new PQueue({ concurrency: 10 });\n this._taskIssues = { totalErrors: 0, totalWarnings: 0, taskWarnings: {}, taskErrors: {} };\n this._pendingTasks = new Map();\n this._completedTasks = new Map();\n this._requiresRerun = new Set();\n this._allTasks = new Map();\n }\n\n /**\n * Get current task stats. Public for testing.\n * @internal\n */\n get _taskStats(): Readonly<TaskStats> {\n return {\n status: this._pendingTasks.size ? 'pending' : 'idle',\n remainingTasks: this._pendingTasks.size,\n totalTasks: this._allTasks.size,\n totalErrors: this._taskIssues.totalErrors,\n totalWarnings: this._taskIssues.totalWarnings,\n };\n }\n\n /**\n * Connects the TaskRunner to the data bus. Tasks will still run without this, but they won't\n * send any notifications to a client (which only matters if a client is listening, e.g.\n * the browser while running `start`).\n */\n public connectToBus(bus: DataBus): void {\n this._bus = bus;\n }\n\n /**\n * Enqueue a task and return its result promise.\n *\n * If a task with the same `id` was already added, it returns either the previous result\n * (if completed) or the promise (if pending). Pass `options.rerun` to force re-running.\n *\n * (Note that any re-runs will use the *original* task function, not the new one.\n * If something has changed that requires a new task function, you should incorporate this\n * into the `id`.)\n */\n add<TReturn>(\n task: Task<TReturn>,\n options?: {\n rerun?: boolean;\n priority?: number;\n },\n ): Promise<TReturn> {\n const { name, id, execute } = task;\n const { rerun, priority } = options || {};\n\n if (!this._allTasks.has(id)) {\n this._allTasks.set(id, task as Task<unknown>);\n }\n\n // Check if we are already completed the task with that id.\n const action = this._completedTasks.get(id) as TReturn | undefined;\n if (action !== undefined && !rerun) {\n return Promise.resolve(action);\n }\n\n // Check if we are already running the task with that id.\n const pending = this._pendingTasks.get(id) as Promise<TReturn> | undefined;\n if (pending !== undefined) {\n if (rerun) {\n this._requiresRerun.add(id);\n }\n return pending;\n }\n\n const resultPromise: Promise<TReturn> = (async () => {\n let taskResult: TReturn | undefined;\n let taskError: unknown;\n\n try {\n do {\n // Delete from rerun list (if present).\n this._requiresRerun.delete(id);\n\n taskResult = await this._queue.add(execute, { priority });\n } while (this._requiresRerun.has(id));\n } catch (error) {\n taskError = error;\n // Re-throw the error, but `finally` will handle completion\n throw error;\n } finally {\n // Delete from pending list.\n this._pendingTasks.delete(id);\n\n this._reportEnd(task, taskResult, taskError);\n }\n\n // Extra check to ensure that the task returned a value.\n // It should never throw, if it does we have a bug.\n if (taskResult === undefined) {\n throw new Error(`Task \"${name}:${id}\" returned undefined, without throwing an error, which was unexpected.`);\n }\n\n // Update finished Tasks.\n this._completedTasks.set(id, taskResult);\n\n return taskResult;\n })();\n\n this._pendingTasks.set(id, resultPromise);\n const wasCompleted = this._completedTasks.delete(id);\n if (wasCompleted) {\n this._removeTaskIssues(task.id);\n }\n\n this._reportStart<TReturn>(task);\n\n return resultPromise;\n }\n\n /**\n * Dispose in-memory resources of all tasks and clear the TaskRunner's state.\n */\n // NOTE: This is also used by clearAllResults(), so if it's updated to do anything that\n // renders the TaskRunner unusable/finished, the common parts should be refactored out.\n dispose(): void {\n this._queue.clear();\n for (const task of this._allTasks.values()) {\n task.dispose?.();\n }\n this._allTasks.clear();\n this._pendingTasks.clear();\n this._completedTasks.clear();\n this._requiresRerun.clear();\n this._taskIssues = { totalErrors: 0, totalWarnings: 0, taskWarnings: {}, taskErrors: {} };\n }\n\n /**\n * Clear the result of a specific task (could involve deleting files from disk) and remove\n * it from the TaskRunner's task records.\n */\n async clearResult(id: string): Promise<void> {\n const task = this._allTasks.get(id);\n task?.dispose?.();\n await task?.clear?.();\n\n this._allTasks.delete(id);\n this._requiresRerun.delete(id);\n this._pendingTasks.delete(id);\n this._completedTasks.delete(id);\n this._removeTaskIssues(id);\n\n if (this._bus) {\n const { tasks, index } = this._findFromTaskList(id);\n if (index !== -1) {\n tasks.splice(index, 1);\n this._publishUpdates({ tasks, stats: true });\n }\n }\n }\n\n /**\n * Clear the results of all tasks (might include deleting files on disk) and clear the\n * TaskRunner's task records.\n *\n * (To only dispose in-memory resources, use `dispose()`.)\n */\n async clearAllResults(): Promise<void> {\n // Publish the empty task list first since deleting things might take awhile.\n this._publishUpdates({ tasks: [] });\n\n for (const task of this._allTasks.values()) {\n task.dispose?.();\n await task.clear?.();\n }\n this.dispose();\n\n // Publish new stats after clearing everything (otherwise the calculated values will be wrong)\n this._publishUpdates({ stats: true });\n }\n\n /**\n * Pauses the TaskRunner (for testing).\n * @internal\n */\n _pause(): void {\n this._queue.pause();\n }\n\n /**\n * Starts or resumes the TaskRunner (for testing).\n * @internal\n */\n _start(): void {\n this._queue.start();\n }\n\n /** Remove any records of previous issues with this task from the totals */\n private _removeTaskIssues(id: string): void {\n this._taskIssues.totalErrors -= this._taskIssues.taskErrors[id] || 0;\n this._taskIssues.totalWarnings -= this._taskIssues.taskWarnings[id] || 0;\n delete this._taskIssues.taskErrors[id];\n delete this._taskIssues.taskWarnings[id];\n }\n\n /**\n * Internal method to report the start of a task to the bus.\n */\n private _reportStart<TReturn>(task: Task<TReturn>): void {\n if (!this._bus || !task.getStartDescription) return;\n\n const { tasks, index } = this._findFromTaskList(task.id);\n\n const taskDesc: TaskDescription = {\n id: task.id,\n name: task.name,\n ...task.getStartDescription(),\n status: 'pending',\n startTime: Date.now(),\n };\n if (index === -1) {\n tasks.push(taskDesc);\n } else {\n tasks[index] = taskDesc;\n }\n\n this._publishUpdates({ tasks, stats: true });\n }\n\n /**\n * Internal method to report the end of a task to the bus.\n */\n private _reportEnd<TReturn>(task: Task<TReturn>, taskResult: TReturn | undefined, taskError: unknown): void {\n if (!this._bus || !task.getEndDescription) return;\n\n // Replace the usual description with an error if relevant\n const description: TaskEndDescription = taskError\n ? {\n errors: [\n {\n source: 'running task',\n // eslint-disable-next-line @typescript-eslint/no-base-to-string\n text: taskError instanceof Error ? taskError.stack || taskError.message : String(taskError),\n },\n ],\n }\n : task.getEndDescription(taskResult);\n const errorCount = description.errors?.length || 0;\n const warningCount = description.warnings?.length || 0;\n if (errorCount) {\n this._taskIssues.taskErrors[task.id] = errorCount;\n this._taskIssues.totalErrors += errorCount;\n }\n if (warningCount) {\n this._taskIssues.taskWarnings[task.id] = warningCount;\n this._taskIssues.totalWarnings += warningCount;\n }\n\n const { tasks, index } = this._findFromTaskList(task.id);\n const startDescription = tasks[index];\n\n if (startDescription) {\n const now = Date.now();\n tasks[index] = {\n ...startDescription,\n ...description,\n status: 'complete',\n duration: now - startDescription.startTime,\n lastUpdated: now,\n };\n\n this._publishUpdates({ tasks, stats: true });\n }\n }\n\n /** Get the task list from the data bus, and find the task's index. */\n private _findFromTaskList(id: string): { tasks: TaskDescription[]; index: number } {\n const tasks = this._bus?.getData<TaskList>(taskListSource.path)?.tasks || [];\n const index = tasks.findIndex((t) => t.id === id);\n return { tasks, index };\n }\n\n /**\n * Publish tasks and/or stats to the data bus.\n */\n private _publishUpdates(params: { tasks?: TaskDescription[]; stats?: boolean }): void {\n const { tasks, stats } = params;\n // Publish using .path for easier testing\n stats && this._bus?.publish<TaskStats>(taskStatsSource.path, this._taskStats);\n tasks && this._bus?.publish<TaskList>(taskListSource.path, { tasks });\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundleTask.d.ts","sourceRoot":"","sources":["../../src/utilities/bundleTask.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAO/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"bundleTask.d.ts","sourceRoot":"","sources":["../../src/utilities/bundleTask.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAO/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAK1D;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,iCAAiC;IACjC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,iCAAiC;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,uCAAuC;IACvC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,+BAA+B;IAC/B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,aAAa,CAAC;CAC9B;AAED,MAAM,MAAM,iBAAiB,GAAG,cAAc,CAC5C,UAAU,GAAG,eAAe,GAAG,UAAU,GAAG,iBAAiB,GAAG,mBAAmB,EACnF,YAAY,GAAG,QAAQ,GAAG,UAAU,GAAG,WAAW,GAAG,eAAe,CACrE,CAAC;AAEF;;GAEG;AACH,wBAAsB,UAAU,CAAC,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CA2CtG"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { bundle
|
|
1
|
+
import { bundle } from '@ms-cloudpack/bundler';
|
|
2
2
|
import { writeJson } from '@ms-cloudpack/json-utilities';
|
|
3
3
|
import { getExportsMap } from '@ms-cloudpack/package-utilities';
|
|
4
4
|
import { SpanStatusCode } from '@ms-cloudpack/telemetry';
|
|
@@ -12,6 +12,8 @@ import { readResultFromCache } from './readResultFromCache.js';
|
|
|
12
12
|
import { saveResultToCache } from './saveResultToCache.js';
|
|
13
13
|
import { formatBundleTaskResult } from './formatBundleTaskResult.js';
|
|
14
14
|
import { writeStubForDensityEntries } from './writeStubForDensityEntries.js';
|
|
15
|
+
import { getExternalsFromPackage } from './getExternalsFromPackage.js';
|
|
16
|
+
import { getEntriesMapFromPackage } from './getEntriesMapFromPackage.js';
|
|
15
17
|
/**
|
|
16
18
|
* Create and run a TaskReporter task which calls `bundle()` from `@ms-cloudpack/bundler` and formats the result.
|
|
17
19
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundleTask.js","sourceRoot":"","sources":["../../src/utilities/bundleTask.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAElG,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAA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AC,QAAQ,CAAC,CAAC;gBACxG,CAAC;YACH,CAAC;QACH,CAAC;QAED,4BAA4B;QAC5B,MAAM,iBAAiB,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;IAChD,CAAC;IAED,4DAA4D;IAC5D,IAAI,mBAAmB,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,IAAI,aAAa,CAAC,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC;QAC9G,+EAA+E;QAC/E,iFAAiF;QACjF,2EAA2E;QAC3E,8CAA8C;QAC9C,MAAM,UAAU,GAAG,MAAM,aAAa,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;QAE9E,MAAM,UAAU,GAAG,MAAM,aAAa,CAAC;YACrC,UAAU;YACV,WAAW,EAAE,aAAa,CAAC,MAAM,CAAC,WAAW;YAC7C,UAAU;YACV,UAAU;YACV,WAAW;SACZ,CAAC,CAAC;QAEH,aAAa,CAAC,MAAM,CAAC,IAAI,GAAG,UAAU,CAAC;QAEvC,IAAI,MAAM,CAAC,aAAa,EAAE,CAAC;YACzB,8DAA8D;YAC9D,KAAK,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,kBAAkB,CAAC,EAAE,UAAU,CAAC,CAAC;QACxE,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import { bundle, getEntriesMapFromPackage, getExternalsFromPackage } from '@ms-cloudpack/bundler';\nimport type { BundleOptions } from '@ms-cloudpack/common-types';\nimport { writeJson } from '@ms-cloudpack/json-utilities';\nimport { getExportsMap } from '@ms-cloudpack/package-utilities';\nimport { SpanStatusCode } from '@ms-cloudpack/telemetry';\nimport { formatPackageName } from '@ms-cloudpack/task-reporter';\nimport path from 'path';\nimport { prepareOutputPath } from '../common/prepareOutputPath.js';\nimport type { BundleRequest } from '../types/BundleRequest.js';\nimport { getBundleInfo } from './getBundleInfo.js';\nimport { getBundleLocation } from './getBundleLocation.js';\nimport { isCachedResultValid } from './isCachedResultValid.js';\nimport { readResultFromCache } from './readResultFromCache.js';\nimport { saveResultToCache } from './saveResultToCache.js';\nimport { formatBundleTaskResult } from './formatBundleTaskResult.js';\nimport type { PartialContext } from '../types/Context.js';\nimport { writeStubForDensityEntries } from './writeStubForDensityEntries.js';\n\n/**\n * Options for a bundle task.\n */\nexport interface BundleTaskOptions {\n /** Force a bundle to be rerun */\n force?: boolean;\n /** Hash to avoid re-computing */\n hash?: string;\n /** Source hash to avoid recomputing */\n sourceHash?: string;\n /** Retry count for the task */\n retryCount?: number;\n bundleRequest: BundleRequest;\n}\n\nexport type BundleTaskContext = PartialContext<\n 'packages' | 'packageHashes' | 'reporter' | 'telemetryClient' | 'remoteCacheClient',\n 'resolveMap' | 'config' | 'sequence' | 'cachePath' | 'dedupeAliases'\n>;\n\n/**\n * Create and run a TaskReporter task which calls `bundle()` from `@ms-cloudpack/bundler` and formats the result.\n */\nexport async function bundleTask(options: BundleTaskOptions, context: BundleTaskContext): Promise<void> {\n const { bundleRequest, retryCount } = options;\n const { packageName, version } = bundleRequest;\n const { reporter, telemetryClient, session } = context;\n const { sequence } = session;\n\n const task = reporter.addTask(\n `Bundle ${formatPackageName({ name: packageName, version })}${retryCount ? ` (retry ${retryCount})` : ''}`,\n );\n\n try {\n await telemetryClient.tracer.startActiveSpan('BUNDLE_TASK', async (span) => {\n await bundleTaskInternal(options, context);\n\n span.setAttributes({\n sequence,\n isCacheHit: !!bundleRequest.resultFromCache,\n isExternal: bundleRequest.isExternal,\n packageName: bundleRequest.packageName,\n packageVersion: bundleRequest.version,\n bundleSource: bundleRequest.result?.bundleSource,\n bundler: bundleRequest.result?.bundler,\n bundlerVersion: bundleRequest.result?.bundlerVersion,\n ...(retryCount !== undefined && { retryCount }),\n });\n\n if (bundleRequest.result?.errors?.length) {\n // Set the status to `ERROR`\n span.setStatus({ code: SpanStatusCode.ERROR });\n }\n });\n } catch (err) {\n // If an unexpected error is thrown, add it to the result.\n // This ensures consistent handling of either actual bundler errors or exceptions.\n bundleRequest.result ??= {};\n bundleRequest.result.errors ??= [];\n bundleRequest.result.errors.push({\n text: `Unexpected exception while bundling: ${(err as Error).stack || String(err)}`,\n source: 'bundleTask',\n });\n }\n\n task.complete(formatBundleTaskResult(bundleRequest, reporter));\n}\n\n/**\n * Actually read the result from the cache or call `bundle()`.\n * NOTE: The result is returned by mutating `options.bundleRequest.result`.\n */\nasync function bundleTaskInternal(options: BundleTaskOptions, context: BundleTaskContext): Promise<void> {\n const { bundleRequest, force, hash, sourceHash } = options;\n const { packageName, version, targetEnvironment } = bundleRequest;\n const { packageHashes, packages, session } = context;\n const { config, dedupeAliases } = session;\n const { mode } = config;\n\n // If force is set, dispose the existing result.\n if (force && bundleRequest.result?.dispose) {\n bundleRequest.result.dispose();\n bundleRequest.result = undefined;\n }\n\n const { packagePath, isExternal, isIncremental, disableSourceMaps, shouldGetBundleInfo } = bundleRequest;\n\n const outputPath =\n bundleRequest.outputPath ??\n (await getBundleLocation({ packagePath, targetEnvironment, shouldRecalculate: force, hash }, context)).path;\n\n // Rehydrate the result if not incremental.\n if (bundleRequest.result === undefined && !force) {\n bundleRequest.result = await readResultFromCache(\n { packageName, version, inputPath: packagePath, outputPath, targetEnvironment },\n context,\n );\n }\n\n const cacheValidationHash = !isExternal\n ? sourceHash ||\n (await packageHashes.get({\n packagePath,\n targetEnvironment,\n isSourceHashingEnabled: true,\n shouldRecalculate: true,\n }))\n : undefined;\n\n // if the cached result is valid, use it.\n if (!force && isCachedResultValid({ bundleRequest, hash: cacheValidationHash })) {\n console.debug(`Using cached result for ${bundleRequest.packageName}@${bundleRequest.version}`);\n bundleRequest.resultFromCache = true;\n } else {\n bundleRequest.resultFromCache = false;\n\n // Only use cached result if it's successful.\n await prepareOutputPath(outputPath);\n\n if (bundleRequest.result?.rebuild) {\n bundleRequest.result = {\n ...(await bundleRequest.result.rebuild()),\n outputPath: bundleRequest.result.outputPath,\n hash: cacheValidationHash,\n };\n } else {\n const {\n bundler,\n bundlerOptions,\n inlinedDependencies,\n dynamicImports,\n bundlerCapabilities,\n ignoredBundlerWarnings,\n unsafeCjsExportNames,\n } = (await packages.get(packagePath)).cloudpack || {};\n\n const bundleOptions: BundleOptions = {\n // We need the package name without transforms to ensure we get the original name.\n packageName: (await packages.get(packagePath, { disableTransforms: true })).name,\n bundler,\n minify: mode === 'production',\n targetEnvironment,\n bundlerOptions,\n inputPath: packagePath,\n outputPath,\n incremental: isIncremental !== undefined ? isIncremental : false,\n sourcemap: !disableSourceMaps,\n entries: await getEntriesMapFromPackage({ inputPath: packagePath, targetEnvironment }, { packages, config }),\n inlined: inlinedDependencies,\n external: await getExternalsFromPackage({ inputPath: packagePath }, { packages }),\n dynamicImports,\n ignoredBundlerWarnings,\n bundlerCapabilities,\n unsafeCjsExportNames,\n dedupeAliases,\n };\n\n const bundleInternalResult = await bundle(bundleOptions, { config });\n bundleRequest.result = {\n ...bundleInternalResult,\n outputPath: bundleOptions.outputPath ?? outputPath,\n hash: cacheValidationHash,\n bundleSource: 'bundler',\n };\n\n if (bundlerCapabilities?.density) {\n // Get export maps that need to be written as stubs for density.\n // If there are density exports, write stubs for them.\n const densityResult = await writeStubForDensityEntries({\n options: {\n packageName,\n packagePath,\n result: bundleInternalResult,\n densityOptions: bundlerCapabilities.density,\n },\n context: { packages, config },\n });\n\n // Add errors and warnings to the appropriate arrays\n if (densityResult.errors.length > 0) {\n bundleRequest.result.errors = [...(bundleRequest.result.errors ?? []), ...densityResult.errors];\n }\n\n if (densityResult.warnings.length > 0) {\n bundleRequest.result.warnings = [...(bundleRequest.result.warnings ?? []), ...densityResult.warnings];\n }\n }\n }\n\n // Write the result to disk.\n await saveResultToCache(bundleRequest.result);\n }\n\n // If we should find required imports and exports per bundle\n if (shouldGetBundleInfo && !bundleRequest.result?.errors?.length && bundleRequest.result?.outputFiles?.length) {\n // Exports map is needed to find the bundle info per entry we intend to bundle.\n // Exports map is used instead of bundleRequest.entries since it is easier to use\n // because it contains the paths other packages use to import the entry and\n // the relative location of the bundled files.\n const exportsMap = await getExportsMap({ packagePath }, { packages, config });\n\n const bundleInfo = await getBundleInfo({\n outputPath,\n outputFiles: bundleRequest.result.outputFiles,\n exportsMap,\n isExternal,\n packagePath,\n });\n\n bundleRequest.result.info = bundleInfo;\n\n if (config.logBundleInfo) {\n // Write to cache for future use. (Ignore the promise result.)\n void writeJson(path.join(outputPath, 'bundle-info.json'), bundleInfo);\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"bundleTask.js","sourceRoot":"","sources":["../../src/utilities/bundleTask.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE/C,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAEnE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAErE,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAsBzE;;G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EAAE,WAAW,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;QAE9E,MAAM,UAAU,GAAG,MAAM,aAAa,CAAC;YACrC,UAAU;YACV,WAAW,EAAE,aAAa,CAAC,MAAM,CAAC,WAAW;YAC7C,UAAU;YACV,UAAU;YACV,WAAW;SACZ,CAAC,CAAC;QAEH,aAAa,CAAC,MAAM,CAAC,IAAI,GAAG,UAAU,CAAC;QAEvC,IAAI,MAAM,CAAC,aAAa,EAAE,CAAC;YACzB,8DAA8D;YAC9D,KAAK,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,kBAAkB,CAAC,EAAE,UAAU,CAAC,CAAC;QACxE,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import { bundle } from '@ms-cloudpack/bundler';\nimport type { BundleOptions } from '@ms-cloudpack/common-types';\nimport { writeJson } from '@ms-cloudpack/json-utilities';\nimport { getExportsMap } from '@ms-cloudpack/package-utilities';\nimport { SpanStatusCode } from '@ms-cloudpack/telemetry';\nimport { formatPackageName } from '@ms-cloudpack/task-reporter';\nimport path from 'path';\nimport { prepareOutputPath } from '../common/prepareOutputPath.js';\nimport type { BundleRequest } from '../types/BundleRequest.js';\nimport { getBundleInfo } from './getBundleInfo.js';\nimport { getBundleLocation } from './getBundleLocation.js';\nimport { isCachedResultValid } from './isCachedResultValid.js';\nimport { readResultFromCache } from './readResultFromCache.js';\nimport { saveResultToCache } from './saveResultToCache.js';\nimport { formatBundleTaskResult } from './formatBundleTaskResult.js';\nimport type { PartialContext } from '../types/Context.js';\nimport { writeStubForDensityEntries } from './writeStubForDensityEntries.js';\nimport { getExternalsFromPackage } from './getExternalsFromPackage.js';\nimport { getEntriesMapFromPackage } from './getEntriesMapFromPackage.js';\n\n/**\n * Options for a bundle task.\n */\nexport interface BundleTaskOptions {\n /** Force a bundle to be rerun */\n force?: boolean;\n /** Hash to avoid re-computing */\n hash?: string;\n /** Source hash to avoid recomputing */\n sourceHash?: string;\n /** Retry count for the task */\n retryCount?: number;\n bundleRequest: BundleRequest;\n}\n\nexport type BundleTaskContext = PartialContext<\n 'packages' | 'packageHashes' | 'reporter' | 'telemetryClient' | 'remoteCacheClient',\n 'resolveMap' | 'config' | 'sequence' | 'cachePath' | 'dedupeAliases'\n>;\n\n/**\n * Create and run a TaskReporter task which calls `bundle()` from `@ms-cloudpack/bundler` and formats the result.\n */\nexport async function bundleTask(options: BundleTaskOptions, context: BundleTaskContext): Promise<void> {\n const { bundleRequest, retryCount } = options;\n const { packageName, version } = bundleRequest;\n const { reporter, telemetryClient, session } = context;\n const { sequence } = session;\n\n const task = reporter.addTask(\n `Bundle ${formatPackageName({ name: packageName, version })}${retryCount ? ` (retry ${retryCount})` : ''}`,\n );\n\n try {\n await telemetryClient.tracer.startActiveSpan('BUNDLE_TASK', async (span) => {\n await bundleTaskInternal(options, context);\n\n span.setAttributes({\n sequence,\n isCacheHit: !!bundleRequest.resultFromCache,\n isExternal: bundleRequest.isExternal,\n packageName: bundleRequest.packageName,\n packageVersion: bundleRequest.version,\n bundleSource: bundleRequest.result?.bundleSource,\n bundler: bundleRequest.result?.bundler,\n bundlerVersion: bundleRequest.result?.bundlerVersion,\n ...(retryCount !== undefined && { retryCount }),\n });\n\n if (bundleRequest.result?.errors?.length) {\n // Set the status to `ERROR`\n span.setStatus({ code: SpanStatusCode.ERROR });\n }\n });\n } catch (err) {\n // If an unexpected error is thrown, add it to the result.\n // This ensures consistent handling of either actual bundler errors or exceptions.\n bundleRequest.result ??= {};\n bundleRequest.result.errors ??= [];\n bundleRequest.result.errors.push({\n text: `Unexpected exception while bundling: ${(err as Error).stack || String(err)}`,\n source: 'bundleTask',\n });\n }\n\n task.complete(formatBundleTaskResult(bundleRequest, reporter));\n}\n\n/**\n * Actually read the result from the cache or call `bundle()`.\n * NOTE: The result is returned by mutating `options.bundleRequest.result`.\n */\nasync function bundleTaskInternal(options: BundleTaskOptions, context: BundleTaskContext): Promise<void> {\n const { bundleRequest, force, hash, sourceHash } = options;\n const { packageName, version, targetEnvironment } = bundleRequest;\n const { packageHashes, packages, session } = context;\n const { config, dedupeAliases } = session;\n const { mode } = config;\n\n // If force is set, dispose the existing result.\n if (force && bundleRequest.result?.dispose) {\n bundleRequest.result.dispose();\n bundleRequest.result = undefined;\n }\n\n const { packagePath, isExternal, isIncremental, disableSourceMaps, shouldGetBundleInfo } = bundleRequest;\n\n const outputPath =\n bundleRequest.outputPath ??\n (await getBundleLocation({ packagePath, targetEnvironment, shouldRecalculate: force, hash }, context)).path;\n\n // Rehydrate the result if not incremental.\n if (bundleRequest.result === undefined && !force) {\n bundleRequest.result = await readResultFromCache(\n { packageName, version, inputPath: packagePath, outputPath, targetEnvironment },\n context,\n );\n }\n\n const cacheValidationHash = !isExternal\n ? sourceHash ||\n (await packageHashes.get({\n packagePath,\n targetEnvironment,\n isSourceHashingEnabled: true,\n shouldRecalculate: true,\n }))\n : undefined;\n\n // if the cached result is valid, use it.\n if (!force && isCachedResultValid({ bundleRequest, hash: cacheValidationHash })) {\n console.debug(`Using cached result for ${bundleRequest.packageName}@${bundleRequest.version}`);\n bundleRequest.resultFromCache = true;\n } else {\n bundleRequest.resultFromCache = false;\n\n // Only use cached result if it's successful.\n await prepareOutputPath(outputPath);\n\n if (bundleRequest.result?.rebuild) {\n bundleRequest.result = {\n ...(await bundleRequest.result.rebuild()),\n outputPath: bundleRequest.result.outputPath,\n hash: cacheValidationHash,\n };\n } else {\n const {\n bundler,\n bundlerOptions,\n inlinedDependencies,\n dynamicImports,\n bundlerCapabilities,\n ignoredBundlerWarnings,\n unsafeCjsExportNames,\n } = (await packages.get(packagePath)).cloudpack || {};\n\n const bundleOptions: BundleOptions = {\n // We need the package name without transforms to ensure we get the original name.\n packageName: (await packages.get(packagePath, { disableTransforms: true })).name,\n bundler,\n minify: mode === 'production',\n targetEnvironment,\n bundlerOptions,\n inputPath: packagePath,\n outputPath,\n incremental: isIncremental !== undefined ? isIncremental : false,\n sourcemap: !disableSourceMaps,\n entries: await getEntriesMapFromPackage({ inputPath: packagePath, targetEnvironment }, { packages, config }),\n inlined: inlinedDependencies,\n external: await getExternalsFromPackage({ inputPath: packagePath }, { packages }),\n dynamicImports,\n ignoredBundlerWarnings,\n bundlerCapabilities,\n unsafeCjsExportNames,\n dedupeAliases,\n };\n\n const bundleInternalResult = await bundle(bundleOptions, { config });\n bundleRequest.result = {\n ...bundleInternalResult,\n outputPath: bundleOptions.outputPath ?? outputPath,\n hash: cacheValidationHash,\n bundleSource: 'bundler',\n };\n\n if (bundlerCapabilities?.density) {\n // Get export maps that need to be written as stubs for density.\n // If there are density exports, write stubs for them.\n const densityResult = await writeStubForDensityEntries({\n options: {\n packageName,\n packagePath,\n result: bundleInternalResult,\n densityOptions: bundlerCapabilities.density,\n },\n context: { packages, config },\n });\n\n // Add errors and warnings to the appropriate arrays\n if (densityResult.errors.length > 0) {\n bundleRequest.result.errors = [...(bundleRequest.result.errors ?? []), ...densityResult.errors];\n }\n\n if (densityResult.warnings.length > 0) {\n bundleRequest.result.warnings = [...(bundleRequest.result.warnings ?? []), ...densityResult.warnings];\n }\n }\n }\n\n // Write the result to disk.\n await saveResultToCache(bundleRequest.result);\n }\n\n // If we should find required imports and exports per bundle\n if (shouldGetBundleInfo && !bundleRequest.result?.errors?.length && bundleRequest.result?.outputFiles?.length) {\n // Exports map is needed to find the bundle info per entry we intend to bundle.\n // Exports map is used instead of bundleRequest.entries since it is easier to use\n // because it contains the paths other packages use to import the entry and\n // the relative location of the bundled files.\n const exportsMap = await getExportsMap({ packagePath }, { packages, config });\n\n const bundleInfo = await getBundleInfo({\n outputPath,\n outputFiles: bundleRequest.result.outputFiles,\n exportsMap,\n isExternal,\n packagePath,\n });\n\n bundleRequest.result.info = bundleInfo;\n\n if (config.logBundleInfo) {\n // Write to cache for future use. (Ignore the promise result.)\n void writeJson(path.join(outputPath, 'bundle-info.json'), bundleInfo);\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CloudpackConfig, PackageDefinitionsCache, TargetEnvironment } from '@ms-cloudpack/common-types';
|
|
2
|
+
/**
|
|
3
|
+
* Gets the entries map for a given package. An entries map is different from an exports map in that
|
|
4
|
+
* the keys are relative paths to where the output should live, rather than how the entry is imported.
|
|
5
|
+
* The data structure is used for bundler config; not for resolution of imports.
|
|
6
|
+
*/
|
|
7
|
+
export declare function getEntriesMapFromPackage(options: {
|
|
8
|
+
inputPath: string;
|
|
9
|
+
targetEnvironment: TargetEnvironment;
|
|
10
|
+
}, context: {
|
|
11
|
+
packages: PackageDefinitionsCache;
|
|
12
|
+
config: Pick<CloudpackConfig, 'features'>;
|
|
13
|
+
}): Promise<Record<string, string>>;
|
|
14
|
+
//# sourceMappingURL=getEntriesMapFromPackage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getEntriesMapFromPackage.d.ts","sourceRoot":"","sources":["../../src/utilities/getEntriesMapFromPackage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAQ9G;;;;GAIG;AACH,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE;IACP,SAAS,EAAE,MAAM,CAAC;IAClB,iBAAiB,EAAE,iBAAiB,CAAC;CACtC,EACD,OAAO,EAAE;IACP,QAAQ,EAAE,uBAAuB,CAAC;IAClC,MAAM,EAAE,IAAI,CAAC,eAAe,EAAE,UAAU,CAAC,CAAC;CAC3C,GACA,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAsCjC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { flattenExportsMap, getExportsMap } from '@ms-cloudpack/package-utilities';
|
|
2
|
+
import { normalizeRelativePath } from '@ms-cloudpack/path-string-parsing';
|
|
3
|
+
import { intermediateToSourcePath, isExternalPackage } from '@ms-cloudpack/path-utilities';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import { isValidBundleEntry } from './isValidBundleEntry.js';
|
|
6
|
+
import { toNormalizedEntryKey } from './toNormalizedEntryKey.js';
|
|
7
|
+
/**
|
|
8
|
+
* Gets the entries map for a given package. An entries map is different from an exports map in that
|
|
9
|
+
* the keys are relative paths to where the output should live, rather than how the entry is imported.
|
|
10
|
+
* The data structure is used for bundler config; not for resolution of imports.
|
|
11
|
+
*/
|
|
12
|
+
export async function getEntriesMapFromPackage(options, context) {
|
|
13
|
+
const { inputPath, targetEnvironment } = options;
|
|
14
|
+
const isInternal = !isExternalPackage(inputPath);
|
|
15
|
+
const exportsMap = await getExportsMap({ packagePath: inputPath }, context);
|
|
16
|
+
const flattenedMap = flattenExportsMap(exportsMap, {
|
|
17
|
+
conditions: `${targetEnvironment}-defaults`,
|
|
18
|
+
});
|
|
19
|
+
let sourceExportsMap;
|
|
20
|
+
// The flattened map values tell us what physical files will show up in the import map on the page. We use these
|
|
21
|
+
// as the keys for the entries map, which results in physical file output from the bundler.
|
|
22
|
+
// For internal packages, we want the values (the inputs to the each entry) to use source paths if available. To
|
|
23
|
+
// get these, we can either derive from exports map "source" entries, or if those are not available, we can attempt
|
|
24
|
+
// to derive source paths from intermediate paths.
|
|
25
|
+
if (isInternal) {
|
|
26
|
+
sourceExportsMap = flattenExportsMap(exportsMap, {
|
|
27
|
+
// Allow traversing into targetEnvironment conditions to find 'source' conditions
|
|
28
|
+
conditions: [targetEnvironment, 'source'],
|
|
29
|
+
requiredConditions: ['source'],
|
|
30
|
+
});
|
|
31
|
+
for (const [key, value] of Object.entries(flattenedMap)) {
|
|
32
|
+
if (!sourceExportsMap[key]) {
|
|
33
|
+
sourceExportsMap[key] = intermediateToSourcePath(value, inputPath) || value;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return Object.fromEntries(Object.entries(flattenedMap)
|
|
38
|
+
.filter(([, value]) => isValidBundleEntry(value))
|
|
39
|
+
.map(([key, value]) => [
|
|
40
|
+
toNormalizedEntryKey(value),
|
|
41
|
+
toNormalizedRelativePath(inputPath, sourceExportsMap?.[key] || value),
|
|
42
|
+
]));
|
|
43
|
+
}
|
|
44
|
+
function toNormalizedRelativePath(inputPath, entry) {
|
|
45
|
+
if (path.isAbsolute(entry)) {
|
|
46
|
+
entry = path.relative(inputPath, entry);
|
|
47
|
+
}
|
|
48
|
+
return normalizeRelativePath(entry);
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=getEntriesMapFromPackage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getEntriesMapFromPackage.js","sourceRoot":"","sources":["../../src/utilities/getEntriesMapFromPackage.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AACnF,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAC3F,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAC5C,OAGC,EACD,OAGC;IAED,MAAM,EAAE,SAAS,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAC;IACjD,MAAM,UAAU,GAAG,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC;IACjD,MAAM,UAAU,GAAG,MAAM,aAAa,CAAC,EAAE,WAAW,EAAE,SAAS,EAAE,EAAE,OAAO,CAAC,CAAC;IAC5E,MAAM,YAAY,GAAG,iBAAiB,CAAC,UAAU,EAAE;QACjD,UAAU,EAAE,GAAG,iBAAiB,WAAW;KAC5C,CAAC,CAAC;IACH,IAAI,gBAAwC,CAAC;IAE7C,gHAAgH;IAChH,2FAA2F;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ms-cloudpack/common-types';\nimport { flattenExportsMap, getExportsMap } from '@ms-cloudpack/package-utilities';\nimport { normalizeRelativePath } from '@ms-cloudpack/path-string-parsing';\nimport { intermediateToSourcePath, isExternalPackage } from '@ms-cloudpack/path-utilities';\nimport path from 'path';\nimport { isValidBundleEntry } from './isValidBundleEntry.js';\nimport { toNormalizedEntryKey } from './toNormalizedEntryKey.js';\n\n/**\n * Gets the entries map for a given package. An entries map is different from an exports map in that\n * the keys are relative paths to where the output should live, rather than how the entry is imported.\n * The data structure is used for bundler config; not for resolution of imports.\n */\nexport async function getEntriesMapFromPackage(\n options: {\n inputPath: string;\n targetEnvironment: TargetEnvironment;\n },\n context: {\n packages: PackageDefinitionsCache;\n config: Pick<CloudpackConfig, 'features'>;\n },\n): Promise<Record<string, string>> {\n const { inputPath, targetEnvironment } = options;\n const isInternal = !isExternalPackage(inputPath);\n const exportsMap = await getExportsMap({ packagePath: inputPath }, context);\n const flattenedMap = flattenExportsMap(exportsMap, {\n conditions: `${targetEnvironment}-defaults`,\n });\n let sourceExportsMap: Record<string, string>;\n\n // The flattened map values tell us what physical files will show up in the import map on the page. We use these\n // as the keys for the entries map, which results in physical file output from the bundler.\n\n // For internal packages, we want the values (the inputs to the each entry) to use source paths if available. To\n // get these, we can either derive from exports map \"source\" entries, or if those are not available, we can attempt\n // to derive source paths from intermediate paths.\n\n if (isInternal) {\n sourceExportsMap = flattenExportsMap(exportsMap, {\n // Allow traversing into targetEnvironment conditions to find 'source' conditions\n conditions: [targetEnvironment, 'source'],\n requiredConditions: ['source'],\n });\n\n for (const [key, value] of Object.entries(flattenedMap)) {\n if (!sourceExportsMap[key]) {\n sourceExportsMap[key] = intermediateToSourcePath(value, inputPath) || value;\n }\n }\n }\n\n return Object.fromEntries(\n Object.entries(flattenedMap)\n .filter(([, value]) => isValidBundleEntry(value))\n .map(([key, value]) => [\n toNormalizedEntryKey(value),\n toNormalizedRelativePath(inputPath, sourceExportsMap?.[key] || value),\n ]),\n );\n}\n\nfunction toNormalizedRelativePath(inputPath: string, entry: string): string {\n if (path.isAbsolute(entry)) {\n entry = path.relative(inputPath, entry);\n }\n\n return normalizeRelativePath(entry);\n}\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { PackageDefinitionsCache } from '@ms-cloudpack/common-types';
|
|
2
|
+
/**
|
|
3
|
+
* Reads a package definition and derives a flat array of dependencies to externalize for bundling.
|
|
4
|
+
*
|
|
5
|
+
* To reduce the chances of accidentally bundling something that should be external, this includes
|
|
6
|
+
* the names of original dependencies of all types (prior to transforms), as well as any
|
|
7
|
+
* `includedDependencies` from config that were added by `createPackageSettingsTransform`.
|
|
8
|
+
*/
|
|
9
|
+
export declare function getExternalsFromPackage(options: {
|
|
10
|
+
inputPath: string;
|
|
11
|
+
}, context: {
|
|
12
|
+
packages: PackageDefinitionsCache;
|
|
13
|
+
}): Promise<string[]>;
|
|
14
|
+
//# sourceMappingURL=getExternalsFromPackage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getExternalsFromPackage.d.ts","sourceRoot":"","sources":["../../src/utilities/getExternalsFromPackage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAG1E;;;;;;GAMG;AACH,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE;IACP,SAAS,EAAE,MAAM,CAAC;CACnB,EACD,OAAO,EAAE;IACP,QAAQ,EAAE,uBAAuB,CAAC;CACnC,GACA,OAAO,CAAC,MAAM,EAAE,CAAC,CAgBnB"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { getDependencies } from '@ms-cloudpack/package-utilities';
|
|
2
|
+
/**
|
|
3
|
+
* Reads a package definition and derives a flat array of dependencies to externalize for bundling.
|
|
4
|
+
*
|
|
5
|
+
* To reduce the chances of accidentally bundling something that should be external, this includes
|
|
6
|
+
* the names of original dependencies of all types (prior to transforms), as well as any
|
|
7
|
+
* `includedDependencies` from config that were added by `createPackageSettingsTransform`.
|
|
8
|
+
*/
|
|
9
|
+
export async function getExternalsFromPackage(options, context) {
|
|
10
|
+
const { inputPath } = options;
|
|
11
|
+
const { packages } = context;
|
|
12
|
+
const transformedDefinition = await packages.get(inputPath);
|
|
13
|
+
const originalDefinition = await packages.get(inputPath, { disableTransforms: true });
|
|
14
|
+
return Object.keys({
|
|
15
|
+
// Use mostly original dependencies in case of removals by createPackageSettingsTransform.
|
|
16
|
+
...getDependencies(originalDefinition, { includeAll: true }),
|
|
17
|
+
// peerDependenciesMeta names should be redundant with peerDependencies.
|
|
18
|
+
// But in rare cases (debug@4), it may incorrectly include deps that aren't listed elsewhere...
|
|
19
|
+
// Include them just in case, since we want to externalize as many things as possible.
|
|
20
|
+
...originalDefinition.peerDependenciesMeta,
|
|
21
|
+
// Also use the transformed deps in case any includedDependencies weren't listed in orignal deps.
|
|
22
|
+
...transformedDefinition.dependencies,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=getExternalsFromPackage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getExternalsFromPackage.js","sourceRoot":"","sources":["../../src/utilities/getExternalsFromPackage.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAElE;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,OAEC,EACD,OAEC;IAED,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAC9B,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IAC7B,MAAM,qBAAqB,GAAG,MAAM,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IAC5D,MAAM,kBAAkB,GAAG,MAAM,QAAQ,CAAC,GAAG,CAAC,SAAS,EAAE,EAAE,iBAAiB,EAAE,IAAI,EAAE,CAAC,CAAC;IAEtF,OAAO,MAAM,CAAC,IAAI,CAAC;QACjB,0FAA0F;QAC1F,GAAG,eAAe,CAAC,kBAAkB,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;QAC5D,wEAAwE;QACxE,+FAA+F;QAC/F,sFAAsF;QACtF,GAAG,kBAAkB,CAAC,oBAAoB;QAC1C,iGAAiG;QACjG,GAAG,qBAAqB,CAAC,YAAY;KACtC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { PackageDefinitionsCache } from '@ms-cloudpack/common-types';\nimport { getDependencies } from '@ms-cloudpack/package-utilities';\n\n/**\n * Reads a package definition and derives a flat array of dependencies to externalize for bundling.\n *\n * To reduce the chances of accidentally bundling something that should be external, this includes\n * the names of original dependencies of all types (prior to transforms), as well as any\n * `includedDependencies` from config that were added by `createPackageSettingsTransform`.\n */\nexport async function getExternalsFromPackage(\n options: {\n inputPath: string;\n },\n context: {\n packages: PackageDefinitionsCache;\n },\n): Promise<string[]> {\n const { inputPath } = options;\n const { packages } = context;\n const transformedDefinition = await packages.get(inputPath);\n const originalDefinition = await packages.get(inputPath, { disableTransforms: true });\n\n return Object.keys({\n // Use mostly original dependencies in case of removals by createPackageSettingsTransform.\n ...getDependencies(originalDefinition, { includeAll: true }),\n // peerDependenciesMeta names should be redundant with peerDependencies.\n // But in rare cases (debug@4), it may incorrectly include deps that aren't listed elsewhere...\n // Include them just in case, since we want to externalize as many things as possible.\n ...originalDefinition.peerDependenciesMeta,\n // Also use the transformed deps in case any includedDependencies weren't listed in orignal deps.\n ...transformedDefinition.dependencies,\n });\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns true if the file path is a valid bundle-able file extension. This is used to filter exports maps out
|
|
3
|
+
* to ensure we prevent trying to bundle things that bundlers don't support. We can bundle things like TS,
|
|
4
|
+
* JS, CSS, SCSS, JSON, and even text extensions like .txt and .html. These formats all will produce javascript
|
|
5
|
+
* modules. "Valid" is defined by what the bundler abstraction expects. In the future we may want this code to be
|
|
6
|
+
* provided by the plugin itself so that it owns what's "supported".
|
|
7
|
+
*/
|
|
8
|
+
export declare function isValidBundleEntry(filePath: string): boolean;
|
|
9
|
+
//# sourceMappingURL=isValidBundleEntry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isValidBundleEntry.d.ts","sourceRoot":"","sources":["../../src/utilities/isValidBundleEntry.ts"],"names":[],"mappings":"AAcA;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAW5D"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { nonJsSourceExtensions, base64AssetExtensions, sourceRegex, textExtensions, } from '@ms-cloudpack/path-utilities';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
const supportedNonJsExtensions = [...base64AssetExtensions, ...nonJsSourceExtensions, ...textExtensions];
|
|
4
|
+
// Note: excluded extensions only need to contain things that are allowed by supportedExtensions but using
|
|
5
|
+
// an extended syntax that we don't want to support. For example, we want to support .ts files but not .d.ts.
|
|
6
|
+
const excludedExtensions = ['.d.ts'];
|
|
7
|
+
/**
|
|
8
|
+
* Returns true if the file path is a valid bundle-able file extension. This is used to filter exports maps out
|
|
9
|
+
* to ensure we prevent trying to bundle things that bundlers don't support. We can bundle things like TS,
|
|
10
|
+
* JS, CSS, SCSS, JSON, and even text extensions like .txt and .html. These formats all will produce javascript
|
|
11
|
+
* modules. "Valid" is defined by what the bundler abstraction expects. In the future we may want this code to be
|
|
12
|
+
* provided by the plugin itself so that it owns what's "supported".
|
|
13
|
+
*/
|
|
14
|
+
export function isValidBundleEntry(filePath) {
|
|
15
|
+
filePath = filePath.toLowerCase();
|
|
16
|
+
const ext = path.extname(filePath);
|
|
17
|
+
const isSupported = sourceRegex.test(ext) || supportedNonJsExtensions.includes(ext);
|
|
18
|
+
const isExcluded = excludedExtensions.some((excludedExt) => filePath.endsWith(excludedExt)) ||
|
|
19
|
+
// Exclude files that start with an underscore, as they are typically partials or other non-entry files.
|
|
20
|
+
// https://sass-lang.com/documentation/at-rules/import/#partials
|
|
21
|
+
(ext === '.scss' && path.basename(filePath).startsWith('_'));
|
|
22
|
+
return isSupported && !isExcluded;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=isValidBundleEntry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isValidBundleEntry.js","sourceRoot":"","sources":["../../src/utilities/isValidBundleEntry.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,WAAW,EACX,cAAc,GACf,MAAM,8BAA8B,CAAC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,MAAM,wBAAwB,GAAG,CAAC,GAAG,qBAAqB,EAAE,GAAG,qBAAqB,EAAE,GAAG,cAAc,CAAC,CAAC;AAEzG,0GAA0G;AAC1G,6GAA6G;AAC7G,MAAM,kBAAkB,GAAG,CAAC,OAAO,CAAC,CAAC;AAErC;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAAC,QAAgB;IACjD,QAAQ,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;IAClC,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACnC,MAAM,WAAW,GAAG,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,wBAAwB,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IACpF,MAAM,UAAU,GACd,kBAAkB,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;QACxE,wGAAwG;QACxG,gEAAgE;QAChE,CAAC,GAAG,KAAK,OAAO,IAAI,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;IAE/D,OAAO,WAAW,IAAI,CAAC,UAAU,CAAC;AACpC,CAAC","sourcesContent":["import {\n nonJsSourceExtensions,\n base64AssetExtensions,\n sourceRegex,\n textExtensions,\n} from '@ms-cloudpack/path-utilities';\nimport path from 'path';\n\nconst supportedNonJsExtensions = [...base64AssetExtensions, ...nonJsSourceExtensions, ...textExtensions];\n\n// Note: excluded extensions only need to contain things that are allowed by supportedExtensions but using\n// an extended syntax that we don't want to support. For example, we want to support .ts files but not .d.ts.\nconst excludedExtensions = ['.d.ts'];\n\n/**\n * Returns true if the file path is a valid bundle-able file extension. This is used to filter exports maps out\n * to ensure we prevent trying to bundle things that bundlers don't support. We can bundle things like TS,\n * JS, CSS, SCSS, JSON, and even text extensions like .txt and .html. These formats all will produce javascript\n * modules. \"Valid\" is defined by what the bundler abstraction expects. In the future we may want this code to be\n * provided by the plugin itself so that it owns what's \"supported\".\n */\nexport function isValidBundleEntry(filePath: string): boolean {\n filePath = filePath.toLowerCase();\n const ext = path.extname(filePath);\n const isSupported = sourceRegex.test(ext) || supportedNonJsExtensions.includes(ext);\n const isExcluded =\n excludedExtensions.some((excludedExt) => filePath.endsWith(excludedExt)) ||\n // Exclude files that start with an underscore, as they are typically partials or other non-entry files.\n // https://sass-lang.com/documentation/at-rules/import/#partials\n (ext === '.scss' && path.basename(filePath).startsWith('_'));\n\n return isSupported && !isExcluded;\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* When we derive keys, we want to preserve unknown script extensions. For others, remove them as the bundler
|
|
3
|
+
* will add back `'.js'` for us in the output.
|
|
4
|
+
*/
|
|
5
|
+
export declare function toNormalizedEntryKey(entry: string): string;
|
|
6
|
+
//# sourceMappingURL=toNormalizedEntryKey.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toNormalizedEntryKey.d.ts","sourceRoot":"","sources":["../../src/utilities/toNormalizedEntryKey.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE1D"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { sourceRegex } from '@ms-cloudpack/path-utilities';
|
|
2
|
+
/**
|
|
3
|
+
* When we derive keys, we want to preserve unknown script extensions. For others, remove them as the bundler
|
|
4
|
+
* will add back `'.js'` for us in the output.
|
|
5
|
+
*/
|
|
6
|
+
export function toNormalizedEntryKey(entry) {
|
|
7
|
+
return entry.replace(sourceRegex, '');
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=toNormalizedEntryKey.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toNormalizedEntryKey.js","sourceRoot":"","sources":["../../src/utilities/toNormalizedEntryKey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAE3D;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAa;IAChD,OAAO,KAAK,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;AACxC,CAAC","sourcesContent":["import { sourceRegex } from '@ms-cloudpack/path-utilities';\n\n/**\n * When we derive keys, we want to preserve unknown script extensions. For others, remove them as the bundler\n * will add back `'.js'` for us in the output.\n */\nexport function toNormalizedEntryKey(entry: string): string {\n return entry.replace(sourceRegex, '');\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { generateESMStubFromExports } from '@ms-cloudpack/esm-stub-utilities';
|
|
2
2
|
import { writeFile } from 'fs/promises';
|
|
3
3
|
import path from 'path';
|
|
4
|
-
import { toNormalizedEntryKey } from '
|
|
4
|
+
import { toNormalizedEntryKey } from './toNormalizedEntryKey.js';
|
|
5
5
|
import { flattenExportsMap, getExportsMap } from '@ms-cloudpack/package-utilities';
|
|
6
6
|
import { slash } from '@ms-cloudpack/path-string-parsing';
|
|
7
7
|
const errorSource = 'density-entry-stub';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writeStubForDensityEntries.js","sourceRoot":"","sources":["../../src/utilities/writeStubForDensityEntries.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,0BAA0B,EAAE,MAAM,kCAAkC,CAAC;AAC9E,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,oBAAoB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"writeStubForDensityEntries.js","sourceRoot":"","sources":["../../src/utilities/writeStubForDensityEntries.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,0BAA0B,EAAE,MAAM,kCAAkC,CAAC;AAC9E,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AACnF,OAAO,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;AAE1D,MAAM,WAAW,GAAG,oBAAoB,CAAC;AACzC,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAAC,MAWhD;IACC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;IACpC,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IACrD,MAAM,UAAU,GAAG,MAAM,aAAa,CAAC,EAAE,WAAW,EAAE,EAAE,OAAO,CAAC,CAAC;IACjE,MAAM,gBAAgB,GAAG,CAAC,SAAS,CAAC,CAAC;IACrC,MAAM,iBAAiB,GAAG,iBAAiB,CAAC,UAAU,EAAE;QACtD,kBAAkB,EAAE,gBAAgB;QACpC,UAAU,EAAE,gBAAgB;KAC7B,CAAC,CAAC;IAEH,IAAI,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,CAAC,cAAc,KAAK,IAAI,EAAE,CAAC;QACnF,OAAO,EAA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AG,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;YAEvF,wEAAwE;YACxE,wDAAwD;YACxD,MAAM,IAAI,GAAG,0BAA0B,CAAC;gBACtC,MAAM,EAAE;oBACN,IAAI,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO;oBAC7C,0GAA0G;oBAC1G,kDAAkD;oBAClD,IAAI,EAAE,UAAU,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,SAAS,CAAC,IAAI,EAAE;iBAC/D;gBACD,eAAe,EAAE,8CAA8C,KAAK,CAAC,QAAQ,CAAC,KAAK;aACpF,CAAC,CAAC;YAEH,MAAM,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,UAAU,CAAC,UAAU,CAAC,EAAE,IAAI,CAAC,CAAC;QAC7E,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,MAAM,CAAC,IAAI,CAAC;gBACV,IAAI,EAAE,4CAA4C,GAAG,MAAM,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG;gBACxG,MAAM,EAAE,WAAW;aACpB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;AAC9B,CAAC","sourcesContent":["import type {\n BundleMessage,\n BundlerCapabilitiesOptions,\n BundlerResult,\n CloudpackConfig,\n PackageDefinitionsCache,\n} from '@ms-cloudpack/common-types';\nimport { generateESMStubFromExports } from '@ms-cloudpack/esm-stub-utilities';\nimport { writeFile } from 'fs/promises';\nimport path from 'path';\nimport { toNormalizedEntryKey } from './toNormalizedEntryKey.js';\nimport { flattenExportsMap, getExportsMap } from '@ms-cloudpack/package-utilities';\nimport { slash } from '@ms-cloudpack/path-string-parsing';\n\nconst errorSource = 'density-entry-stub';\nexport async function writeStubForDensityEntries(params: {\n options: {\n packageName: string;\n packagePath: string;\n result: BundlerResult;\n densityOptions: NonNullable<BundlerCapabilitiesOptions['density']>;\n };\n context: {\n packages: PackageDefinitionsCache;\n config: CloudpackConfig;\n };\n}): Promise<{ errors: BundleMessage[]; warnings: BundleMessage[] }> {\n const { options, context } = params;\n const { packagePath, packageName, result } = options;\n const exportsMap = await getExportsMap({ packagePath }, context);\n const densityCondition = ['density'];\n const densityExportsMap = flattenExportsMap(exportsMap, {\n requiredConditions: densityCondition,\n conditions: densityCondition,\n });\n\n if (Object.keys(densityExportsMap).length === 0 && options.densityOptions === true) {\n return { errors: [], warnings: [] };\n }\n\n if (!result.outputFiles) {\n return {\n errors: [\n {\n source: errorSource,\n text: 'No output files found in the result.',\n },\n ],\n warnings: [],\n };\n }\n\n if (!result.outputPath) {\n return {\n errors: [\n {\n source: errorSource,\n text: 'No output path found in the result.',\n },\n ],\n warnings: [],\n };\n }\n\n const errors: BundleMessage[] = [];\n const warnings: BundleMessage[] = [];\n\n const entriesToStub = Object.entries(densityExportsMap);\n\n if (typeof options.densityOptions === 'object' && Array.isArray(options.densityOptions.entries)) {\n // Add entries that are in the options list\n const flattenedExportsMap = flattenExportsMap(exportsMap);\n\n for (const key of options.densityOptions.entries) {\n const normalizedKey = toNormalizedEntryKey(key);\n if (!flattenedExportsMap[normalizedKey]) {\n warnings.push({\n text: `Entry \"${key}\" from density capability not found in package exports map. Available entries: ${Object.keys(flattenedExportsMap).join(', ')}`,\n source: errorSource,\n });\n continue;\n }\n\n if (densityExportsMap[normalizedKey]) {\n warnings.push({\n text: `Entry \"${key}\" from density capability already has a \"density\" condition in exports map, skipping custom entry`,\n source: errorSource,\n });\n continue;\n }\n\n // Automatically detect the correct extension from the original export\n const originalPath = flattenedExportsMap[normalizedKey];\n const normalizedPath = toNormalizedEntryKey(originalPath);\n const extension = path.extname(originalPath) || '.js'; // Fallback to .js if no extension\n const densityPath = `${normalizedPath}${extension}`;\n\n entriesToStub.push([normalizedKey, densityPath]);\n }\n }\n\n // Generate density stubs for each entry\n for (const [key, value] of entriesToStub) {\n try {\n const entryPath = toNormalizedEntryKey(value);\n const outputFile = result.outputFiles.find((o) => o.outputPath === value);\n if (!outputFile) {\n const availableOutputs = result.outputFiles.map((f) => f.outputPath).join(', ');\n errors.push({\n text: `No output file found for density entry \"${key}\" (expected: ${entryPath}). Available output files: ${availableOutputs}. This might indicate a bundler configuration issue or the entry was not processed correctly.`,\n source: errorSource,\n });\n continue;\n }\n\n const moduleId = key === '.' ? options.packageName : path.join(packageName, entryPath);\n\n // generate new stab file for the external entry by using output.exports\n // found the output file. This file need to be replaced.\n const stub = generateESMStubFromExports({\n export: {\n type: outputFile.exports ? 'object' : 'other',\n // These exports are not technically correct since they might include a default export from the esm bundle\n // but density returns packages without a default.\n keys: outputFile.exports?.filter((e) => e !== 'default') ?? [],\n },\n importStatement: `const moduleExport = requireDensityModule(\"${slash(moduleId)}\");`,\n });\n\n await writeFile(path.join(result.outputPath, outputFile.outputPath), stub);\n } catch (e) {\n errors.push({\n text: `Failed to create density stub for entry \"${key}\": ${e instanceof Error ? e.message : String(e)}.`,\n source: errorSource,\n });\n }\n }\n\n return { errors, warnings };\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ms-cloudpack/api-server",
|
|
3
|
-
"version": "0.65.
|
|
3
|
+
"version": "0.65.11",
|
|
4
4
|
"description": "Internal API server for Cloudpack",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -35,34 +35,34 @@
|
|
|
35
35
|
"test": "cloudpack-scripts test"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@ms-cloudpack/bundler": "^0.
|
|
39
|
-
"@ms-cloudpack/common-types": "^0.33.
|
|
40
|
-
"@ms-cloudpack/config": "^0.38.
|
|
41
|
-
"@ms-cloudpack/create-express-app": "^1.10.
|
|
42
|
-
"@ms-cloudpack/data-bus": "^0.5.
|
|
38
|
+
"@ms-cloudpack/bundler": "^0.27.1",
|
|
39
|
+
"@ms-cloudpack/common-types": "^0.33.1",
|
|
40
|
+
"@ms-cloudpack/config": "^0.38.21",
|
|
41
|
+
"@ms-cloudpack/create-express-app": "^1.10.66",
|
|
42
|
+
"@ms-cloudpack/data-bus": "^0.5.1",
|
|
43
43
|
"@ms-cloudpack/environment": "^0.1.1",
|
|
44
|
-
"@ms-cloudpack/esm-stub-utilities": "^0.15.
|
|
45
|
-
"@ms-cloudpack/file-watcher": "^0.4.
|
|
46
|
-
"@ms-cloudpack/import-map": "^0.10.
|
|
44
|
+
"@ms-cloudpack/esm-stub-utilities": "^0.15.35",
|
|
45
|
+
"@ms-cloudpack/file-watcher": "^0.4.24",
|
|
46
|
+
"@ms-cloudpack/import-map": "^0.10.62",
|
|
47
47
|
"@ms-cloudpack/json-utilities": "^0.1.11",
|
|
48
|
-
"@ms-cloudpack/package-hashes": "^0.8.
|
|
49
|
-
"@ms-cloudpack/package-utilities": "^13.2.
|
|
48
|
+
"@ms-cloudpack/package-hashes": "^0.8.45",
|
|
49
|
+
"@ms-cloudpack/package-utilities": "^13.2.5",
|
|
50
50
|
"@ms-cloudpack/path-string-parsing": "^1.2.7",
|
|
51
|
-
"@ms-cloudpack/path-utilities": "^3.2.
|
|
52
|
-
"@ms-cloudpack/remote-cache": "^0.11.
|
|
51
|
+
"@ms-cloudpack/path-utilities": "^3.2.2",
|
|
52
|
+
"@ms-cloudpack/remote-cache": "^0.11.57",
|
|
53
53
|
"@ms-cloudpack/task-reporter": "^0.17.4",
|
|
54
|
-
"@ms-cloudpack/telemetry": "^0.11.
|
|
54
|
+
"@ms-cloudpack/telemetry": "^0.11.57",
|
|
55
55
|
"@trpc/client": "^11.1.1",
|
|
56
56
|
"@trpc/server": "^11.1.1",
|
|
57
57
|
"cors": "^2.8.5",
|
|
58
58
|
"es-module-lexer": "^1.4.1",
|
|
59
|
-
"filenamify": "^
|
|
59
|
+
"filenamify": "^7.0.0",
|
|
60
60
|
"get-port": "^7.0.0",
|
|
61
61
|
"object-hash": "^3.0.0",
|
|
62
|
-
"p-queue": "^
|
|
62
|
+
"p-queue": "^9.0.0",
|
|
63
63
|
"source-map": "^0.7.0",
|
|
64
64
|
"ws": "^8.16.0",
|
|
65
|
-
"zod": "^
|
|
65
|
+
"zod": "^4.0.0"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
68
|
"@ms-cloudpack/eslint-plugin-internal": "^0.0.1",
|