@ms-cloudpack/api-server 0.37.4 → 0.38.0

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.
Files changed (33) hide show
  1. package/lib/index.d.ts +0 -4
  2. package/lib/index.d.ts.map +1 -1
  3. package/lib/index.js.map +1 -1
  4. package/lib/types/BundleInfo.d.ts +12 -0
  5. package/lib/types/BundleInfo.d.ts.map +1 -1
  6. package/lib/types/BundleInfo.js.map +1 -1
  7. package/lib/utilities/bundleTask.js +7 -0
  8. package/lib/utilities/bundleTask.js.map +1 -1
  9. package/lib/utilities/getBundleInfo.d.ts +1 -0
  10. package/lib/utilities/getBundleInfo.d.ts.map +1 -1
  11. package/lib/utilities/getBundleInfo.js +6 -3
  12. package/lib/utilities/getBundleInfo.js.map +1 -1
  13. package/lib/utilities/getImportsAndExports.d.ts +4 -5
  14. package/lib/utilities/getImportsAndExports.d.ts.map +1 -1
  15. package/lib/utilities/getImportsAndExports.js +58 -5
  16. package/lib/utilities/getImportsAndExports.js.map +1 -1
  17. package/package.json +11 -10
  18. package/lib/types/CreateHtmlFunction.d.ts +0 -7
  19. package/lib/types/CreateHtmlFunction.d.ts.map +0 -1
  20. package/lib/types/CreateHtmlFunction.js +0 -2
  21. package/lib/types/CreateHtmlFunction.js.map +0 -1
  22. package/lib/types/CreateHtmlOptions.d.ts +0 -20
  23. package/lib/types/CreateHtmlOptions.d.ts.map +0 -1
  24. package/lib/types/CreateHtmlOptions.js +0 -2
  25. package/lib/types/CreateHtmlOptions.js.map +0 -1
  26. package/lib/types/CreateHtmlResult.d.ts +0 -9
  27. package/lib/types/CreateHtmlResult.d.ts.map +0 -1
  28. package/lib/types/CreateHtmlResult.js +0 -2
  29. package/lib/types/CreateHtmlResult.js.map +0 -1
  30. package/lib/types/CreateHtmlScript.d.ts +0 -8
  31. package/lib/types/CreateHtmlScript.d.ts.map +0 -1
  32. package/lib/types/CreateHtmlScript.js +0 -2
  33. package/lib/types/CreateHtmlScript.js.map +0 -1
package/lib/index.d.ts CHANGED
@@ -10,10 +10,6 @@ export type { TaskMessage } from './types/TaskMessage.js';
10
10
  export type { TaskOptions } from './types/TaskOptions.js';
11
11
  export type { TaskStartDescription } from './types/TaskStartDescription.js';
12
12
  export type { CloudpackServer } from './trpc/createCloudpackServer.js';
13
- export type { CreateHtmlFunction } from './types/CreateHtmlFunction.js';
14
- export type { CreateHtmlOptions } from './types/CreateHtmlOptions.js';
15
- export type { CreateHtmlResult } from './types/CreateHtmlResult.js';
16
- export type { CreateHtmlScript } from './types/CreateHtmlScript.js';
17
13
  export type { AddPackageOverrideInput } from './apis/addPackageOverride.js';
18
14
  export type { OpenCodeEditorInput } from './apis/openCodeEditor.js';
19
15
  export type { OpenFilePathInput } from './apis/openFilePath.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,YAAY,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,YAAY,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACxD,YAAY,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,YAAY,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,YAAY,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAC5C,YAAY,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,YAAY,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACxE,YAAY,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,YAAY,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,YAAY,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAC5E,YAAY,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAEvE,YAAY,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,C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sourcesContent":["export type { ApiServer } from './types/ApiServer.js';\nexport type { Context } from './types/Context.js';\nexport type { BundleInfo } from './types/BundleInfo.js';\nexport type { Session } from './types/Session.js';\nexport type { TaskStats } from './types/TaskStats.js';\nexport type { Task } from './types/Task.js';\nexport type { TaskDescription } from './types/TaskDescription.js';\nexport type { TaskEndDescription } from './types/TaskEndDescription.js';\nexport type { TaskMessage } from './types/TaskMessage.js';\nexport type { TaskOptions } from './types/TaskOptions.js';\nexport type { TaskStartDescription } from './types/TaskStartDescription.js';\nexport type { CloudpackServer } from './trpc/createCloudpackServer.js';\n\nexport type { CreateHtmlFunction } from './types/CreateHtmlFunction.js';\nexport type { CreateHtmlOptions } from './types/CreateHtmlOptions.js';\nexport type { CreateHtmlResult } from './types/CreateHtmlResult.js';\nexport type { CreateHtmlScript } from './types/CreateHtmlScript.js';\n\n// API types\nexport type { AddPackageOverrideInput } from './apis/addPackageOverride.js';\nexport type { OpenCodeEditorInput } from './apis/openCodeEditor.js';\nexport type { OpenFilePathInput } from './apis/openFilePath.js';\nexport type { ReportMetricInput } from './apis/reportMetric.js';\nexport type { ValidatePackageOverrideInput, ValidatePackageOverrideOutput } from './apis/validatePackageOverride.js';\n\n// TODO: delete these type exports once API reporting of \"forgotten\" exports is enabled\n// (they're not used and don't really need to be visible in the API)\nexport type {\n EnsurePackageBundledContext,\n EnsurePackageBundledInput,\n EnsurePackageBundledOutput,\n EnsurePackageBundledResult,\n} from './apis/ensurePackageBundled.js';\nexport type { BundleRequest } from './types/BundleRequest.js';\nexport type { BundleTaskOptions } from './types/BundleTaskOptions.js';\nexport type { OverrideOptions } from './types/OverrideOptions.js';\n\nexport { TaskRunner } from './utilities/TaskRunner.js';\nexport { reloadCountSource, taskListSource, taskStatsSource } from './data/busSources.js';\nexport { startApiServer } from './startApiServer.js';\nexport { createCloudpackClient } from './trpc/createCloudpackClient.js';\nexport { createCloudpackServer } from './trpc/createCloudpackServer.js';\nexport { ZodTaskDescription } from './types/TaskDescription.js';\nexport { ZodTaskEndDescription } from './types/TaskEndDescription.js';\nexport { ZodTaskMessage } from './types/TaskMessage.js';\nexport { ZodTaskStartDescription } from './types/TaskStartDescription.js';\nexport { getCachePath, getLocalCachePath } from './utilities/getCachePath.js';\nexport { getConsumedDependencies } from './utilities/getConsumedDependencies.js';\nexport { getConsumedPaths } from './utilities/getConsumedPaths.js';\n\n// Utilities\nexport { parseRequestInfo } from './utilities/parseRequestInfo.js';\nexport { createPartialApiContext } from './common/createPartialApiContext.js';\n\n// API methods\nexport {\n addPackageOverride,\n ensurePackageBundled,\n getData,\n getSessionId,\n onDataChanged,\n openCodeEditor,\n openConfigEditor,\n openFilePath,\n reportMetric,\n syncDownload,\n syncUpload,\n validatePackageOverride,\n} from './apis/index.js';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAgCA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC1F,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAC9E,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AACjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAEnE,YAAY;AACZ,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAE9E,cAAc;AACd,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,OAAO,EACP,YAAY,EACZ,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,uBAAuB,GACxB,MAAM,iBAAiB,CAAC","sourcesContent":["export type { ApiServer } from './types/ApiServer.js';\nexport type { Context } from './types/Context.js';\nexport type { BundleInfo } from './types/BundleInfo.js';\nexport type { Session } from './types/Session.js';\nexport type { TaskStats } from './types/TaskStats.js';\nexport type { Task } from './types/Task.js';\nexport type { TaskDescription } from './types/TaskDescription.js';\nexport type { TaskEndDescription } from './types/TaskEndDescription.js';\nexport type { TaskMessage } from './types/TaskMessage.js';\nexport type { TaskOptions } from './types/TaskOptions.js';\nexport type { TaskStartDescription } from './types/TaskStartDescription.js';\nexport type { CloudpackServer } from './trpc/createCloudpackServer.js';\n\n// API types\nexport type { AddPackageOverrideInput } from './apis/addPackageOverride.js';\nexport type { OpenCodeEditorInput } from './apis/openCodeEditor.js';\nexport type { OpenFilePathInput } from './apis/openFilePath.js';\nexport type { ReportMetricInput } from './apis/reportMetric.js';\nexport type { ValidatePackageOverrideInput, ValidatePackageOverrideOutput } from './apis/validatePackageOverride.js';\n\n// TODO: delete these type exports once API reporting of \"forgotten\" exports is enabled\n// (they're not used and don't really need to be visible in the API)\nexport type {\n EnsurePackageBundledContext,\n EnsurePackageBundledInput,\n EnsurePackageBundledOutput,\n EnsurePackageBundledResult,\n} from './apis/ensurePackageBundled.js';\nexport type { BundleRequest } from './types/BundleRequest.js';\nexport type { BundleTaskOptions } from './types/BundleTaskOptions.js';\nexport type { OverrideOptions } from './types/OverrideOptions.js';\n\nexport { TaskRunner } from './utilities/TaskRunner.js';\nexport { reloadCountSource, taskListSource, taskStatsSource } from './data/busSources.js';\nexport { startApiServer } from './startApiServer.js';\nexport { createCloudpackClient } from './trpc/createCloudpackClient.js';\nexport { createCloudpackServer } from './trpc/createCloudpackServer.js';\nexport { ZodTaskDescription } from './types/TaskDescription.js';\nexport { ZodTaskEndDescription } from './types/TaskEndDescription.js';\nexport { ZodTaskMessage } from './types/TaskMessage.js';\nexport { ZodTaskStartDescription } from './types/TaskStartDescription.js';\nexport { getCachePath, getLocalCachePath } from './utilities/getCachePath.js';\nexport { getConsumedDependencies } from './utilities/getConsumedDependencies.js';\nexport { getConsumedPaths } from './utilities/getConsumedPaths.js';\n\n// Utilities\nexport { parseRequestInfo } from './utilities/parseRequestInfo.js';\nexport { createPartialApiContext } from './common/createPartialApiContext.js';\n\n// API methods\nexport {\n addPackageOverride,\n ensurePackageBundled,\n getData,\n getSessionId,\n onDataChanged,\n openCodeEditor,\n openConfigEditor,\n openFilePath,\n reportMetric,\n syncDownload,\n syncUpload,\n validatePackageOverride,\n} from './apis/index.js';\n"]}
@@ -26,6 +26,8 @@ export type BundleEntryInfo = {
26
26
  produces: string[];
27
27
  /** Names from other packages consumed by this path. */
28
28
  consumes: BundleEntryConsumes[];
29
+ /** Dynamic imports consumed by this path. */
30
+ dynamicImports?: DynamicImport[];
29
31
  };
30
32
  /**
31
33
  * Info about imports consumed from a path in another package.
@@ -38,4 +40,14 @@ export type BundleEntryConsumes = {
38
40
  /** Export names consumed */
39
41
  names: string[];
40
42
  };
43
+ export type ConsumedImport = {
44
+ packageName: string;
45
+ importPath: string;
46
+ names: string[];
47
+ };
48
+ export type DynamicImport = {
49
+ packageName: string;
50
+ importSpecifier: string;
51
+ importOrigin: string;
52
+ };
41
53
  //# sourceMappingURL=BundleInfo.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"BundleInfo.d.ts","sourceRoot":"","sources":["../../src/types/BundleInfo.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,CAAC,SAAS,EAAE,MA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AC;CACjB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"BundleInfo.js","sourceRoot":"","sources":["../../src/types/BundleInfo.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * BundleInfo is a map of entry file paths to produce/consume information.\n * The keys are paths from the exports map.\n * e.g.:\n * ```json\n * {\n * \".\": {\n * \"bundlePath\": \"./index.js\",\n * \"produces\": [\"bar\"],\n * \"consumes\": [{ \"packageName\": \"foo\", \"importPath\": \"foo\", \"names\": [ \"foo\" ] }],\n * },\n * }\n * ```\n */\nexport type BundleInfo = {\n [entryPath: string]: BundleEntryInfo;\n};\n\n/**\n * Info about a bundled file's produced export names, and the import names it consumes\n * from other packages.\n */\nexport type BundleEntryInfo = {\n /** Relative path to the bundled file from the output root. */\n bundlePath: string;\n /** Export names produced by this path. */\n produces: string[];\n /** Names from other packages consumed by this path. */\n consumes: BundleEntryConsumes[];\n};\n\n/**\n * Info about imports consumed from a path in another package.\n */\nexport type BundleEntryConsumes = {\n /** Name of the package */\n packageName: string;\n /** Path consumed within the package (this will be the exports map key) */\n importPath: string;\n /** Export names consumed */\n names: string[];\n};\n"]}
1
+ {"version":3,"file":"BundleInfo.js","sourceRoot":"","sources":["../../src/types/BundleInfo.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * BundleInfo is a map of entry file paths to produce/consume information.\n * The keys are paths from the exports map.\n * e.g.:\n * ```json\n * {\n * \".\": {\n * \"bundlePath\": \"./index.js\",\n * \"produces\": [\"bar\"],\n * \"consumes\": [{ \"packageName\": \"foo\", \"importPath\": \"foo\", \"names\": [ \"foo\" ] }],\n * },\n * }\n * ```\n */\nexport type BundleInfo = {\n [entryPath: string]: BundleEntryInfo;\n};\n\n/**\n * Info about a bundled file's produced export names, and the import names it consumes\n * from other packages.\n */\nexport type BundleEntryInfo = {\n /** Relative path to the bundled file from the output root. */\n bundlePath: string;\n /** Export names produced by this path. */\n produces: string[];\n /** Names from other packages consumed by this path. */\n consumes: BundleEntryConsumes[];\n /** Dynamic imports consumed by this path. */\n dynamicImports?: DynamicImport[];\n};\n\n/**\n * Info about imports consumed from a path in another package.\n */\nexport type BundleEntryConsumes = {\n /** Name of the package */\n packageName: string;\n /** Path consumed within the package (this will be the exports map key) */\n importPath: string;\n /** Export names consumed */\n names: string[];\n};\n\nexport type ConsumedImport = {\n packageName: string;\n importPath: string;\n names: string[];\n};\n\nexport type DynamicImport = {\n packageName: string;\n importSpecifier: string;\n importOrigin: string;\n};\n"]}
@@ -86,6 +86,11 @@ async function bundle(params) {
86
86
  ...(userPackageSettings?.inlinedDependencies || []),
87
87
  ...(generatedPackageSettings?.inlinedDependencies || []),
88
88
  ];
89
+ // These are only used by the bundler-plugin-ori.
90
+ const dynamicImports = [
91
+ ...(userPackageSettings?.dynamicImports || []),
92
+ ...(generatedPackageSettings?.dynamicImports || []),
93
+ ];
89
94
  const bundleOptions = {
90
95
  bundlerType: bundleRequest.bundlerType || bundlerType,
91
96
  overrideOptions: bundlerOptions,
@@ -96,6 +101,7 @@ async function bundle(params) {
96
101
  entries: await getEntriesMapFromPackage({ inputPath: packagePath }, context),
97
102
  inlined: inlinedDependencies,
98
103
  external: await getExternalsFromPackage({ inputPath: packagePath }, context),
104
+ dynamicImports,
99
105
  };
100
106
  const bundleInternalResult = await bundleInternal(bundleOptions, { config });
101
107
  bundleRequest.result = {
@@ -120,6 +126,7 @@ async function bundle(params) {
120
126
  outputFiles: bundleRequest.result.outputFiles,
121
127
  exportsMap,
122
128
  isExternal,
129
+ packagePath,
123
130
  });
124
131
  bundleRequest.result.info = bundleInfo;
125
132
  // Write to cache for future use. (Ignore the promise result.)
@@ -1 +1 @@
1
- {"version":3,"file":"bundleTask.js","sourceRoot":"","sources":["../../src/utilities/bundleTask.ts"],"names":[],"mappings":"AAAA,OAA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AAI,CAAC,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,IAAI,aAAa,CAAC,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC;QAC9G,MAAM,cAAc,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,kBAAkB,CAAC,CAAC;QAEjE,+EAA+E;QAC/E,iFAAiF;QACjF,2EAA2E;QAC3E,8CAA8C;QAC9C,MAAM,UAAU,GAAG,MAAM,aAAa,CAAC,EAAE,WAAW,EAAE,EAAE,OAAO,CAAC,CAAC;QAEjE,MAAM,UAAU,GAAG,MAAM,aAAa,CAAC;YACrC,UAAU;YACV,WAAW,EAAE,aAAa,CAAC,MAAM,CAAC,WAAW;YAC7C,UAAU;YACV,UAAU;SACX,CAAC,CAAC;QAEH,aAAa,CAAC,MAAM,CAAC,IAAI,GAAG,UAAU,CAAC;QAEvC,8DAA8D;QAC9D,mEAAmE;QACnE,SAAS,CAAC,cAAc,EAAE,UAAU,CAAC,CAAC;IACxC,CAAC;IAED,OAAO,aAAa,CAAC;AACvB,CAAC","sourcesContent":["import { bundle as bundleInternal, getEntriesMapFromPackage, getExternalsFromPackage } from '@ms-cloudpack/bundler';\nimport type { BundleOptions, CloudpackConfig, PackageDefinitionsCache } from '@ms-cloudpack/common-types';\nimport type { PackageHashes } from '@ms-cloudpack/package-hashes';\nimport { getPackageSettings } from '@ms-cloudpack/config';\nimport { writeJson } from '@ms-cloudpack/json-utilities';\nimport { getExportsMap, type ResolveMap } from '@ms-cloudpack/package-utilities';\nimport { formatPackageName, type TaskReporter, type TaskReporterTaskResult } from '@ms-cloudpack/task-reporter';\nimport type { TelemetryClient } from '@ms-cloudpack/telemetry';\nimport path from 'path';\nimport { prepareOutputPath } from '../common/prepareOutputPath.js';\nimport type { BundleRequest } from '../types/BundleRequest.js';\nimport type { BundleTaskOptions } from '../types/BundleTaskOptions.js';\nimport { diskCacheRatioMetricEventAggregator } from './diskCacheRatioMetricEventAggregator.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';\n\nexport async function bundleTask(params: {\n bundleRequest: BundleRequest;\n options?: BundleTaskOptions;\n context: {\n packages: PackageDefinitionsCache;\n config: CloudpackConfig;\n resolveMap: ResolveMap;\n packageHashes: PackageHashes;\n reporter?: TaskReporter;\n telemetryClient?: TelemetryClient;\n };\n}): Promise<BundleRequest> {\n const { bundleRequest, options = {}, context } = params;\n const { packageName, version } = bundleRequest;\n const { reporter, telemetryClient } = context;\n const { retryCount } = options;\n\n telemetryClient?.performance.registerAggregator(diskCacheRatioMetricEventAggregator);\n\n const executeBundle = async (): Promise<TaskReporterTaskResult> => {\n await bundle({ bundleRequest, context, options });\n\n diskCacheRatioMetricEventAggregator?.record({\n isCacheHit: !!bundleRequest.resultFromCache,\n isExternal: bundleRequest.isExternal,\n });\n\n return formatBundleTaskResult(bundleRequest);\n };\n\n if (reporter) {\n const taskName = `Bundle ${formatPackageName({\n name: packageName,\n version,\n })}${retryCount ? ` (retry ${retryCount})` : ''}`;\n await reporter.runTask(taskName, executeBundle);\n } else {\n await executeBundle();\n }\n\n return bundleRequest;\n}\n\nasync function bundle(params: {\n bundleRequest: BundleRequest;\n context: {\n packages: PackageDefinitionsCache;\n config: CloudpackConfig;\n packageHashes: PackageHashes;\n };\n options?: BundleTaskOptions;\n}): Promise<BundleRequest> {\n const { bundleRequest, context, options = {} } = params;\n const { config, packageHashes } = context;\n const { force, hash, sourceHash } = options;\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, shouldRecalculate: force, hash }, context)).path;\n\n // Rehydrate the result if not incremental.\n if (bundleRequest.result === undefined && !force) {\n bundleRequest.result = await readResultFromCache(outputPath, {\n inputPath: packagePath,\n });\n }\n\n const cacheValidationHash = !isExternal\n ? sourceHash || (await packageHashes.get({ packagePath, isSourceHashingEnabled: true, shouldRecalculate: true }))\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 { userPackageSettings, generatedPackageSettings } =\n getPackageSettings({\n name: bundleRequest.packageName,\n version: bundleRequest.version,\n config,\n }) || {};\n const { bundlerType, bundlerOptions } = userPackageSettings || {};\n\n const inlinedDependencies = [\n ...(userPackageSettings?.inlinedDependencies || []),\n ...(generatedPackageSettings?.inlinedDependencies || []),\n ];\n\n const bundleOptions: BundleOptions = {\n bundlerType: bundleRequest.bundlerType || bundlerType,\n overrideOptions: bundlerOptions,\n inputPath: packagePath,\n outputPath,\n incremental: isIncremental !== undefined ? isIncremental : !isExternal,\n sourcemap: disableSourceMaps ? undefined : 'linked',\n entries: await getEntriesMapFromPackage({ inputPath: packagePath }, context),\n inlined: inlinedDependencies,\n external: await getExternalsFromPackage({ inputPath: packagePath }, context),\n };\n\n const bundleInternalResult = await bundleInternal(bundleOptions, { config });\n bundleRequest.result = {\n ...bundleInternalResult,\n outputPath: bundleOptions.outputPath ?? outputPath,\n hash: cacheValidationHash,\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 const bundleInfoPath = path.join(outputPath, 'bundle-info.json');\n\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 }, context);\n\n const bundleInfo = await getBundleInfo({\n outputPath,\n outputFiles: bundleRequest.result.outputFiles,\n exportsMap,\n isExternal,\n });\n\n bundleRequest.result.info = bundleInfo;\n\n // Write to cache for future use. (Ignore the promise result.)\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n writeJson(bundleInfoPath, bundleInfo);\n }\n\n return bundleRequest;\n}\n"]}
1
+ {"version":3,"file":"bundleTask.js","sourceRoot":"","sources":["../../src/utilities/bundleTask.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,cAAc,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAGpH,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,aAAa,EAAmB,MAAM,iCAAiC,CAAC;AACjF,OAAO,EAAE,iBAAiB,EAAkD,MAAM,6BAA6B,CAAC;AAEhH,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAGnE,OAAO,EAAE,mCAAmC,EAAE,MAAM,0CAA0C,CAAC;AAC/F,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,MAA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CAAC,MAAM,CAAC,IAAI,GAAG,UAAU,CAAC;QAEvC,8DAA8D;QAC9D,mEAAmE;QACnE,SAAS,CAAC,cAAc,EAAE,UAAU,CAAC,CAAC;IACxC,CAAC;IAED,OAAO,aAAa,CAAC;AACvB,CAAC","sourcesContent":["import { bundle as bundleInternal, getEntriesMapFromPackage, getExternalsFromPackage } from '@ms-cloudpack/bundler';\nimport type { BundleOptions, CloudpackConfig, PackageDefinitionsCache } from '@ms-cloudpack/common-types';\nimport type { PackageHashes } from '@ms-cloudpack/package-hashes';\nimport { getPackageSettings } from '@ms-cloudpack/config';\nimport { writeJson } from '@ms-cloudpack/json-utilities';\nimport { getExportsMap, type ResolveMap } from '@ms-cloudpack/package-utilities';\nimport { formatPackageName, type TaskReporter, type TaskReporterTaskResult } from '@ms-cloudpack/task-reporter';\nimport type { TelemetryClient } from '@ms-cloudpack/telemetry';\nimport path from 'path';\nimport { prepareOutputPath } from '../common/prepareOutputPath.js';\nimport type { BundleRequest } from '../types/BundleRequest.js';\nimport type { BundleTaskOptions } from '../types/BundleTaskOptions.js';\nimport { diskCacheRatioMetricEventAggregator } from './diskCacheRatioMetricEventAggregator.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';\n\nexport async function bundleTask(params: {\n bundleRequest: BundleRequest;\n options?: BundleTaskOptions;\n context: {\n packages: PackageDefinitionsCache;\n config: CloudpackConfig;\n resolveMap: ResolveMap;\n packageHashes: PackageHashes;\n reporter?: TaskReporter;\n telemetryClient?: TelemetryClient;\n };\n}): Promise<BundleRequest> {\n const { bundleRequest, options = {}, context } = params;\n const { packageName, version } = bundleRequest;\n const { reporter, telemetryClient } = context;\n const { retryCount } = options;\n\n telemetryClient?.performance.registerAggregator(diskCacheRatioMetricEventAggregator);\n\n const executeBundle = async (): Promise<TaskReporterTaskResult> => {\n await bundle({ bundleRequest, context, options });\n\n diskCacheRatioMetricEventAggregator?.record({\n isCacheHit: !!bundleRequest.resultFromCache,\n isExternal: bundleRequest.isExternal,\n });\n\n return formatBundleTaskResult(bundleRequest);\n };\n\n if (reporter) {\n const taskName = `Bundle ${formatPackageName({\n name: packageName,\n version,\n })}${retryCount ? ` (retry ${retryCount})` : ''}`;\n await reporter.runTask(taskName, executeBundle);\n } else {\n await executeBundle();\n }\n\n return bundleRequest;\n}\n\nasync function bundle(params: {\n bundleRequest: BundleRequest;\n context: {\n packages: PackageDefinitionsCache;\n config: CloudpackConfig;\n packageHashes: PackageHashes;\n };\n options?: BundleTaskOptions;\n}): Promise<BundleRequest> {\n const { bundleRequest, context, options = {} } = params;\n const { config, packageHashes } = context;\n const { force, hash, sourceHash } = options;\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, shouldRecalculate: force, hash }, context)).path;\n\n // Rehydrate the result if not incremental.\n if (bundleRequest.result === undefined && !force) {\n bundleRequest.result = await readResultFromCache(outputPath, {\n inputPath: packagePath,\n });\n }\n\n const cacheValidationHash = !isExternal\n ? sourceHash || (await packageHashes.get({ packagePath, isSourceHashingEnabled: true, shouldRecalculate: true }))\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 { userPackageSettings, generatedPackageSettings } =\n getPackageSettings({\n name: bundleRequest.packageName,\n version: bundleRequest.version,\n config,\n }) || {};\n const { bundlerType, bundlerOptions } = userPackageSettings || {};\n\n const inlinedDependencies = [\n ...(userPackageSettings?.inlinedDependencies || []),\n ...(generatedPackageSettings?.inlinedDependencies || []),\n ];\n\n // These are only used by the bundler-plugin-ori.\n const dynamicImports = [\n ...(userPackageSettings?.dynamicImports || []),\n ...(generatedPackageSettings?.dynamicImports || []),\n ];\n\n const bundleOptions: BundleOptions = {\n bundlerType: bundleRequest.bundlerType || bundlerType,\n overrideOptions: bundlerOptions,\n inputPath: packagePath,\n outputPath,\n incremental: isIncremental !== undefined ? isIncremental : !isExternal,\n sourcemap: disableSourceMaps ? undefined : 'linked',\n entries: await getEntriesMapFromPackage({ inputPath: packagePath }, context),\n inlined: inlinedDependencies,\n external: await getExternalsFromPackage({ inputPath: packagePath }, context),\n dynamicImports,\n };\n\n const bundleInternalResult = await bundleInternal(bundleOptions, { config });\n bundleRequest.result = {\n ...bundleInternalResult,\n outputPath: bundleOptions.outputPath ?? outputPath,\n hash: cacheValidationHash,\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 const bundleInfoPath = path.join(outputPath, 'bundle-info.json');\n\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 }, context);\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 // Write to cache for future use. (Ignore the promise result.)\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n writeJson(bundleInfoPath, bundleInfo);\n }\n\n return bundleRequest;\n}\n"]}
@@ -4,6 +4,7 @@ import type { BundleInfo } from '../types/BundleInfo.js';
4
4
  * Returns a mapping from entry file path to list of paths that are produced and consumed in the searched files.
5
5
  */
6
6
  export declare function getBundleInfo(params: {
7
+ packagePath: string;
7
8
  outputPath: string;
8
9
  outputFiles: BundleOutputFile[];
9
10
  exportsMap: PackageJsonExports;
@@ -1 +1 @@
1
- {"version":3,"file":"getBundleInfo.d.ts","sourceRoot":"","sources":["../../src/utilities/getBundleInfo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAIvF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEzD;;GAEG;AACH,wBAAsB,aAAa,CAAC,MAAM,EAAE;IAC1C,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,gBAAgB,EAAE,CAAC;IAChC,UAAU,EAAE,kBAAkB,CAAC;IAC/B,UAAU,EAAE,OAAO,CAAC;CACrB,GAAG,OAAO,CAAC,UAAU,CAAC,CAmHtB"}
1
+ {"version":3,"file":"getBundleInfo.d.ts","sourceRoot":"","sources":["../../src/utilities/getBundleInfo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAIvF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEzD;;GAEG;AACH,wBAAsB,aAAa,CAAC,MAAM,EAAE;IAC1C,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,gBAAgB,EAAE,CAAC;IAChC,UAAU,EAAE,kBAAkB,CAAC;IAC/B,UAAU,EAAE,OAAO,CAAC;CACrB,GAAG,OAAO,CAAC,UAAU,CAAC,CAuHtB"}
@@ -6,7 +6,7 @@ import { getImportsAndExports } from './getImportsAndExports.js';
6
6
  * Returns a mapping from entry file path to list of paths that are produced and consumed in the searched files.
7
7
  */
8
8
  export async function getBundleInfo(params) {
9
- const { outputPath, outputFiles, exportsMap, isExternal } = params;
9
+ const { packagePath, outputPath, outputFiles, exportsMap, isExternal } = params;
10
10
  const bundleInfo = {};
11
11
  // If there are no output files, return the empty bundle info.
12
12
  if (!outputFiles.length) {
@@ -55,11 +55,11 @@ export async function getBundleInfo(params) {
55
55
  if (safePath === undefined || !outputFileInfo[safePath]) {
56
56
  throw new Error(`Found file that was not expected to be processed: ${filePath}`);
57
57
  }
58
- const parseResult = await getImportsAndExports(filePath);
58
+ const parseResult = await getImportsAndExports(filePath, packagePath);
59
59
  if (!parseResult) {
60
60
  continue;
61
61
  }
62
- const { exportNames, imports } = parseResult;
62
+ const { exportNames, imports, dynamicImports } = parseResult;
63
63
  const { entry, produces } = outputFileInfo[safePath];
64
64
  exportNames.forEach((name) => produces.add(name));
65
65
  bundleInfo[entry] ??= {
@@ -67,6 +67,9 @@ export async function getBundleInfo(params) {
67
67
  produces: Array.from(produces),
68
68
  consumes: [],
69
69
  };
70
+ if (dynamicImports.length) {
71
+ bundleInfo[entry].dynamicImports = dynamicImports;
72
+ }
70
73
  for (const { packageName, importPath, names } of imports) {
71
74
  if (packageName?.startsWith('.')) {
72
75
  const localPath = path.resolve(path.dirname(filePath), packageName, importPath || '');
@@ -1 +1 @@
1
- {"version":3,"file":"getBundleInfo.js","sourceRoot":"","sources":["../../src/utilities/getBundleInfo.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,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BACL,CAAC;qBAAM,CAAC;oBACN,8CAA8C;oBAC9C,4EAA4E;oBAC5E,UAAU,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,KAAK,GAAG,KAAK,CAAC,IAAI,CACvD,IAAI,GAAG,CAAC,CAAC,GAAG,KAAK,EAAE,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,CAAC,CACrE,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;QACD,IAAI,eAAe,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,CAAC,EAAE,CAAC;YAC1C,sCAAsC;YACtC,KAAK,MAAM,aAAa,IAAI,eAAe,CAAC,QAAQ,CAAC,EAAE,CAAC;gBACtD,IAAI,aAAa,KAAK,KAAK,EAAE,CAAC;oBAC5B,UAAU,CAAC,aAAa,CAAC,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;gBAChD,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC","sourcesContent":["import type { BundleOutputFile, PackageJsonExports } from '@ms-cloudpack/common-types';\nimport { getRuntimeEntryPaths } from '@ms-cloudpack/import-map';\nimport { normalizeRelativePath } from '@ms-cloudpack/path-string-parsing';\nimport path from 'path';\nimport type { BundleInfo } from '../types/BundleInfo.js';\nimport { getImportsAndExports } from './getImportsAndExports.js';\n/**\n * Returns a mapping from entry file path to list of paths that are produced and consumed in the searched files.\n */\nexport async function getBundleInfo(params: {\n outputPath: string;\n outputFiles: BundleOutputFile[];\n exportsMap: PackageJsonExports;\n isExternal: boolean;\n}): Promise<BundleInfo> {\n const { outputPath, outputFiles, exportsMap, isExternal } = params;\n const bundleInfo: BundleInfo = {};\n\n // If there are no output files, return the empty bundle info.\n if (!outputFiles.length) {\n return bundleInfo;\n }\n\n /** Mapping from output file (safe/normalized relative path) to possible entry path and exports. */\n const outputFileInfo: Record<string, { entry: string; produces: Set<string> }> = {};\n outputFiles.forEach((file) => {\n // Normalize the path to start with ./ (or . for an empty path)\n const safePath = normalizeRelativePath(file.outputPath);\n // Store safe path to possible entry path and exports.\n outputFileInfo[safePath] = {\n entry: safePath,\n produces: new Set<string>(file.exports),\n };\n });\n\n const repeatedExports: Record<string, string[]> = {};\n const entryPaths = getRuntimeEntryPaths({ isExternal, exportsMap });\n\n for (const [importPath, actualEntryPath] of Object.entries(entryPaths)) {\n const safePath = normalizeRelativePath(actualEntryPath);\n\n if (outputFileInfo[safePath]) {\n if (repeatedExports[safePath]) {\n repeatedExports[safePath].push(importPath);\n } else {\n // Change best guess entry path to exports map entry.\n outputFileInfo[safePath].entry = importPath;\n repeatedExports[safePath] = [importPath];\n }\n }\n }\n\n const localPathToSafe: Record<string, string> = {};\n Object.keys(outputFileInfo).forEach((safePath) => {\n localPathToSafe[path.resolve(outputPath, safePath)] = safePath;\n });\n\n const filePaths = Object.keys(localPathToSafe);\n const visitedPaths = new Set(filePaths);\n const pathsToParse = [...filePaths];\n\n while (pathsToParse.length) {\n const filePath = pathsToParse.shift();\n // Ignore any non-JS/TS files such as SVGs and sourcemaps\n if (!filePath || path.extname(filePath) !== '.js') {\n continue;\n }\n\n const safePath = localPathToSafe[filePath];\n if (safePath === undefined || !outputFileInfo[safePath]) {\n throw new Error(`Found file that was not expected to be processed: ${filePath}`);\n }\n\n const parseResult = await getImportsAndExports(filePath);\n if (!parseResult) {\n continue;\n }\n const { exportNames, imports } = parseResult;\n\n const { entry, produces } = outputFileInfo[safePath];\n exportNames.forEach((name) => produces.add(name));\n\n bundleInfo[entry] ??= {\n bundlePath: safePath,\n produces: Array.from(produces),\n consumes: [],\n };\n\n for (const { packageName, importPath, names } of imports) {\n if (packageName?.startsWith('.')) {\n const localPath = path.resolve(path.dirname(filePath), packageName, importPath || '');\n\n if (!visitedPaths.has(localPath)) {\n visitedPaths.add(localPath);\n pathsToParse.push(localPath);\n localPathToSafe[localPath] = importPath;\n }\n } else if (packageName && !packageName.startsWith('node:')) {\n // Find if the import is already in the consumes list.\n const entryIndex = bundleInfo[entry].consumes.findIndex(\n (c) => c.packageName === packageName && c.importPath === importPath,\n );\n if (entryIndex < 0) {\n // If not, add it.\n bundleInfo[entry].consumes.push({\n packageName: packageName,\n importPath: importPath || '.',\n names: [...names],\n });\n } else {\n // If so, add the names to the existing entry.\n // This is necessary because the same import may be used in multiple places.\n bundleInfo[entry].consumes[entryIndex].names = Array.from(\n new Set([...names, ...bundleInfo[entry].consumes[entryIndex].names]),\n );\n }\n }\n }\n if (repeatedExports[safePath]?.length > 1) {\n // Multiple entries for the same path.\n for (const repeatedEntry of repeatedExports[safePath]) {\n if (repeatedEntry !== entry) {\n bundleInfo[repeatedEntry] = bundleInfo[entry];\n }\n }\n }\n }\n\n return bundleInfo;\n}\n"]}
1
+ {"version":3,"file":"getBundleInfo.js","sourceRoot":"","sources":["../../src/utilities/getBundleInfo.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,MAMnC;IACC,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC;IAChF,MAAM,UAAU,GAAe,EAAE,CAAC;IAElC,8DAA8D;IAC9D,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC;QACxB,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,mGAAmG;IACnG,MAAM,cAAc,GAA6D,EAAE,CAAC;IACpF,WAAW,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QAC3B,+DAA+D;QAC/D,MAAM,QAAQ,GAAG,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AAQ,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,CAAC,CACrE,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;QACD,IAAI,eAAe,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,CAAC,EAAE,CAAC;YAC1C,sCAAsC;YACtC,KAAK,MAAM,aAAa,IAAI,eAAe,CAAC,QAAQ,CAAC,EAAE,CAAC;gBACtD,IAAI,aAAa,KAAK,KAAK,EAAE,CAAC;oBAC5B,UAAU,CAAC,aAAa,CAAC,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;gBAChD,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC","sourcesContent":["import type { BundleOutputFile, PackageJsonExports } from '@ms-cloudpack/common-types';\nimport { getRuntimeEntryPaths } from '@ms-cloudpack/import-map';\nimport { normalizeRelativePath } from '@ms-cloudpack/path-string-parsing';\nimport path from 'path';\nimport type { BundleInfo } from '../types/BundleInfo.js';\nimport { getImportsAndExports } from './getImportsAndExports.js';\n/**\n * Returns a mapping from entry file path to list of paths that are produced and consumed in the searched files.\n */\nexport async function getBundleInfo(params: {\n packagePath: string;\n outputPath: string;\n outputFiles: BundleOutputFile[];\n exportsMap: PackageJsonExports;\n isExternal: boolean;\n}): Promise<BundleInfo> {\n const { packagePath, outputPath, outputFiles, exportsMap, isExternal } = params;\n const bundleInfo: BundleInfo = {};\n\n // If there are no output files, return the empty bundle info.\n if (!outputFiles.length) {\n return bundleInfo;\n }\n\n /** Mapping from output file (safe/normalized relative path) to possible entry path and exports. */\n const outputFileInfo: Record<string, { entry: string; produces: Set<string> }> = {};\n outputFiles.forEach((file) => {\n // Normalize the path to start with ./ (or . for an empty path)\n const safePath = normalizeRelativePath(file.outputPath);\n // Store safe path to possible entry path and exports.\n outputFileInfo[safePath] = {\n entry: safePath,\n produces: new Set<string>(file.exports),\n };\n });\n\n const repeatedExports: Record<string, string[]> = {};\n const entryPaths = getRuntimeEntryPaths({ isExternal, exportsMap });\n\n for (const [importPath, actualEntryPath] of Object.entries(entryPaths)) {\n const safePath = normalizeRelativePath(actualEntryPath);\n\n if (outputFileInfo[safePath]) {\n if (repeatedExports[safePath]) {\n repeatedExports[safePath].push(importPath);\n } else {\n // Change best guess entry path to exports map entry.\n outputFileInfo[safePath].entry = importPath;\n repeatedExports[safePath] = [importPath];\n }\n }\n }\n\n const localPathToSafe: Record<string, string> = {};\n Object.keys(outputFileInfo).forEach((safePath) => {\n localPathToSafe[path.resolve(outputPath, safePath)] = safePath;\n });\n\n const filePaths = Object.keys(localPathToSafe);\n const visitedPaths = new Set(filePaths);\n const pathsToParse = [...filePaths];\n\n while (pathsToParse.length) {\n const filePath = pathsToParse.shift();\n // Ignore any non-JS/TS files such as SVGs and sourcemaps\n if (!filePath || path.extname(filePath) !== '.js') {\n continue;\n }\n\n const safePath = localPathToSafe[filePath];\n if (safePath === undefined || !outputFileInfo[safePath]) {\n throw new Error(`Found file that was not expected to be processed: ${filePath}`);\n }\n\n const parseResult = await getImportsAndExports(filePath, packagePath);\n if (!parseResult) {\n continue;\n }\n const { exportNames, imports, dynamicImports } = parseResult;\n\n const { entry, produces } = outputFileInfo[safePath];\n exportNames.forEach((name) => produces.add(name));\n\n bundleInfo[entry] ??= {\n bundlePath: safePath,\n produces: Array.from(produces),\n consumes: [],\n };\n\n if (dynamicImports.length) {\n bundleInfo[entry].dynamicImports = dynamicImports;\n }\n\n for (const { packageName, importPath, names } of imports) {\n if (packageName?.startsWith('.')) {\n const localPath = path.resolve(path.dirname(filePath), packageName, importPath || '');\n\n if (!visitedPaths.has(localPath)) {\n visitedPaths.add(localPath);\n pathsToParse.push(localPath);\n localPathToSafe[localPath] = importPath;\n }\n } else if (packageName && !packageName.startsWith('node:')) {\n // Find if the import is already in the consumes list.\n const entryIndex = bundleInfo[entry].consumes.findIndex(\n (c) => c.packageName === packageName && c.importPath === importPath,\n );\n if (entryIndex < 0) {\n // If not, add it.\n bundleInfo[entry].consumes.push({\n packageName: packageName,\n importPath: importPath || '.',\n names: [...names],\n });\n } else {\n // If so, add the names to the existing entry.\n // This is necessary because the same import may be used in multiple places.\n bundleInfo[entry].consumes[entryIndex].names = Array.from(\n new Set([...names, ...bundleInfo[entry].consumes[entryIndex].names]),\n );\n }\n }\n }\n if (repeatedExports[safePath]?.length > 1) {\n // Multiple entries for the same path.\n for (const repeatedEntry of repeatedExports[safePath]) {\n if (repeatedEntry !== entry) {\n bundleInfo[repeatedEntry] = bundleInfo[entry];\n }\n }\n }\n }\n\n return bundleInfo;\n}\n"]}
@@ -1,12 +1,11 @@
1
- import { type ImportStringResult } from '@ms-cloudpack/path-string-parsing';
1
+ import type { ConsumedImport, DynamicImport } from '../types/BundleInfo.js';
2
2
  /**
3
3
  * Get info about imports and exports from a file.
4
4
  * Returns undefined if the file doesn't exist or can't be parsed.
5
5
  */
6
- export declare function getImportsAndExports(filePath: string): Promise<{
6
+ export declare function getImportsAndExports(filePath: string, packagePath?: string): Promise<{
7
7
  exportNames: Set<string>;
8
- imports: Array<ImportStringResult & {
9
- names: Set<string>;
10
- }>;
8
+ imports: ConsumedImport[];
9
+ dynamicImports: DynamicImport[];
11
10
  } | undefined>;
12
11
  //# sourceMappingURL=getImportsAndExports.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getImportsAndExports.d.ts","sourceRoot":"","sources":["../../src/utilities/getImportsAndExports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwC,KAAK,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAIlH;;;GAGG;AACH,wBAAsB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CACjE;IACE,WAAW,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACzB,OAAO,EAAE,KAAK,CAAC,kBAAkB,GAAG;QAAE,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;KAAE,CAAC,CAAC;CAC7D,GACD,SAAS,CACZ,CAkGA"}
1
+ {"version":3,"file":"getImportsAndExports.d.ts","sourceRoot":"","sources":["../../src/utilities/getImportsAndExports.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAE5E;;;GAGG;AACH,wBAAsB,oBAAoB,CACxC,QAAQ,EAAE,MAAM,EAChB,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CACN;IACE,WAAW,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACzB,OAAO,EAAE,cAAc,EAAE,CAAC;IAC1B,cAAc,EAAE,aAAa,EAAE,CAAC;CACjC,GACD,SAAS,CACZ,CAsIA"}
@@ -1,11 +1,14 @@
1
1
  import { parseImportString, parseNamedImports } from '@ms-cloudpack/path-string-parsing';
2
2
  import { parse } from 'es-module-lexer';
3
3
  import fsPromises from 'fs/promises';
4
+ import { SourceMapConsumer } from 'source-map';
5
+ import path from 'path';
6
+ import { normalizedPathRelativeTo } from '@ms-cloudpack/path-utilities';
4
7
  /**
5
8
  * Get info about imports and exports from a file.
6
9
  * Returns undefined if the file doesn't exist or can't be parsed.
7
10
  */
8
- export async function getImportsAndExports(filePath) {
11
+ export async function getImportsAndExports(filePath, packagePath) {
9
12
  let source;
10
13
  try {
11
14
  source = await fsPromises.readFile(filePath, 'utf-8');
@@ -33,6 +36,7 @@ export async function getImportsAndExports(filePath) {
33
36
  // TODO: Remove when https://github.com/guybedford/es-module-lexer/issues/76 is fixed
34
37
  let exportStarImport = false;
35
38
  const imports = [];
39
+ const dynamicImports = [];
36
40
  for (const imprt of new Set(rawImports)) {
37
41
  // es-module-lexer returns entries where the "n" property equals the import source.
38
42
  // This includes the package name and path. For example, in this case:
@@ -53,9 +57,44 @@ export async function getImportsAndExports(filePath) {
53
57
  // If it's a static string which happened to use backticks for some reason, we can parse that.
54
58
  importPath = importSpecifier.slice(1, -1);
55
59
  }
60
+ else if (packagePath) {
61
+ // Find the original source of the import.
62
+ let rawSourceMap;
63
+ let originalSource = null;
64
+ try {
65
+ rawSourceMap = JSON.parse(await fsPromises.readFile(`${filePath}.map`, 'utf-8'));
66
+ const consumer = await new SourceMapConsumer(rawSourceMap);
67
+ const pos = getLineAndColumn(source, imprt.s);
68
+ const originalPos = consumer.originalPositionFor(pos);
69
+ originalSource = originalPos.source;
70
+ consumer.destroy(); // Clean up the consumer
71
+ if (originalSource === null) {
72
+ console.debug(`Failed to find original source for import:\nFilename:${filePath}\nImport:\n ${importCode}`);
73
+ }
74
+ }
75
+ catch (err) {
76
+ console.debug(`Failed to read sourcemap for import:\nFilename:${filePath}\nImport:\n ${importCode}`, err);
77
+ }
78
+ // Original source where the import was found.
79
+ const absoluteImportSpecifier = originalSource
80
+ ? path.resolve(path.dirname(filePath), originalSource)
81
+ : filePath;
82
+ let packageName = '.'; // Default to local package
83
+ // Remove leading quote from the import specifier if it exists.
84
+ const lazyCleanImportSpecifier = importSpecifier.replace(/^["'`]/, '');
85
+ if (!lazyCleanImportSpecifier.startsWith('.')) {
86
+ packageName = parseImportString(lazyCleanImportSpecifier).packageName;
87
+ }
88
+ dynamicImports.push({
89
+ packageName,
90
+ // Relative path from package path to file with import. Prefer original source if available.
91
+ // or use the file path if original source is not available.
92
+ importOrigin: normalizedPathRelativeTo(packagePath, absoluteImportSpecifier),
93
+ importSpecifier,
94
+ });
95
+ continue;
96
+ }
56
97
  else {
57
- // For more complex cases, it's possible that we could handle this in the future at the
58
- // javascript layer and expand it into multiple potential imports.
59
98
  console.debug(`Found an import that didn't have a static path:\nFilename:${filePath}\nImport:\n ${importCode}`);
60
99
  continue;
61
100
  }
@@ -72,7 +111,7 @@ export async function getImportsAndExports(filePath) {
72
111
  }
73
112
  imports.push({
74
113
  ...parseImportString(importPath),
75
- names: new Set(importedNames),
114
+ names: Array.from(new Set(importedNames)),
76
115
  });
77
116
  }
78
117
  // Processing exports is cheap as we already have to parse the source.
@@ -91,6 +130,20 @@ export async function getImportsAndExports(filePath) {
91
130
  if (exportStarImport) {
92
131
  exportNames.add('*');
93
132
  }
94
- return { exportNames, imports };
133
+ return { exportNames, imports, dynamicImports };
134
+ }
135
+ function getLineAndColumn(source, position) {
136
+ let line = 1;
137
+ let column = 1;
138
+ for (let i = 0; i < position; i++) {
139
+ if (source[i] === '\n') {
140
+ line++;
141
+ column = 1;
142
+ }
143
+ else {
144
+ column++;
145
+ }
146
+ }
147
+ return { line, column };
95
148
  }
96
149
  //# sourceMappingURL=getImportsAndExports.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getImportsAndExports.js","sourceRoot":"","sources":["../../src/utilities/getImportsAndExports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAA2B,MAAM,mCAAmC,CAAC;AAClH,OAAO,EAAE,KAAK,EAA8C,MAAM,iBAAiB,CAAC;AACpF,OAAO,UAAU,MAAM,aAAa,CAAC;AAErC;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,QAAgB;IAOzD,IAAI,MAAc,CAAC;IACnB,IAAI,CAAC;QACH,MAAM,GAAG,MAAM,UAAU,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACxD,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,oDAAoD;QACpD,OAAO,CAAC,IAAI,CAAC,kBAAkB,QAAQ,GAAG,EAAE,GAAG,CAAC,CAAC;QACjD,OAAO;IACT,CAAC;IAED,IAAI,UAAsC,CAAC;IAC3C,IAAI,UAAsC,CAAC;IAC3C,IAAI,CAAC;QACH,8DAA8D;QAC9D,2DAA2D;QAC3D,6DAA6D;QAC7D,CAAC,UAAU,EAAE,UAAU,CAAC,GAAG,MAAM,KAAK,CAAC,MAAM,CAAC,CAAC;IACjD,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,sDAAsD;QACtD,OAAO,CAAC,IAAI,CAAC,mBAAmB,QAAQ,KAAK,GAAG,iBAAiB,MAAM,EAAE,CAAC,CAAC;QAC3E,OAAO;IACT,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AI,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,CAAC;YAC1C,oGAAoG;YACpG,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC1B,CAAC;QAED,OAAO,CAAC,IAAI,CAAC;YACX,GAAG,iBAAiB,CAAC,UAAU,CAAC;YAChC,KAAK,EAAE,IAAI,GAAG,CAAS,aAAa,CAAC;SACtC,CAAC,CAAC;IACL,CAAC;IAED,sEAAsE;IACtE,+CAA+C;IAC/C,MAAM,WAAW,GAAG,IAAI,GAAG,EAAU,CAAC;IACtC,KAAK,MAAM,KAAK,IAAI,UAAU,EAAE,CAAC;QAC/B,IAAI,KAAK,CAAC,CAAC,EAAE,CAAC;YACZ,2CAA2C;YAC3C,iCAAiC;YACjC,WAAW,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAC3B,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,KAAK,CACX,2DAA2D,QAAQ,gBAAgB,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,CACpH,CAAC;QACJ,CAAC;IACH,CAAC;IAED,IAAI,gBAAgB,EAAE,CAAC;QACrB,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACvB,CAAC;IAED,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC;AAClC,CAAC","sourcesContent":["import { parseImportString, parseNamedImports, type ImportStringResult } from '@ms-cloudpack/path-string-parsing';\nimport { parse, type ImportSpecifier, type ExportSpecifier } from 'es-module-lexer';\nimport fsPromises from 'fs/promises';\n\n/**\n * Get info about imports and exports from a file.\n * Returns undefined if the file doesn't exist or can't be parsed.\n */\nexport async function getImportsAndExports(filePath: string): Promise<\n | {\n exportNames: Set<string>;\n imports: Array<ImportStringResult & { names: Set<string> }>;\n }\n | undefined\n> {\n let source: string;\n try {\n source = await fsPromises.readFile(filePath, 'utf-8');\n } catch (err) {\n // This could happen if a package is missing a file.\n console.warn(`Failed to read ${filePath}:`, err);\n return;\n }\n\n let rawImports: readonly ImportSpecifier[];\n let rawExports: readonly ExportSpecifier[];\n try {\n // es-module-lexer/parse may return Promise in some conditions\n // https://github.com/guybedford/es-module-lexer/issues/155\n // eslint-disable-next-line @typescript-eslint/await-thenable\n [rawImports, rawExports] = await parse(source);\n } catch (err) {\n // This could happen if the source file isn't valid JS\n console.warn(`Failed to parse ${filePath}: ${err}\\nSource is:\\n${source}`);\n return;\n }\n\n // es-module-lexer doesn't handle export * from statements correctly as it parses them as\n // imports but not as exports. We need to handle them separately.\n // TODO: Remove when https://github.com/guybedford/es-module-lexer/issues/76 is fixed\n let exportStarImport = false;\n\n const imports: Array<ImportStringResult & { names: Set<string> }> = [];\n for (const imprt of new Set(rawImports)) {\n // es-module-lexer returns entries where the \"n\" property equals the import source.\n // This includes the package name and path. For example, in this case:\n // import { Button } from '@fluentui/react/lib/Button';\n // imprt.n is \"@fluentui/react/lib/Button\"\n let importPath = imprt.n;\n // ss and se point to the entire import string's start/end\n const importCode = source.slice(imprt.ss, imprt.se);\n // s and e point to the specificer's start/end, including quotes -- e.g. \"@fluentui/react/lib/Button\"\n const importSpecifier = source.slice(imprt.s, imprt.e);\n\n if (!importPath) {\n if (imprt.d === -2) {\n continue; // -2 means import.meta, which we don't care about\n }\n\n // Currently when the import source is a backtick string, the path (\"n\" property) is undefined.\n // This is a limitation in es-module-lexer.\n if (/^`[^$`]+`$/.test(importSpecifier)) {\n // If it's a static string which happened to use backticks for some reason, we can parse that.\n importPath = importSpecifier.slice(1, -1);\n } else {\n // For more complex cases, it's possible that we could handle this in the future at the\n // javascript layer and expand it into multiple potential imports.\n console.debug(\n `Found an import that didn't have a static path:\\nFilename:${filePath}\\nImport:\\n ${importCode}`,\n );\n continue;\n }\n }\n\n // Handling export * from import statements\n if (importCode.includes('export * from')) {\n exportStarImport = true;\n }\n\n // Parse the import string into its component parts.\n const importedNames = parseNamedImports(importCode);\n if (imprt.d >= 0 && !importedNames.length) {\n // This is a dynamic import. In this case we don't know which names are used, so assume all of them.\n importedNames.push('*');\n }\n\n imports.push({\n ...parseImportString(importPath),\n names: new Set<string>(importedNames),\n });\n }\n\n // Processing exports is cheap as we already have to parse the source.\n // Helps find exports uncaught by output files.\n const exportNames = new Set<string>();\n for (const exprt of rawExports) {\n if (exprt.n) {\n // Exports don't need to be parsed as it is\n // already in the format we need.\n exportNames.add(exprt.n);\n } else {\n console.debug(\n `Found an export that didn't parse correctly:\\nFilename: ${filePath}\\nExport:\\n ${source.slice(exprt.s, exprt.e)}`,\n );\n }\n }\n\n if (exportStarImport) {\n exportNames.add('*');\n }\n\n return { exportNames, imports };\n}\n"]}
1
+ {"version":3,"file":"getImportsAndExports.js","sourceRoot":"","sources":["../../src/utilities/getImportsAndExports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACzF,OAAO,EAAE,KAAK,EAA8C,MAAM,iBAAiB,CAAC;AACpF,OAAO,UAAU,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,iBAAiB,EAAqB,MAAM,YAAY,CAAC;AAClE,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AAGxE;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,QAAgB,EAChB,WAAoB;IASpB,IAAI,MAAc,CAAC;IACnB,IAAI,CAAC;QACH,MAAM,GAAG,MAAM,UAAU,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACxD,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,oDAAoD;QACpD,OAAO,CAAC,IAAI,CAAC,kBAAkB,QAAQ,GAAG,EAAE,GAAG,CAAC,CAAC;QACjD,OAAO;IACT,CAAC;IAED,IAAI,UAAsC,CAAC;IAC3C,IAAI,UAAs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aAAM,CAAC;YACN,OAAO,CAAC,KAAK,CACX,2DAA2D,QAAQ,gBAAgB,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,CACpH,CAAC;QACJ,CAAC;IACH,CAAC;IAED,IAAI,gBAAgB,EAAE,CAAC;QACrB,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACvB,CAAC;IAED,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,cAAc,EAAE,CAAC;AAClD,CAAC;AAED,SAAS,gBAAgB,CAAC,MAAc,EAAE,QAAgB;IACxD,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,IAAI,MAAM,GAAG,CAAC,CAAC;IAEf,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,EAAE,CAAC,EAAE,EAAE,CAAC;QAClC,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;YACvB,IAAI,EAAE,CAAC;YACP,MAAM,GAAG,CAAC,CAAC;QACb,CAAC;aAAM,CAAC;YACN,MAAM,EAAE,CAAC;QACX,CAAC;IACH,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AAC1B,CAAC","sourcesContent":["import { parseImportString, parseNamedImports } from '@ms-cloudpack/path-string-parsing';\nimport { parse, type ImportSpecifier, type ExportSpecifier } from 'es-module-lexer';\nimport fsPromises from 'fs/promises';\nimport { SourceMapConsumer, type RawSourceMap } from 'source-map';\nimport path from 'path';\nimport { normalizedPathRelativeTo } from '@ms-cloudpack/path-utilities';\nimport type { ConsumedImport, DynamicImport } from '../types/BundleInfo.js';\n\n/**\n * Get info about imports and exports from a file.\n * Returns undefined if the file doesn't exist or can't be parsed.\n */\nexport async function getImportsAndExports(\n filePath: string,\n packagePath?: string,\n): Promise<\n | {\n exportNames: Set<string>;\n imports: ConsumedImport[];\n dynamicImports: DynamicImport[];\n }\n | undefined\n> {\n let source: string;\n try {\n source = await fsPromises.readFile(filePath, 'utf-8');\n } catch (err) {\n // This could happen if a package is missing a file.\n console.warn(`Failed to read ${filePath}:`, err);\n return;\n }\n\n let rawImports: readonly ImportSpecifier[];\n let rawExports: readonly ExportSpecifier[];\n try {\n // es-module-lexer/parse may return Promise in some conditions\n // https://github.com/guybedford/es-module-lexer/issues/155\n // eslint-disable-next-line @typescript-eslint/await-thenable\n [rawImports, rawExports] = await parse(source);\n } catch (err) {\n // This could happen if the source file isn't valid JS\n console.warn(`Failed to parse ${filePath}: ${err}\\nSource is:\\n${source}`);\n return;\n }\n\n // es-module-lexer doesn't handle export * from statements correctly as it parses them as\n // imports but not as exports. We need to handle them separately.\n // TODO: Remove when https://github.com/guybedford/es-module-lexer/issues/76 is fixed\n let exportStarImport = false;\n\n const imports: ConsumedImport[] = [];\n const dynamicImports: DynamicImport[] = [];\n for (const imprt of new Set(rawImports)) {\n // es-module-lexer returns entries where the \"n\" property equals the import source.\n // This includes the package name and path. For example, in this case:\n // import { Button } from '@fluentui/react/lib/Button';\n // imprt.n is \"@fluentui/react/lib/Button\"\n let importPath = imprt.n;\n // ss and se point to the entire import string's start/end\n const importCode = source.slice(imprt.ss, imprt.se);\n // s and e point to the specificer's start/end, including quotes -- e.g. \"@fluentui/react/lib/Button\"\n const importSpecifier = source.slice(imprt.s, imprt.e);\n\n if (!importPath) {\n if (imprt.d === -2) {\n continue; // -2 means import.meta, which we don't care about\n }\n\n // Currently when the import source is a backtick string, the path (\"n\" property) is undefined.\n // This is a limitation in es-module-lexer.\n if (/^`[^$`]+`$/.test(importSpecifier)) {\n // If it's a static string which happened to use backticks for some reason, we can parse that.\n importPath = importSpecifier.slice(1, -1);\n } else if (packagePath) {\n // Find the original source of the import.\n let rawSourceMap: RawSourceMap;\n let originalSource: string | null = null;\n try {\n rawSourceMap = JSON.parse(await fsPromises.readFile(`${filePath}.map`, 'utf-8')) as RawSourceMap;\n const consumer = await new SourceMapConsumer(rawSourceMap);\n const pos = getLineAndColumn(source, imprt.s);\n const originalPos = consumer.originalPositionFor(pos);\n originalSource = originalPos.source;\n consumer.destroy(); // Clean up the consumer\n if (originalSource === null) {\n console.debug(`Failed to find original source for import:\\nFilename:${filePath}\\nImport:\\n ${importCode}`);\n }\n } catch (err) {\n console.debug(`Failed to read sourcemap for import:\\nFilename:${filePath}\\nImport:\\n ${importCode}`, err);\n }\n\n // Original source where the import was found.\n const absoluteImportSpecifier = originalSource\n ? path.resolve(path.dirname(filePath), originalSource)\n : filePath;\n\n let packageName = '.'; // Default to local package\n // Remove leading quote from the import specifier if it exists.\n const lazyCleanImportSpecifier = importSpecifier.replace(/^[\"'`]/, '');\n if (!lazyCleanImportSpecifier.startsWith('.')) {\n packageName = parseImportString(lazyCleanImportSpecifier).packageName;\n }\n dynamicImports.push({\n packageName,\n // Relative path from package path to file with import. Prefer original source if available.\n // or use the file path if original source is not available.\n importOrigin: normalizedPathRelativeTo(packagePath, absoluteImportSpecifier),\n importSpecifier,\n });\n continue;\n } else {\n console.debug(\n `Found an import that didn't have a static path:\\nFilename:${filePath}\\nImport:\\n ${importCode}`,\n );\n continue;\n }\n }\n\n // Handling export * from import statements\n if (importCode.includes('export * from')) {\n exportStarImport = true;\n }\n\n // Parse the import string into its component parts.\n const importedNames = parseNamedImports(importCode);\n if (imprt.d >= 0 && !importedNames.length) {\n // This is a dynamic import. In this case we don't know which names are used, so assume all of them.\n importedNames.push('*');\n }\n\n imports.push({\n ...parseImportString(importPath),\n names: Array.from(new Set<string>(importedNames)),\n });\n }\n\n // Processing exports is cheap as we already have to parse the source.\n // Helps find exports uncaught by output files.\n const exportNames = new Set<string>();\n for (const exprt of rawExports) {\n if (exprt.n) {\n // Exports don't need to be parsed as it is\n // already in the format we need.\n exportNames.add(exprt.n);\n } else {\n console.debug(\n `Found an export that didn't parse correctly:\\nFilename: ${filePath}\\nExport:\\n ${source.slice(exprt.s, exprt.e)}`,\n );\n }\n }\n\n if (exportStarImport) {\n exportNames.add('*');\n }\n\n return { exportNames, imports, dynamicImports };\n}\n\nfunction getLineAndColumn(source: string, position: number): { line: number; column: number } {\n let line = 1;\n let column = 1;\n\n for (let i = 0; i < position; i++) {\n if (source[i] === '\\n') {\n line++;\n column = 1;\n } else {\n column++;\n }\n }\n\n return { line, column };\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ms-cloudpack/api-server",
3
- "version": "0.37.4",
3
+ "version": "0.38.0",
4
4
  "description": "An implementation of the API server that does interacts with a task scheduler.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -27,19 +27,19 @@
27
27
  "@lage-run/logger": "^1.3.0",
28
28
  "@lage-run/scheduler": "^1.1.9",
29
29
  "@lage-run/target-graph": "^0.8.9",
30
- "@ms-cloudpack/bundler": "^0.19.7",
31
- "@ms-cloudpack/common-types": "^0.2.5",
32
- "@ms-cloudpack/config": "^0.19.5",
33
- "@ms-cloudpack/create-express-app": "^1.6.6",
30
+ "@ms-cloudpack/bundler": "^0.20.1",
31
+ "@ms-cloudpack/common-types": "^0.3.0",
32
+ "@ms-cloudpack/config": "^0.19.7",
33
+ "@ms-cloudpack/create-express-app": "^1.6.7",
34
34
  "@ms-cloudpack/data-bus": "^0.4.2",
35
35
  "@ms-cloudpack/file-watcher": "^0.1.2",
36
- "@ms-cloudpack/import-map": "^0.2.7",
36
+ "@ms-cloudpack/import-map": "^0.2.9",
37
37
  "@ms-cloudpack/json-utilities": "^0.1.4",
38
- "@ms-cloudpack/package-hashes": "^0.5.7",
39
- "@ms-cloudpack/package-utilities": "^7.1.7",
38
+ "@ms-cloudpack/package-hashes": "^0.5.9",
39
+ "@ms-cloudpack/package-utilities": "^7.2.1",
40
40
  "@ms-cloudpack/path-string-parsing": "^1.2.1",
41
- "@ms-cloudpack/path-utilities": "^2.7.3",
42
- "@ms-cloudpack/remote-cache": "^0.7.0",
41
+ "@ms-cloudpack/path-utilities": "^2.7.4",
42
+ "@ms-cloudpack/remote-cache": "^0.7.1",
43
43
  "@ms-cloudpack/task-reporter": "^0.13.1",
44
44
  "@ms-cloudpack/telemetry": "^0.5.1",
45
45
  "@trpc/client": "^10.45.0",
@@ -50,6 +50,7 @@
50
50
  "fs-extra": "^11.2.0",
51
51
  "get-port": "^7.0.0",
52
52
  "p-queue": "^8.0.1",
53
+ "source-map": "^0.7.0",
53
54
  "uuid": "^9.0.0",
54
55
  "ws": "^8.16.0",
55
56
  "zod": "^3.21.4"
@@ -1,7 +0,0 @@
1
- import type { CreateHtmlOptions } from './CreateHtmlOptions.js';
2
- import type { CreateHtmlResult } from './CreateHtmlResult.js';
3
- /**
4
- * A custom server render function that can be used to override the default HTML response.
5
- */
6
- export type CreateHtmlFunction = (options: CreateHtmlOptions) => Promise<CreateHtmlResult> | CreateHtmlResult;
7
- //# sourceMappingURL=CreateHtmlFunction.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CreateHtmlFunction.d.ts","sourceRoot":"","sources":["../../src/types/CreateHtmlFunction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE9D;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,EAAE,iBAAiB,KAAK,OAAO,CAAC,gBAAgB,CAAC,GAAG,gBAAgB,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=CreateHtmlFunction.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CreateHtmlFunction.js","sourceRoot":"","sources":["../../src/types/CreateHtmlFunction.ts"],"names":[],"mappings":"","sourcesContent":["import type { CreateHtmlOptions } from './CreateHtmlOptions.js';\nimport type { CreateHtmlResult } from './CreateHtmlResult.js';\n\n/**\n * A custom server render function that can be used to override the default HTML response.\n */\nexport type CreateHtmlFunction = (options: CreateHtmlOptions) => Promise<CreateHtmlResult> | CreateHtmlResult;\n"]}
@@ -1,20 +0,0 @@
1
- import type { ImportMap } from '@ms-cloudpack/import-map';
2
- import type { PackageJson, Route } from '@ms-cloudpack/common-types';
3
- import type { Request, Response } from '@ms-cloudpack/create-express-app';
4
- import type { Session } from './Session.js';
5
- /**
6
- * The input options for a `createHtml` custom server render function.
7
- */
8
- export interface CreateHtmlOptions {
9
- session: Session;
10
- route: Route;
11
- baseUrl: string;
12
- definition: PackageJson;
13
- importMap: ImportMap;
14
- overlayScript: string | undefined;
15
- entryScript: string | undefined;
16
- inlineScripts: string[];
17
- req: Request;
18
- res: Response;
19
- }
20
- //# sourceMappingURL=CreateHtmlOptions.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CreateHtmlOptions.d.ts","sourceRoot":"","sources":["../../src/types/CreateHtmlOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACrE,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,KAAK,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,WAAW,CAAC;IACxB,SAAS,EAAE,SAAS,CAAC;IACrB,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,GAAG,EAAE,OAAO,CAAC;IACb,GAAG,EAAE,QAAQ,CAAC;CACf"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=CreateHtmlOptions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CreateHtmlOptions.js","sourceRoot":"","sources":["../../src/types/CreateHtmlOptions.ts"],"names":[],"mappings":"","sourcesContent":["import type { ImportMap } from '@ms-cloudpack/import-map';\nimport type { PackageJson, Route } from '@ms-cloudpack/common-types';\nimport type { Request, Response } from '@ms-cloudpack/create-express-app';\nimport type { Session } from './Session.js';\n\n/**\n * The input options for a `createHtml` custom server render function.\n */\nexport interface CreateHtmlOptions {\n session: Session;\n route: Route;\n baseUrl: string;\n definition: PackageJson;\n importMap: ImportMap;\n overlayScript: string | undefined;\n entryScript: string | undefined;\n inlineScripts: string[];\n req: Request;\n res: Response;\n}\n"]}
@@ -1,9 +0,0 @@
1
- /**
2
- * The expected result of the createHtml custom server render function.
3
- */
4
- export type CreateHtmlResult = string | {
5
- content: string;
6
- statusCode?: number;
7
- contentType?: string;
8
- };
9
- //# sourceMappingURL=CreateHtmlResult.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CreateHtmlResult.d.ts","sourceRoot":"","sources":["../../src/types/CreateHtmlResult.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,gBAAgB,GACxB,MAAM,GACN;IACE,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=CreateHtmlResult.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CreateHtmlResult.js","sourceRoot":"","sources":["../../src/types/CreateHtmlResult.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * The expected result of the createHtml custom server render function.\n */\nexport type CreateHtmlResult =\n | string\n | {\n content: string;\n statusCode?: number;\n contentType?: string;\n };\n"]}
@@ -1,8 +0,0 @@
1
- import type { CreateHtmlFunction } from './CreateHtmlFunction.js';
2
- /**
3
- * The expected shape of the createHtml custom server render function script.
4
- */
5
- export type CreateHtmlScript = {
6
- default: CreateHtmlFunction;
7
- };
8
- //# sourceMappingURL=CreateHtmlScript.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CreateHtmlScript.d.ts","sourceRoot":"","sources":["../../src/types/CreateHtmlScript.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAElE;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAAE,OAAO,EAAE,kBAAkB,CAAA;CAAE,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=CreateHtmlScript.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CreateHtmlScript.js","sourceRoot":"","sources":["../../src/types/CreateHtmlScript.ts"],"names":[],"mappings":"","sourcesContent":["import type { CreateHtmlFunction } from './CreateHtmlFunction.js';\n\n/**\n * The expected shape of the createHtml custom server render function script.\n */\nexport type CreateHtmlScript = { default: CreateHtmlFunction };\n"]}