@ms-cloudpack/api-server 0.37.5 → 0.39.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.
- package/lib/common/createSession.d.ts.map +1 -1
- package/lib/common/createSession.js +17 -7
- package/lib/common/createSession.js.map +1 -1
- package/lib/index.d.ts +0 -4
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/types/BundleInfo.d.ts +12 -0
- package/lib/types/BundleInfo.d.ts.map +1 -1
- package/lib/types/BundleInfo.js.map +1 -1
- package/lib/types/Session.d.ts +2 -4
- package/lib/types/Session.d.ts.map +1 -1
- package/lib/types/Session.js.map +1 -1
- package/lib/utilities/addOverride.js +2 -2
- package/lib/utilities/addOverride.js.map +1 -1
- package/lib/utilities/bundleTask.js +8 -1
- package/lib/utilities/bundleTask.js.map +1 -1
- package/lib/utilities/createBundleTask.js +1 -1
- package/lib/utilities/createBundleTask.js.map +1 -1
- package/lib/utilities/getBundleInfo.d.ts +1 -0
- package/lib/utilities/getBundleInfo.d.ts.map +1 -1
- package/lib/utilities/getBundleInfo.js +7 -4
- package/lib/utilities/getBundleInfo.js.map +1 -1
- package/lib/utilities/getImportsAndExports.d.ts +4 -5
- package/lib/utilities/getImportsAndExports.d.ts.map +1 -1
- package/lib/utilities/getImportsAndExports.js +58 -5
- package/lib/utilities/getImportsAndExports.js.map +1 -1
- package/package.json +10 -9
- package/lib/types/CreateHtmlFunction.d.ts +0 -7
- package/lib/types/CreateHtmlFunction.d.ts.map +0 -1
- package/lib/types/CreateHtmlFunction.js +0 -2
- package/lib/types/CreateHtmlFunction.js.map +0 -1
- package/lib/types/CreateHtmlOptions.d.ts +0 -20
- package/lib/types/CreateHtmlOptions.d.ts.map +0 -1
- package/lib/types/CreateHtmlOptions.js +0 -2
- package/lib/types/CreateHtmlOptions.js.map +0 -1
- package/lib/types/CreateHtmlResult.d.ts +0 -9
- package/lib/types/CreateHtmlResult.d.ts.map +0 -1
- package/lib/types/CreateHtmlResult.js +0 -2
- package/lib/types/CreateHtmlResult.js.map +0 -1
- package/lib/types/CreateHtmlScript.d.ts +0 -8
- package/lib/types/CreateHtmlScript.d.ts.map +0 -1
- package/lib/types/CreateHtmlScript.js +0 -2
- package/lib/types/CreateHtmlScript.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createSession.d.ts","sourceRoot":"","sources":["../../src/common/createSession.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAE3F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AASnD,wBAAsB,aAAa,CACjC,OAAO,EAAE;IACP,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,eAAe,CAAC;CACzB,EACD,OAAO,EAAE;IAAE,QAAQ,EAAE,YAAY,CAAC;IAAC,QAAQ,EAAE,uBAAuB,CAAA;CAAE,GACrE,OAAO,CAAC,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"createSession.d.ts","sourceRoot":"","sources":["../../src/common/createSession.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAE3F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AASnD,wBAAsB,aAAa,CACjC,OAAO,EAAE;IACP,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,eAAe,CAAC;CACzB,EACD,OAAO,EAAE;IAAE,QAAQ,EAAE,YAAY,CAAC;IAAC,QAAQ,EAAE,uBAAuB,CAAA;CAAE,GACrE,OAAO,CAAC,OAAO,CAAC,CA0ElB"}
|
|
@@ -8,7 +8,7 @@ export async function createSession(options, context) {
|
|
|
8
8
|
const { appPath, config, overlayPath } = options;
|
|
9
9
|
const projectName = path.basename(appPath);
|
|
10
10
|
const id = uuid();
|
|
11
|
-
|
|
11
|
+
let resolveMap = await resolveDependenciesTask({
|
|
12
12
|
appPath,
|
|
13
13
|
additionalPaths: overlayPath ? [overlayPath] : [],
|
|
14
14
|
}, context);
|
|
@@ -23,17 +23,25 @@ export async function createSession(options, context) {
|
|
|
23
23
|
await fsExtra.writeJson(versionsPath, { sessionVersion: 0, targetVersions: {} }, { spaces: 2 });
|
|
24
24
|
}
|
|
25
25
|
const versions = (await fsExtra.readJSON(versionsPath));
|
|
26
|
-
|
|
26
|
+
const session = {
|
|
27
27
|
id,
|
|
28
28
|
appPath,
|
|
29
29
|
config,
|
|
30
30
|
projectName,
|
|
31
31
|
type: 'web-app',
|
|
32
32
|
mode: 'library',
|
|
33
|
-
resolveMap
|
|
33
|
+
get resolveMap() {
|
|
34
|
+
return resolveMap;
|
|
35
|
+
},
|
|
36
|
+
set resolveMap(newResolveMap) {
|
|
37
|
+
// If the resolve map changes, clear the import map
|
|
38
|
+
// so that it is regenerated on the next request
|
|
39
|
+
importMap = undefined;
|
|
40
|
+
resolveMap = newResolveMap;
|
|
41
|
+
},
|
|
34
42
|
sequence: 0,
|
|
35
43
|
targetVersions: versions.targetVersions,
|
|
36
|
-
|
|
44
|
+
get sessionVersion() {
|
|
37
45
|
return versions.sessionVersion;
|
|
38
46
|
},
|
|
39
47
|
incrementSessionVersion: () => {
|
|
@@ -50,11 +58,13 @@ export async function createSession(options, context) {
|
|
|
50
58
|
// eslint-disable-next-line @ms-cloudpack/internal/no-sync-filesystem -- this function can't be async
|
|
51
59
|
fs.writeFileSync(versionsPath, JSON.stringify(versions, null, 2));
|
|
52
60
|
},
|
|
53
|
-
|
|
54
|
-
setImportMap: (newImportMap) => {
|
|
55
|
-
importMap = newImportMap;
|
|
61
|
+
get importMap() {
|
|
56
62
|
return importMap;
|
|
57
63
|
},
|
|
64
|
+
set importMap(newImportMap) {
|
|
65
|
+
importMap = newImportMap;
|
|
66
|
+
},
|
|
58
67
|
};
|
|
68
|
+
return session;
|
|
59
69
|
}
|
|
60
70
|
//# sourceMappingURL=createSession.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createSession.js","sourceRoot":"","sources":["../../src/common/createSession.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,OAAO,MAAM,UAAU,CAAC;AAC/B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAElF,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,OAIC,EACD,OAAsE;IAEtE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;IAEjD,MAAM,WAAW,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC3C,MAAM,EAAE,GAAG,IAAI,EAAE,CAAC;IAClB,
|
|
1
|
+
{"version":3,"file":"createSession.js","sourceRoot":"","sources":["../../src/common/createSession.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,OAAO,MAAM,UAAU,CAAC;AAC/B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAElF,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,OAI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AAa;YAC1B,mDAAmD;YACnD,gDAAgD;YAChD,SAAS,GAAG,SAAS,CAAC;YACtB,UAAU,GAAG,aAAa,CAAC;QAC7B,CAAC;QACD,QAAQ,EAAE,CAAC;QACX,cAAc,EAAE,QAAQ,CAAC,cAAc;QACvC,IAAI,cAAc;YAChB,OAAO,QAAQ,CAAC,cAAc,CAAC;QACjC,CAAC;QACD,uBAAuB,EAAE,GAAG,EAAE;YAC5B,QAAQ,CAAC,cAAc,EAAE,CAAC;YAC1B,SAAS,GAAG,SAAS,CAAC;YACtB,4CAA4C;YAC5C,qGAAqG;YACrG,EAAE,CAAC,aAAa,CAAC,YAAY,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QACpE,CAAC;QACD,sBAAsB,EAAE,CAAC,SAAiB,EAAE,EAAE;YAC5C,QAAQ,CAAC,cAAc,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;YACzC,QAAQ,CAAC,cAAc,CAAC,SAAS,CAAC,EAAE,CAAC;YACrC,SAAS,GAAG,SAAS,CAAC;YACtB,qGAAqG;YACrG,EAAE,CAAC,aAAa,CAAC,YAAY,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QACpE,CAAC;QACD,IAAI,SAAS;YACX,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,IAAI,SAAS,CAAC,YAAY;YACxB,SAAS,GAAG,YAAY,CAAC;QAC3B,CAAC;KACF,CAAC;IAEF,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import type { CloudpackConfig, PackageDefinitionsCache } from '@ms-cloudpack/common-types';\nimport type { ImportMap } from '@ms-cloudpack/import-map';\nimport type { TaskReporter } from '@ms-cloudpack/task-reporter';\nimport type { Session } from '../types/Session.js';\n\nimport fs from 'fs';\nimport fsExtra from 'fs-extra';\nimport path from 'path';\nimport { v4 as uuid } from 'uuid';\nimport { getLocalCachePath } from '../utilities/getCachePath.js';\nimport { resolveDependenciesTask } from '../utilities/resolveDependenciesTask.js';\n\nexport async function createSession(\n options: {\n appPath: string;\n overlayPath?: string;\n config: CloudpackConfig;\n },\n context: { reporter: TaskReporter; packages: PackageDefinitionsCache },\n): Promise<Session> {\n const { appPath, config, overlayPath } = options;\n\n const projectName = path.basename(appPath);\n const id = uuid();\n let resolveMap = await resolveDependenciesTask(\n {\n appPath,\n additionalPaths: overlayPath ? [overlayPath] : [],\n },\n context,\n );\n\n if (!resolveMap) {\n throw new Error('Could not resolve dependencies.');\n }\n\n let importMap: ImportMap | undefined = undefined;\n\n await fsExtra.ensureDir(getLocalCachePath(appPath));\n const versionsPath = path.join(getLocalCachePath(appPath), 'sessionVersions.json');\n const versionsFileExists = await fsExtra.pathExists(versionsPath);\n if (!versionsFileExists) {\n await fsExtra.writeJson(versionsPath, { sessionVersion: 0, targetVersions: {} }, { spaces: 2 });\n }\n const versions = (await fsExtra.readJSON(versionsPath)) as {\n sessionVersion: number;\n targetVersions: Record<string, number>;\n };\n\n const session: Session = {\n id,\n appPath,\n config,\n projectName,\n type: 'web-app',\n mode: 'library',\n get resolveMap() {\n return resolveMap;\n },\n set resolveMap(newResolveMap) {\n // If the resolve map changes, clear the import map\n // so that it is regenerated on the next request\n importMap = undefined;\n resolveMap = newResolveMap;\n },\n sequence: 0,\n targetVersions: versions.targetVersions,\n get sessionVersion() {\n return versions.sessionVersion;\n },\n incrementSessionVersion: () => {\n versions.sessionVersion++;\n importMap = undefined;\n // Write the new session version to the file\n // eslint-disable-next-line @ms-cloudpack/internal/no-sync-filesystem -- this function can't be async\n fs.writeFileSync(versionsPath, JSON.stringify(versions, null, 2));\n },\n incrementTargetVersion: (inputPath: string) => {\n versions.targetVersions[inputPath] ??= 0;\n versions.targetVersions[inputPath]++;\n importMap = undefined;\n // eslint-disable-next-line @ms-cloudpack/internal/no-sync-filesystem -- this function can't be async\n fs.writeFileSync(versionsPath, JSON.stringify(versions, null, 2));\n },\n get importMap() {\n return importMap;\n },\n set importMap(newImportMap) {\n importMap = newImportMap;\n },\n };\n\n return session;\n}\n"]}
|
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';
|
package/lib/index.d.ts.map
CHANGED
|
@@ -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,EAA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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,MAAM,GAAG,eAAe,CAAC;CACtC,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,8DAA8D;IAC9D,UAAU,EAAE,MAAM,CAAC;IACnB,0CAA0C;IAC1C,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,uDAAuD;IACvD,QAAQ,EAAE,mBAAmB,EAAE,CAAC;
|
|
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,MAAM,GAAG,eAAe,CAAC;CACtC,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,8DAA8D;IAC9D,UAAU,EAAE,MAAM,CAAC;IACnB,0CAA0C;IAC1C,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,uDAAuD;IACvD,QAAQ,EAAE,mBAAmB,EAAE,CAAC;IAChC,6CAA6C;IAC7C,cAAc,CAAC,EAAE,aAAa,EAAE,CAAC;CAClC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,0BAA0B;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,0EAA0E;IAC1E,UAAU,EAAE,MAAM,CAAC;IACnB,4BAA4B;IAC5B,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,EAAE,CAAC;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"]}
|
package/lib/types/Session.d.ts
CHANGED
|
@@ -38,10 +38,9 @@ export interface Session {
|
|
|
38
38
|
*/
|
|
39
39
|
sequence: number;
|
|
40
40
|
/**
|
|
41
|
-
* Get session version.
|
|
42
41
|
* Used to force a hard refresh on the client.
|
|
43
42
|
*/
|
|
44
|
-
|
|
43
|
+
sessionVersion: number;
|
|
45
44
|
/**
|
|
46
45
|
* Used to increment the session version by 1.
|
|
47
46
|
*/
|
|
@@ -63,7 +62,6 @@ export interface Session {
|
|
|
63
62
|
/**
|
|
64
63
|
* The import map for the session.
|
|
65
64
|
*/
|
|
66
|
-
|
|
67
|
-
setImportMap: (newImportMap: ImportMap) => ImportMap;
|
|
65
|
+
importMap: ImportMap | undefined;
|
|
68
66
|
}
|
|
69
67
|
//# sourceMappingURL=Session.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Session.d.ts","sourceRoot":"","sources":["../../src/types/Session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAElE,MAAM,WAAW,OAAO;IACtB;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;OAEG;IACH,MAAM,EAAE,eAAe,CAAC;IAExB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;;;OAIG;IACH,IAAI,EAAE,SAAS,GAAG,SAAS,CAAC;IAE5B;;;;;;OAMG;IACH,IAAI,EAAE,SAAS,GAAG,aAAa,GAAG,YAAY,CAAC;IAE/C;;OAEG;IACH,UAAU,EAAE,UAAU,CAAC;IAEvB;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB
|
|
1
|
+
{"version":3,"file":"Session.d.ts","sourceRoot":"","sources":["../../src/types/Session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAElE,MAAM,WAAW,OAAO;IACtB;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;OAEG;IACH,MAAM,EAAE,eAAe,CAAC;IAExB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;;;OAIG;IACH,IAAI,EAAE,SAAS,GAAG,SAAS,CAAC;IAE5B;;;;;;OAMG;IACH,IAAI,EAAE,SAAS,GAAG,aAAa,GAAG,YAAY,CAAC;IAE/C;;OAEG;IACH,UAAU,EAAE,UAAU,CAAC;IAEvB;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IAEvB;;OAEG;IACH,uBAAuB,EAAE,MAAM,IAAI,CAAC;IAEpC;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEvC;;OAEG;IACH,sBAAsB,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IAEpD;;OAEG;IACH,SAAS,EAAE,SAAS,GAAG,SAAS,CAAC;CAClC"}
|
package/lib/types/Session.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Session.js","sourceRoot":"","sources":["../../src/types/Session.ts"],"names":[],"mappings":"","sourcesContent":["import type { ImportMap } from '@ms-cloudpack/import-map';\nimport type { ResolveMap } from '@ms-cloudpack/package-utilities';\nimport type { CloudpackConfig } from '@ms-cloudpack/common-types';\n\nexport interface Session {\n /**\n * The session id, used for identifying\n */\n id: string;\n\n /**\n * The config used by the session.\n */\n config: CloudpackConfig;\n\n /**\n * The primary application path to monitor.\n */\n appPath: string;\n\n /**\n * The type of session controls how the code is served via start.\n * Web apps require app server and asset hosting, while libraries\n * only need a bundle service.\n */\n type: 'web-app' | 'library';\n\n /**\n * The mode of the session controls how the code is bundled. Library\n * mode bundles each package in isolation, while development and\n * production modes bundle the full app graph together. Library\n * mode is fastest but packages must be complaint for loading in\n * the browser.\n */\n mode: 'library' | 'development' | 'production';\n\n /**\n * Used to resolve packages in the dependency graph.\n */\n resolveMap: ResolveMap;\n\n /**\n * Reload sequence to ensure that the client is always\n * up to date with the latest changes.\n */\n sequence: number;\n\n /**\n *
|
|
1
|
+
{"version":3,"file":"Session.js","sourceRoot":"","sources":["../../src/types/Session.ts"],"names":[],"mappings":"","sourcesContent":["import type { ImportMap } from '@ms-cloudpack/import-map';\nimport type { ResolveMap } from '@ms-cloudpack/package-utilities';\nimport type { CloudpackConfig } from '@ms-cloudpack/common-types';\n\nexport interface Session {\n /**\n * The session id, used for identifying\n */\n id: string;\n\n /**\n * The config used by the session.\n */\n config: CloudpackConfig;\n\n /**\n * The primary application path to monitor.\n */\n appPath: string;\n\n /**\n * The type of session controls how the code is served via start.\n * Web apps require app server and asset hosting, while libraries\n * only need a bundle service.\n */\n type: 'web-app' | 'library';\n\n /**\n * The mode of the session controls how the code is bundled. Library\n * mode bundles each package in isolation, while development and\n * production modes bundle the full app graph together. Library\n * mode is fastest but packages must be complaint for loading in\n * the browser.\n */\n mode: 'library' | 'development' | 'production';\n\n /**\n * Used to resolve packages in the dependency graph.\n */\n resolveMap: ResolveMap;\n\n /**\n * Reload sequence to ensure that the client is always\n * up to date with the latest changes.\n */\n sequence: number;\n\n /**\n * Used to force a hard refresh on the client.\n */\n sessionVersion: number;\n\n /**\n * Used to increment the session version by 1.\n */\n incrementSessionVersion: () => void;\n\n /**\n * The name of the project folder.\n * Used to differentiate between multiple projects.\n */\n projectName: string;\n\n /**\n * The version of each target.\n * Used to force a client cache refresh on a single target.\n */\n targetVersions: Record<string, number>;\n\n /**\n * Increments the version for the given target.\n */\n incrementTargetVersion: (inputPath: string) => void;\n\n /**\n * The import map for the session.\n */\n importMap: ImportMap | undefined;\n}\n"]}
|
|
@@ -29,7 +29,7 @@ export async function addOverride(options, context) {
|
|
|
29
29
|
// Get current exports. We want to add an additional entry to what's there - not replace the default exports,
|
|
30
30
|
// so we need the full map for the package.
|
|
31
31
|
const exports = await getExportsMap({ packagePath }, { packages, config: session.config });
|
|
32
|
-
const flattenedExports = flattenExportsMap(exports);
|
|
32
|
+
const flattenedExports = flattenExportsMap(exports, { packagePath });
|
|
33
33
|
// Return false if the import path already exists in the exports map.
|
|
34
34
|
if (flattenedExports[normalizeRelativePath(importPath)]) {
|
|
35
35
|
console.debug(`The import path "${importPath}" already exists in the exports map for "${packageName}".`);
|
|
@@ -78,7 +78,7 @@ export async function addOverride(options, context) {
|
|
|
78
78
|
}
|
|
79
79
|
// Use the first match and ensure exports exist
|
|
80
80
|
configMatches[0].exports ??= {};
|
|
81
|
-
const flattenedMatchExports = flattenExportsMap(configMatches[0].exports);
|
|
81
|
+
const flattenedMatchExports = flattenExportsMap(configMatches[0].exports, { packagePath });
|
|
82
82
|
// Return false if the import path already exists in the match exports map.
|
|
83
83
|
if (flattenedMatchExports[normalizeRelativePath(importPath)]) {
|
|
84
84
|
console.debug(`The import path "${importPath}" already exists in the config exports map for "${packageName}".`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addOverride.js","sourceRoot":"","sources":["../../src/utilities/addOverride.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC7F,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,aAAa,GAEd,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAG1E,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,OAAwB,EACxB,OAA8C;IAO9C,MAAM,EAA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AAM,EAAE,CACrC,CAAC;IACJ,CAAC;IAED,MAAM,oBAAoB,CAAC,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IACpD,OAAO,CAAC,KAAK,CAAC,uBAAuB,WAAW,+BAA+B,CAAC,CAAC;IAEjF,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC;AAClC,CAAC","sourcesContent":["import { checkMatch, readGeneratedConfig, writeGeneratedConfig } from '@ms-cloudpack/config';\nimport {\n addExportsMapEntry,\n findResolveMapEntry,\n flattenExportsMap,\n getExportsMap,\n type ResolveMapEntry,\n} from '@ms-cloudpack/package-utilities';\nimport { normalizeRelativePath } from '@ms-cloudpack/path-string-parsing';\nimport type { Context } from '../types/Context.js';\nimport type { OverrideOptions } from '../types/OverrideOptions.js';\nimport { parseRequestUrl } from './parseRequestUrl.js';\n\n/**\n * The addOverride method is triggered by a user action in the overlay, when we detect new usage of an import path\n * that isn't recognized. When the user triggers this override, we write it to the cloudpack generated config.\n */\nexport async function addOverride(\n options: OverrideOptions,\n context: Pick<Context, 'packages' | 'session'>,\n): Promise<{\n /** Whether the override was successfully added */\n addedOverride: boolean;\n /** The entry (if any) in the resolve map the override was added to */\n entry?: ResolveMapEntry;\n}> {\n const { packageName, importPath, version, issuerUrl } = options;\n const { session, packages } = context;\n let addedOverride = false;\n let requiredBy = undefined;\n\n if (issuerUrl) {\n const { packageName: issuerName, version: issuerVersion } = parseRequestUrl(issuerUrl);\n requiredBy = { name: issuerName, version: issuerVersion };\n }\n\n const entry = findResolveMapEntry({\n packageName,\n resolveMap: session.resolveMap,\n definition: requiredBy,\n version,\n });\n\n if (!entry) {\n console.error(`Could not find entry of package \"${packageName}\" in resolve map`);\n return { addedOverride, entry };\n }\n\n const packagePath = entry.path;\n\n // Get current exports. We want to add an additional entry to what's there - not replace the default exports,\n // so we need the full map for the package.\n const exports = await getExportsMap({ packagePath }, { packages, config: session.config });\n const flattenedExports = flattenExportsMap(exports, { packagePath });\n\n // Return false if the import path already exists in the exports map.\n if (flattenedExports[normalizeRelativePath(importPath)]) {\n console.debug(`The import path \"${importPath}\" already exists in the exports map for \"${packageName}\".`);\n return { addedOverride, entry };\n }\n\n const addedExports = {};\n\n // Add the single new exports entry to the exports map.\n addedOverride = await addExportsMapEntry(\n {\n // This is required as addExportsMapEntry assumes addedExports is a record.\n exports: addedExports,\n packagePath,\n importPath,\n },\n { packages, config: session.config },\n );\n\n if (!addedOverride) {\n console.warn(\n `Unable to add override for package \"${packageName}\" to \"cloudpack.config.json\". The file \"${normalizeRelativePath(\n importPath,\n )}\" could not be found. Please check the import path and try again.`,\n );\n return { addedOverride, entry };\n }\n\n if (Array.isArray(exports)) {\n exports.push(addedExports);\n } else {\n const definition = await packages.get(packagePath);\n if (!definition) {\n console.error(`Could not find definition of package \"${packageName}\" in the cache`);\n return { addedOverride, entry };\n }\n definition.exports = [exports, addedExports];\n }\n\n // Parse the user config if it exists.\n const config = await readGeneratedConfig(session.appPath);\n\n // Ensure packageSettings exist.\n config.packageSettings ??= [];\n\n const configMatches = config.packageSettings.filter(({ match }) =>\n checkMatch({ name: packageName, version: entry.version, match, exactMatch: true }),\n );\n\n if (!configMatches.length) {\n config.packageSettings.push({\n match: {\n name: packageName,\n version: `^${entry.version}`,\n },\n exports: addedExports,\n });\n } else {\n if (configMatches.length > 1) {\n console.debug(\n `Found multiple matches for package \"${packageName}\" in cloudpack.config.json. Using the first match.`,\n );\n }\n\n // Use the first match and ensure exports exist\n configMatches[0].exports ??= {};\n\n const flattenedMatchExports = flattenExportsMap(configMatches[0].exports, { packagePath });\n\n // Return false if the import path already exists in the match exports map.\n if (flattenedMatchExports[normalizeRelativePath(importPath)]) {\n console.debug(`The import path \"${importPath}\" already exists in the config exports map for \"${packageName}\".`);\n return { addedOverride: false, entry };\n }\n\n // Add the single new exports entry to the match exports map.\n await addExportsMapEntry(\n {\n exports: configMatches[0].exports,\n packagePath,\n importPath,\n },\n { packages, config: session.config },\n );\n }\n\n await writeGeneratedConfig(config, session.appPath);\n console.debug(`Added override for \"${packageName}\" to \"cloudpack.config.json\".`);\n\n return { addedOverride, entry };\n}\n"]}
|
|
@@ -86,16 +86,22 @@ 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,
|
|
92
97
|
inputPath: packagePath,
|
|
93
98
|
outputPath,
|
|
94
|
-
incremental: isIncremental !== undefined ? isIncremental :
|
|
99
|
+
incremental: isIncremental !== undefined ? isIncremental : false,
|
|
95
100
|
sourcemap: disableSourceMaps ? undefined : 'linked',
|
|
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,OAAO,EAAE,MAAM,IAAI,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C,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,MAAM,wBAAwB,CA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AAI,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 : false,\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"]}
|
|
@@ -34,7 +34,7 @@ export function createBundleTask(params) {
|
|
|
34
34
|
});
|
|
35
35
|
try {
|
|
36
36
|
const importMapHash = sourceHash || hash || (await packageHashes.get({ packagePath, isSourceHashingEnabled: !isExternal }));
|
|
37
|
-
addImportMapHash({ packageName, version, importMap: session.
|
|
37
|
+
addImportMapHash({ packageName, version, importMap: session.importMap, resolveMap, hash: importMapHash }, {
|
|
38
38
|
packageImportPaths,
|
|
39
39
|
});
|
|
40
40
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createBundleTask.js","sourceRoot":"","sources":["../../src/utilities/createBundleTask.ts"],"names":[],"mappings":"AAIA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAO5D;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAWhC;IACC,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,EAAE,GAAG,MAAM,CAAC;IACxD,MAAM,EAAE,EAAE,EAAE,WAAW,EAAE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,GAAG,aAAa,CAAC;IAC5E,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,kBAAkB,EAAE,QAAQ,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC;IACpG,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;IACvC,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;IACrC,MAAM,IAAI,GAAG,UAAU,WAAW,IAAI,OAAO,EAAE,CAAC;IAEhD,OAAO;QACL,gCAAgC;QAChC,IAAI;QACJ,EAAE;QACF,GAAG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,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;YAE7E,aAAa,CAAC,MAAM,GAAG,SAAS,CAAC;QACnC,CAAC;QACD,SAAS,EAAE,GAAG,EAAE;YACd,aAAa,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,CAAC;QACpC,CAAC;QACD,SAAS,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,MAAM,EAAE,MAAM;QAC7C,mBAAmB,EAAE,GAAG,EAAE,CAAC,CAAC;YAC1B,EAAE;YACF,kCAAkC;YAClC,IAAI;YACJ,SAAS,EAAE,WAAW,IAAI,EAAE;SAC7B,CAAC;QACF,iBAAiB,EAAE,CAAC,UAAU,EAAE,EAAE,CAChC,CAAC;YACC,EAAE;YACF,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM;YAClC,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ;YACtC,UAAU,EAAE,aAAa,CAAC,MAAM,EAAE,UAAU,IAAI,EAAE;SACnD,CAAuB;KAC3B,CAAC;AACJ,CAAC","sourcesContent":["import type { BundleTaskOptions } from '../types/BundleTaskOptions.js';\nimport type { BundleRequest } from '../types/BundleRequest.js';\nimport type { Task } from '../types/Task.js';\nimport type { TaskEndDescription } from '../types/TaskEndDescription.js';\nimport path from 'path';\nimport fs from 'fs';\nimport { bundleTask } from './bundleTask.js';\nimport type { TaskReporter } from '@ms-cloudpack/task-reporter';\nimport { addImportMapHash } from '@ms-cloudpack/import-map';\nimport type { Session } from '../types/Session.js';\nimport type { TelemetryClient } from '@ms-cloudpack/telemetry';\nimport type { PackageImportPaths } from '@ms-cloudpack/import-map';\nimport type { PackageDefinitionsCache } from '@ms-cloudpack/common-types';\nimport type { PackageHashes } from '@ms-cloudpack/package-hashes';\n\n/**\n * Creates a bundle task tracked in the task runner of the api server. This allows active tasks to be tracked\n * remotely (e.g. in the browser) and allows the user to cancel tasks.\n */\nexport function createBundleTask(params: {\n bundleRequest: BundleRequest;\n context: {\n session: Session;\n packages: PackageDefinitionsCache;\n packageHashes: PackageHashes;\n packageImportPaths: PackageImportPaths;\n reporter?: TaskReporter;\n telemetryClient?: TelemetryClient;\n };\n options?: BundleTaskOptions;\n}): Task<BundleRequest> {\n const { bundleRequest, context, options = {} } = params;\n const { id, packageName, version, packagePath, isExternal } = bundleRequest;\n const { session, reporter, telemetryClient, packageImportPaths, packages, packageHashes } = context;\n const { config, resolveMap } = session;\n const { hash, sourceHash } = options;\n const name = `Bundle ${packageName}@${version}`;\n\n return {\n // Name for task runner logging.\n name,\n id,\n dir: `${path.join(packagePath, 'src')}`,\n watch: !isExternal,\n async execute(): Promise<BundleRequest> {\n await bundleTask({\n bundleRequest,\n options,\n context: {\n packages,\n config,\n resolveMap,\n packageHashes,\n reporter,\n telemetryClient,\n },\n });\n try {\n const importMapHash =\n sourceHash || hash || (await packageHashes.get({ packagePath, isSourceHashingEnabled: !isExternal }));\n addImportMapHash(\n { packageName, version, importMap: session.importMap, resolveMap, hash: importMapHash },\n {\n packageImportPaths,\n },\n );\n } catch (e) {\n console.error(`Error adding hash to import map for ${bundleRequest.packagePath}:`, (e as Error).stack || e);\n }\n return bundleRequest;\n },\n clear: () => {\n if (!bundleRequest.result) {\n return;\n }\n\n bundleRequest.result.dispose?.();\n\n // eslint-disable-next-line @ms-cloudpack/internal/no-sync-filesystem -- this function can't be async\n fs.rmSync(bundleRequest.result.outputPath, { recursive: true, force: true });\n\n bundleRequest.result = undefined;\n },\n onDispose: () => {\n bundleRequest.result?.dispose?.();\n },\n getErrors: () => bundleRequest.result?.errors,\n getStartDescription: () => ({\n id,\n // Name to display in the overlay.\n name,\n inputPath: packagePath || '',\n }),\n getEndDescription: (taskResult) =>\n ({\n id,\n errors: taskResult?.result?.errors,\n warnings: taskResult?.result?.warnings,\n outputPath: bundleRequest.result?.outputPath || '',\n }) as TaskEndDescription,\n };\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,
|
|
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) {
|
|
@@ -24,7 +24,7 @@ export async function getBundleInfo(params) {
|
|
|
24
24
|
};
|
|
25
25
|
});
|
|
26
26
|
const repeatedExports = {};
|
|
27
|
-
const entryPaths = getRuntimeEntryPaths({ isExternal, exportsMap });
|
|
27
|
+
const entryPaths = getRuntimeEntryPaths({ packagePath, isExternal, exportsMap });
|
|
28
28
|
for (const [importPath, actualEntryPath] of Object.entries(entryPaths)) {
|
|
29
29
|
const safePath = normalizeRelativePath(actualEntryPath);
|
|
30
30
|
if (outputFileInfo[safePath]) {
|
|
@@ -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,CAAC,
|
|
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,qBAAqB,CAAC,IAAI,CAAC,UA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,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({ packagePath, 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 {
|
|
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:
|
|
9
|
-
|
|
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":"
|
|
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,oDAAo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C;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,MA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,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.
|
|
3
|
+
"version": "0.39.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,18 +27,18 @@
|
|
|
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.20.
|
|
31
|
-
"@ms-cloudpack/common-types": "^0.
|
|
32
|
-
"@ms-cloudpack/config": "^0.19.
|
|
33
|
-
"@ms-cloudpack/create-express-app": "^1.6.
|
|
30
|
+
"@ms-cloudpack/bundler": "^0.20.2",
|
|
31
|
+
"@ms-cloudpack/common-types": "^0.3.0",
|
|
32
|
+
"@ms-cloudpack/config": "^0.19.8",
|
|
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.
|
|
36
|
+
"@ms-cloudpack/import-map": "^0.3.0",
|
|
37
37
|
"@ms-cloudpack/json-utilities": "^0.1.4",
|
|
38
|
-
"@ms-cloudpack/package-hashes": "^0.5.
|
|
39
|
-
"@ms-cloudpack/package-utilities": "^7.
|
|
38
|
+
"@ms-cloudpack/package-hashes": "^0.5.10",
|
|
39
|
+
"@ms-cloudpack/package-utilities": "^7.3.0",
|
|
40
40
|
"@ms-cloudpack/path-string-parsing": "^1.2.1",
|
|
41
|
-
"@ms-cloudpack/path-utilities": "^2.7.
|
|
41
|
+
"@ms-cloudpack/path-utilities": "^2.7.4",
|
|
42
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",
|
|
@@ -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 +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 +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 +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 +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 +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"]}
|