@ms-cloudpack/bundler 0.18.3 → 0.18.5

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.js CHANGED
@@ -1,5 +1,4 @@
1
1
  import { chooseBundler } from './chooseBundler.js';
2
- import {} from '@ms-cloudpack/config-types';
3
2
  import { writeJson } from '@ms-cloudpack/json-utilities';
4
3
  import path from 'path';
5
4
  import { detectModuleType } from '@ms-cloudpack/package-utilities';
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;AACnD,OAAO,EAAwB,MAAM,4BAA4B,CAAC;AAElE,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,IAAI,CAAC;YAChB,IAAI,EAAE,eAAe;YACrB,IAAI,EAAE,mCAAmC;SAC1C,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,gBAAgB;YACtB,IAAI,EAAE,8BAA8B;SACrC,CAAC,CAAC;IACL,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,C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Aa,GAAG,SAAS,EAAE,GAAG,OAAO,CAAC;IAE3F,MAAM,OAAO,CAAC,GAAG,CAAC;QAChB,IAAI,CAAC,MAAM,EAAE,MAAM,IAAI,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,GAAG,WAAW,cAAc,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC;QACrG,QAAQ,IAAI,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,GAAG,WAAW,aAAa,CAAC,EAAE,QAAQ,CAAC;QACtF,SAAS,IAAI,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,GAAG,WAAW,cAAc,CAAC,EAAE,SAAS,CAAC;KAC1F,CAAC,CAAC;IAEH,MAAM,MAAM,GAAiB,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,CAAC;IAE1E,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 CloudpackConfig } from '@ms-cloudpack/config-types';\nimport type { BundleMessage, BundleOptions, BundleResult, BundlerPluginResult } from '@ms-cloudpack/bundler-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 type: 'invalid-input',\n text: 'No input path provided to bundle.',\n });\n } else if (!path.isAbsolute(options.inputPath)) {\n configErrors.push({\n type: 'input-relative',\n text: 'Input path must be absolute.',\n });\n }\n\n if (!Object.keys(options.entries || {}).length) {\n configErrors.push({\n type: 'no-entries',\n text: `No entries provided to bundle at inputPath \"${options.inputPath}\".`,\n });\n } else if (Object.entries(options.entries).some(([k, v]) => path.isAbsolute(k) || path.isAbsolute(v))) {\n configErrors.push({\n type: 'entry-absolute',\n text: `Entry paths must be relative.`,\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 firstSourceEntry = Object.values(options.entries).find((fileName) =>\n sourceExtensions.includes(path.extname(fileName)),\n );\n const moduleType = firstSourceEntry\n ? await detectModuleType(path.resolve(options.inputPath, firstSourceEntry))\n : undefined;\n const isTypescript = firstSourceEntry ? typescriptExtensions.includes(path.extname(firstSourceEntry)) : false;\n\n const bundler = await chooseBundler({ bundlerType: options.bundlerType, moduleType, isTypescript });\n const bundleFunc = () => bundler.bundle(options, { ...context, moduleType });\n return bundleInternal(bundleFunc, { ...options, bundlerName: 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<BundlerPluginResult>,\n options: BundleOptions & { bundlerName: string },\n): Promise<BundleResult> {\n let pluginResult: BundlerPluginResult | undefined = undefined;\n\n try {\n pluginResult = await pluginBundle();\n } catch (e) {\n const errorMessage: BundleMessage = { text: `Exception while bundling: ${e}` };\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 { bundlerName, inputPath, entries, outputPath: logOutputPath = inputPath } = options;\n\n await Promise.all([\n rest.errors?.length && writeJson(path.join(logOutputPath, `${bundlerName}-errors.json`), rest.errors),\n rawInput && writeJson(path.join(logOutputPath, `${bundlerName}-input.json`), rawInput),\n rawOutput && writeJson(path.join(logOutputPath, `${bundlerName}-output.json`), rawOutput),\n ]);\n\n const result: BundleResult = { bundlerName, inputPath, entries, ...rest };\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;AAGnD,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,IAAI,CAAC;YAChB,IAAI,EAAE,eAAe;YACrB,IAAI,EAAE,mCAAmC;SAC1C,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,gBAAgB;YACtB,IAAI,EAAE,8BAA8B;SACrC,CAAC,CAAC;IACL,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC;QAC/C,YAAY,CAAC,IAAI,CAAC;YAChB,IAAI,EAAE,YAA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,MAAM,IAAI,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,GAAG,WAAW,cAAc,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC;QACrG,QAAQ,IAAI,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,GAAG,WAAW,aAAa,CAAC,EAAE,QAAQ,CAAC;QACtF,SAAS,IAAI,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,GAAG,WAAW,cAAc,CAAC,EAAE,SAAS,CAAC;KAC1F,CAAC,CAAC;IAEH,MAAM,MAAM,GAAiB,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,CAAC;IAE1E,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 CloudpackConfig } from '@ms-cloudpack/config-types';\nimport type { BundleMessage, BundleOptions, BundleResult, BundlerPluginResult } from '@ms-cloudpack/bundler-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 type: 'invalid-input',\n text: 'No input path provided to bundle.',\n });\n } else if (!path.isAbsolute(options.inputPath)) {\n configErrors.push({\n type: 'input-relative',\n text: 'Input path must be absolute.',\n });\n }\n\n if (!Object.keys(options.entries || {}).length) {\n configErrors.push({\n type: 'no-entries',\n text: `No entries provided to bundle at inputPath \"${options.inputPath}\".`,\n });\n } else if (Object.entries(options.entries).some(([k, v]) => path.isAbsolute(k) || path.isAbsolute(v))) {\n configErrors.push({\n type: 'entry-absolute',\n text: `Entry paths must be relative.`,\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 firstSourceEntry = Object.values(options.entries).find((fileName) =>\n sourceExtensions.includes(path.extname(fileName)),\n );\n const moduleType = firstSourceEntry\n ? await detectModuleType(path.resolve(options.inputPath, firstSourceEntry))\n : undefined;\n const isTypescript = firstSourceEntry ? typescriptExtensions.includes(path.extname(firstSourceEntry)) : false;\n\n const bundler = await chooseBundler({ bundlerType: options.bundlerType, moduleType, isTypescript });\n const bundleFunc = () => bundler.bundle(options, { ...context, moduleType });\n return bundleInternal(bundleFunc, { ...options, bundlerName: 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<BundlerPluginResult>,\n options: BundleOptions & { bundlerName: string },\n): Promise<BundleResult> {\n let pluginResult: BundlerPluginResult | undefined = undefined;\n\n try {\n pluginResult = await pluginBundle();\n } catch (e) {\n const errorMessage: BundleMessage = { text: `Exception while bundling: ${e}` };\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 { bundlerName, inputPath, entries, outputPath: logOutputPath = inputPath } = options;\n\n await Promise.all([\n rest.errors?.length && writeJson(path.join(logOutputPath, `${bundlerName}-errors.json`), rest.errors),\n rawInput && writeJson(path.join(logOutputPath, `${bundlerName}-input.json`), rawInput),\n rawOutput && writeJson(path.join(logOutputPath, `${bundlerName}-output.json`), rawOutput),\n ]);\n\n const result: BundleResult = { bundlerName, inputPath, entries, ...rest };\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,4 +1,3 @@
1
- import {} from '@ms-cloudpack/config-types';
2
1
  import { flattenExportsMap, getExportsMap, isExternalPackage } from '@ms-cloudpack/package-utilities';
3
2
  import { normalizeRelativePath } from '@ms-cloudpack/path-string-parsing';
4
3
  import { intermediateToSourcePath, sourceExtensions } from '@ms-cloudpack/path-utilities';
@@ -1 +1 @@
1
- {"version":3,"file":"getEntriesMapFromPackage.js","sourceRoot":"","sources":["../src/getEntriesMapFromPackage.ts"],"names":[],"mappings":"AACA,OAAO,EAAwB,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACtG,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAC1F,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D;;;;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;IAE3F,gHAAgH;IAChH,mHAA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AAI,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 { PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';\nimport { type CloudpackConfig } from '@ms-cloudpack/config-types';\nimport { flattenExportsMap, getExportsMap, isExternalPackage } from '@ms-cloudpack/package-utilities';\nimport { normalizeRelativePath } from '@ms-cloudpack/path-string-parsing';\nimport { intermediateToSourcePath, sourceExtensions } from '@ms-cloudpack/path-utilities';\nimport path from 'path';\nimport { isValidBundleEntry } from './isValidBundleEntry.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: CloudpackConfig;\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, { conditions: ['source'], requiredConditions: ['source'] });\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\n/**\n * When we derive keys, we want to preserve unknown script extensions. For others, remove them as the bundler\n * will add back `'.js'` for us in the output.\n */\nfunction toNormalizedEntryKey(entry: string): string {\n const extension = path.extname(entry);\n if (sourceExtensions.includes(extension)) {\n return entry.slice(0, -extension.length);\n }\n\n return entry;\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.js","sourceRoot":"","sources":["../src/getEntriesMapFromPackage.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACtG,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAC1F,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D;;;;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;IAE3F,gHAAgH;IAChH,mHAAmH;IACnH,kDAAkD;IA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U,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 { PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';\nimport { type CloudpackConfig } from '@ms-cloudpack/config-types';\nimport { flattenExportsMap, getExportsMap, isExternalPackage } from '@ms-cloudpack/package-utilities';\nimport { normalizeRelativePath } from '@ms-cloudpack/path-string-parsing';\nimport { intermediateToSourcePath, sourceExtensions } from '@ms-cloudpack/path-utilities';\nimport path from 'path';\nimport { isValidBundleEntry } from './isValidBundleEntry.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: CloudpackConfig;\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, { conditions: ['source'], requiredConditions: ['source'] });\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\n/**\n * When we derive keys, we want to preserve unknown script extensions. For others, remove them as the bundler\n * will add back `'.js'` for us in the output.\n */\nfunction toNormalizedEntryKey(entry: string): string {\n const extension = path.extname(entry);\n if (sourceExtensions.includes(extension)) {\n return entry.slice(0, -extension.length);\n }\n\n return entry;\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.18.3",
3
+ "version": "0.18.5",
4
4
  "description": "An abstraction to bundle source code.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -14,14 +14,14 @@
14
14
  }
15
15
  },
16
16
  "dependencies": {
17
+ "@ms-cloudpack/bundler-plugin-ori": "^0.15.5",
18
+ "@ms-cloudpack/bundler-plugin-rollup": "^0.12.1",
19
+ "@ms-cloudpack/bundler-plugin-webpack": "^0.2.5",
20
+ "@ms-cloudpack/bundler-types": "^0.25.2",
21
+ "@ms-cloudpack/config": "^0.17.36",
22
+ "@ms-cloudpack/config-types": "^0.7.0",
17
23
  "@ms-cloudpack/json-utilities": "^0.1.4",
18
- "@ms-cloudpack/bundler-plugin-ori": "^0.15.3",
19
- "@ms-cloudpack/bundler-plugin-rollup": "^0.11.3",
20
- "@ms-cloudpack/bundler-plugin-webpack": "^0.2.3",
21
- "@ms-cloudpack/bundler-types": "^0.25.1",
22
- "@ms-cloudpack/config": "^0.17.35",
23
- "@ms-cloudpack/config-types": "^0.6.0",
24
- "@ms-cloudpack/package-utilities": "^6.0.1",
24
+ "@ms-cloudpack/package-utilities": "^6.0.2",
25
25
  "@ms-cloudpack/path-string-parsing": "^1.2.1",
26
26
  "@ms-cloudpack/path-utilities": "^2.6.1"
27
27
  },