@ms-cloudpack/bundler 0.23.33 → 0.23.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/bundle.d.ts CHANGED
@@ -1,17 +1,13 @@
1
- import type { BundleOptions, BundleResult, BundlerResult, CloudpackConfig } from '@ms-cloudpack/common-types';
1
+ import type { BundleContext, BundleOptions, Bundler, BundleResult, BundlerResult } from '@ms-cloudpack/common-types';
2
2
  /**
3
3
  * Abstracted consumer input to the bundle method for the appropriate bundler. Provides a more
4
4
  * advanced api surface.
5
5
  */
6
- export declare function bundle(options: BundleOptions, context: {
7
- config: CloudpackConfig;
8
- }): Promise<BundleResult>;
6
+ export declare function bundle(options: BundleOptions, context: Pick<BundleContext, 'config'>): Promise<BundleResult>;
9
7
  /**
10
8
  * Wrapper for bundling and normalizing the result. This is separated to allow sharing the logic
11
9
  * between normal `bundle()` calls and `result.rebuild()` (if provided by the bundler plugin),
12
10
  * and helps with testing.
13
11
  */
14
- export declare function bundleInternal(pluginBundle: () => Promise<BundlerResult>, options: BundleOptions & {
15
- bundler: string;
16
- }): Promise<BundleResult>;
12
+ export declare function bundleInternal(pluginBundle: () => Promise<BundlerResult>, options: BundleOptions & Pick<Bundler, 'name' | 'version'>): Promise<BundleResult>;
17
13
  //# sourceMappingURL=bundle.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../src/bundle.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,aAAa,EACb,YAAY,EACZ,aAAa,EACb,eAAe,EAEhB,MAAM,4BAA4B,CAAC;AAMpC;;;GAGG;AACH,wBAAsB,MAAM,CAAC,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE;IAAE,MAAM,EAAE,eAAe,CAAA;CAAE,GAAG,OAAO,CAAC,YAAY,CAAC,CAgEhH;AAED;;;;GAIG;AACH,wBAAsB,cAAc,CAClC,YAAY,EAAE,MAAM,OAAO,CAAC,aAAa,CAAC,EAC1C,OAAO,EAAE,aAAa,GAAG;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,GAC3C,OAAO,CAAC,YAAY,CAAC,CAsCvB"}
1
+ {"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../src/bundle.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,aAAa,EAEb,aAAa,EACb,OAAO,EACP,YAAY,EACZ,aAAa,EAEd,MAAM,4BAA4B,CAAC;AAMpC;;;GAGG;AACH,wBAAsB,MAAM,CAAC,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,IAAI,CAAC,aAAa,EAAE,QAAQ,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC,CAgElH;AAED;;;;GAIG;AACH,wBAAsB,cAAc,CAClC,YAAY,EAAE,MAAM,OAAO,CAAC,aAAa,CAAC,EAC1C,OAAO,EAAE,aAAa,GAAG,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC,GACzD,OAAO,CAAC,YAAY,CAAC,CAwCvB"}
package/lib/bundle.js CHANGED
@@ -61,7 +61,7 @@ export async function bundle(options, context) {
61
61
  isTypescript,
62
62
  });
63
63
  const bundleFunc = () => bundler.bundle(options, { ...context, moduleType });
64
- return bundleInternal(bundleFunc, { ...options, bundler: bundler.name });
64
+ return bundleInternal(bundleFunc, { ...options, name: bundler.name, version: bundler.version });
65
65
  }
66
66
  /**
67
67
  * Wrapper for bundling and normalizing the result. This is separated to allow sharing the logic
@@ -69,12 +69,14 @@ export async function bundle(options, context) {
69
69
  * and helps with testing.
70
70
  */
71
71
  export async function bundleInternal(pluginBundle, options) {
72
+ const bundler = options.name;
73
+ const bundlerVersion = await options.version;
72
74
  let pluginResult = undefined;
73
75
  try {
74
76
  pluginResult = await pluginBundle();
75
77
  }
76
78
  catch (e) {
77
- const errorMessage = { text: `Exception while bundling: ${e}`, source: options.bundler };
79
+ const errorMessage = { text: `Exception while bundling: ${e}`, source: bundler };
78
80
  if (e instanceof Error && e.stack) {
79
81
  // remove the message from the stack
80
82
  errorMessage.notes = [{ text: e.stack.includes(e.message) ? e.stack.split(e.message)[1] : '' }];
@@ -84,13 +86,13 @@ export async function bundleInternal(pluginBundle, options) {
84
86
  };
85
87
  }
86
88
  const { rawInput, rawOutput, rebuild, ...rest } = pluginResult || {};
87
- const { bundler, inputPath, entries, outputPath: logOutputPath = inputPath } = options;
89
+ const { inputPath, entries, outputPath: logOutputPath = inputPath } = options;
88
90
  await Promise.all([
89
91
  rest.errors?.length && writeJson(path.join(logOutputPath, `${bundler}-errors.json`), rest.errors),
90
92
  rawInput && writeJson(path.join(logOutputPath, `${bundler}-input.json`), rawInput),
91
93
  rawOutput && writeJson(path.join(logOutputPath, `${bundler}-output.json`), rawOutput),
92
94
  ]);
93
- const result = { bundler, inputPath, entries, ...rest };
95
+ const result = { bundler, bundlerVersion, inputPath, entries, ...rest };
94
96
  if (options.ignoredBundlerWarnings?.length && result.warnings?.length) {
95
97
  result.warnings = result.warnings.filter((warning) => !options.ignoredBundlerWarnings?.some((suppressed) => warning.text.includes(suppressed)));
96
98
  }
package/lib/bundle.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"bundle.js","sourceRoot":"","sources":["../src/bundle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AASnD,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAEtF;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,OAAsB,EAAE,OAAoC;IACvF,MAAM,YAAY,GAAoB,EAAE,CAAC;IAEzC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,CAAC;QAC/B,YAAY,CAAC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AAC;IAEH,MAAM,MAAM,GAAiB,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,CAAC;IACtE,IAAI,OAAO,CAAC,sBAAsB,EAAE,MAAM,IAAI,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAC;QACtE,MAAM,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CACtC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,sBAAsB,EAAE,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CACtG,CAAC;IACJ,CAAC;IAED,IAAI,OAAO,EAAE,CAAC;QACZ,2CAA2C;QAC3C,MAAM,CAAC,OAAO,GAAG,GAAG,EAAE,CAAC,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC1D,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { chooseBundler } from './chooseBundler.js';\nimport type {\n BundleMessage,\n BundleOptions,\n BundleResult,\n BundlerResult,\n CloudpackConfig,\n ModuleType,\n} from '@ms-cloudpack/common-types';\nimport { writeJson } from '@ms-cloudpack/json-utilities';\nimport path from 'path';\nimport { detectModuleType } from '@ms-cloudpack/package-utilities';\nimport { sourceExtensions, typescriptExtensions } from '@ms-cloudpack/path-utilities';\n\n/**\n * Abstracted consumer input to the bundle method for the appropriate bundler. Provides a more\n * advanced api surface.\n */\nexport async function bundle(options: BundleOptions, context: { config: CloudpackConfig }): Promise<BundleResult> {\n const configErrors: BundleMessage[] = [];\n\n if (!options.inputPath?.length) {\n configErrors.push({\n text: 'No input path provided to bundle.',\n source: 'bundle',\n });\n } else if (!path.isAbsolute(options.inputPath)) {\n configErrors.push({\n text: 'Input path must be absolute.',\n source: 'bundle',\n });\n }\n\n if (!Object.keys(options.entries || {}).length) {\n configErrors.push({\n text: `No entries provided to bundle at inputPath \"${options.inputPath}\".`,\n source: 'bundle',\n });\n } else if (Object.entries(options.entries).some(([k, v]) => path.isAbsolute(k) || path.isAbsolute(v))) {\n configErrors.push({\n text: `Entry paths must be relative.`,\n source: 'bundle',\n });\n }\n\n if (options.bundlerOptions && !options.bundler) {\n configErrors.push({\n text: '`bundlerOptions` are bundler-specific, so a `bundler` must be specified.',\n source: 'bundle',\n });\n }\n\n if (configErrors.length) {\n return { inputPath: options.inputPath, errors: configErrors };\n }\n\n // Choose the bundler type and bundle.\n const sourceEntries = Object.values(options.entries).filter((fileName) =>\n sourceExtensions.includes(path.extname(fileName)),\n );\n\n let moduleType: ModuleType = 'esm';\n\n // Check the module type of each entry, short circuiting if we find a cjs or amd file.\n for (const sourceEntry of sourceEntries) {\n const sourceType = await detectModuleType(path.resolve(options.inputPath, sourceEntry));\n if (sourceType === 'amd' || sourceType === 'cjs') {\n moduleType = sourceType;\n break;\n }\n }\n\n const isTypescript = sourceEntries.some((fileName) => typescriptExtensions.includes(path.extname(fileName)));\n\n const bundler = await chooseBundler({\n bundler: options.bundler,\n mode: context.config.mode,\n moduleType,\n isTypescript,\n });\n const bundleFunc = () => bundler.bundle(options, { ...context, moduleType });\n return bundleInternal(bundleFunc, { ...options, bundler: bundler.name });\n}\n\n/**\n * Wrapper for bundling and normalizing the result. This is separated to allow sharing the logic\n * between normal `bundle()` calls and `result.rebuild()` (if provided by the bundler plugin),\n * and helps with testing.\n */\nexport async function bundleInternal(\n pluginBundle: () => Promise<BundlerResult>,\n options: BundleOptions & { bundler: string },\n): Promise<BundleResult> {\n let pluginResult: BundlerResult | undefined = undefined;\n\n try {\n pluginResult = await pluginBundle();\n } catch (e) {\n const errorMessage: BundleMessage = { text: `Exception while bundling: ${e}`, source: options.bundler };\n if (e instanceof Error && e.stack) {\n // remove the message from the stack\n errorMessage.notes = [{ text: e.stack.includes(e.message) ? e.stack.split(e.message)[1] : '' }];\n }\n pluginResult = {\n errors: [errorMessage],\n };\n }\n\n const { rawInput, rawOutput, rebuild, ...rest } = pluginResult || {};\n const { bundler, inputPath, entries, outputPath: logOutputPath = inputPath } = options;\n\n await Promise.all([\n rest.errors?.length && writeJson(path.join(logOutputPath, `${bundler}-errors.json`), rest.errors),\n rawInput && writeJson(path.join(logOutputPath, `${bundler}-input.json`), rawInput),\n rawOutput && writeJson(path.join(logOutputPath, `${bundler}-output.json`), rawOutput),\n ]);\n\n const result: BundleResult = { bundler, inputPath, entries, ...rest };\n if (options.ignoredBundlerWarnings?.length && result.warnings?.length) {\n result.warnings = result.warnings.filter(\n (warning) => !options.ignoredBundlerWarnings?.some((suppressed) => warning.text.includes(suppressed)),\n );\n }\n\n if (rebuild) {\n // Wrap rebuild with proper result handling\n result.rebuild = () => bundleInternal(rebuild, options);\n }\n\n return result;\n}\n"]}
1
+ {"version":3,"file":"bundle.js","sourceRoot":"","sources":["../src/bundle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAUnD,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAEtF;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,OAAsB,EAAE,OAAsC;IACzF,MAAM,YAAY,GAAoB,EAAE,CAAC;IAEzC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,CAAC;QAC/B,YAAY,CAAC,IAAI,CAAC;YAChB,IAAI,EAAE,mCAAmC;YACzC,MAAM,EAAE,QAAQ;SACjB,CAAC,CAAC;IACL,CAAC;SAAM,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;QAC/C,YAAY,CAAC,IAAI,CAAC;YAChB,IAAI,EAAE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AC;IACtF,IAAI,OAAO,CAAC,sBAAsB,EAAE,MAAM,IAAI,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAC;QACtE,MAAM,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CACtC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,sBAAsB,EAAE,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CACtG,CAAC;IACJ,CAAC;IAED,IAAI,OAAO,EAAE,CAAC;QACZ,2CAA2C;QAC3C,MAAM,CAAC,OAAO,GAAG,GAAG,EAAE,CAAC,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC1D,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { chooseBundler } from './chooseBundler.js';\nimport type {\n BundleContext,\n BundleMessage,\n BundleOptions,\n Bundler,\n BundleResult,\n BundlerResult,\n ModuleType,\n} from '@ms-cloudpack/common-types';\nimport { writeJson } from '@ms-cloudpack/json-utilities';\nimport path from 'path';\nimport { detectModuleType } from '@ms-cloudpack/package-utilities';\nimport { sourceExtensions, typescriptExtensions } from '@ms-cloudpack/path-utilities';\n\n/**\n * Abstracted consumer input to the bundle method for the appropriate bundler. Provides a more\n * advanced api surface.\n */\nexport async function bundle(options: BundleOptions, context: Pick<BundleContext, 'config'>): Promise<BundleResult> {\n const configErrors: BundleMessage[] = [];\n\n if (!options.inputPath?.length) {\n configErrors.push({\n text: 'No input path provided to bundle.',\n source: 'bundle',\n });\n } else if (!path.isAbsolute(options.inputPath)) {\n configErrors.push({\n text: 'Input path must be absolute.',\n source: 'bundle',\n });\n }\n\n if (!Object.keys(options.entries || {}).length) {\n configErrors.push({\n text: `No entries provided to bundle at inputPath \"${options.inputPath}\".`,\n source: 'bundle',\n });\n } else if (Object.entries(options.entries).some(([k, v]) => path.isAbsolute(k) || path.isAbsolute(v))) {\n configErrors.push({\n text: `Entry paths must be relative.`,\n source: 'bundle',\n });\n }\n\n if (options.bundlerOptions && !options.bundler) {\n configErrors.push({\n text: '`bundlerOptions` are bundler-specific, so a `bundler` must be specified.',\n source: 'bundle',\n });\n }\n\n if (configErrors.length) {\n return { inputPath: options.inputPath, errors: configErrors };\n }\n\n // Choose the bundler type and bundle.\n const sourceEntries = Object.values(options.entries).filter((fileName) =>\n sourceExtensions.includes(path.extname(fileName)),\n );\n\n let moduleType: ModuleType = 'esm';\n\n // Check the module type of each entry, short circuiting if we find a cjs or amd file.\n for (const sourceEntry of sourceEntries) {\n const sourceType = await detectModuleType(path.resolve(options.inputPath, sourceEntry));\n if (sourceType === 'amd' || sourceType === 'cjs') {\n moduleType = sourceType;\n break;\n }\n }\n\n const isTypescript = sourceEntries.some((fileName) => typescriptExtensions.includes(path.extname(fileName)));\n\n const bundler = await chooseBundler({\n bundler: options.bundler,\n mode: context.config.mode,\n moduleType,\n isTypescript,\n });\n const bundleFunc = () => bundler.bundle(options, { ...context, moduleType });\n return bundleInternal(bundleFunc, { ...options, name: bundler.name, version: bundler.version });\n}\n\n/**\n * Wrapper for bundling and normalizing the result. This is separated to allow sharing the logic\n * between normal `bundle()` calls and `result.rebuild()` (if provided by the bundler plugin),\n * and helps with testing.\n */\nexport async function bundleInternal(\n pluginBundle: () => Promise<BundlerResult>,\n options: BundleOptions & Pick<Bundler, 'name' | 'version'>,\n): Promise<BundleResult> {\n const bundler = options.name;\n const bundlerVersion = await options.version;\n let pluginResult: BundlerResult | undefined = undefined;\n\n try {\n pluginResult = await pluginBundle();\n } catch (e) {\n const errorMessage: BundleMessage = { text: `Exception while bundling: ${e}`, source: bundler };\n if (e instanceof Error && e.stack) {\n // remove the message from the stack\n errorMessage.notes = [{ text: e.stack.includes(e.message) ? e.stack.split(e.message)[1] : '' }];\n }\n pluginResult = {\n errors: [errorMessage],\n };\n }\n\n const { rawInput, rawOutput, rebuild, ...rest } = pluginResult || {};\n const { inputPath, entries, outputPath: logOutputPath = inputPath } = options;\n\n await Promise.all([\n rest.errors?.length && writeJson(path.join(logOutputPath, `${bundler}-errors.json`), rest.errors),\n rawInput && writeJson(path.join(logOutputPath, `${bundler}-input.json`), rawInput),\n rawOutput && writeJson(path.join(logOutputPath, `${bundler}-output.json`), rawOutput),\n ]);\n\n const result: BundleResult = { bundler, bundlerVersion, inputPath, entries, ...rest };\n if (options.ignoredBundlerWarnings?.length && result.warnings?.length) {\n result.warnings = result.warnings.filter(\n (warning) => !options.ignoredBundlerWarnings?.some((suppressed) => warning.text.includes(suppressed)),\n );\n }\n\n if (rebuild) {\n // Wrap rebuild with proper result handling\n result.rebuild = () => bundleInternal(rebuild, options);\n }\n\n return result;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"getEntriesMapFromPackage.d.ts","sourceRoot":"","sources":["../src/getEntriesMapFromPackage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAQ3F;;;;GAIG;AACH,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE;IACP,SAAS,EAAE,MAAM,CAAC;CACnB,EACD,OAAO,EAAE;IACP,QAAQ,EAAE,uBAAuB,CAAC;IAClC,MAAM,EAAE,IAAI,CAAC,eAAe,EAAE,UAAU,CAAC,CAAC;CAC3C,GACA,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAmCjC"}
1
+ {"version":3,"file":"getEntriesMapFromPackage.d.ts","sourceRoot":"","sources":["../src/getEntriesMapFromPackage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAQ3F;;;;GAIG;AACH,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE;IACP,SAAS,EAAE,MAAM,CAAC;CACnB,EACD,OAAO,EAAE;IACP,QAAQ,EAAE,uBAAuB,CAAC;IAClC,MAAM,EAAE,IAAI,CAAC,eAAe,EAAE,UAAU,CAAC,CAAC;CAC3C,GACA,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAoCjC"}
@@ -22,7 +22,8 @@ export async function getEntriesMapFromPackage(options, context) {
22
22
  // to derive source paths from intermediate paths.
23
23
  if (isInternal) {
24
24
  sourceExportsMap = flattenExportsMap(exportsMap, {
25
- conditions: ['source'],
25
+ // Allow traversing into 'browser' environment conditions to find 'source' conditions
26
+ conditions: ['browser', 'source'],
26
27
  requiredConditions: ['source'],
27
28
  });
28
29
  for (const [key, value] of Object.entries(flattenedMap)) {
@@ -1 +1 @@
1
- {"version":3,"file":"getEntriesMapFromPackage.js","sourceRoot":"","sources":["../src/getEntriesMapFromPackage.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AACnF,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAC3F,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAC5C,OAEC,EACD,OAGC;IAED,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAC9B,MAAM,UAAU,GAAG,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC;IACjD,MAAM,UAAU,GAAG,MAAM,aAAa,CAAC,EAAE,WAAW,EAAE,SAAS,EAAE,EAAE,OAAO,CAAC,CAAC;IAC5E,MAAM,YAAY,GAAG,iBAAiB,CAAC,UAAU,CAAC,CAAC;IACnD,IAAI,gBAAwC,CAAC;IAE7C,gHAAgH;IAChH,2FAA2F;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} from '@ms-cloudpack/package-utilities';\nimport { normalizeRelativePath } from '@ms-cloudpack/path-string-parsing';\nimport { intermediateToSourcePath, isExternalPackage } from '@ms-cloudpack/path-utilities';\nimport path from 'path';\nimport { isValidBundleEntry } from './isValidBundleEntry.js';\nimport { toNormalizedEntryKey } from './toNormalizedEntryKey.js';\n\n/**\n * Gets the entries map for a given package. An entries map is different from an exports map in that\n * the keys are relative paths to where the output should live, rather than how the entry is imported.\n * The data structure is used for bundler config; not for resolution of imports.\n */\nexport async function getEntriesMapFromPackage(\n options: {\n inputPath: string;\n },\n context: {\n packages: PackageDefinitionsCache;\n config: Pick<CloudpackConfig, 'features'>;\n },\n): Promise<Record<string, string>> {\n const { inputPath } = options;\n const isInternal = !isExternalPackage(inputPath);\n const exportsMap = await getExportsMap({ packagePath: inputPath }, context);\n const flattenedMap = flattenExportsMap(exportsMap);\n let sourceExportsMap: Record<string, string>;\n\n // The flattened map values tell us what physical files will show up in the import map on the page. We use these\n // as the keys for the entries map, which results in physical file output from the bundler.\n\n // For internal packages, we want the values (the inputs to the each entry) to use source paths if available. To\n // get these, we can either derive from exports map \"source\" entries, or if those are not available, we can attempt\n // to derive source paths from intermediate paths.\n\n if (isInternal) {\n sourceExportsMap = flattenExportsMap(exportsMap, {\n conditions: ['source'],\n requiredConditions: ['source'],\n });\n\n for (const [key, value] of Object.entries(flattenedMap)) {\n if (!sourceExportsMap[key]) {\n sourceExportsMap[key] = intermediateToSourcePath(value, inputPath) || value;\n }\n }\n }\n\n return Object.fromEntries(\n Object.entries(flattenedMap)\n .filter(([, value]) => isValidBundleEntry(value))\n .map(([key, value]) => [\n toNormalizedEntryKey(value),\n toNormalizedRelativePath(inputPath, sourceExportsMap?.[key] || value),\n ]),\n );\n}\n\nfunction toNormalizedRelativePath(inputPath: string, entry: string): string {\n if (path.isAbsolute(entry)) {\n entry = path.relative(inputPath, entry);\n }\n\n return normalizeRelativePath(entry);\n}\n"]}
1
+ {"version":3,"file":"getEntriesMapFromPackage.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AwB,CAAC,KAAK,EAAE,SAAS,CAAC,IAAI,KAAK,CAAC;YAC9E,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC;SACzB,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;SAChD,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC;QACrB,oBAAoB,CAAC,KAAK,CAAC;QAC3B,wBAAwB,CAAC,SAAS,EAAE,gBAAgB,EAAE,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC;KACtE,CAAC,CACL,CAAC;AACJ,CAAC;AAED,SAAS,wBAAwB,CAAC,SAAiB,EAAE,KAAa;IAChE,IAAI,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;QAC3B,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;IAC1C,CAAC;IAED,OAAO,qBAAqB,CAAC,KAAK,CAAC,CAAC;AACtC,CAAC","sourcesContent":["import type { CloudpackConfig, PackageDefinitionsCache } from '@ms-cloudpack/common-types';\nimport { flattenExportsMap, getExportsMap } from '@ms-cloudpack/package-utilities';\nimport { normalizeRelativePath } from '@ms-cloudpack/path-string-parsing';\nimport { intermediateToSourcePath, isExternalPackage } from '@ms-cloudpack/path-utilities';\nimport path from 'path';\nimport { isValidBundleEntry } from './isValidBundleEntry.js';\nimport { toNormalizedEntryKey } from './toNormalizedEntryKey.js';\n\n/**\n * Gets the entries map for a given package. An entries map is different from an exports map in that\n * the keys are relative paths to where the output should live, rather than how the entry is imported.\n * The data structure is used for bundler config; not for resolution of imports.\n */\nexport async function getEntriesMapFromPackage(\n options: {\n inputPath: string;\n },\n context: {\n packages: PackageDefinitionsCache;\n config: Pick<CloudpackConfig, 'features'>;\n },\n): Promise<Record<string, string>> {\n const { inputPath } = options;\n const isInternal = !isExternalPackage(inputPath);\n const exportsMap = await getExportsMap({ packagePath: inputPath }, context);\n const flattenedMap = flattenExportsMap(exportsMap);\n let sourceExportsMap: Record<string, string>;\n\n // The flattened map values tell us what physical files will show up in the import map on the page. We use these\n // as the keys for the entries map, which results in physical file output from the bundler.\n\n // For internal packages, we want the values (the inputs to the each entry) to use source paths if available. To\n // get these, we can either derive from exports map \"source\" entries, or if those are not available, we can attempt\n // to derive source paths from intermediate paths.\n\n if (isInternal) {\n sourceExportsMap = flattenExportsMap(exportsMap, {\n // Allow traversing into 'browser' environment conditions to find 'source' conditions\n conditions: ['browser', 'source'],\n requiredConditions: ['source'],\n });\n\n for (const [key, value] of Object.entries(flattenedMap)) {\n if (!sourceExportsMap[key]) {\n sourceExportsMap[key] = intermediateToSourcePath(value, inputPath) || value;\n }\n }\n }\n\n return Object.fromEntries(\n Object.entries(flattenedMap)\n .filter(([, value]) => isValidBundleEntry(value))\n .map(([key, value]) => [\n toNormalizedEntryKey(value),\n toNormalizedRelativePath(inputPath, sourceExportsMap?.[key] || value),\n ]),\n );\n}\n\nfunction toNormalizedRelativePath(inputPath: string, entry: string): string {\n if (path.isAbsolute(entry)) {\n entry = path.relative(inputPath, entry);\n }\n\n return normalizeRelativePath(entry);\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ms-cloudpack/bundler",
3
- "version": "0.23.33",
3
+ "version": "0.23.35",
4
4
  "description": "An abstraction to bundle source code.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -14,16 +14,16 @@
14
14
  }
15
15
  },
16
16
  "dependencies": {
17
- "@ms-cloudpack/bundler-ori": "^0.2.15",
18
- "@ms-cloudpack/bundler-rollup": "^0.2.9",
19
- "@ms-cloudpack/bundler-rspack": "^0.2.20",
20
- "@ms-cloudpack/bundler-webpack": "^0.2.17",
21
- "@ms-cloudpack/common-types": "^0.24.3",
22
- "@ms-cloudpack/config": "^0.33.9",
17
+ "@ms-cloudpack/bundler-ori": "^0.2.17",
18
+ "@ms-cloudpack/bundler-rollup": "^0.2.11",
19
+ "@ms-cloudpack/bundler-rspack": "^0.2.22",
20
+ "@ms-cloudpack/bundler-webpack": "^0.2.19",
21
+ "@ms-cloudpack/common-types": "^0.24.4",
22
+ "@ms-cloudpack/config": "^0.33.11",
23
23
  "@ms-cloudpack/json-utilities": "^0.1.10",
24
- "@ms-cloudpack/package-utilities": "^11.2.0",
24
+ "@ms-cloudpack/package-utilities": "^11.3.1",
25
25
  "@ms-cloudpack/path-string-parsing": "^1.2.6",
26
- "@ms-cloudpack/path-utilities": "^2.8.4"
26
+ "@ms-cloudpack/path-utilities": "^3.0.1"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@ms-cloudpack/eslint-plugin-internal": "^0.0.1",