@ms-cloudpack/package-utilities 5.1.12 → 5.1.14

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"]}
@@ -1 +1 @@
1
- {"version":3,"file":"findFileInPackage.d.ts","sourceRoot":"","sources":["../src/findFileInPackage.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAI3E,MAAM,MAAM,wBAAwB,GAAG;IACrC,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF;;;;;;;;;GASG;AAEH,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,wBAAwB,EACjC,OAAO,EAAE;IAAE,QAAQ,EAAE,uBAAuB,CAAA;CAAE,GAC7C,OAAO,CAAC,uBAAuB,CAAC,CAuFlC"}
1
+ {"version":3,"file":"findFileInPackage.d.ts","sourceRoot":"","sources":["../src/findFileInPackage.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAO3E,MAAM,MAAM,wBAAwB,GAAG;IACrC,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF;;;;;;;;;GASG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,wBAAwB,EACjC,OAAO,EAAE;IAAE,QAAQ,EAAE,uBAAuB,CAAA;CAAE,GAC7C,OAAO,CAAC,uBAAuB,CAAC,CAoFlC"}
@@ -1,10 +1,12 @@
1
1
  import path from 'path';
2
- import { intermediateToSourcePath, sourceToIntermediatePath, isFile } from '@ms-cloudpack/path-utilities';
3
- import { isExternalPackage } from './isExternalPackage.js';
4
- import { safeRelativePath } from '@ms-cloudpack/path-string-parsing';
2
+ import { intermediateToSourcePath, sourceToIntermediatePath, isFileSync } from '@ms-cloudpack/path-utilities';
3
+ import { safeRelativePath, slash } from '@ms-cloudpack/path-string-parsing';
5
4
  import { getExportsMap } from './getExportsMap.js';
6
5
  import { flattenExportsMap } from './flattenExportsMap.js';
7
- const typescriptExtensions = ['.ts', '.tsx', '.cts', '.mts'];
6
+ import { getCandidates } from './getCandidates.js';
7
+ import { isExternalPackage } from './isExternalPackage.js';
8
+ const sourceExtensions = ['.ts', '.tsx', '.cts', '.mts', '.jsx'];
9
+ const javascriptExtensions = ['.js', '.mjs', '.cjs'];
8
10
  /**
9
11
  * Given a requested partial filePath, resolves the relative intermediate path if the file exists, with special
10
12
  * consideration for internal packages, which may not have intermediate files but only source files. Paths returned
@@ -16,48 +18,17 @@ const typescriptExtensions = ['.ts', '.tsx', '.cts', '.mts'];
16
18
  * exist, then we should not include it in the exports map.
17
19
  */
18
20
  export async function findFileInPackage(options, context) {
19
- const { packagePath } = options;
20
- let filePath = safeRelativePath(options.filePath);
21
+ const originalPath = safeRelativePath(options.filePath);
22
+ const packagePath = slash(options.packagePath);
23
+ let filePath;
21
24
  let sourcePath;
22
25
  let typesPath;
23
26
  const isInternal = !isExternalPackage(packagePath);
24
- const candidates = [
25
- filePath,
26
- filePath + '.js',
27
- filePath + '.mjs',
28
- filePath + '.cjs',
29
- safeRelativePath(path.join(filePath, 'index.js')),
30
- safeRelativePath(path.join(filePath, 'package.json')),
31
- ];
32
- filePath = undefined;
33
- for (const candidate of candidates) {
34
- if (await isFile(path.join(packagePath, candidate))) {
35
- filePath = candidate;
36
- break;
37
- }
38
- }
39
- // For internal packages, try and find source/typings and convert to intermediate (which may be missing.)
40
- if (isInternal) {
41
- for (const candidate of candidates) {
42
- sourcePath = intermediateToSourcePath(candidate, packagePath);
43
- if (sourcePath) {
44
- break;
45
- }
46
- }
47
- // If the discovered source file is the same as the provided file, resolve the intermediate path.
48
- if (sourcePath && (!filePath || sourcePath === filePath)) {
49
- filePath = sourceToIntermediatePath(sourcePath);
50
- }
51
- // If the sourcePath is the same as the filePath, clear it. By this point we should have resolved
52
- // the true intermediate path.
53
- if (sourcePath === filePath) {
54
- sourcePath = undefined;
55
- }
56
- if (sourcePath && typescriptExtensions.includes(path.extname(sourcePath))) {
57
- typesPath = filePath && path.extname(filePath) === '.js' ? filePath.replace(/\.js$/, '.d.ts') : undefined;
58
- }
59
- }
60
- const isNestedPackageDefinition = filePath && path.basename(filePath) === 'package.json' && path.basename(options.filePath) !== 'package.json';
27
+ const candidates = getCandidates({ filePath: originalPath, packagePath });
28
+ // Try and resolve a physical file given the candidates.
29
+ // eslint-disable-next-line @ms-cloudpack/internal/no-sync-filesystem
30
+ filePath = candidates.find((candidate) => isFileSync(path.join(packagePath, candidate)));
31
+ const isNestedPackageDefinition = filePath && path.basename(filePath) === 'package.json' && path.basename(originalPath) !== 'package.json';
61
32
  const result = {};
62
33
  if (isNestedPackageDefinition) {
63
34
  const nestedDefinitionPath = path.dirname(path.join(packagePath, filePath));
@@ -74,6 +45,32 @@ export async function findFileInPackage(options, context) {
74
45
  };
75
46
  }
76
47
  }
48
+ // If the resolved file is a typescript file in an internal package, try to resolve the intermediate.
49
+ if (filePath && sourceExtensions.includes(path.extname(filePath))) {
50
+ sourcePath = filePath;
51
+ filePath = isInternal ? sourceToIntermediatePath(filePath) : undefined;
52
+ }
53
+ // If we haven't resolved a sourcePath, try to resolve it from the intermediate.
54
+ if (isInternal && filePath && !sourcePath) {
55
+ const ext = path.extname(filePath);
56
+ const isJavaScriptExt = javascriptExtensions.includes(ext);
57
+ if (isJavaScriptExt) {
58
+ // Not a TS file, but a JS file. Try to find the source.
59
+ sourcePath = intermediateToSourcePath(filePath, packagePath);
60
+ // If we couldn't find a TS file, clear sourcePath.
61
+ if (sourcePath === filePath) {
62
+ sourcePath = undefined;
63
+ }
64
+ }
65
+ }
66
+ // Try to resolve the typesPath
67
+ if (sourcePath && filePath) {
68
+ typesPath = filePath.replace(/\.js$/, '.d.ts');
69
+ // eslint-disable-next-line @ms-cloudpack/internal/no-sync-filesystem
70
+ if (!isInternal && !isFileSync(path.join(packagePath, typesPath))) {
71
+ typesPath = undefined;
72
+ }
73
+ }
77
74
  if (typesPath) {
78
75
  result.typesPath = safeRelativePath(typesPath);
79
76
  }
@@ -1 +1 @@
1
- {"version":3,"file":"findFileInPackage.js","sourceRoot":"","sources":["../src/findFileInPackage.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,wBAAwB,EAAE,wBAAwB,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAC1G,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAC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Q,EAAE,gBAAgB,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,IAAI,CAAC,IAAI,CAAC,oBAAoB,EAAE,SAAS,CAAC,CAAC,CAAC;iBACnG,EACD,OAAO,CACR,CAAC;gBACF,SAAS,EACP,SAAS,IAAI,gBAAgB,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,IAAI,CAAC,IAAI,CAAC,oBAAoB,EAAE,SAAS,CAAC,CAAC,CAAC;aACxG,CAAC;SACH;KACF;IAED,IAAI,SAAS,EAAE;QACb,MAAM,CAAC,SAAS,GAAG,gBAAgB,CAAC,SAAS,CAAC,CAAC;KAChD;IAED,IAAI,QAAQ,EAAE;QACZ,MAAM,CAAC,QAAQ,GAAG,gBAAgB,CAAC,QAAQ,CAAC,CAAC;KAC9C;IAED,IAAI,UAAU,EAAE;QACd,MAAM,CAAC,UAAU,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAC;KAClD;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import path from 'path';\nimport { intermediateToSourcePath, sourceToIntermediatePath, isFile } from '@ms-cloudpack/path-utilities';\nimport { isExternalPackage } from './isExternalPackage.js';\nimport { safeRelativePath } from '@ms-cloudpack/path-string-parsing';\nimport { getExportsMap } from './getExportsMap.js';\nimport { flattenExportsMap } from './flattenExportsMap.js';\nimport type { PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';\n\nconst typescriptExtensions = ['.ts', '.tsx', '.cts', '.mts'];\n\nexport type FindFileInPackageOptions = {\n packagePath: string;\n filePath: string;\n};\n\nexport type FindFileInPackageResult = {\n filePath?: string;\n typesPath?: string;\n sourcePath?: string;\n};\n\n/**\n * Given a requested partial filePath, resolves the relative intermediate path if the file exists, with special\n * consideration for internal packages, which may not have intermediate files but only source files. Paths returned\n * are always relative and start with `./`.\n *\n * This helper is used in deriving if the given package.json entries are actual validate candidates when constructing an\n * exports map from existing metadata. For example, a package.json may list `main` as `lib/index.js`. If this file\n * exists, or in internal packages, if `src/index.tsx` exists, then this is a valid candidate. If the file does not\n * exist, then we should not include it in the exports map.\n */\n\nexport async function findFileInPackage(\n options: FindFileInPackageOptions,\n context: { packages: PackageDefinitionsCache },\n): Promise<FindFileInPackageResult> {\n const { packagePath } = options;\n let filePath: string | undefined = safeRelativePath(options.filePath);\n let sourcePath: string | undefined;\n let typesPath: string | undefined;\n const isInternal = !isExternalPackage(packagePath);\n const candidates = [\n filePath,\n filePath + '.js',\n filePath + '.mjs',\n filePath + '.cjs',\n safeRelativePath(path.join(filePath, 'index.js')),\n safeRelativePath(path.join(filePath, 'package.json')),\n ];\n\n filePath = undefined;\n for (const candidate of candidates) {\n if (await isFile(path.join(packagePath, candidate))) {\n filePath = candidate;\n break;\n }\n }\n\n // For internal packages, try and find source/typings and convert to intermediate (which may be missing.)\n if (isInternal) {\n for (const candidate of candidates) {\n sourcePath = intermediateToSourcePath(candidate, packagePath);\n if (sourcePath) {\n break;\n }\n }\n\n // If the discovered source file is the same as the provided file, resolve the intermediate path.\n if (sourcePath && (!filePath || sourcePath === filePath)) {\n filePath = sourceToIntermediatePath(sourcePath);\n }\n\n // If the sourcePath is the same as the filePath, clear it. By this point we should have resolved\n // the true intermediate path.\n if (sourcePath === filePath) {\n sourcePath = undefined;\n }\n\n if (sourcePath && typescriptExtensions.includes(path.extname(sourcePath))) {\n typesPath = filePath && path.extname(filePath) === '.js' ? filePath.replace(/\\.js$/, '.d.ts') : undefined;\n }\n }\n\n const isNestedPackageDefinition =\n filePath && path.basename(filePath) === 'package.json' && path.basename(options.filePath) !== 'package.json';\n const result: FindFileInPackageResult = {};\n\n if (isNestedPackageDefinition) {\n const nestedDefinitionPath = path.dirname(path.join(packagePath, filePath as string));\n const exportsMap = await getExportsMap({ packagePath: nestedDefinitionPath }, context);\n const entryPath = flattenExportsMap(exportsMap)['.'];\n\n if (entryPath) {\n typesPath = flattenExportsMap(exportsMap, { conditions: ['types'] })['.'];\n\n return {\n ...(await findFileInPackage(\n {\n packagePath,\n filePath: safeRelativePath(path.relative(packagePath, path.join(nestedDefinitionPath, entryPath))),\n },\n context,\n )),\n typesPath:\n typesPath && safeRelativePath(path.relative(packagePath, path.join(nestedDefinitionPath, typesPath))),\n };\n }\n }\n\n if (typesPath) {\n result.typesPath = safeRelativePath(typesPath);\n }\n\n if (filePath) {\n result.filePath = safeRelativePath(filePath);\n }\n\n if (sourcePath) {\n result.sourcePath = safeRelativePath(sourcePath);\n }\n\n return result;\n}\n"]}
1
+ {"version":3,"file":"findFileInPackage.js","sourceRoot":"","sources":["../src/findFileInPackage.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,wBAAwB,EAAE,wBAAwB,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC9G,OAAO,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AACjE,MAAM,oBAAoB,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAarD;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,OAAiC,EACjC,OAA8C;IAE9C,MAAM,YAAY,GAAG,gBAAgB,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACxD,MAAM,WAAW,GAAG,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IAC/C,IAAI,QAA4B,CAAC;IACjC,IAAI,UAA8B,CAAC;IACnC,IAAI,SAA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CAAC,QAAQ,GAAG,gBAAgB,CAAC,QAAQ,CAAC,CAAC;KAC9C;IAED,IAAI,UAAU,EAAE;QACd,MAAM,CAAC,UAAU,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAC;KAClD;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import path from 'path';\nimport { intermediateToSourcePath, sourceToIntermediatePath, isFileSync } from '@ms-cloudpack/path-utilities';\nimport { safeRelativePath, slash } from '@ms-cloudpack/path-string-parsing';\nimport { getExportsMap } from './getExportsMap.js';\nimport { flattenExportsMap } from './flattenExportsMap.js';\nimport type { PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';\nimport { getCandidates } from './getCandidates.js';\nimport { isExternalPackage } from './isExternalPackage.js';\n\nconst sourceExtensions = ['.ts', '.tsx', '.cts', '.mts', '.jsx'];\nconst javascriptExtensions = ['.js', '.mjs', '.cjs'];\n\nexport type FindFileInPackageOptions = {\n packagePath: string;\n filePath: string;\n};\n\nexport type FindFileInPackageResult = {\n filePath?: string;\n typesPath?: string;\n sourcePath?: string;\n};\n\n/**\n * Given a requested partial filePath, resolves the relative intermediate path if the file exists, with special\n * consideration for internal packages, which may not have intermediate files but only source files. Paths returned\n * are always relative and start with `./`.\n *\n * This helper is used in deriving if the given package.json entries are actual validate candidates when constructing an\n * exports map from existing metadata. For example, a package.json may list `main` as `lib/index.js`. If this file\n * exists, or in internal packages, if `src/index.tsx` exists, then this is a valid candidate. If the file does not\n * exist, then we should not include it in the exports map.\n */\nexport async function findFileInPackage(\n options: FindFileInPackageOptions,\n context: { packages: PackageDefinitionsCache },\n): Promise<FindFileInPackageResult> {\n const originalPath = safeRelativePath(options.filePath);\n const packagePath = slash(options.packagePath);\n let filePath: string | undefined;\n let sourcePath: string | undefined;\n let typesPath: string | undefined;\n const isInternal = !isExternalPackage(packagePath);\n const candidates = getCandidates({ filePath: originalPath, packagePath });\n\n // Try and resolve a physical file given the candidates.\n // eslint-disable-next-line @ms-cloudpack/internal/no-sync-filesystem\n filePath = candidates.find((candidate) => isFileSync(path.join(packagePath, candidate)));\n\n const isNestedPackageDefinition =\n filePath && path.basename(filePath) === 'package.json' && path.basename(originalPath) !== 'package.json';\n const result: FindFileInPackageResult = {};\n\n if (isNestedPackageDefinition) {\n const nestedDefinitionPath = path.dirname(path.join(packagePath, filePath as string));\n const exportsMap = await getExportsMap({ packagePath: nestedDefinitionPath }, context);\n const entryPath = flattenExportsMap(exportsMap)['.'];\n\n if (entryPath) {\n typesPath = flattenExportsMap(exportsMap, { conditions: ['types'] })['.'];\n\n return {\n ...(await findFileInPackage(\n {\n packagePath,\n filePath: safeRelativePath(path.relative(packagePath, path.join(nestedDefinitionPath, entryPath))),\n },\n context,\n )),\n typesPath:\n typesPath && safeRelativePath(path.relative(packagePath, path.join(nestedDefinitionPath, typesPath))),\n };\n }\n }\n\n // If the resolved file is a typescript file in an internal package, try to resolve the intermediate.\n if (filePath && sourceExtensions.includes(path.extname(filePath))) {\n sourcePath = filePath;\n filePath = isInternal ? sourceToIntermediatePath(filePath) : undefined;\n }\n\n // If we haven't resolved a sourcePath, try to resolve it from the intermediate.\n if (isInternal && filePath && !sourcePath) {\n const ext = path.extname(filePath);\n const isJavaScriptExt = javascriptExtensions.includes(ext);\n\n if (isJavaScriptExt) {\n // Not a TS file, but a JS file. Try to find the source.\n sourcePath = intermediateToSourcePath(filePath, packagePath);\n\n // If we couldn't find a TS file, clear sourcePath.\n if (sourcePath === filePath) {\n sourcePath = undefined;\n }\n }\n }\n\n // Try to resolve the typesPath\n if (sourcePath && filePath) {\n typesPath = filePath.replace(/\\.js$/, '.d.ts');\n\n // eslint-disable-next-line @ms-cloudpack/internal/no-sync-filesystem\n if (!isInternal && !isFileSync(path.join(packagePath, typesPath))) {\n typesPath = undefined;\n }\n }\n\n if (typesPath) {\n result.typesPath = safeRelativePath(typesPath);\n }\n\n if (filePath) {\n result.filePath = safeRelativePath(filePath);\n }\n\n if (sourcePath) {\n result.sourcePath = safeRelativePath(sourcePath);\n }\n\n return result;\n}\n"]}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Given a packagePath and a filePath from its exports map (or main/module), build candidate paths
3
+ * to look for the physical file in order of priority. For internal packages, we try to discover
4
+ * source files first, and then fallback to the original file name. We also search for index files
5
+ * and expand folder paths as well for ambiguous references. For external packages, we prioritize
6
+ * intermediate paths.
7
+ */
8
+ export declare function getCandidates(options: {
9
+ filePath: string;
10
+ packagePath: string;
11
+ }): string[];
12
+ //# sourceMappingURL=getCandidates.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getCandidates.d.ts","sourceRoot":"","sources":["../src/getCandidates.ts"],"names":[],"mappings":"AA0BA;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,YAoD/E"}
@@ -0,0 +1,98 @@
1
+ import { safeRelativePath } from '@ms-cloudpack/path-string-parsing';
2
+ import path from 'path';
3
+ import { isExternalPackage } from './isExternalPackage.js';
4
+ // Mappings to possible candidate extensions for a given input extension.
5
+ const externalExtensions = ['.js', '.mjs', '.cjs'];
6
+ const internalExtensions = ['.ts', '.tsx', '.mts', '.cts', '.jsx', '.js', '.mjs', '.cjs'];
7
+ const internalExtensionMap = {
8
+ '.ts': ['.ts', '.js'],
9
+ '.tsx': ['.tsx', '.js'],
10
+ '.mts': ['.mts', '.mjs', '.js'],
11
+ '.cts': ['.cts', '.cjs', '.js'],
12
+ '.jsx': ['.jsx', '.js'],
13
+ '.js': ['.ts', '.tsx', '.mts', '.cts', '.jsx', '.js'],
14
+ '.mjs': ['.mjs', '.js'],
15
+ '.cjs': ['.cjs', '.js'],
16
+ };
17
+ const externalExtensionMap = {
18
+ '.ts': ['.ts', '.js'],
19
+ '.tsx': ['.js'],
20
+ '.mts': ['.mjs', '.js'],
21
+ '.cts': ['.mts', '.cts'],
22
+ '.jsx': ['.js'],
23
+ '.js': ['.js'],
24
+ };
25
+ /**
26
+ * Given a packagePath and a filePath from its exports map (or main/module), build candidate paths
27
+ * to look for the physical file in order of priority. For internal packages, we try to discover
28
+ * source files first, and then fallback to the original file name. We also search for index files
29
+ * and expand folder paths as well for ambiguous references. For external packages, we prioritize
30
+ * intermediate paths.
31
+ */
32
+ export function getCandidates(options) {
33
+ const { filePath, packagePath } = options;
34
+ const isBlankPath = !filePath || filePath === '.';
35
+ const originalPath = isBlankPath ? './index' : safeRelativePath(filePath);
36
+ const originalExt = path.extname(originalPath);
37
+ const isInternal = !isExternalPackage(packagePath);
38
+ const endsWithSlash = originalPath.endsWith('/');
39
+ const candidates = [];
40
+ const defaultExtensions = isInternal ? internalExtensions : externalExtensions;
41
+ const extensions = (isInternal ? internalExtensionMap : externalExtensionMap)[originalExt] || defaultExtensions;
42
+ const pathsToAdd = [originalPath];
43
+ if (isInternal && originalPath.startsWith('./lib')) {
44
+ pathsToAdd.unshift(originalPath.replace(/^\.\/lib/, './src'));
45
+ }
46
+ for (let currentPath of pathsToAdd) {
47
+ const unrecognizedExt = originalExt && !extensions.includes(path.extname(currentPath));
48
+ // For internal packages, we try and resolve the original file name first.
49
+ if (isInternal && unrecognizedExt) {
50
+ candidates.push(currentPath);
51
+ }
52
+ // If the path doesn't end with a slash, it could be a file. Add extensions.
53
+ if (!endsWithSlash) {
54
+ candidates.push(...expandExtensions(currentPath, extensions));
55
+ }
56
+ // For non-extension references, we might be referring to a folder, or a barrel file within a folder. Add the
57
+ // appropriate extensions for the barrel file, and fall back to a package.json in the case of nested definitions.
58
+ if (!originalExt) {
59
+ if (isBlankPath) {
60
+ candidates.push('./package.json');
61
+ }
62
+ else {
63
+ // Trim trailing slash
64
+ if (endsWithSlash) {
65
+ currentPath = currentPath.slice(0, -1);
66
+ }
67
+ candidates.push(...expandExtensions(currentPath + '/index', extensions));
68
+ candidates.push(currentPath + '/package.json');
69
+ }
70
+ }
71
+ // For external packages, we try and resolve the original file name last.
72
+ if (!isInternal && unrecognizedExt) {
73
+ candidates.push(currentPath);
74
+ }
75
+ }
76
+ return candidates;
77
+ }
78
+ /**
79
+ * Given a filepath and list of extensions, maps extensions to prepend the filepath. In the case that
80
+ * the filepath has an extension already in the list, avoids appending the extension twice.
81
+ *
82
+ * For example, filePath = './foo/bar.js' with extensions ['.ts', '.js'] would result in:
83
+ *
84
+ * ['./foo/bar.ts.js', './foo/bar.js'].
85
+ *
86
+ */
87
+ function expandExtensions(filePath, extensions) {
88
+ const result = [];
89
+ const ext = path.extname(filePath);
90
+ if (extensions.includes(ext)) {
91
+ filePath = `${filePath.slice(0, -ext.length)}`;
92
+ }
93
+ for (const currentExt of extensions) {
94
+ result.push(filePath + currentExt);
95
+ }
96
+ return result;
97
+ }
98
+ //# sourceMappingURL=getCandidates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getCandidates.js","sourceRoot":"","sources":["../src/getCandidates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,yEAAyE;AACzE,MAAM,kBAAkB,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AACnD,MAAM,kBAAkB,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAC1F,MAAM,oBAAoB,GAA6B;IACrD,KAAK,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC;IACrB,MAAM,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC;IACvB,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC;IAC/B,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC;IAC/B,MAAM,EAAE,CAAC,MAAM,EAAE,KAAK,CAA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;;;;;;GAQG;AACH,SAAS,gBAAgB,CAAC,QAAgB,EAAE,UAAoB;IAC9D,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAEnC,IAAI,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;QAC5B,QAAQ,GAAG,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;KAChD;IAED,KAAK,MAAM,UAAU,IAAI,UAAU,EAAE;QACnC,MAAM,CAAC,IAAI,CAAC,QAAQ,GAAG,UAAU,CAAC,CAAC;KACpC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { safeRelativePath } from '@ms-cloudpack/path-string-parsing';\nimport path from 'path';\nimport { isExternalPackage } from './isExternalPackage.js';\n\n// Mappings to possible candidate extensions for a given input extension.\nconst externalExtensions = ['.js', '.mjs', '.cjs'];\nconst internalExtensions = ['.ts', '.tsx', '.mts', '.cts', '.jsx', '.js', '.mjs', '.cjs'];\nconst internalExtensionMap: Record<string, string[]> = {\n '.ts': ['.ts', '.js'],\n '.tsx': ['.tsx', '.js'],\n '.mts': ['.mts', '.mjs', '.js'],\n '.cts': ['.cts', '.cjs', '.js'],\n '.jsx': ['.jsx', '.js'],\n '.js': ['.ts', '.tsx', '.mts', '.cts', '.jsx', '.js'],\n '.mjs': ['.mjs', '.js'],\n '.cjs': ['.cjs', '.js'],\n};\nconst externalExtensionMap: Record<string, string[]> = {\n '.ts': ['.ts', '.js'],\n '.tsx': ['.js'],\n '.mts': ['.mjs', '.js'],\n '.cts': ['.mts', '.cts'],\n '.jsx': ['.js'],\n '.js': ['.js'],\n};\n\n/**\n * Given a packagePath and a filePath from its exports map (or main/module), build candidate paths\n * to look for the physical file in order of priority. For internal packages, we try to discover\n * source files first, and then fallback to the original file name. We also search for index files\n * and expand folder paths as well for ambiguous references. For external packages, we prioritize\n * intermediate paths.\n */\nexport function getCandidates(options: { filePath: string; packagePath: string }) {\n const { filePath, packagePath } = options;\n const isBlankPath = !filePath || filePath === '.';\n const originalPath = isBlankPath ? './index' : safeRelativePath(filePath);\n const originalExt = path.extname(originalPath);\n const isInternal = !isExternalPackage(packagePath);\n const endsWithSlash = originalPath.endsWith('/');\n const candidates = [];\n const defaultExtensions = isInternal ? internalExtensions : externalExtensions;\n const extensions = (isInternal ? internalExtensionMap : externalExtensionMap)[originalExt] || defaultExtensions;\n const pathsToAdd = [originalPath];\n\n if (isInternal && originalPath.startsWith('./lib')) {\n pathsToAdd.unshift(originalPath.replace(/^\\.\\/lib/, './src'));\n }\n\n for (let currentPath of pathsToAdd) {\n const unrecognizedExt = originalExt && !extensions.includes(path.extname(currentPath));\n\n // For internal packages, we try and resolve the original file name first.\n if (isInternal && unrecognizedExt) {\n candidates.push(currentPath);\n }\n\n // If the path doesn't end with a slash, it could be a file. Add extensions.\n if (!endsWithSlash) {\n candidates.push(...expandExtensions(currentPath, extensions));\n }\n\n // For non-extension references, we might be referring to a folder, or a barrel file within a folder. Add the\n // appropriate extensions for the barrel file, and fall back to a package.json in the case of nested definitions.\n if (!originalExt) {\n if (isBlankPath) {\n candidates.push('./package.json');\n } else {\n // Trim trailing slash\n if (endsWithSlash) {\n currentPath = currentPath.slice(0, -1);\n }\n\n candidates.push(...expandExtensions(currentPath + '/index', extensions));\n candidates.push(currentPath + '/package.json');\n }\n }\n\n // For external packages, we try and resolve the original file name last.\n if (!isInternal && unrecognizedExt) {\n candidates.push(currentPath);\n }\n }\n\n return candidates;\n}\n\n/**\n * Given a filepath and list of extensions, maps extensions to prepend the filepath. In the case that\n * the filepath has an extension already in the list, avoids appending the extension twice.\n *\n * For example, filePath = './foo/bar.js' with extensions ['.ts', '.js'] would result in:\n *\n * ['./foo/bar.ts.js', './foo/bar.js'].\n *\n */\nfunction expandExtensions(filePath: string, extensions: string[]) {\n const result: string[] = [];\n const ext = path.extname(filePath);\n\n if (extensions.includes(ext)) {\n filePath = `${filePath.slice(0, -ext.length)}`;\n }\n\n for (const currentExt of extensions) {\n result.push(filePath + currentExt);\n }\n\n return result;\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,CAAC;AACxD,YAAY,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,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,OAA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C;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.14",
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",