@ms-cloudpack/api-server 0.56.7 → 0.56.9
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/bundleTask.d.ts.map +1 -1
- package/lib/utilities/bundleTask.js +20 -0
- package/lib/utilities/bundleTask.js.map +1 -1
- package/lib/utilities/getBundleInfo.d.ts +2 -1
- package/lib/utilities/getBundleInfo.d.ts.map +1 -1
- package/lib/utilities/getBundleInfo.js +49 -71
- package/lib/utilities/getBundleInfo.js.map +1 -1
- package/lib/utilities/getImportsAndExports.d.ts +1 -0
- package/lib/utilities/getImportsAndExports.d.ts.map +1 -1
- package/lib/utilities/getImportsAndExports.js +65 -64
- package/lib/utilities/getImportsAndExports.js.map +1 -1
- package/lib/utilities/writeStubForDensityEntries.d.ts +13 -0
- package/lib/utilities/writeStubForDensityEntries.d.ts.map +1 -0
- package/lib/utilities/writeStubForDensityEntries.js +69 -0
- package/lib/utilities/writeStubForDensityEntries.js.map +1 -0
- package/package.json +12 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundleTask.d.ts","sourceRoot":"","sources":["../../src/utilities/bundleTask.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAOvE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"bundleTask.d.ts","sourceRoot":"","sources":["../../src/utilities/bundleTask.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAOvE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAG1D,MAAM,MAAM,yBAAyB,GAAG,iBAAiB,GAAG;IAAE,aAAa,EAAE,aAAa,CAAA;CAAE,CAAC;AAC7F,MAAM,MAAM,yBAAyB,GAAG,cAAc,CACpD,UAAU,GAAG,eAAe,GAAG,UAAU,GAAG,iBAAiB,EAC7D,YAAY,GAAG,QAAQ,GAAG,UAAU,GAAG,WAAW,CACnD,CAAC;AAEF;;GAEG;AACH,wBAAsB,UAAU,CAC9B,OAAO,EAAE,yBAAyB,EAClC,OAAO,EAAE,yBAAyB,GACjC,OAAO,CAAC,IAAI,CAAC,CAsJf"}
|
|
@@ -10,6 +10,7 @@ import { isCachedResultValid } from './isCachedResultValid.js';
|
|
|
10
10
|
import { readResultFromCache } from './readResultFromCache.js';
|
|
11
11
|
import { saveResultToCache } from './saveResultToCache.js';
|
|
12
12
|
import { formatBundleTaskResult } from './formatBundleTaskResult.js';
|
|
13
|
+
import { writeStubForDensityEntries } from './writeStubForDensityEntries.js';
|
|
13
14
|
/**
|
|
14
15
|
* Create and run a TaskReporter task which calls `bundle()` from `@ms-cloudpack/bundler` and formats the result.
|
|
15
16
|
*/
|
|
@@ -78,11 +79,30 @@ export async function bundleTask(options, context) {
|
|
|
78
79
|
bundlerCapabilities,
|
|
79
80
|
};
|
|
80
81
|
const bundleInternalResult = await bundle(bundleOptions, { config });
|
|
82
|
+
if (bundleInternalResult.bundler) {
|
|
83
|
+
span.setAttribute('bundler', bundleInternalResult.bundler);
|
|
84
|
+
}
|
|
81
85
|
bundleRequest.result = {
|
|
82
86
|
...bundleInternalResult,
|
|
83
87
|
outputPath: bundleOptions.outputPath ?? outputPath,
|
|
84
88
|
hash: cacheValidationHash,
|
|
85
89
|
};
|
|
90
|
+
if (bundlerCapabilities?.density) {
|
|
91
|
+
// Get export maps that need to be written as stubs for density.
|
|
92
|
+
// If there are density exports, write stubs for them.
|
|
93
|
+
const densityErrors = await writeStubForDensityEntries({
|
|
94
|
+
options: {
|
|
95
|
+
packageName,
|
|
96
|
+
packagePath,
|
|
97
|
+
result: bundleInternalResult,
|
|
98
|
+
},
|
|
99
|
+
context: { packages, config },
|
|
100
|
+
});
|
|
101
|
+
// Add any errors to the result.
|
|
102
|
+
if (densityErrors.length > 0) {
|
|
103
|
+
bundleRequest.result.errors = [...(bundleRequest.result.errors ?? []), ...densityErrors];
|
|
104
|
+
}
|
|
105
|
+
}
|
|
86
106
|
}
|
|
87
107
|
// Write the result to disk.
|
|
88
108
|
await saveResultToCache(bundleRequest.result);
|
|
@@ -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,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAGnE,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;AASrE;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,OAAkC,EAClC,OAAkC;IAElC,MAAM,EAAE,aAAa,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;IAC3D,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,GAAG,aAAa,CAAC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V,WAAW,EAAE,aAAa,CAAC,MAAM,CAAC,WAAW;oBAC7C,UAAU;oBACV,UAAU;oBACV,WAAW;iBACZ,CAAC,CAAC;gBAEH,aAAa,CAAC,MAAM,CAAC,IAAI,GAAG,UAAU,CAAC;gBAEvC,8DAA8D;gBAC9D,mEAAmE;gBACnE,SAAS,CAAC,cAAc,EAAE,UAAU,CAAC,CAAC;YACxC,CAAC;YAED,IAAI,CAAC,aAAa,CAAC;gBACjB,QAAQ;gBACR,UAAU,EAAE,CAAC,CAAC,aAAa,CAAC,eAAe;gBAC3C,UAAU,EAAE,aAAa,CAAC,UAAU;aACrC,CAAC,CAAC;YAEH,MAAM,UAAU,GAAG,sBAAsB,CAAC,aAAa,CAAC,CAAC;YAEzD,OAAO,UAAU,CAAC;QACpB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,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 { formatPackageName } from '@ms-cloudpack/task-reporter';\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 { 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';\n\nexport type BundleTaskInternalOptions = BundleTaskOptions & { bundleRequest: BundleRequest };\nexport type BundleTaskInternalContext = PartialContext<\n 'packages' | 'packageHashes' | 'reporter' | 'telemetryClient',\n 'resolveMap' | 'config' | 'sequence' | 'cachePath'\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(\n options: BundleTaskInternalOptions,\n context: BundleTaskInternalContext,\n): Promise<void> {\n const { bundleRequest, force, hash, sourceHash } = options;\n const { packageName, version } = bundleRequest;\n const { reporter, telemetryClient, packageHashes, packages, session } = context;\n const { config, sequence } = session;\n const { mode } = config;\n const { retryCount } = options;\n\n const taskName = `Bundle ${formatPackageName({\n name: packageName,\n version,\n })}${retryCount ? ` (retry ${retryCount})` : ''}`;\n\n await reporter.runTask(taskName, async () => {\n await telemetryClient.tracer.startActiveSpan('BUNDLE_TASK', async (span) => {\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 ||\n (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 {\n bundler,\n bundlerOptions,\n inlinedDependencies,\n dynamicImports,\n bundlerCapabilities,\n ignoredBundlerWarnings,\n } = (await packages.get(packagePath)).cloudpack || {};\n\n const bundleOptions: BundleOptions = {\n bundler,\n minify: mode === 'production',\n bundlerOptions,\n inputPath: packagePath,\n outputPath,\n incremental: isIncremental !== undefined ? isIncremental : false,\n sourcemap: !disableSourceMaps,\n entries: await getEntriesMapFromPackage({ inputPath: packagePath }, { packages, config }),\n inlined: inlinedDependencies,\n external: await getExternalsFromPackage({ inputPath: packagePath }, { packages }),\n dynamicImports,\n ignoredBundlerWarnings,\n bundlerCapabilities,\n };\n\n const bundleInternalResult = await bundle(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 }, { 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 // 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 span.setAttributes({\n sequence,\n isCacheHit: !!bundleRequest.resultFromCache,\n isExternal: bundleRequest.isExternal,\n });\n\n const taskResult = formatBundleTaskResult(bundleRequest);\n\n return taskResult;\n });\n });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"bundleTask.js","sourceRoot":"","sources":["../../src/utilities/bundleTask.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EA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,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,kBAAkB,CAAC,CAAC;gBAEjE,+EAA+E;gBAC/E,iFAAiF;gBACjF,2EAA2E;gBAC3E,8CAA8C;gBAC9C,MAAM,UAAU,GAAG,MAAM,aAAa,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;gBAE9E,MAAM,UAAU,GAAG,MAAM,aAAa,CAAC;oBACrC,UAAU;oBACV,WAAW,EAAE,aAAa,CAAC,MAAM,CAAC,WAAW;oBAC7C,UAAU;oBACV,UAAU;oBACV,WAAW;iBACZ,CAAC,CAAC;gBAEH,aAAa,CAAC,MAAM,CAAC,IAAI,GAAG,UAAU,CAAC;gBAEvC,8DAA8D;gBAC9D,mEAAmE;gBACnE,SAAS,CAAC,cAAc,EAAE,UAAU,CAAC,CAAC;YACxC,CAAC;YAED,IAAI,CAAC,aAAa,CAAC;gBACjB,QAAQ;gBACR,UAAU,EAAE,CAAC,CAAC,aAAa,CAAC,eAAe;gBAC3C,UAAU,EAAE,aAAa,CAAC,UAAU;aACrC,CAAC,CAAC;YAEH,MAAM,UAAU,GAAG,sBAAsB,CAAC,aAAa,CAAC,CAAC;YAEzD,OAAO,UAAU,CAAC;QACpB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,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 { formatPackageName } from '@ms-cloudpack/task-reporter';\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 { 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\nexport type BundleTaskInternalOptions = BundleTaskOptions & { bundleRequest: BundleRequest };\nexport type BundleTaskInternalContext = PartialContext<\n 'packages' | 'packageHashes' | 'reporter' | 'telemetryClient',\n 'resolveMap' | 'config' | 'sequence' | 'cachePath'\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(\n options: BundleTaskInternalOptions,\n context: BundleTaskInternalContext,\n): Promise<void> {\n const { bundleRequest, force, hash, sourceHash } = options;\n const { packageName, version } = bundleRequest;\n const { reporter, telemetryClient, packageHashes, packages, session } = context;\n const { config, sequence } = session;\n const { mode } = config;\n const { retryCount } = options;\n\n const taskName = `Bundle ${formatPackageName({\n name: packageName,\n version,\n })}${retryCount ? ` (retry ${retryCount})` : ''}`;\n\n await reporter.runTask(taskName, async () => {\n await telemetryClient.tracer.startActiveSpan('BUNDLE_TASK', async (span) => {\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 ||\n (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 {\n bundler,\n bundlerOptions,\n inlinedDependencies,\n dynamicImports,\n bundlerCapabilities,\n ignoredBundlerWarnings,\n } = (await packages.get(packagePath)).cloudpack || {};\n\n const bundleOptions: BundleOptions = {\n bundler,\n minify: mode === 'production',\n bundlerOptions,\n inputPath: packagePath,\n outputPath,\n incremental: isIncremental !== undefined ? isIncremental : false,\n sourcemap: !disableSourceMaps,\n entries: await getEntriesMapFromPackage({ inputPath: packagePath }, { packages, config }),\n inlined: inlinedDependencies,\n external: await getExternalsFromPackage({ inputPath: packagePath }, { packages }),\n dynamicImports,\n ignoredBundlerWarnings,\n bundlerCapabilities,\n };\n\n const bundleInternalResult = await bundle(bundleOptions, { config });\n if (bundleInternalResult.bundler) {\n span.setAttribute('bundler', bundleInternalResult.bundler);\n }\n bundleRequest.result = {\n ...bundleInternalResult,\n outputPath: bundleOptions.outputPath ?? outputPath,\n hash: cacheValidationHash,\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 densityErrors = await writeStubForDensityEntries({\n options: {\n packageName,\n packagePath,\n result: bundleInternalResult,\n },\n context: { packages, config },\n });\n\n // Add any errors to the result.\n if (densityErrors.length > 0) {\n bundleRequest.result.errors = [...(bundleRequest.result.errors ?? []), ...densityErrors];\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 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 }, { 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 // 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 span.setAttributes({\n sequence,\n isCacheHit: !!bundleRequest.resultFromCache,\n isExternal: bundleRequest.isExternal,\n });\n\n const taskResult = formatBundleTaskResult(bundleRequest);\n\n return taskResult;\n });\n });\n}\n"]}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { BundleOutputFile, PackageJsonExports } from '@ms-cloudpack/common-types';
|
|
2
2
|
import type { BundleInfo } from '../types/BundleInfo.js';
|
|
3
3
|
/**
|
|
4
|
-
* Returns a mapping from entry file path to list of paths that are produced
|
|
4
|
+
* Returns a mapping from entry file path (exports map key) to list of paths that are produced
|
|
5
|
+
* and consumed in that file.
|
|
5
6
|
*/
|
|
6
7
|
export declare function getBundleInfo(params: {
|
|
7
8
|
packagePath: string;
|
|
@@ -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,
|
|
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,EAAmB,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAG1E;;;GAGG;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,CA+FtB"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { getRuntimeEntryPaths } from '@ms-cloudpack/import-map';
|
|
2
|
-
import {
|
|
2
|
+
import { normalizedPathRelativeTo } from '@ms-cloudpack/path-utilities';
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import { getImportsAndExports } from './getImportsAndExports.js';
|
|
5
5
|
/**
|
|
6
|
-
* Returns a mapping from entry file path to list of paths that are produced
|
|
6
|
+
* Returns a mapping from entry file path (exports map key) to list of paths that are produced
|
|
7
|
+
* and consumed in that file.
|
|
7
8
|
*/
|
|
8
9
|
export async function getBundleInfo(params) {
|
|
9
10
|
const { packagePath, outputPath, outputFiles, exportsMap, isExternal } = params;
|
|
@@ -12,97 +13,74 @@ export async function getBundleInfo(params) {
|
|
|
12
13
|
if (!outputFiles.length) {
|
|
13
14
|
return bundleInfo;
|
|
14
15
|
}
|
|
15
|
-
/** Mapping from output file
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const safePath = normalizeRelativePath(actualEntryPath);
|
|
30
|
-
if (outputFileInfo[safePath]) {
|
|
31
|
-
if (repeatedExports[safePath]) {
|
|
32
|
-
repeatedExports[safePath].push(importPath);
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
// Change best guess entry path to exports map entry.
|
|
36
|
-
outputFileInfo[safePath].entry = importPath;
|
|
37
|
-
repeatedExports[safePath] = [importPath];
|
|
38
|
-
}
|
|
39
|
-
}
|
|
16
|
+
/** Mapping from normalized relative output file path to info about which entry paths
|
|
17
|
+
* (exports map keys) pointed to that file, and what export names it produces.
|
|
18
|
+
* Usually there's at most one entry path per output file. */
|
|
19
|
+
const outputFileInfo = Object.fromEntries(outputFiles.map((file) => [
|
|
20
|
+
file.outputPath,
|
|
21
|
+
{ exportsKeys: [], produces: new Set(file.exports) },
|
|
22
|
+
]));
|
|
23
|
+
// For each entry path (exports map key), get the normalized relative path to the output file
|
|
24
|
+
// that will be used at runtime based on conditions.
|
|
25
|
+
const entryToOutputFile = getRuntimeEntryPaths({ packagePath, isExternal, exportsMap });
|
|
26
|
+
// Update the output file info with the entry paths (exports keys) that point to each output file.
|
|
27
|
+
// Usually there's at most one per output file (or none if it's a shared chunk).
|
|
28
|
+
for (const [entryPath, relOutputFile] of Object.entries(entryToOutputFile)) {
|
|
29
|
+
outputFileInfo[relOutputFile]?.exportsKeys.push(entryPath);
|
|
40
30
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
});
|
|
45
|
-
const filePaths = Object.keys(localPathToSafe);
|
|
46
|
-
const visitedPaths = new Set(filePaths);
|
|
47
|
-
const pathsToParse = [...filePaths];
|
|
48
|
-
while (pathsToParse.length) {
|
|
49
|
-
const filePath = pathsToParse.shift();
|
|
31
|
+
// Build the bundle info based on imports and exports for each output file.
|
|
32
|
+
// exportsKeys are the export map key(s) that point to the output file.
|
|
33
|
+
for (const [relOutputFile, { exportsKeys, produces }] of Object.entries(outputFileInfo)) {
|
|
50
34
|
// Ignore any non-JS/TS files such as SVGs and sourcemaps
|
|
51
|
-
if (
|
|
35
|
+
if (path.extname(relOutputFile) !== '.js') {
|
|
52
36
|
continue;
|
|
53
37
|
}
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
throw new Error(`Found file that was not expected to be processed: ${filePath}`);
|
|
57
|
-
}
|
|
58
|
-
const parseResult = await getImportsAndExports(filePath, packagePath);
|
|
38
|
+
const absOutputFile = path.resolve(outputPath, relOutputFile);
|
|
39
|
+
const parseResult = await getImportsAndExports(absOutputFile, packagePath);
|
|
59
40
|
if (!parseResult) {
|
|
60
41
|
continue;
|
|
61
42
|
}
|
|
62
43
|
const { exportNames, imports, dynamicImports } = parseResult;
|
|
63
|
-
const { entry, produces } = outputFileInfo[safePath];
|
|
64
44
|
exportNames.forEach((name) => produces.add(name));
|
|
65
|
-
|
|
66
|
-
|
|
45
|
+
// Create a bundle info entry for this output file.
|
|
46
|
+
// If there wasn't an exports map key pointing to this file, just use the output path.
|
|
47
|
+
const pathsInBundleInfo = exportsKeys.length ? exportsKeys : [relOutputFile];
|
|
48
|
+
const fileBundleInfo = bundleInfo[pathsInBundleInfo[0]] || {
|
|
49
|
+
bundlePath: relOutputFile,
|
|
67
50
|
produces: Array.from(produces),
|
|
68
51
|
consumes: [],
|
|
69
52
|
};
|
|
53
|
+
// Use the same object for all paths that point to this file.
|
|
54
|
+
pathsInBundleInfo.forEach((p) => (bundleInfo[p] = fileBundleInfo));
|
|
70
55
|
if (dynamicImports.length) {
|
|
71
|
-
|
|
56
|
+
fileBundleInfo.dynamicImports = dynamicImports;
|
|
72
57
|
}
|
|
73
58
|
for (const { packageName, importPath, names } of imports) {
|
|
74
|
-
if (packageName
|
|
75
|
-
const localPath = path.resolve(path.dirname(
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
59
|
+
if (packageName === '.') {
|
|
60
|
+
const localPath = normalizedPathRelativeTo(outputPath, path.resolve(path.dirname(absOutputFile), importPath));
|
|
61
|
+
// Pretty sure any path in the current package which is imported in the bundle output should be
|
|
62
|
+
// in outputFiles, but make it obvious if not.
|
|
63
|
+
if (!outputFileInfo[localPath]) {
|
|
64
|
+
throw new Error(`Imported local file not found in output files for ${outputPath}: ${localPath} ` +
|
|
65
|
+
`(imported from ${absOutputFile} with import path "${importPath}")`);
|
|
80
66
|
}
|
|
81
67
|
}
|
|
82
|
-
else if (
|
|
83
|
-
// Find if the
|
|
84
|
-
const
|
|
85
|
-
if (
|
|
86
|
-
// If
|
|
87
|
-
|
|
68
|
+
else if (!packageName.startsWith('node:')) {
|
|
69
|
+
// Find if the imported package is already in the consumes list.
|
|
70
|
+
const consumesFromPackage = fileBundleInfo.consumes.find((c) => c.packageName === packageName && c.importPath === importPath);
|
|
71
|
+
if (consumesFromPackage) {
|
|
72
|
+
// If so, add the names to the existing entry.
|
|
73
|
+
// This is necessary because the same import may be used in multiple places.
|
|
74
|
+
consumesFromPackage.names = Array.from(new Set([...names, ...consumesFromPackage.names]));
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
// Otherwise, add it.
|
|
78
|
+
fileBundleInfo.consumes.push({
|
|
88
79
|
packageName: packageName,
|
|
89
80
|
importPath: importPath || '.',
|
|
90
81
|
names: [...names],
|
|
91
82
|
});
|
|
92
83
|
}
|
|
93
|
-
else {
|
|
94
|
-
// If so, add the names to the existing entry.
|
|
95
|
-
// This is necessary because the same import may be used in multiple places.
|
|
96
|
-
bundleInfo[entry].consumes[entryIndex].names = Array.from(new Set([...names, ...bundleInfo[entry].consumes[entryIndex].names]));
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
if (repeatedExports[safePath]?.length > 1) {
|
|
101
|
-
// Multiple entries for the same path.
|
|
102
|
-
for (const repeatedEntry of repeatedExports[safePath]) {
|
|
103
|
-
if (repeatedEntry !== entry) {
|
|
104
|
-
bundleInfo[repeatedEntry] = bundleInfo[entry];
|
|
105
|
-
}
|
|
106
84
|
}
|
|
107
85
|
}
|
|
108
86
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getBundleInfo.js","sourceRoot":"","sources":["../../src/utilities/getBundleInfo.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM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OAAO,UAAU,CAAC;AACpB,CAAC","sourcesContent":["import type { BundleOutputFile, PackageJsonExports } from '@ms-cloudpack/common-types';\nimport { getRuntimeEntryPaths } from '@ms-cloudpack/import-map';\nimport { normalizedPathRelativeTo } from '@ms-cloudpack/path-utilities';\nimport path from 'path';\nimport type { BundleEntryInfo, BundleInfo } from '../types/BundleInfo.js';\nimport { getImportsAndExports } from './getImportsAndExports.js';\n\n/**\n * Returns a mapping from entry file path (exports map key) to list of paths that are produced\n * and consumed in that file.\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 normalized relative output file path to info about which entry paths\n * (exports map keys) pointed to that file, and what export names it produces.\n * Usually there's at most one entry path per output file. */\n const outputFileInfo = Object.fromEntries(\n outputFiles.map((file) => [\n file.outputPath,\n { exportsKeys: [] as string[], produces: new Set<string>(file.exports) },\n ]),\n );\n\n // For each entry path (exports map key), get the normalized relative path to the output file\n // that will be used at runtime based on conditions.\n const entryToOutputFile = getRuntimeEntryPaths({ packagePath, isExternal, exportsMap });\n\n // Update the output file info with the entry paths (exports keys) that point to each output file.\n // Usually there's at most one per output file (or none if it's a shared chunk).\n for (const [entryPath, relOutputFile] of Object.entries(entryToOutputFile)) {\n outputFileInfo[relOutputFile]?.exportsKeys.push(entryPath);\n }\n\n // Build the bundle info based on imports and exports for each output file.\n // exportsKeys are the export map key(s) that point to the output file.\n for (const [relOutputFile, { exportsKeys, produces }] of Object.entries(outputFileInfo)) {\n // Ignore any non-JS/TS files such as SVGs and sourcemaps\n if (path.extname(relOutputFile) !== '.js') {\n continue;\n }\n\n const absOutputFile = path.resolve(outputPath, relOutputFile);\n\n const parseResult = await getImportsAndExports(absOutputFile, packagePath);\n if (!parseResult) {\n continue;\n }\n const { exportNames, imports, dynamicImports } = parseResult;\n\n exportNames.forEach((name) => produces.add(name));\n\n // Create a bundle info entry for this output file.\n // If there wasn't an exports map key pointing to this file, just use the output path.\n const pathsInBundleInfo = exportsKeys.length ? exportsKeys : [relOutputFile];\n const fileBundleInfo: BundleEntryInfo = bundleInfo[pathsInBundleInfo[0]] || {\n bundlePath: relOutputFile,\n produces: Array.from(produces),\n consumes: [],\n };\n // Use the same object for all paths that point to this file.\n pathsInBundleInfo.forEach((p) => (bundleInfo[p] = fileBundleInfo));\n\n if (dynamicImports.length) {\n fileBundleInfo.dynamicImports = dynamicImports;\n }\n\n for (const { packageName, importPath, names } of imports) {\n if (packageName === '.') {\n const localPath = normalizedPathRelativeTo(outputPath, path.resolve(path.dirname(absOutputFile), importPath));\n // Pretty sure any path in the current package which is imported in the bundle output should be\n // in outputFiles, but make it obvious if not.\n if (!outputFileInfo[localPath]) {\n throw new Error(\n `Imported local file not found in output files for ${outputPath}: ${localPath} ` +\n `(imported from ${absOutputFile} with import path \"${importPath}\")`,\n );\n }\n } else if (!packageName.startsWith('node:')) {\n // Find if the imported package is already in the consumes list.\n const consumesFromPackage = fileBundleInfo.consumes.find(\n (c) => c.packageName === packageName && c.importPath === importPath,\n );\n if (consumesFromPackage) {\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 consumesFromPackage.names = Array.from(new Set([...names, ...consumesFromPackage.names]));\n } else {\n // Otherwise, add it.\n fileBundleInfo.consumes.push({\n packageName: packageName,\n importPath: importPath || '.',\n names: [...names],\n });\n }\n }\n }\n }\n\n return bundleInfo;\n}\n"]}
|
|
@@ -6,6 +6,7 @@ import type { ConsumedImport, DynamicImport } from '../types/BundleInfo.js';
|
|
|
6
6
|
export declare function getImportsAndExports(filePath: string, packagePath?: string): Promise<{
|
|
7
7
|
exportNames: Set<string>;
|
|
8
8
|
imports: ConsumedImport[];
|
|
9
|
+
/** Dynamic (async) imports with non-literal paths consumed by this file. */
|
|
9
10
|
dynamicImports: DynamicImport[];
|
|
10
11
|
} | undefined>;
|
|
11
12
|
//# sourceMappingURL=getImportsAndExports.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,4EAA4E;IAC5E,cAAc,EAAE,aAAa,EAAE,CAAC;CACjC,GACD,SAAS,CACZ,CAqIA"}
|
|
@@ -34,85 +34,86 @@ export async function getImportsAndExports(filePath, packagePath) {
|
|
|
34
34
|
// es-module-lexer doesn't handle export * from statements correctly as it parses them as
|
|
35
35
|
// imports but not as exports. We need to handle them separately.
|
|
36
36
|
// TODO: Remove when https://github.com/guybedford/es-module-lexer/issues/76 is fixed
|
|
37
|
-
const
|
|
37
|
+
const exportStarPaths = [];
|
|
38
38
|
const imports = [];
|
|
39
39
|
const dynamicImports = [];
|
|
40
40
|
for (const imprt of new Set(rawImports)) {
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
if (imprt.d === -2) {
|
|
42
|
+
continue; // -2 means import.meta, which we don't care about
|
|
43
|
+
}
|
|
44
|
+
// es-module-lexer returns objects where the "n" property is the import source,
|
|
45
|
+
// e.g. "@fluentui/react/lib/Button" for this import:
|
|
43
46
|
// import { Button } from '@fluentui/react/lib/Button';
|
|
44
|
-
//
|
|
47
|
+
// However, "n" will be undefined for import() if isn't a plain string literal.
|
|
45
48
|
let importPath = imprt.n;
|
|
46
49
|
// ss and se point to the entire import string's start/end
|
|
47
50
|
const importCode = source.slice(imprt.ss, imprt.se);
|
|
48
51
|
// s and e point to the specificer's start/end, including quotes -- e.g. "@fluentui/react/lib/Button"
|
|
49
52
|
const importSpecifier = source.slice(imprt.s, imprt.e);
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
53
|
+
// Currently when the import source is a backtick string, the path ("n" property) is undefined.
|
|
54
|
+
// This is a limitation in es-module-lexer.
|
|
55
|
+
if (/^`[^$`]+`$/.test(importSpecifier)) {
|
|
56
|
+
// If it's a static string which happened to use backticks for some reason, we can parse that.
|
|
57
|
+
importPath = importSpecifier.slice(1, -1);
|
|
58
|
+
}
|
|
59
|
+
// Handle literal paths first
|
|
60
|
+
if (importPath) {
|
|
61
|
+
// Handling `export * from` import statements
|
|
62
|
+
if (/export\s*\*\s*from/.test(importCode)) {
|
|
63
|
+
exportStarPaths.push(importPath);
|
|
59
64
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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;
|
|
65
|
+
let importedNames;
|
|
66
|
+
if (imprt.d >= 0) {
|
|
67
|
+
// This is a dynamic import. In this case we don't know which names are used, so assume all of them.
|
|
68
|
+
importedNames = ['*'];
|
|
96
69
|
}
|
|
97
70
|
else {
|
|
98
|
-
|
|
99
|
-
|
|
71
|
+
// Parse the import string into its component parts.
|
|
72
|
+
importedNames = parseNamedImports(importCode);
|
|
100
73
|
}
|
|
74
|
+
imports.push({
|
|
75
|
+
...parseImportString(importPath),
|
|
76
|
+
names: Array.from(new Set(importedNames)),
|
|
77
|
+
});
|
|
101
78
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
79
|
+
else if (packagePath) {
|
|
80
|
+
// Non-literal path.
|
|
81
|
+
// Find the original source of the import.
|
|
82
|
+
let rawSourceMap;
|
|
83
|
+
let originalSource = null;
|
|
84
|
+
try {
|
|
85
|
+
rawSourceMap = JSON.parse(await fsPromises.readFile(`${filePath}.map`, 'utf-8'));
|
|
86
|
+
const consumer = await new SourceMapConsumer(rawSourceMap);
|
|
87
|
+
const pos = getLineAndColumn(source, imprt.s);
|
|
88
|
+
originalSource = consumer.originalPositionFor(pos).source;
|
|
89
|
+
consumer.destroy(); // Clean up the consumer
|
|
90
|
+
if (originalSource === null) {
|
|
91
|
+
console.debug(`Failed to find original source for import:\nFilename:${filePath}\nImport:\n ${importCode}`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
catch (err) {
|
|
95
|
+
console.debug(`Failed to read sourcemap for import:\nFilename:${filePath}\nImport:\n ${importCode}`, err);
|
|
96
|
+
}
|
|
97
|
+
// Original source where the import was found.
|
|
98
|
+
const absoluteImportSpecifier = originalSource ? path.resolve(path.dirname(filePath), originalSource) : filePath;
|
|
99
|
+
// TODO: This will give a bad path for a lot of template or concatenated strings
|
|
100
|
+
let packageName = '.'; // Default to local package
|
|
101
|
+
// Remove leading quote from the import specifier if it exists.
|
|
102
|
+
const cleanImportSpecifier = importSpecifier.replace(/^["'`]/, '');
|
|
103
|
+
if (!cleanImportSpecifier.startsWith('.')) {
|
|
104
|
+
packageName = parseImportString(cleanImportSpecifier).packageName;
|
|
105
|
+
}
|
|
106
|
+
dynamicImports.push({
|
|
107
|
+
packageName,
|
|
108
|
+
// Relative path from package path to file with import. Prefer original source if available.
|
|
109
|
+
// or use the file path if original source is not available.
|
|
110
|
+
importOrigin: normalizedPathRelativeTo(packagePath, absoluteImportSpecifier),
|
|
111
|
+
importSpecifier,
|
|
112
|
+
});
|
|
105
113
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
if (imprt.d >= 0 && !importedNames.length) {
|
|
109
|
-
// This is a dynamic import. In this case we don't know which names are used, so assume all of them.
|
|
110
|
-
importedNames.push('*');
|
|
114
|
+
else {
|
|
115
|
+
console.debug(`Found an import that didn't have a static path:\nFilename:${filePath}\nImport:\n ${importCode}`);
|
|
111
116
|
}
|
|
112
|
-
imports.push({
|
|
113
|
-
...parseImportString(importPath),
|
|
114
|
-
names: Array.from(new Set(importedNames)),
|
|
115
|
-
});
|
|
116
117
|
}
|
|
117
118
|
// Processing exports is cheap as we already have to parse the source.
|
|
118
119
|
// Helps find exports uncaught by output files.
|
|
@@ -127,7 +128,7 @@ export async function getImportsAndExports(filePath, packagePath) {
|
|
|
127
128
|
console.debug(`Found an export that didn't parse correctly:\nFilename: ${filePath}\nExport:\n ${source.slice(exprt.s, exprt.e)}`);
|
|
128
129
|
}
|
|
129
130
|
}
|
|
130
|
-
for (const exportPath of
|
|
131
|
+
for (const exportPath of exportStarPaths) {
|
|
131
132
|
// This follows the following convention: https://github.com/guybedford/es-module-lexer/issues/76#issuecomment-868561807
|
|
132
133
|
exportNames.add(`*${exportPath}`);
|
|
133
134
|
}
|
|
@@ -1 +1 @@
|
|
|
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,C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pack/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 const exportStarImport = [];\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.push(importPath);\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 for (const exportPath of exportStarImport) {\n // This follows the following convention: https://github.com/guybedford/es-module-lexer/issues/76#issuecomment-868561807\n exportNames.add(`*${exportPath}`);\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"]}
|
|
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;IAUpB,IAAI,MAAc,CAAC;IACnB,IAAI,CAAC;QACH,MAAM,GAAG,MAAM,UAAU,CAAC,QAAQ,CAAC,QAAQ,EA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AC;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,KAAK,MAAM,UAAU,IAAI,eAAe,EAAE,CAAC;QACzC,wHAAwH;QACxH,WAAW,CAAC,GAAG,CAAC,IAAI,UAAU,EAAE,CAAC,CAAC;IACpC,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 /** Dynamic (async) imports with non-literal paths consumed by this file. */\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 const exportStarPaths: string[] = [];\n\n const imports: ConsumedImport[] = [];\n const dynamicImports: DynamicImport[] = [];\n for (const imprt of new Set(rawImports)) {\n if (imprt.d === -2) {\n continue; // -2 means import.meta, which we don't care about\n }\n\n // es-module-lexer returns objects where the \"n\" property is the import source,\n // e.g. \"@fluentui/react/lib/Button\" for this import:\n // import { Button } from '@fluentui/react/lib/Button';\n // However, \"n\" will be undefined for import() if isn't a plain string literal.\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 // 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 }\n\n // Handle literal paths first\n if (importPath) {\n // Handling `export * from` import statements\n if (/export\\s*\\*\\s*from/.test(importCode)) {\n exportStarPaths.push(importPath);\n }\n\n let importedNames: string[];\n if (imprt.d >= 0) {\n // This is a dynamic import. In this case we don't know which names are used, so assume all of them.\n importedNames = ['*'];\n } else {\n // Parse the import string into its component parts.\n importedNames = parseNamedImports(importCode);\n }\n\n imports.push({\n ...parseImportString(importPath),\n names: Array.from(new Set(importedNames)),\n });\n } else if (packagePath) {\n // Non-literal path.\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 originalSource = consumer.originalPositionFor(pos).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 ? path.resolve(path.dirname(filePath), originalSource) : filePath;\n\n // TODO: This will give a bad path for a lot of template or concatenated strings\n let packageName = '.'; // Default to local package\n // Remove leading quote from the import specifier if it exists.\n const cleanImportSpecifier = importSpecifier.replace(/^[\"'`]/, '');\n if (!cleanImportSpecifier.startsWith('.')) {\n packageName = parseImportString(cleanImportSpecifier).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 } else {\n console.debug(`Found an import that didn't have a static path:\\nFilename:${filePath}\\nImport:\\n ${importCode}`);\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 for (const exportPath of exportStarPaths) {\n // This follows the following convention: https://github.com/guybedford/es-module-lexer/issues/76#issuecomment-868561807\n exportNames.add(`*${exportPath}`);\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"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { BundleMessage, BundlerResult, CloudpackConfig, PackageDefinitionsCache } from '@ms-cloudpack/common-types';
|
|
2
|
+
export declare function writeStubForDensityEntries(params: {
|
|
3
|
+
options: {
|
|
4
|
+
packageName: string;
|
|
5
|
+
packagePath: string;
|
|
6
|
+
result: BundlerResult;
|
|
7
|
+
};
|
|
8
|
+
context: {
|
|
9
|
+
packages: PackageDefinitionsCache;
|
|
10
|
+
config: CloudpackConfig;
|
|
11
|
+
};
|
|
12
|
+
}): Promise<BundleMessage[]>;
|
|
13
|
+
//# sourceMappingURL=writeStubForDensityEntries.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"writeStubForDensityEntries.d.ts","sourceRoot":"","sources":["../../src/utilities/writeStubForDensityEntries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,aAAa,EACb,eAAe,EACf,uBAAuB,EACxB,MAAM,4BAA4B,CAAC;AAQpC,wBAAsB,0BAA0B,CAAC,MAAM,EAAE;IACvD,OAAO,EAAE;QACP,WAAW,EAAE,MAAM,CAAC;QACpB,WAAW,EAAE,MAAM,CAAC;QACpB,MAAM,EAAE,aAAa,CAAC;KACvB,CAAC;IACF,OAAO,EAAE;QACP,QAAQ,EAAE,uBAAuB,CAAC;QAClC,MAAM,EAAE,eAAe,CAAC;KACzB,CAAC;CACH,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CAqE3B"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { generateESMStubFromExports } from '@ms-cloudpack/esm-stub-utilities';
|
|
2
|
+
import { writeFile } from 'fs/promises';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import { toNormalizedEntryKey } from '@ms-cloudpack/bundler';
|
|
5
|
+
import { flattenExportsMap, getExportsMap } from '@ms-cloudpack/package-utilities';
|
|
6
|
+
const errorSource = 'density-entry-stub';
|
|
7
|
+
export async function writeStubForDensityEntries(params) {
|
|
8
|
+
const { options, context } = params;
|
|
9
|
+
const { packagePath, packageName, result } = options;
|
|
10
|
+
const exportsMap = await getExportsMap({ packagePath }, context);
|
|
11
|
+
const densityCondition = ['density'];
|
|
12
|
+
const densityExportsMap = flattenExportsMap(exportsMap, {
|
|
13
|
+
requiredConditions: densityCondition,
|
|
14
|
+
conditions: densityCondition,
|
|
15
|
+
});
|
|
16
|
+
if (Object.keys(densityExportsMap).length === 0) {
|
|
17
|
+
return [];
|
|
18
|
+
}
|
|
19
|
+
if (!result.outputFiles) {
|
|
20
|
+
return [
|
|
21
|
+
{
|
|
22
|
+
source: errorSource,
|
|
23
|
+
text: `No output files found in the result. package name:${packageName}, package path:${packagePath}`,
|
|
24
|
+
},
|
|
25
|
+
];
|
|
26
|
+
}
|
|
27
|
+
if (!result.outputPath) {
|
|
28
|
+
return [
|
|
29
|
+
{
|
|
30
|
+
source: errorSource,
|
|
31
|
+
text: `No output path found in the result. package name:${packageName}, package path:${packagePath}`,
|
|
32
|
+
},
|
|
33
|
+
];
|
|
34
|
+
}
|
|
35
|
+
const errors = [];
|
|
36
|
+
// find the corresponding output file from the result for each external entry
|
|
37
|
+
for (const [key, value] of Object.entries(densityExportsMap)) {
|
|
38
|
+
try {
|
|
39
|
+
const entryPath = toNormalizedEntryKey(value);
|
|
40
|
+
const outputFile = result.outputFiles.find((o) => o.outputPath === value);
|
|
41
|
+
if (!outputFile) {
|
|
42
|
+
errors.push({
|
|
43
|
+
text: `No output file found for external entry: ${entryPath}, package name:${packageName}, package path:${packagePath}`,
|
|
44
|
+
source: errorSource,
|
|
45
|
+
});
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
const moduleId = key === '.' ? options.packageName : path.join(packageName, entryPath);
|
|
49
|
+
// generate new stab file for the external entry by using output.exports
|
|
50
|
+
// found the output file. This file need to be replaced.
|
|
51
|
+
const stub = generateESMStubFromExports({
|
|
52
|
+
export: {
|
|
53
|
+
type: outputFile.exports ? 'object' : 'other',
|
|
54
|
+
keys: outputFile.exports ?? [],
|
|
55
|
+
},
|
|
56
|
+
importStatement: `const moduleExport = requireDensityModule("${moduleId}");`,
|
|
57
|
+
});
|
|
58
|
+
await writeFile(path.join(result.outputPath, outputFile.outputPath), stub);
|
|
59
|
+
}
|
|
60
|
+
catch (e) {
|
|
61
|
+
errors.push({
|
|
62
|
+
text: `Error while creating stub for external entry: ${e}, package name:${packageName}, package path:${packagePath}`,
|
|
63
|
+
source: errorSource,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return errors;
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=writeStubForDensityEntries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"writeStubForDensityEntries.js","sourceRoot":"","sources":["../../src/utilities/writeStubForDensityEntries.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,0BAA0B,EAAE,MAAM,kCAAkC,CAAC;AAC9E,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,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AAC","sourcesContent":["import type {\n BundleMessage,\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 '@ms-cloudpack/bundler';\nimport { flattenExportsMap, getExportsMap } from '@ms-cloudpack/package-utilities';\n\nconst errorSource = 'density-entry-stub';\nexport async function writeStubForDensityEntries(params: {\n options: {\n packageName: string;\n packagePath: string;\n result: BundlerResult;\n };\n context: {\n packages: PackageDefinitionsCache;\n config: CloudpackConfig;\n };\n}): Promise<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) {\n return [];\n }\n\n if (!result.outputFiles) {\n return [\n {\n source: errorSource,\n text: `No output files found in the result. package name:${packageName}, package path:${packagePath}`,\n },\n ];\n }\n\n if (!result.outputPath) {\n return [\n {\n source: errorSource,\n text: `No output path found in the result. package name:${packageName}, package path:${packagePath}`,\n },\n ];\n }\n\n const errors: BundleMessage[] = [];\n\n // find the corresponding output file from the result for each external entry\n for (const [key, value] of Object.entries(densityExportsMap)) {\n try {\n const entryPath = toNormalizedEntryKey(value);\n const outputFile = result.outputFiles.find((o) => o.outputPath === value);\n if (!outputFile) {\n errors.push({\n text: `No output file found for external entry: ${entryPath}, package name:${packageName}, package path:${packagePath}`,\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 keys: outputFile.exports ?? [],\n },\n importStatement: `const moduleExport = requireDensityModule(\"${moduleId}\");`,\n });\n\n await writeFile(path.join(result.outputPath, outputFile.outputPath), stub);\n } catch (e) {\n errors.push({\n text: `Error while creating stub for external entry: ${e}, package name:${packageName}, package path:${packagePath}`,\n source: errorSource,\n });\n }\n }\n\n return errors;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ms-cloudpack/api-server",
|
|
3
|
-
"version": "0.56.
|
|
3
|
+
"version": "0.56.9",
|
|
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,21 +27,22 @@
|
|
|
27
27
|
"@lage-run/logger": "^1.3.0",
|
|
28
28
|
"@lage-run/scheduler": "^1.2.1",
|
|
29
29
|
"@lage-run/target-graph": "^0.9.0",
|
|
30
|
-
"@ms-cloudpack/bundler": "^0.23.
|
|
31
|
-
"@ms-cloudpack/common-types": "^0.23.
|
|
32
|
-
"@ms-cloudpack/config": "^0.33.
|
|
33
|
-
"@ms-cloudpack/create-express-app": "^1.10.
|
|
30
|
+
"@ms-cloudpack/bundler": "^0.23.19",
|
|
31
|
+
"@ms-cloudpack/common-types": "^0.23.5",
|
|
32
|
+
"@ms-cloudpack/config": "^0.33.2",
|
|
33
|
+
"@ms-cloudpack/create-express-app": "^1.10.7",
|
|
34
34
|
"@ms-cloudpack/data-bus": "^0.4.2",
|
|
35
|
+
"@ms-cloudpack/esm-stub-utilities": "^0.13.18",
|
|
35
36
|
"@ms-cloudpack/file-watcher": "^0.1.2",
|
|
36
|
-
"@ms-cloudpack/import-map": "^0.8.
|
|
37
|
+
"@ms-cloudpack/import-map": "^0.8.17",
|
|
37
38
|
"@ms-cloudpack/json-utilities": "^0.1.8",
|
|
38
|
-
"@ms-cloudpack/package-hashes": "^0.7.
|
|
39
|
-
"@ms-cloudpack/package-utilities": "^10.
|
|
39
|
+
"@ms-cloudpack/package-hashes": "^0.7.13",
|
|
40
|
+
"@ms-cloudpack/package-utilities": "^10.4.1",
|
|
40
41
|
"@ms-cloudpack/path-string-parsing": "^1.2.5",
|
|
41
|
-
"@ms-cloudpack/path-utilities": "^2.7.
|
|
42
|
-
"@ms-cloudpack/remote-cache": "^0.9.
|
|
42
|
+
"@ms-cloudpack/path-utilities": "^2.7.55",
|
|
43
|
+
"@ms-cloudpack/remote-cache": "^0.9.12",
|
|
43
44
|
"@ms-cloudpack/task-reporter": "^0.14.6",
|
|
44
|
-
"@ms-cloudpack/telemetry": "^0.9.
|
|
45
|
+
"@ms-cloudpack/telemetry": "^0.9.6",
|
|
45
46
|
"@trpc/client": "11.0.0-rc.608",
|
|
46
47
|
"@trpc/server": "11.0.0-rc.608",
|
|
47
48
|
"cors": "^2.8.5",
|