@ms-cloudpack/package-utilities 5.1.12 → 5.1.13

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.
@@ -1 +1 @@
1
- {"version":3,"file":"PackageDefinitions.d.ts","sourceRoot":"","sources":["../src/PackageDefinitions.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,0BAA0B,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAIpH,qBAAa,kBAAmB,YAAW,uBAAuB;IAChE,OAAO,CAAC,YAAY,CAA8B;IAClD,OAAO,CAAC,uBAAuB,CAA8B;IAC7D,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,WAAW,CAAoC;IACvD,OAAO,CAAC,mBAAmB,CAAuD;IAClF,OAAO,CAAC,OAAO,CAA6B;IAE5C;;;;;OAKG;gBACS,eAAe,GAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAM,EAAE,MAAM,CAAC,EAAE,OAAO;IAQzE,GAAG,CACP,WAAW,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,OAAO,CAAC;QAAC,iBAAiB,CAAC,EAAE,OAAO,CAAA;KAAE,GAC3D,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC;IAwCnC;;;;OAIG;IACH,iBAAiB,CAAC,OAAO,EAAE,CAAC,MAAM,CAAC,EAAE,OAAO,KAAK,0BAA0B;IAO3E;;OAEG;IACH,KAAK,CAAC,OAAO,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE;IAYvC;;;;OAIG;IACG,OAAO,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IA2BnD;;;OAGG;IACH,UAAU,CAAC,WAAW,EAAE,MAAM;CAG/B"}
1
+ {"version":3,"file":"PackageDefinitions.d.ts","sourceRoot":"","sources":["../src/PackageDefinitions.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,0BAA0B,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAIpH,qBAAa,kBAAmB,YAAW,uBAAuB;IAChE,OAAO,CAAC,YAAY,CAA8B;IAClD,OAAO,CAAC,uBAAuB,CAA8B;IAC7D,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,WAAW,CAAoC;IACvD,OAAO,CAAC,mBAAmB,CAAuD;IAClF,OAAO,CAAC,OAAO,CAAsB;IAErC;;;;;OAKG;gBACS,eAAe,GAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAM,EAAE,MAAM,CAAC,EAAE,OAAO;IASzE,GAAG,CACP,WAAW,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,OAAO,CAAC;QAAC,iBAAiB,CAAC,EAAE,OAAO,CAAA;KAAE,GAC3D,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC;IAwCnC;;;;OAIG;IACH,iBAAiB,CAAC,OAAO,EAAE,CAAC,MAAM,CAAC,EAAE,OAAO,KAAK,0BAA0B;IAO3E;;OAEG;IACH,KAAK,CAAC,OAAO,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE;IAYvC;;;;OAIG;IACG,OAAO,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IA2BnD;;;OAGG;IACH,UAAU,CAAC,WAAW,EAAE,MAAM;CAG/B"}
@@ -12,12 +12,12 @@ export class PackageDefinitions {
12
12
  */
13
13
  constructor(definitionCache = {}, config) {
14
14
  this._transforms = [];
15
- this._hashes = new Map();
16
15
  this._definitions = definitionCache;
17
16
  this._transformedDefinitions = {};
18
17
  this._config = config;
19
18
  this._transforms = [applyOverrides];
20
19
  this._transformFactories = [];
20
+ this._hashes = new Map();
21
21
  }
22
22
  async get(packagePath, options) {
23
23
  let definition = this._definitions[packagePath];
@@ -1 +1 @@
1
- {"version":3,"file":"Package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AE,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;SACvG;IACH,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,OAAO,CAAC,WAAmB;QAC/B,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE;YACjC,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAW,CAAC;SAChD;QAED,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QAC/C,IAAI,CAAC,UAAU,EAAE;YACf,MAAM,IAAI,KAAK,CAAC,4DAA4D,WAAW,GAAG,CAAC,CAAC;SAC7F;QAED,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,UAAU,CAAC;QACrC,IAAI,CAAC,IAAI,EAAE;YACT,MAAM,IAAI,KAAK,CAAC,sDAAsD,WAAW,GAAG,CAAC,CAAC;SACvF;QAED,MAAM,UAAU,GAAG,iBAAiB,CAAC,WAAW,CAAC,CAAC;QAClD,MAAM,QAAQ,GAAG,IAAI,CAAC;YACpB,IAAI;YACJ,GAAG,UAAU;YACb,OAAO,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,WAAW;SAC7D,CAAC,CAAC;QAEH,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;QAExC,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;OAGG;IACH,UAAU,CAAC,WAAmB;QAC5B,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IACnC,CAAC;CACF","sourcesContent":["import path from 'path';\nimport { applyOverrides } from '@ms-cloudpack/package-overrides';\nimport { readJson } from '@ms-cloudpack/json-utilities';\nimport type { PackageJson, PackageDefinitionTransform, PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';\nimport hash from 'object-hash';\nimport { isExternalPackage } from './isExternalPackage.js';\n\nexport class PackageDefinitions implements PackageDefinitionsCache {\n private _definitions: Record<string, PackageJson>;\n private _transformedDefinitions: Record<string, PackageJson>;\n private _config: unknown;\n private _transforms: PackageDefinitionTransform[] = [];\n private _transformFactories: ((config?: unknown) => PackageDefinitionTransform)[];\n private _hashes = new Map<string, string>();\n\n /**\n * Constructor for PackageDefinitions.\n * @param definitionCache - The map of package paths to package definitions, used mainly for testing.\n * @param config - The optional config object to pass to transforms. When `reset` is called with a new value, the\n * transforms will be re-created using the new config.\n */\n constructor(definitionCache: Record<string, PackageJson> = {}, config?: unknown) {\n this._definitions = definitionCache;\n this._transformedDefinitions = {};\n this._config = config;\n this._transforms = [applyOverrides];\n this._transformFactories = [];\n }\n\n async get(\n packagePath: string,\n options?: { refresh?: boolean; disableTransforms?: boolean },\n ): Promise<PackageJson | undefined> {\n let definition: PackageJson | undefined = this._definitions[packagePath];\n let transformedDefinition: PackageJson | undefined = this._transformedDefinitions[packagePath];\n const { refresh, disableTransforms } = options || {};\n\n // If we already have the answer they need, return immediately.\n if (!refresh) {\n if (disableTransforms && definition) {\n return definition;\n }\n\n if (!disableTransforms && transformedDefinition) {\n return transformedDefinition;\n }\n }\n\n // If we don't have the definition, try to load it.\n if (!definition || refresh) {\n definition = await readJson(path.join(packagePath, 'package.json'));\n\n if (!definition) {\n return undefined;\n }\n\n this._definitions[packagePath] = definition;\n }\n\n // If we don't want to skip the transform, transform the definition.\n if (!disableTransforms && (!transformedDefinition || refresh)) {\n for (const transform of this._transforms) {\n transformedDefinition =\n (await transform(transformedDefinition || definition, packagePath, this)) || transformedDefinition;\n }\n\n this._transformedDefinitions[packagePath] = transformedDefinition;\n }\n\n return (!disableTransforms && transformedDefinition) || definition;\n }\n\n /**\n * Registers a transform factory function, which will be called on initialization, and when reset, to re-generate\n * the transform function. Transform functions are called only when the package definition hasn't been loaded before,\n * and the result will be cached. Calling `reset` will reset the cache.\n */\n registerTransform(factory: (config?: unknown) => PackageDefinitionTransform) {\n this._transformFactories.push(factory);\n this._transforms.push(factory(this._config));\n\n this.reset();\n }\n\n /**\n * Resets the cache of package definitions. This is useful when testing, to ensure that the cache is empty.\n */\n reset(options?: { newConfig?: unknown }) {\n this._definitions = {};\n this._transformedDefinitions = {};\n\n const { newConfig } = options || {};\n\n if (newConfig) {\n this._config = newConfig;\n this._transforms = [applyOverrides, ...this._transformFactories.map((factory) => factory(newConfig))];\n }\n }\n\n /**\n * Gets the hash for a given package path. This is useful for caching, to determine if the package has changed.\n * @param packagePath - The package path to get the hash for.\n * @returns The hash for the package.\n */\n async getHash(packagePath: string): Promise<string> {\n if (this._hashes.has(packagePath)) {\n return this._hashes.get(packagePath) as string;\n }\n\n const definition = await this.get(packagePath);\n if (!definition) {\n throw new Error(`Package definition (package.json) missing or invalid at \"${packagePath}\"`);\n }\n\n const { name, version } = definition;\n if (!name) {\n throw new Error(`Package definition (package.json) missing name at \"${packagePath}\"`);\n }\n\n const isExternal = isExternalPackage(packagePath);\n const bundleId = hash({\n name,\n ...definition,\n version: (isExternal ? version : packagePath) || packagePath,\n });\n\n this._hashes.set(packagePath, bundleId);\n\n return bundleId;\n }\n\n /**\n * Removes the hash for a given package path.\n * @param packagePath - The package path to remove the hash for.\n */\n removeHash(packagePath: string) {\n this._hashes.delete(packagePath);\n }\n}\n"]}
1
+ {"version":3,"file":"PackageDefinitions.js","sourceRoot":"","sources":["../src/PackageDefinitions.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAExD,OAAO,IAAI,MAAM,aAAa,CAAC;AAC/B,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,MAAM,OAAO,kBAAkB;IAQ7B;;;;;OAKG;IACH,YAAY,kBAA+C,EAAE,EAAE,MAAgB;QAVvE,gBAAW,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AAM,IAAI,KAAK,CAAC,4DAA4D,WAAW,GAAG,CAAC,CAAC;SAC7F;QAED,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,UAAU,CAAC;QACrC,IAAI,CAAC,IAAI,EAAE;YACT,MAAM,IAAI,KAAK,CAAC,sDAAsD,WAAW,GAAG,CAAC,CAAC;SACvF;QAED,MAAM,UAAU,GAAG,iBAAiB,CAAC,WAAW,CAAC,CAAC;QAClD,MAAM,QAAQ,GAAG,IAAI,CAAC;YACpB,IAAI;YACJ,GAAG,UAAU;YACb,OAAO,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,WAAW;SAC7D,CAAC,CAAC;QAEH,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;QAExC,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;OAGG;IACH,UAAU,CAAC,WAAmB;QAC5B,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IACnC,CAAC;CACF","sourcesContent":["import path from 'path';\nimport { applyOverrides } from '@ms-cloudpack/package-overrides';\nimport { readJson } from '@ms-cloudpack/json-utilities';\nimport type { PackageJson, PackageDefinitionTransform, PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';\nimport hash from 'object-hash';\nimport { isExternalPackage } from './isExternalPackage.js';\n\nexport class PackageDefinitions implements PackageDefinitionsCache {\n private _definitions: Record<string, PackageJson>;\n private _transformedDefinitions: Record<string, PackageJson>;\n private _config: unknown;\n private _transforms: PackageDefinitionTransform[] = [];\n private _transformFactories: ((config?: unknown) => PackageDefinitionTransform)[];\n private _hashes: Map<string, string>;\n\n /**\n * Constructor for PackageDefinitions.\n * @param definitionCache - The map of package paths to package definitions, used mainly for testing.\n * @param config - The optional config object to pass to transforms. When `reset` is called with a new value, the\n * transforms will be re-created using the new config.\n */\n constructor(definitionCache: Record<string, PackageJson> = {}, config?: unknown) {\n this._definitions = definitionCache;\n this._transformedDefinitions = {};\n this._config = config;\n this._transforms = [applyOverrides];\n this._transformFactories = [];\n this._hashes = new Map<string, string>();\n }\n\n async get(\n packagePath: string,\n options?: { refresh?: boolean; disableTransforms?: boolean },\n ): Promise<PackageJson | undefined> {\n let definition: PackageJson | undefined = this._definitions[packagePath];\n let transformedDefinition: PackageJson | undefined = this._transformedDefinitions[packagePath];\n const { refresh, disableTransforms } = options || {};\n\n // If we already have the answer they need, return immediately.\n if (!refresh) {\n if (disableTransforms && definition) {\n return definition;\n }\n\n if (!disableTransforms && transformedDefinition) {\n return transformedDefinition;\n }\n }\n\n // If we don't have the definition, try to load it.\n if (!definition || refresh) {\n definition = await readJson(path.join(packagePath, 'package.json'));\n\n if (!definition) {\n return undefined;\n }\n\n this._definitions[packagePath] = definition;\n }\n\n // If we don't want to skip the transform, transform the definition.\n if (!disableTransforms && (!transformedDefinition || refresh)) {\n for (const transform of this._transforms) {\n transformedDefinition =\n (await transform(transformedDefinition || definition, packagePath, this)) || transformedDefinition;\n }\n\n this._transformedDefinitions[packagePath] = transformedDefinition;\n }\n\n return (!disableTransforms && transformedDefinition) || definition;\n }\n\n /**\n * Registers a transform factory function, which will be called on initialization, and when reset, to re-generate\n * the transform function. Transform functions are called only when the package definition hasn't been loaded before,\n * and the result will be cached. Calling `reset` will reset the cache.\n */\n registerTransform(factory: (config?: unknown) => PackageDefinitionTransform) {\n this._transformFactories.push(factory);\n this._transforms.push(factory(this._config));\n\n this.reset();\n }\n\n /**\n * Resets the cache of package definitions. This is useful when testing, to ensure that the cache is empty.\n */\n reset(options?: { newConfig?: unknown }) {\n this._definitions = {};\n this._transformedDefinitions = {};\n\n const { newConfig } = options || {};\n\n if (newConfig) {\n this._config = newConfig;\n this._transforms = [applyOverrides, ...this._transformFactories.map((factory) => factory(newConfig))];\n }\n }\n\n /**\n * Gets the hash for a given package path. This is useful for caching, to determine if the package has changed.\n * @param packagePath - The package path to get the hash for.\n * @returns The hash for the package.\n */\n async getHash(packagePath: string): Promise<string> {\n if (this._hashes.has(packagePath)) {\n return this._hashes.get(packagePath) as string;\n }\n\n const definition = await this.get(packagePath);\n if (!definition) {\n throw new Error(`Package definition (package.json) missing or invalid at \"${packagePath}\"`);\n }\n\n const { name, version } = definition;\n if (!name) {\n throw new Error(`Package definition (package.json) missing name at \"${packagePath}\"`);\n }\n\n const isExternal = isExternalPackage(packagePath);\n const bundleId = hash({\n name,\n ...definition,\n version: (isExternal ? version : packagePath) || packagePath,\n });\n\n this._hashes.set(packagePath, bundleId);\n\n return bundleId;\n }\n\n /**\n * Removes the hash for a given package path.\n * @param packagePath - The package path to remove the hash for.\n */\n removeHash(packagePath: string) {\n this._hashes.delete(packagePath);\n }\n}\n"]}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * A class for storing the import paths for a given package path.
3
+ * This is used to cache the import paths for a given package path, so that they don't need to be resolved again.
4
+ * This is useful for performance, as resolving import paths can be expensive.
5
+ */
6
+ export declare class PackageImportPaths {
7
+ private _importPaths;
8
+ constructor();
9
+ /**
10
+ * Adds an import path to the list of paths for a given package path.
11
+ * @param packagePath - The package path to add the path to.
12
+ * @param resolvedImportPath - The import path to add.
13
+ */
14
+ add(packagePath: string, resolvedImportPath: string): void;
15
+ /**
16
+ * Gets the list of import paths for a given package path.
17
+ * @param packagePath - The package path to get the paths for.
18
+ * @returns The list of import paths for the given package path.
19
+ */
20
+ get(packagePath: string): string[];
21
+ /**
22
+ * Clears the list of import paths for a given package path.
23
+ * @param packagePath - The package path to clear the import paths for.
24
+ */
25
+ clear(): void;
26
+ }
27
+ //# sourceMappingURL=PackageImportPaths.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PackageImportPaths.d.ts","sourceRoot":"","sources":["../src/PackageImportPaths.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,YAAY,CAAwB;;IAM5C;;;;OAIG;IACH,GAAG,CAAC,WAAW,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,GAAG,IAAI;IAO1D;;;;OAIG;IACH,GAAG,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE;IAIlC;;;OAGG;IACH,KAAK,IAAI,IAAI;CAGd"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * A class for storing the import paths for a given package path.
3
+ * This is used to cache the import paths for a given package path, so that they don't need to be resolved again.
4
+ * This is useful for performance, as resolving import paths can be expensive.
5
+ */
6
+ export class PackageImportPaths {
7
+ constructor() {
8
+ this._importPaths = new Map();
9
+ }
10
+ /**
11
+ * Adds an import path to the list of paths for a given package path.
12
+ * @param packagePath - The package path to add the path to.
13
+ * @param resolvedImportPath - The import path to add.
14
+ */
15
+ add(packagePath, resolvedImportPath) {
16
+ if (!this._importPaths.has(packagePath)) {
17
+ this._importPaths.set(packagePath, []);
18
+ }
19
+ this._importPaths.get(packagePath)?.push(resolvedImportPath);
20
+ }
21
+ /**
22
+ * Gets the list of import paths for a given package path.
23
+ * @param packagePath - The package path to get the paths for.
24
+ * @returns The list of import paths for the given package path.
25
+ */
26
+ get(packagePath) {
27
+ return this._importPaths.get(packagePath) ?? [];
28
+ }
29
+ /**
30
+ * Clears the list of import paths for a given package path.
31
+ * @param packagePath - The package path to clear the import paths for.
32
+ */
33
+ clear() {
34
+ this._importPaths.clear();
35
+ }
36
+ }
37
+ //# sourceMappingURL=PackageImportPaths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PackageImportPaths.js","sourceRoot":"","sources":["../src/PackageImportPaths.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,OAAO,kBAAkB;IAG7B;QACE,IAAI,CAAC,YAAY,GAAG,IAAI,GAAG,EAAoB,CAAC;IAClD,CAAC;IAED;;;;OAIG;IACH,GAAG,CAAC,WAAmB,EAAE,kBAA0B;QACjD,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE;YACvC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;SACxC;QACD,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,IAAI,CAAC,kBAAkB,CAAC,CAAC;IAC/D,CAAC;IAED;;;;OAIG;IACH,GAAG,CAAC,WAAmB;QACrB,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;IAClD,CAAC;IAED;;;OAGG;IACH,KAAK;QACH,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;IAC5B,CAAC;CACF","sourcesContent":["/**\n * A class for storing the import paths for a given package path.\n * This is used to cache the import paths for a given package path, so that they don't need to be resolved again.\n * This is useful for performance, as resolving import paths can be expensive.\n */\nexport class PackageImportPaths {\n private _importPaths: Map<string, string[]>;\n\n constructor() {\n this._importPaths = new Map<string, string[]>();\n }\n\n /**\n * Adds an import path to the list of paths for a given package path.\n * @param packagePath - The package path to add the path to.\n * @param resolvedImportPath - The import path to add.\n */\n add(packagePath: string, resolvedImportPath: string): void {\n if (!this._importPaths.has(packagePath)) {\n this._importPaths.set(packagePath, []);\n }\n this._importPaths.get(packagePath)?.push(resolvedImportPath);\n }\n\n /**\n * Gets the list of import paths for a given package path.\n * @param packagePath - The package path to get the paths for.\n * @returns The list of import paths for the given package path.\n */\n get(packagePath: string): string[] {\n return this._importPaths.get(packagePath) ?? [];\n }\n\n /**\n * Clears the list of import paths for a given package path.\n * @param packagePath - The package path to clear the import paths for.\n */\n clear(): void {\n this._importPaths.clear();\n }\n}\n"]}
@@ -0,0 +1,24 @@
1
+ import type { ImportMap } from './createImportMap.js';
2
+ import type { ResolveMap } from './types/ResolveMap.js';
3
+ import type { PackageImportPaths } from './PackageImportPaths.js';
4
+ /**
5
+ * Adds hash to import map for a package.
6
+ * @param packagePath Path to package
7
+ * @param importMap Import map to add hash to
8
+ * @param resolveMap Resolve map to use
9
+ * @param hash Hash to add
10
+ * @param context Context
11
+ */
12
+ export declare function addImportMapHash(packageName: string, version: string, importMap: ImportMap | undefined, resolveMap: ResolveMap, hash: string, context: {
13
+ packageImportPaths: PackageImportPaths;
14
+ }): void;
15
+ /**
16
+ * Adds hash after name and version.
17
+ * If hash already exists, replaces it.
18
+ * @param url URL to add hash to
19
+ * @param packageUrl Package name and version
20
+ * @param hash Hash to add
21
+ * @returns URL with hash
22
+ */
23
+ export declare function addHashUrl(url: string, packageUrl: string, hash: string): string;
24
+ //# sourceMappingURL=addImportMapHash.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addImportMapHash.d.ts","sourceRoot":"","sources":["../src/addImportMapHash.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAElE;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAC9B,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,SAAS,GAAG,SAAS,EAChC,UAAU,EAAE,UAAU,EACtB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE;IAAE,kBAAkB,EAAE,kBAAkB,CAAA;CAAE,QAyCpD;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAmBhF"}
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Adds hash to import map for a package.
3
+ * @param packagePath Path to package
4
+ * @param importMap Import map to add hash to
5
+ * @param resolveMap Resolve map to use
6
+ * @param hash Hash to add
7
+ * @param context Context
8
+ */
9
+ export function addImportMapHash(packageName, version, importMap, resolveMap, hash, context) {
10
+ if (!importMap) {
11
+ return;
12
+ }
13
+ const { packageImportPaths } = context;
14
+ const resolveEntry = resolveMap[packageName];
15
+ if (!resolveEntry) {
16
+ throw new Error(`Could not find package ${packageName} in the resolve map.`);
17
+ }
18
+ if (version === resolveEntry.version) {
19
+ // Package is not scoped
20
+ const entry = resolveEntry;
21
+ const packageUrl = `${entry.name}@${entry.version}`;
22
+ const importPaths = packageImportPaths.get(entry.path);
23
+ importPaths.forEach((importPath) => {
24
+ importMap.imports[importPath] = addHashUrl(importMap.imports[importPath], packageUrl, hash);
25
+ });
26
+ }
27
+ else if (resolveEntry.scopedVersions?.[version] !== undefined && importMap.scopes) {
28
+ // Package is scoped
29
+ const entry = resolveEntry.scopedVersions?.[version];
30
+ if (!entry) {
31
+ throw new Error(`Could not find package ${packageName}@${version} in the resolve map.`);
32
+ }
33
+ const packageUrl = `${entry.name}@${entry.version}`;
34
+ const importPaths = packageImportPaths.get(entry.path);
35
+ const bundleServerUrl = new URL(Object.values(importMap.imports)[0]).origin;
36
+ for (const requiredById of Object.keys(entry.requiredBy)) {
37
+ const key = `${bundleServerUrl}/${requiredById}/`;
38
+ importPaths.forEach((importPath) => {
39
+ if (!importMap.scopes) {
40
+ return;
41
+ }
42
+ importMap.scopes[key][importPath] = addHashUrl(importMap.scopes[key][importPath], packageUrl, hash);
43
+ });
44
+ }
45
+ }
46
+ }
47
+ /**
48
+ * Adds hash after name and version.
49
+ * If hash already exists, replaces it.
50
+ * @param url URL to add hash to
51
+ * @param packageUrl Package name and version
52
+ * @param hash Hash to add
53
+ * @returns URL with hash
54
+ */
55
+ export function addHashUrl(url, packageUrl, hash) {
56
+ const search = url.indexOf(packageUrl);
57
+ if (search !== -1) {
58
+ const hashIndex = search + packageUrl.length;
59
+ const prefix = 'h-';
60
+ const pending = 'pending';
61
+ if (url.startsWith(prefix, hashIndex + 1)) {
62
+ // Replace hash if it already exists
63
+ if (url.startsWith(pending, hashIndex + prefix.length + 1)) {
64
+ url = url.slice(0, hashIndex) + `/h-${hash}` + url.slice(hashIndex + prefix.length + pending.length + 1);
65
+ }
66
+ else {
67
+ url = url.slice(0, hashIndex) + `/h-${hash}` + url.slice(hashIndex + hash.length + prefix.length + 1);
68
+ }
69
+ }
70
+ else {
71
+ // Add hash after name and version
72
+ url = url.slice(0, hashIndex) + `/h-${hash}` + url.slice(hashIndex);
73
+ }
74
+ }
75
+ return url;
76
+ }
77
+ //# sourceMappingURL=addImportMapHash.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addImportMapHash.js","sourceRoot":"","sources":["../src/addImportMapHash.ts"],"names":[],"mappings":"AAIA;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAC9B,WAAmB,EACnB,OAAe,EACf,SAAgC,EAChC,UAAsB,EACtB,IAAY,EACZ,OAAmD;IAEnD,IAAI,CAAC,SAAS,EAAE;QACd,OAAO;KACR;IAED,MAAM,EAAE,kBAAkB,EAAE,GAAG,OAAO,CAAC;IAEvC,MAAM,YAAY,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC;IAE7C,IAAI,CAAC,YAAY,EAAE;QACjB,MAAM,IAAI,KAAK,CAAC,0BAA0B,WAAW,sBAAsB,CAAC,CAAC;KAC9E;IAED,IAAI,OAAO,KAAK,YAAY,CAAC,OAAO,EAAE;QACpC,wBAAwB;QACxB,MAAM,KAAK,GAAG,YAAY,CAAC;QAC3B,MAAM,UAAU,GAAG,GAAG,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;QACpD,MAAM,WAAW,GAAG,kBAAkB,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACvD,WAAW,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE;YACjC,SAAS,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC,SAAS,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC;QAC9F,CAAC,CAAC,CAAC;KACJ;SAAM,IAAI,YAAY,CAAC,cAAc,EAAE,CAAC,O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G,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;QAC7C,MAAM,MAAM,GAAG,IAAI,CAAC;QACpB,MAAM,OAAO,GAAG,SAAS,CAAC;QAC1B,IAAI,GAAG,CAAC,UAAU,CAAC,MAAM,EAAE,SAAS,GAAG,CAAC,CAAC,EAAE;YACzC,oCAAoC;YACpC,IAAI,GAAG,CAAC,UAAU,CAAC,OAAO,EAAE,SAAS,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE;gBAC1D,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,GAAG,MAAM,IAAI,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,SAAS,GAAG,MAAM,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;aAC1G;iBAAM;gBACL,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,GAAG,MAAM,IAAI,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,SAAS,GAAG,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;aACvG;SACF;aAAM;YACL,kCAAkC;YAClC,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,GAAG,MAAM,IAAI,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;SACrE;KACF;IACD,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["import type { ImportMap } from './createImportMap.js';\nimport type { ResolveMap } from './types/ResolveMap.js';\nimport type { PackageImportPaths } from './PackageImportPaths.js';\n\n/**\n * Adds hash to import map for a package.\n * @param packagePath Path to package\n * @param importMap Import map to add hash to\n * @param resolveMap Resolve map to use\n * @param hash Hash to add\n * @param context Context\n */\nexport function addImportMapHash(\n packageName: string,\n version: string,\n importMap: ImportMap | undefined,\n resolveMap: ResolveMap,\n hash: string,\n context: { packageImportPaths: PackageImportPaths },\n) {\n if (!importMap) {\n return;\n }\n\n const { packageImportPaths } = context;\n\n const resolveEntry = resolveMap[packageName];\n\n if (!resolveEntry) {\n throw new Error(`Could not find package ${packageName} in the resolve map.`);\n }\n\n if (version === resolveEntry.version) {\n // Package is not scoped\n const entry = resolveEntry;\n const packageUrl = `${entry.name}@${entry.version}`;\n const importPaths = packageImportPaths.get(entry.path);\n importPaths.forEach((importPath) => {\n importMap.imports[importPath] = addHashUrl(importMap.imports[importPath], packageUrl, hash);\n });\n } else if (resolveEntry.scopedVersions?.[version] !== undefined && importMap.scopes) {\n // Package is scoped\n const entry = resolveEntry.scopedVersions?.[version];\n if (!entry) {\n throw new Error(`Could not find package ${packageName}@${version} in the resolve map.`);\n }\n const packageUrl = `${entry.name}@${entry.version}`;\n const importPaths = packageImportPaths.get(entry.path);\n const bundleServerUrl = new URL(Object.values(importMap.imports)[0]).origin;\n for (const requiredById of Object.keys(entry.requiredBy)) {\n const key = `${bundleServerUrl}/${requiredById}/`;\n importPaths.forEach((importPath) => {\n if (!importMap.scopes) {\n return;\n }\n importMap.scopes[key][importPath] = addHashUrl(importMap.scopes[key][importPath], packageUrl, hash);\n });\n }\n }\n}\n\n/**\n * Adds hash after name and version.\n * If hash already exists, replaces it.\n * @param url URL to add hash to\n * @param packageUrl Package name and version\n * @param hash Hash to add\n * @returns URL with hash\n */\nexport function addHashUrl(url: string, packageUrl: string, hash: string): string {\n const search = url.indexOf(packageUrl);\n if (search !== -1) {\n const hashIndex = search + packageUrl.length;\n const prefix = 'h-';\n const pending = 'pending';\n if (url.startsWith(prefix, hashIndex + 1)) {\n // Replace hash if it already exists\n if (url.startsWith(pending, hashIndex + prefix.length + 1)) {\n url = url.slice(0, hashIndex) + `/h-${hash}` + url.slice(hashIndex + prefix.length + pending.length + 1);\n } else {\n url = url.slice(0, hashIndex) + `/h-${hash}` + url.slice(hashIndex + hash.length + prefix.length + 1);\n }\n } else {\n // Add hash after name and version\n url = url.slice(0, hashIndex) + `/h-${hash}` + url.slice(hashIndex);\n }\n }\n return url;\n}\n"]}
@@ -1,5 +1,6 @@
1
1
  import type { PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';
2
2
  import type { ResolveMap } from './types/ResolveMap.js';
3
+ import type { PackageImportPaths } from './PackageImportPaths.js';
3
4
  export interface ImportMap {
4
5
  imports: Record<string, string>;
5
6
  scopes?: Record<string, Record<string, string>>;
@@ -12,7 +13,9 @@ export declare function createImportMap(options: {
12
13
  bundleServerUrl: string;
13
14
  sessionVersion?: number;
14
15
  targetVersions?: Record<string, number>;
16
+ hashPackages?: boolean;
15
17
  }, context: {
16
18
  packages: PackageDefinitionsCache;
19
+ packageImportPaths?: PackageImportPaths;
17
20
  }): Promise<ImportMap>;
18
21
  //# sourceMappingURL=createImportMap.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"createImportMap.d.ts","sourceRoot":"","sources":["../src/createImportMap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAC3E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAQxD,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACjD;AAED;;GAEG;AACH,wBAAsB,eAAe,CACnC,OAAO,EAAE;IACP,UAAU,EAAE,UAAU,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACzC,EACD,OAAO,EAAE;IACP,QAAQ,EAAE,uBAAuB,CAAC;CACnC,GACA,OAAO,CAAC,SAAS,CAAC,CAmCpB"}
1
+ {"version":3,"file":"createImportMap.d.ts","sourceRoot":"","sources":["../src/createImportMap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAC3E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAOxD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAElE,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACjD;AAED;;GAEG;AACH,wBAAsB,eAAe,CACnC,OAAO,EAAE;IACP,UAAU,EAAE,UAAU,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxC,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,EACD,OAAO,EAAE;IACP,QAAQ,EAAE,uBAAuB,CAAC;IAClC,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;CACzC,GACA,OAAO,CAAC,SAAS,CAAC,CA+CpB"}
@@ -7,18 +7,19 @@ import { isExternalPackage } from './isExternalPackage.js';
7
7
  * Given a resolve map and a bundleServerUrl, returns an import map to be used in the browser.
8
8
  */
9
9
  export async function createImportMap(options, context) {
10
- const { resolveMap, bundleServerUrl, sessionVersion = 0, targetVersions } = options;
11
- const { packages } = context;
10
+ const { resolveMap, bundleServerUrl, sessionVersion = 0, targetVersions, hashPackages } = options;
11
+ const { packages, packageImportPaths } = context;
12
12
  const importMap = {
13
13
  imports: {},
14
14
  };
15
+ packageImportPaths?.clear();
15
16
  for (const resolveEntry of Object.values(resolveMap)) {
16
- merge(importMap.imports, await getImportMapFromEntry(resolveEntry, bundleServerUrl, packages, sessionVersion, targetVersions));
17
+ merge(importMap.imports, await getImportMapFromEntry(resolveEntry, bundleServerUrl, packages, sessionVersion, packageImportPaths, targetVersions, hashPackages));
17
18
  if (resolveEntry.scopedVersions) {
18
19
  // Initialize scopes
19
20
  importMap.scopes ??= {};
20
21
  for (const scopedEntry of Object.values(resolveEntry.scopedVersions)) {
21
- const importMapForEntry = await getImportMapFromEntry(scopedEntry, bundleServerUrl, packages, sessionVersion, targetVersions);
22
+ const importMapForEntry = await getImportMapFromEntry(scopedEntry, bundleServerUrl, packages, sessionVersion, packageImportPaths, targetVersions, hashPackages);
22
23
  for (const requiredById of Object.keys(scopedEntry.requiredBy)) {
23
24
  const scopes = (importMap.scopes[`${bundleServerUrl}/${requiredById}/`] ??= {});
24
25
  merge(scopes, importMapForEntry);
@@ -28,7 +29,7 @@ export async function createImportMap(options, context) {
28
29
  }
29
30
  return importMap;
30
31
  }
31
- async function getImportMapFromEntry(entry, bundleServerUrl, packages, sessionVersion, targetVersions) {
32
+ async function getImportMapFromEntry(entry, bundleServerUrl, packages, sessionVersion, packageImportPaths, targetVersions, hashPackages) {
32
33
  const importMap = {};
33
34
  const definition = await packages.get(entry.path);
34
35
  const exportsMap = await getExportsMap({ packagePath: entry.path }, { packages });
@@ -48,14 +49,15 @@ async function getImportMapFromEntry(entry, bundleServerUrl, packages, sessionVe
48
49
  const bundledExportsMap = flattenExportsMap(exportsMap);
49
50
  const packagePrefix = `${entry.name}@${entry.version}/`;
50
51
  const baseUrl = `${bundleServerUrl}/${packagePrefix}`;
52
+ const isExternal = isExternalPackage(entry.path);
53
+ const targetVersion = targetVersions?.[entry.path];
54
+ const cacheBuster = `v${sessionVersion ?? 0}${targetVersion ? `.${targetVersion}` : ''}/`;
55
+ const hash = hashPackages ? (isExternal ? `h-${await packages.getHash(entry.path)}/` : 'h-pending/') : '';
51
56
  // Add the bundled entries to the import map, but prefer unbundled if the entry exists.
52
57
  for (const [importPath, bundledFilePath] of Object.entries(bundledExportsMap)) {
53
- const isExternal = isExternalPackage(entry.path);
54
58
  const unbundledFilePath = isExternal ? unbundledExportsMap[importPath] : undefined;
55
59
  let resolvedFilePath = unbundledFilePath ? `unbundled/${unbundledFilePath}` : `bundled/${bundledFilePath}`;
56
- const targetVersion = targetVersions?.[entry.path];
57
- const cacheBuster = `v${sessionVersion ?? 0}${targetVersion ? `.${targetVersion}` : ''}/`;
58
- resolvedFilePath = `${cacheBuster}${resolvedFilePath}`;
60
+ resolvedFilePath = `${hash}${cacheBuster}${resolvedFilePath}`;
59
61
  const ext = path.extname(resolvedFilePath);
60
62
  // For bundled files:
61
63
  if (!unbundledFilePath) {
@@ -70,7 +72,9 @@ async function getImportMapFromEntry(entry, bundleServerUrl, packages, sessionVe
70
72
  // Plus signs should be replaced with underscores.
71
73
  resolvedFilePath = resolvedFilePath.replace(/\+/g, '_');
72
74
  }
73
- importMap[importPath.replace('.', `${definition.name}`)] = new URL(resolvedFilePath, baseUrl).href;
75
+ const resolvedImportPath = importPath.replace('.', `${definition.name}`);
76
+ packageImportPaths?.add(entry.path, resolvedImportPath);
77
+ importMap[resolvedImportPath] = new URL(resolvedFilePath, baseUrl).href;
74
78
  }
75
79
  // Finally add a fallback for all other unexpected bundle entries. (Note, this should point to a script
76
80
  // which logs this as an error to the user and offers a way to add the entry to exports overrides.)
@@ -1 +1 @@
1
- {"version":3,"file":"createImportMap.js","sourceRoot":"","sources":["../src/createImportMap.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAO3D;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,OAKC,EACD,OAEC;IAED,MAAM,EAAE,UAAU,EAAE,eAAe,EAA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Aa,CAAC,CAAC,CAAC,IAAI,aAAa,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC;QAE1F,gBAAgB,GAAG,GAAG,WAAW,GAAG,gBAAgB,EAAE,CAAC;QACvD,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;QAE3C,qBAAqB;QACrB,IAAI,CAAC,iBAAiB,EAAE;YACtB,uBAAuB;YACvB,IAAI,gBAAgB,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;gBACtC,SAAS;aACV;YAED,0EAA0E;YAC1E,IAAI,GAAG,KAAK,KAAK,EAAE;gBACjB,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAC1B,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,EAC9B,IAAI,CAAC,QAAQ,CAAC,gBAAgB,EAAE,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,KAAK,CAAC,CAC9E,CAAC;aACH;YAED,kDAAkD;YAClD,gBAAgB,GAAG,gBAAgB,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;SACzD;QAED,SAAS,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;KACpG;IAED,uGAAuG;IACvG,mGAAmG;IACnG,2DAA2D;IAE3D,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import type { PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';\nimport type { ResolveMap } from './types/ResolveMap.js';\nimport type { ResolveMapEntry } from './types/ResolveMapEntry.js';\nimport { merge } from 'merge';\nimport { flattenExportsMap } from './flattenExportsMap.js';\nimport path from 'path';\nimport { getExportsMap } from './getExportsMap.js';\nimport { isExternalPackage } from './isExternalPackage.js';\n\nexport interface ImportMap {\n imports: Record<string, string>;\n scopes?: Record<string, Record<string, string>>;\n}\n\n/**\n * Given a resolve map and a bundleServerUrl, returns an import map to be used in the browser.\n */\nexport async function createImportMap(\n options: {\n resolveMap: ResolveMap;\n bundleServerUrl: string;\n sessionVersion?: number;\n targetVersions?: Record<string, number>;\n },\n context: {\n packages: PackageDefinitionsCache;\n },\n): Promise<ImportMap> {\n const { resolveMap, bundleServerUrl, sessionVersion = 0, targetVersions } = options;\n const { packages } = context;\n const importMap: ImportMap = {\n imports: {},\n };\n\n for (const resolveEntry of Object.values(resolveMap)) {\n merge(\n importMap.imports,\n await getImportMapFromEntry(resolveEntry, bundleServerUrl, packages, sessionVersion, targetVersions),\n );\n\n if (resolveEntry.scopedVersions) {\n // Initialize scopes\n importMap.scopes ??= {};\n\n for (const scopedEntry of Object.values(resolveEntry.scopedVersions)) {\n const importMapForEntry = await getImportMapFromEntry(\n scopedEntry,\n bundleServerUrl,\n packages,\n sessionVersion,\n targetVersions,\n );\n\n for (const requiredById of Object.keys(scopedEntry.requiredBy)) {\n const scopes = (importMap.scopes[`${bundleServerUrl}/${requiredById}/`] ??= {});\n merge(scopes, importMapForEntry);\n }\n }\n }\n }\n\n return importMap;\n}\n\nasync function getImportMapFromEntry(\n entry: ResolveMapEntry,\n bundleServerUrl: string,\n packages: PackageDefinitionsCache,\n sessionVersion: number,\n targetVersions?: Record<string, number>,\n): Promise<Record<string, string>> {\n const importMap: Record<string, string> = {};\n const definition = await packages.get(entry.path);\n const exportsMap = await getExportsMap({ packagePath: entry.path }, { packages });\n\n if (\n !definition ||\n !definition.name ||\n !definition.version ||\n !exportsMap ||\n Object.keys(exportsMap).length === 0 ||\n definition.name.startsWith('@types/')\n ) {\n return importMap;\n }\n\n // Get both the unbundled entries from the exports map\n const unbundledExportsMap = flattenExportsMap(exportsMap, {\n conditions: ['browser-esm'],\n requiredConditions: ['browser-esm'],\n });\n const bundledExportsMap = flattenExportsMap(exportsMap);\n const packagePrefix = `${entry.name}@${entry.version}/`;\n const baseUrl = `${bundleServerUrl}/${packagePrefix}`;\n\n // Add the bundled entries to the import map, but prefer unbundled if the entry exists.\n for (const [importPath, bundledFilePath] of Object.entries(bundledExportsMap)) {\n const isExternal = isExternalPackage(entry.path);\n const unbundledFilePath = isExternal ? unbundledExportsMap[importPath] : undefined;\n let resolvedFilePath = unbundledFilePath ? `unbundled/${unbundledFilePath}` : `bundled/${bundledFilePath}`;\n const targetVersion = targetVersions?.[entry.path];\n const cacheBuster = `v${sessionVersion ?? 0}${targetVersion ? `.${targetVersion}` : ''}/`;\n\n resolvedFilePath = `${cacheBuster}${resolvedFilePath}`;\n const ext = path.extname(resolvedFilePath);\n\n // For bundled files:\n if (!unbundledFilePath) {\n // Ignore .d.ts entries\n if (resolvedFilePath.endsWith('.d.ts')) {\n continue;\n }\n\n // We always expect responses to come back as javascript (.js extensions.)\n if (ext !== '.js') {\n resolvedFilePath = path.join(\n path.dirname(resolvedFilePath),\n path.basename(resolvedFilePath, ext) + (ext === '.mjs' ? '.js' : ext + '.js'),\n );\n }\n\n // Plus signs should be replaced with underscores.\n resolvedFilePath = resolvedFilePath.replace(/\\+/g, '_');\n }\n\n importMap[importPath.replace('.', `${definition.name}`)] = new URL(resolvedFilePath, baseUrl).href;\n }\n\n // Finally add a fallback for all other unexpected bundle entries. (Note, this should point to a script\n // which logs this as an error to the user and offers a way to add the entry to exports overrides.)\n // importMap[definition.name + '/'] = baseUrl + 'missing/';\n\n return importMap;\n}\n"]}
1
+ {"version":3,"file":"createImportMap.js","sourceRoot":"","sources":["../src/createImportMap.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,M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zD;QAED,MAAM,kBAAkB,GAAG,UAAU,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC;QACzE,kBAAkB,EAAE,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,kBAAkB,CAAC,CAAC;QACxD,SAAS,CAAC,kBAAkB,CAAC,GAAG,IAAI,GAAG,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;KACzE;IAED,uGAAuG;IACvG,mGAAmG;IACnG,2DAA2D;IAE3D,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import type { PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';\nimport type { ResolveMap } from './types/ResolveMap.js';\nimport type { ResolveMapEntry } from './types/ResolveMapEntry.js';\nimport { merge } from 'merge';\nimport { flattenExportsMap } from './flattenExportsMap.js';\nimport path from 'path';\nimport { getExportsMap } from './getExportsMap.js';\nimport { isExternalPackage } from './isExternalPackage.js';\nimport type { PackageImportPaths } from './PackageImportPaths.js';\n\nexport interface ImportMap {\n imports: Record<string, string>;\n scopes?: Record<string, Record<string, string>>;\n}\n\n/**\n * Given a resolve map and a bundleServerUrl, returns an import map to be used in the browser.\n */\nexport async function createImportMap(\n options: {\n resolveMap: ResolveMap;\n bundleServerUrl: string;\n sessionVersion?: number;\n targetVersions?: Record<string, number>;\n hashPackages?: boolean;\n },\n context: {\n packages: PackageDefinitionsCache;\n packageImportPaths?: PackageImportPaths;\n },\n): Promise<ImportMap> {\n const { resolveMap, bundleServerUrl, sessionVersion = 0, targetVersions, hashPackages } = options;\n const { packages, packageImportPaths } = context;\n const importMap: ImportMap = {\n imports: {},\n };\n\n packageImportPaths?.clear();\n\n for (const resolveEntry of Object.values(resolveMap)) {\n merge(\n importMap.imports,\n await getImportMapFromEntry(\n resolveEntry,\n bundleServerUrl,\n packages,\n sessionVersion,\n packageImportPaths,\n targetVersions,\n hashPackages,\n ),\n );\n\n if (resolveEntry.scopedVersions) {\n // Initialize scopes\n importMap.scopes ??= {};\n\n for (const scopedEntry of Object.values(resolveEntry.scopedVersions)) {\n const importMapForEntry = await getImportMapFromEntry(\n scopedEntry,\n bundleServerUrl,\n packages,\n sessionVersion,\n packageImportPaths,\n targetVersions,\n hashPackages,\n );\n\n for (const requiredById of Object.keys(scopedEntry.requiredBy)) {\n const scopes = (importMap.scopes[`${bundleServerUrl}/${requiredById}/`] ??= {});\n merge(scopes, importMapForEntry);\n }\n }\n }\n }\n\n return importMap;\n}\n\nasync function getImportMapFromEntry(\n entry: ResolveMapEntry,\n bundleServerUrl: string,\n packages: PackageDefinitionsCache,\n sessionVersion: number,\n packageImportPaths?: PackageImportPaths,\n targetVersions?: Record<string, number>,\n hashPackages?: boolean,\n): Promise<Record<string, string>> {\n const importMap: Record<string, string> = {};\n const definition = await packages.get(entry.path);\n const exportsMap = await getExportsMap({ packagePath: entry.path }, { packages });\n\n if (\n !definition ||\n !definition.name ||\n !definition.version ||\n !exportsMap ||\n Object.keys(exportsMap).length === 0 ||\n definition.name.startsWith('@types/')\n ) {\n return importMap;\n }\n\n // Get both the unbundled entries from the exports map\n const unbundledExportsMap = flattenExportsMap(exportsMap, {\n conditions: ['browser-esm'],\n requiredConditions: ['browser-esm'],\n });\n const bundledExportsMap = flattenExportsMap(exportsMap);\n const packagePrefix = `${entry.name}@${entry.version}/`;\n const baseUrl = `${bundleServerUrl}/${packagePrefix}`;\n const isExternal = isExternalPackage(entry.path);\n const targetVersion = targetVersions?.[entry.path];\n const cacheBuster = `v${sessionVersion ?? 0}${targetVersion ? `.${targetVersion}` : ''}/`;\n const hash = hashPackages ? (isExternal ? `h-${await packages.getHash(entry.path)}/` : 'h-pending/') : '';\n\n // Add the bundled entries to the import map, but prefer unbundled if the entry exists.\n for (const [importPath, bundledFilePath] of Object.entries(bundledExportsMap)) {\n const unbundledFilePath = isExternal ? unbundledExportsMap[importPath] : undefined;\n let resolvedFilePath = unbundledFilePath ? `unbundled/${unbundledFilePath}` : `bundled/${bundledFilePath}`;\n\n resolvedFilePath = `${hash}${cacheBuster}${resolvedFilePath}`;\n const ext = path.extname(resolvedFilePath);\n\n // For bundled files:\n if (!unbundledFilePath) {\n // Ignore .d.ts entries\n if (resolvedFilePath.endsWith('.d.ts')) {\n continue;\n }\n\n // We always expect responses to come back as javascript (.js extensions.)\n if (ext !== '.js') {\n resolvedFilePath = path.join(\n path.dirname(resolvedFilePath),\n path.basename(resolvedFilePath, ext) + (ext === '.mjs' ? '.js' : ext + '.js'),\n );\n }\n\n // Plus signs should be replaced with underscores.\n resolvedFilePath = resolvedFilePath.replace(/\\+/g, '_');\n }\n\n const resolvedImportPath = importPath.replace('.', `${definition.name}`);\n packageImportPaths?.add(entry.path, resolvedImportPath);\n importMap[resolvedImportPath] = new URL(resolvedFilePath, baseUrl).href;\n }\n\n // Finally add a fallback for all other unexpected bundle entries. (Note, this should point to a script\n // which logs this as an error to the user and offers a way to add the entry to exports overrides.)\n // importMap[definition.name + '/'] = baseUrl + 'missing/';\n\n return importMap;\n}\n"]}
package/lib/index.d.ts CHANGED
@@ -11,6 +11,8 @@ export { createExportsMap } from './createExportsMap.js';
11
11
  export { addExportsMapEntry, type AddExportsMapEntryOptions } from './addExportsMapEntry.js';
12
12
  export { getExportsMap } from './getExportsMap.js';
13
13
  export { createImportMap, type ImportMap } from './createImportMap.js';
14
+ export { addImportMapHash } from './addImportMapHash.js';
15
+ export { PackageImportPaths } from './PackageImportPaths.js';
14
16
  export { resolve } from './resolve.js';
15
17
  export { detectModuleType, type ModuleType } from './detectModuleType.js';
16
18
  export { isExternalPackage } from './isExternalPackage.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAG7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC1E,YAAY,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAA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E,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,YAAY,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC1G,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AACxE,YAAY,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAGxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,KAAK,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AAC7F,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGnD,OAAO,EAAE,eAAe,EAAE,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAGvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAGzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAG7D,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAGvC,OAAO,EAAE,gBAAgB,EAAE,KAAK,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,KAAK,wBAAwB,EAAE,KAAK,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACxH,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC"}
package/lib/index.js CHANGED
@@ -11,6 +11,10 @@ export { addExportsMapEntry } from './addExportsMapEntry.js';
11
11
  export { getExportsMap } from './getExportsMap.js';
12
12
  // ImportMap creation
13
13
  export { createImportMap } from './createImportMap.js';
14
+ // ImportMap hashing
15
+ export { addImportMapHash } from './addImportMapHash.js';
16
+ // Import paths caching
17
+ export { PackageImportPaths } from './PackageImportPaths.js';
14
18
  // Import resolution utilities
15
19
  export { resolve } from './resolve.js';
16
20
  // Other package utilities
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,6BAA6B;AAC7B,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,sBAAsB;AACtB,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAG1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAGxE,kCAAkC;AAClC,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAkC,MAAM,yBAAyB,CAAC;AAC7F,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,qBAAqB;AACrB,OAAO,EAAE,eAAe,EAAkB,MAAM,sBAAsB,CAAC;AAEvE,8BAA8B;AAC9B,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,0BAA0B;AAC1B,OAAO,EAAE,gBAAgB,EAAmB,MAAM,uBAAuB,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAA+D,MAAM,wBAAwB,CAAC;AACxH,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC","sourcesContent":["// Package definition parsing\nexport { PackageDefinitions } from './PackageDefinitions.js';\n\n// ResolveMap creation\nexport { createResolveMap } from './createResolveMap/createResolveMap.js';\nexport type { ResolveMap } from './types/ResolveMap.js';\nexport type { ResolveMapEntry } from './types/ResolveMapEntry.js';\nexport { findResolveMapEntry } from './findResolveMapEntry.js';\nexport type { DiffResolveMapsChanges, DiffResolveMapsStats } from './createResolveMap/diffResolveMaps.js';\nexport { diffResolveMaps } from './createResolveMap/diffResolveMaps.js';\nexport type { LinkedPath } from './types/LinkedPath.js';\n\n// ExportsMap parsing and creation\nexport { flattenExportsMap } from './flattenExportsMap.js';\nexport { createExportsMap } from './createExportsMap.js';\nexport { addExportsMapEntry, type AddExportsMapEntryOptions } from './addExportsMapEntry.js';\nexport { getExportsMap } from './getExportsMap.js';\n\n// ImportMap creation\nexport { createImportMap, type ImportMap } from './createImportMap.js';\n\n// Import resolution utilities\nexport { resolve } from './resolve.js';\n\n// Other package utilities\nexport { detectModuleType, type ModuleType } from './detectModuleType.js';\nexport { isExternalPackage } from './isExternalPackage.js';\nexport { findFileInPackage, type FindFileInPackageOptions, type FindFileInPackageResult } from './findFileInPackage.js';\nexport { getVersion } from './getVersion.js';\nexport { getDependencies } from './getDependencies.js';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,6BAA6B;AAC7B,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,sBAAsB;AACtB,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAG1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAGxE,kCAAkC;AAClC,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAkC,MAAM,yBAAyB,CAAC;AAC7F,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,qBAAqB;AACrB,OAAO,EAAE,eAAe,EAAkB,MAAM,sBAAsB,CAAC;AAEvE,oBAAoB;AACpB,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,uBAAuB;AACvB,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,8BAA8B;AAC9B,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,0BAA0B;AAC1B,OAAO,EAAE,gBAAgB,EAAmB,MAAM,uBAAuB,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAA+D,MAAM,wBAAwB,CAAC;AACxH,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC","sourcesContent":["// Package definition parsing\nexport { PackageDefinitions } from './PackageDefinitions.js';\n\n// ResolveMap creation\nexport { createResolveMap } from './createResolveMap/createResolveMap.js';\nexport type { ResolveMap } from './types/ResolveMap.js';\nexport type { ResolveMapEntry } from './types/ResolveMapEntry.js';\nexport { findResolveMapEntry } from './findResolveMapEntry.js';\nexport type { DiffResolveMapsChanges, DiffResolveMapsStats } from './createResolveMap/diffResolveMaps.js';\nexport { diffResolveMaps } from './createResolveMap/diffResolveMaps.js';\nexport type { LinkedPath } from './types/LinkedPath.js';\n\n// ExportsMap parsing and creation\nexport { flattenExportsMap } from './flattenExportsMap.js';\nexport { createExportsMap } from './createExportsMap.js';\nexport { addExportsMapEntry, type AddExportsMapEntryOptions } from './addExportsMapEntry.js';\nexport { getExportsMap } from './getExportsMap.js';\n\n// ImportMap creation\nexport { createImportMap, type ImportMap } from './createImportMap.js';\n\n// ImportMap hashing\nexport { addImportMapHash } from './addImportMapHash.js';\n\n// Import paths caching\nexport { PackageImportPaths } from './PackageImportPaths.js';\n\n// Import resolution utilities\nexport { resolve } from './resolve.js';\n\n// Other package utilities\nexport { detectModuleType, type ModuleType } from './detectModuleType.js';\nexport { isExternalPackage } from './isExternalPackage.js';\nexport { findFileInPackage, type FindFileInPackageOptions, type FindFileInPackageResult } from './findFileInPackage.js';\nexport { getVersion } from './getVersion.js';\nexport { getDependencies } from './getDependencies.js';\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ms-cloudpack/package-utilities",
3
- "version": "5.1.12",
3
+ "version": "5.1.13",
4
4
  "description": "Utilities for resolving/parsing packages and their imports.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -14,9 +14,9 @@
14
14
  }
15
15
  },
16
16
  "dependencies": {
17
- "@ms-cloudpack/bundler-types": "^0.19.3",
17
+ "@ms-cloudpack/bundler-types": "^0.19.4",
18
18
  "@ms-cloudpack/json-utilities": "^0.0.8",
19
- "@ms-cloudpack/package-overrides": "^0.4.6",
19
+ "@ms-cloudpack/package-overrides": "^0.4.7",
20
20
  "@ms-cloudpack/path-utilities": "^2.3.5",
21
21
  "@ms-cloudpack/path-string-parsing": "^1.1.1",
22
22
  "fast-glob": "^3.2.12",