@ms-cloudpack/bundler-ori 0.2.22 → 0.2.24

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":"buildWithRetries.d.ts","sourceRoot":"","sources":["../src/buildWithRetries.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAS,KAAK,WAAW,IAAI,cAAc,EAAE,MAAM,UAAU,CAAC;AAuBrE;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE;IACvC,2BAA2B;IAC3B,QAAQ,EAAE,eAAe,CAAC;IAC1B,0GAA0G;IAC1G,SAAS,EAAE,MAAM,CAAC;CACnB,GAAG,OAAO,CAAC,cAAc,CAAC,CAoC1B"}
1
+ {"version":3,"file":"buildWithRetries.d.ts","sourceRoot":"","sources":["../src/buildWithRetries.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAS,KAAK,WAAW,IAAI,cAAc,EAAE,MAAM,UAAU,CAAC;AAwBrE;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE;IACvC,2BAA2B;IAC3B,QAAQ,EAAE,eAAe,CAAC;IAC1B,0GAA0G;IAC1G,SAAS,EAAE,MAAM,CAAC;CACnB,GAAG,OAAO,CAAC,cAAc,CAAC,CAoC1B"}
@@ -11,7 +11,8 @@ const intermittentErrorRetryPolicy = {
11
11
  handle: (error) => error instanceof Error &&
12
12
  (error.message.includes('room is closed') ||
13
13
  error.message.includes('failed marshalling message') ||
14
- error.message.includes('ori api-service')),
14
+ error.message.includes('ori api-service') ||
15
+ error.message.includes('Connection closed')),
15
16
  };
16
17
  /** Retry 1 time (2 in total) if a timeout error was thrown by ori */
17
18
  const timeoutRetryPolicy = {
@@ -1 +1 @@
1
- {"version":3,"file":"buildWithRetries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ACf,UAAU,GAAG,IAAI,CAAC;QACpB,CAAC;aAAM,IAAI,YAAY,CAAC,MAAM,KAAK,4BAA4B,EAAE,CAAC;YAChE,OAAO,CAAC,IAAI,CACV,4BAA4B,SAAS,WAAW,YAAY,CAAC,YAAY,IAAI,YAAY,CAAC,MAAM,CAAC,UAAU,IAAI;gBAC7G,mCAAoC,YAAY,CAAC,SAAmB,CAAC,OAAO,EAAE,CACjF,CAAC;QACJ,CAAC;QAED,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,EAAE,GAAG,QAAQ,EAAE,yBAAyB,EAAE,SAAS,EAAE,CAAC,CAAC;QAElF,IAAI,UAAU,EAAE,CAAC;YACf,wFAAwF;YACxF,kFAAkF;YAClF,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;gBACnB,IAAI,EACF,wDAAwD,SAAS,MAAM;oBACvE,2GAA2G,SAAS,SAAS;oBAC7H,gEAAgE;aAClB,CAAC,CAAC;QACtD,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { RetryManager, type RetryPolicy } from '@ms-cloudpack/retry';\nimport type { OriBuildOptions } from './getOriOptions.js';\nimport { build, type BuildResult as OriBuildResult } from 'oribuild';\n\n/**\n * Retry 2 times (3 in total) if the error message contains\n * 'room is closed', 'failed marshalling message' or 'ori api-service'.\n * The first two are intermittent errors which may be caused by race conditions.\n * The last one is a known error message from the ori API service.\n */\nconst intermittentErrorRetryPolicy: RetryPolicy = {\n maxRetries: 2,\n handle: (error) =>\n error instanceof Error &&\n (error.message.includes('room is closed') ||\n error.message.includes('failed marshalling message') ||\n error.message.includes('ori api-service')),\n};\n\n/** Retry 1 time (2 in total) if a timeout error was thrown by ori */\nconst timeoutRetryPolicy: RetryPolicy = {\n maxRetries: 1,\n handle: (error) => error instanceof Error && error.message.includes('within the timeout window'),\n};\n\n/**\n * Call ori `build()` with retries. This is a separate function for testing of retry logic.\n */\nexport function buildWithRetries(params: {\n /** Params passed to ori */\n oriInput: OriBuildOptions;\n /** Just used to identify the bundled package in log messages (ori options don't contain this raw path) */\n inputPath: string;\n}): Promise<OriBuildResult> {\n const { oriInput, inputPath } = params;\n const retryManager = new RetryManager([intermittentErrorRetryPolicy, timeoutRetryPolicy]);\n\n let timeoutMs = oriInput.buildAcknowledgeTimeoutMs;\n let hadTimeout = false;\n\n return retryManager.retry(async (retryContext) => {\n if (retryContext.policy === timeoutRetryPolicy) {\n console.warn(\n `ori build for ${inputPath} timed out after ${timeoutMs}ms. Will retry with ${timeoutMs * 2}ms timeout.`,\n );\n timeoutMs *= 2;\n hadTimeout = true;\n } else if (retryContext.policy === intermittentErrorRetryPolicy) {\n console.warn(\n `Will retry ori build for ${inputPath} (retry ${retryContext.retryAttempt}/${retryContext.policy.maxRetries}) ` +\n `after known intermittent error: ${(retryContext.lastError as Error).message}`,\n );\n }\n\n const result = await build({ ...oriInput, buildAcknowledgeTimeoutMs: timeoutMs });\n\n if (hadTimeout) {\n // Include a warning in the output recommending increasing the timeout for this package.\n // The warning is more visible this way than if it was only logged to the console.\n result.warnings.push({\n text:\n `Build succeeded on retry after increasing timeout to ${timeoutMs}ms. ` +\n `You may want to add cloudpack packageSettings with \\`{ \"bundlerOptions\": { \"buildAcknowledgeTimeoutMs\": ${timeoutMs} } }\\` ` +\n 'to use a longer timeout for this package on the first attempt.',\n } as unknown as OriBuildResult['warnings'][number]);\n }\n\n return result;\n });\n}\n"]}
1
+ {"version":3,"file":"buildWithRetries.js","sourceRoot":"","sources":["../src/buildWithRetries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAoB,MAAM,qBAAqB,CAAC;AAErE,OAAO,EAAE,KAAK,EAAsC,MAAM,UAAU,CAAC;AAErE;;;;;GAKG;AACH,MAAM,4BAA4B,GAAgB;IAChD,UAAU,EAAE,CAAC;IACb,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAChB,KAAK,YAAY,KAAK;QACtB,CAAC,KAAK,CA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OAAO,EAAE,CACjF,CAAC;QACJ,CAAC;QAED,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,EAAE,GAAG,QAAQ,EAAE,yBAAyB,EAAE,SAAS,EAAE,CAAC,CAAC;QAElF,IAAI,UAAU,EAAE,CAAC;YACf,wFAAwF;YACxF,kFAAkF;YAClF,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;gBACnB,IAAI,EACF,wDAAwD,SAAS,MAAM;oBACvE,2GAA2G,SAAS,SAAS;oBAC7H,gEAAgE;aAClB,CAAC,CAAC;QACtD,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { RetryManager, type RetryPolicy } from '@ms-cloudpack/retry';\nimport type { OriBuildOptions } from './getOriOptions.js';\nimport { build, type BuildResult as OriBuildResult } from 'oribuild';\n\n/**\n * Retry 2 times (3 in total) if the error message contains\n * 'room is closed', 'failed marshalling message' or 'ori api-service'.\n * The first two are intermittent errors which may be caused by race conditions.\n * The last one is a known error message from the ori API service.\n */\nconst intermittentErrorRetryPolicy: RetryPolicy = {\n maxRetries: 2,\n handle: (error) =>\n error instanceof Error &&\n (error.message.includes('room is closed') ||\n error.message.includes('failed marshalling message') ||\n error.message.includes('ori api-service') ||\n error.message.includes('Connection closed')),\n};\n\n/** Retry 1 time (2 in total) if a timeout error was thrown by ori */\nconst timeoutRetryPolicy: RetryPolicy = {\n maxRetries: 1,\n handle: (error) => error instanceof Error && error.message.includes('within the timeout window'),\n};\n\n/**\n * Call ori `build()` with retries. This is a separate function for testing of retry logic.\n */\nexport function buildWithRetries(params: {\n /** Params passed to ori */\n oriInput: OriBuildOptions;\n /** Just used to identify the bundled package in log messages (ori options don't contain this raw path) */\n inputPath: string;\n}): Promise<OriBuildResult> {\n const { oriInput, inputPath } = params;\n const retryManager = new RetryManager([intermittentErrorRetryPolicy, timeoutRetryPolicy]);\n\n let timeoutMs = oriInput.buildAcknowledgeTimeoutMs;\n let hadTimeout = false;\n\n return retryManager.retry(async (retryContext) => {\n if (retryContext.policy === timeoutRetryPolicy) {\n console.warn(\n `ori build for ${inputPath} timed out after ${timeoutMs}ms. Will retry with ${timeoutMs * 2}ms timeout.`,\n );\n timeoutMs *= 2;\n hadTimeout = true;\n } else if (retryContext.policy === intermittentErrorRetryPolicy) {\n console.warn(\n `Will retry ori build for ${inputPath} (retry ${retryContext.retryAttempt}/${retryContext.policy.maxRetries}) ` +\n `after known intermittent error: ${(retryContext.lastError as Error).message}`,\n );\n }\n\n const result = await build({ ...oriInput, buildAcknowledgeTimeoutMs: timeoutMs });\n\n if (hadTimeout) {\n // Include a warning in the output recommending increasing the timeout for this package.\n // The warning is more visible this way than if it was only logged to the console.\n result.warnings.push({\n text:\n `Build succeeded on retry after increasing timeout to ${timeoutMs}ms. ` +\n `You may want to add cloudpack packageSettings with \\`{ \"bundlerOptions\": { \"buildAcknowledgeTimeoutMs\": ${timeoutMs} } }\\` ` +\n 'to use a longer timeout for this package on the first attempt.',\n } as unknown as OriBuildResult['warnings'][number]);\n }\n\n return result;\n });\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"getOriOptions.d.ts","sourceRoot":"","sources":["../src/getOriOptions.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAA8B,MAAM,4BAA4B,CAAC;AAK3G,OAAO,KAAK,EAAE,YAAY,EAAyC,MAAM,UAAU,CAAC;AAIpF,wFAAwF;AACxF,MAAM,MAAM,eAAe,GAAG,YAAY,GACxC,QAAQ,CAAC,IAAI,CAAC,YAAY,EAAE,eAAe,GAAG,2BAA2B,CAAC,CAAC,CAAC;AAmB9E;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAE1D;AAiJD;;GAEG;AACH,wBAAsB,aAAa,CACjC,OAAO,EAAE,aAAa,EACtB,OAAO,EAAE,IAAI,CAAC,aAAa,EAAE,QAAQ,CAAC,GACrC,OAAO,CAAC,eAAe,CAAC,CAqB1B"}
1
+ {"version":3,"file":"getOriOptions.d.ts","sourceRoot":"","sources":["../src/getOriOptions.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAA8B,MAAM,4BAA4B,CAAC;AAK3G,OAAO,KAAK,EAAE,YAAY,EAAyC,MAAM,UAAU,CAAC;AAIpF,wFAAwF;AACxF,MAAM,MAAM,eAAe,GAAG,YAAY,GACxC,QAAQ,CAAC,IAAI,CAAC,YAAY,EAAE,eAAe,GAAG,2BAA2B,CAAC,CAAC,CAAC;AAmB9E;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAE1D;AAqJD;;GAEG;AACH,wBAAsB,aAAa,CACjC,OAAO,EAAE,aAAa,EACtB,OAAO,EAAE,IAAI,CAAC,aAAa,EAAE,QAAQ,CAAC,GACrC,OAAO,CAAC,eAAe,CAAC,CAqB1B"}
@@ -52,7 +52,7 @@ function buildDynamicImportsFilter(dynamicImports) {
52
52
  * @returns The options for the ori bundler, without capabilities applied.
53
53
  */
54
54
  function getOriOptionsInternal(options, context) {
55
- const { inputPath, sourcemap, entries, outputPath, external = [], inlined = [], minify, incremental, dynamicImports, } = options;
55
+ const { inputPath, sourcemap, entries, outputPath, external = [], inlined = [], minify, incremental, dynamicImports, bundlerCapabilities, } = options;
56
56
  const { config } = context;
57
57
  const { features, mode } = config;
58
58
  const bundlerOptions = (options.bundlerOptions || {});
@@ -61,7 +61,10 @@ function getOriOptionsInternal(options, context) {
61
61
  // Normalize outputPath to be absolute (the passed value can either already be absolute, or be
62
62
  // relative to inputPath). Or if it's not specified, use inputPath.
63
63
  const finalOutputPath = outputPath ? path.resolve(inputPath, outputPath) : inputPath;
64
- const resolveWebExtensions = Boolean(features?.resolveWebExtensions);
64
+ // Enable this if the capability is not set but the feature is to continue supporting the deprecated feature.
65
+ const resolveWebExtensions =
66
+ // eslint-disable-next-line etc/no-deprecated
67
+ !bundlerCapabilities?.['resolve-web-extensions'] && Boolean(features?.resolveWebExtensions);
65
68
  const resolveExtensions = resolveWebExtensions
66
69
  ? ['.web.tsx', '.web.ts', '.web.jsx', '.web.js', ...defaultResolveExtensions]
67
70
  : defaultResolveExtensions;
@@ -1 +1 @@
1
- {"version":3,"file":"getOriOptions.js","sourceRoot":"","sources":["../src/getOriOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAE7F,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,qBAAqB,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;AACjF,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAExC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAMvD,MAAM,YAAY,GAAG,CAAC,GAAG,cAAc,EAAE,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,CAAC;AAI1F,MAAM,cAAc,GAAuB;IACzC;QACE,MAAM,EAAE,aAAa;QACrB,aAAa,EAAE,KAAK;KACrB;IACD;QACE,MAAM,EAAE,MAAM;QACd,aAAa,EAAE,KAAK;KACrB;CACF,CAAC;AAEF,MAAM,wBAAwB,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;AAEjF;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAAC,SAAiB;IAChD,OAAO,eAAe,CAAC,SAAS,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC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BAAiB,EAAE,kBAAkB,CAAC,cAAc,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;KAC3F,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,OAAsB,EACtB,OAAsC;IAEtC,MAAM,cAAc,GAAG,CAAC,OAAO,CAAC,cAAc,IAAI,EAAE,CAA6B,CAAC;IAElF,MAAM,mBAAmB,GAA+B;QACtD,sDAAsD;QACtD,cAAc,EAAE;YACd,sFAAsF;YACtF,UAAU,EAAE,qBAAqB,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,cAAc,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC;SACjF;QACD,GAAG,OAAO,CAAC,mBAAmB;KAC/B,CAAC;IAEF,MAAM,KAAK,GAAG,MAAM,mBAAmB,CAAC;QACtC,WAAW,EAAE,KAAK;QAClB,UAAU,EAAE,qBAAqB,CAAC,OAAO,EAAE,OAAO,CAAC;QACnD,0BAA0B,EAAE,mBAAmB;QAC/C,oBAAoB,EAAE,eAAe;QACrC,2BAA2B,EAAE,OAAO,CAAC,MAAM,CAAC,2BAA2B;KACxE,CAAC,CAAC;IAEH,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import { processCapabilities } from '@ms-cloudpack/bundler-capabilities';\nimport { base64AssetExtensions, defaultTargetSyntax } from '@ms-cloudpack/bundler-utilities';\nimport type { BundleContext, BundleOptions, BundlerCapabilitiesOptions } from '@ms-cloudpack/common-types';\nimport { mergeArrayDefaults } from '@ms-cloudpack/package-utilities';\nimport { normalizeRelativePath, slash } from '@ms-cloudpack/path-string-parsing';\nimport { findProjectRoot } from '@ms-cloudpack/path-utilities';\nimport { builtinModules } from 'module';\nimport type { BuildOptions, PluginJSONConfig as _PluginJSONConfig } from 'oribuild';\nimport path from 'path';\nimport { oriCapabilities } from './oriCapabilities.js';\n\n/** Ori options with important properties always set by cloudpack marked as required. */\nexport type OriBuildOptions = BuildOptions &\n Required<Pick<BuildOptions, 'absWorkingDir' | 'buildAcknowledgeTimeoutMs'>>;\n\nconst nodeBuiltins = [...builtinModules, ...builtinModules.map((name) => `node:${name}`)];\n\n// The type from ori is now missing the extra properties\ntype PluginJSONConfig = _PluginJSONConfig & Record<string, string | boolean>;\nconst defaultPlugins: PluginJSONConfig[] = [\n {\n plugin: 'css-modules',\n prefixClasses: false,\n },\n {\n plugin: 'sass',\n prefixClasses: false,\n },\n];\n\nconst defaultResolveExtensions = ['.tsx', '.ts', '.jsx', '.js', '.css', '.json'];\n\n/**\n * The intended use of `absWorkingDir` in esbuild is to resolve relative paths from options.\n * However, ori also uses `absWorkingDir` as the virtual FS root for module resolution in plugins.\n * This means if `inputPath` is an individual package in a monorepo, ori won't be able to resolve\n * scss `@import`s from other packages (which are often in `node_modules` at the git root).\n * As a workaround, we use the git root (if available) as `absWorkingDir` and adjust all other paths.\n * https://github.com/microsoft/cloudpack/issues/1174\n */\nexport function getAbsWorkingDir(inputPath: string): string {\n return findProjectRoot(inputPath, { noPackageRoot: true }) || inputPath;\n}\n\n/**\n * Join two relative paths, with forward slashes and removing any extra segments.\n */\nfunction joinRelativePaths(p1: string, p2: string): string {\n return normalizeRelativePath(path.normalize(path.join(p1, p2)));\n}\n\n/**\n * Get a slash-normalized relative path from the calculated `absWorkingDir` to the item.\n */\nfunction getRelativePath(absWorkingDir: string, absItemPath: string): string {\n return slash(path.relative(absWorkingDir, absItemPath));\n}\n\nfunction buildDynamicImportsFilter(dynamicImports: string[]): string {\n // Using the basename works good enough for now, we might want to include the path in the future,\n // but we would need to make sure it matches successfully in the dynamic import plugin.\n const joined = dynamicImports.map((s) => path.basename(s)).join('|');\n // Add the default dynamic import extensions to the list of dynamic imports.\n return `(${joined}|.dynamic.(js|mjs|ts|tsx))$`;\n}\n\n/**\n * @returns The options for the ori bundler, without capabilities applied.\n */\nfunction getOriOptionsInternal(options: BundleOptions, context: Pick<BundleContext, 'config'>): OriBuildOptions {\n const {\n inputPath,\n sourcemap,\n entries,\n outputPath,\n external = [],\n inlined = [],\n minify,\n incremental,\n dynamicImports,\n } = options;\n const { config } = context;\n const { features, mode } = config;\n\n const bundlerOptions = (options.bundlerOptions || {}) as Partial<OriBuildOptions>;\n\n const absWorkingDir = getAbsWorkingDir(inputPath);\n const relInputPath = getRelativePath(absWorkingDir, inputPath);\n\n // Normalize outputPath to be absolute (the passed value can either already be absolute, or be\n // relative to inputPath). Or if it's not specified, use inputPath.\n const finalOutputPath = outputPath ? path.resolve(inputPath, outputPath) : inputPath;\n\n const resolveWebExtensions = Boolean(features?.resolveWebExtensions);\n const resolveExtensions = resolveWebExtensions\n ? ['.web.tsx', '.web.ts', '.web.jsx', '.web.js', ...defaultResolveExtensions]\n : defaultResolveExtensions;\n\n const plugins = mergeArrayDefaults(bundlerOptions.plugins, defaultPlugins) as PluginJSONConfig[];\n if (dynamicImports?.length) {\n plugins.push({\n plugin: 'dynamic-imports',\n filter: buildDynamicImportsFilter(dynamicImports),\n });\n }\n\n // Translate options into ori config.\n return {\n splitting: true,\n serviceOptions: {},\n buildAcknowledgeTimeoutMs: 10000,\n sourcemap: sourcemap ? 'linked' : 'none',\n // Default to es2022 so top-level await works\n target: defaultTargetSyntax,\n\n // bundlerOptions takes precedence over the defaults above\n ...bundlerOptions,\n\n // BundleOptions values take precedence over bundlerOptions\n incremental,\n minify,\n\n // Critical options that shouldn't be overridden\n metafile: true,\n write: true,\n\n // Calculated or manually merged options\n absWorkingDir,\n\n entryPoints: Object.fromEntries(\n Object.entries(entries).map(([outFile, inFile]) => [\n // outFile is relative to outputPath, which will still be correct because we updated outputPath\n outFile,\n // Either esbuild or ori appears to require entries to be prefixed with ./\n joinRelativePaths(relInputPath, inFile),\n ]),\n ),\n\n outdir: finalOutputPath,\n\n // outbase is probably only relevant for an array of entry point paths, not the full entryPoints\n // mapping (output path to input path) that ori uses, but go ahead and correct it if provided\n outbase: typeof bundlerOptions.outbase === 'string' ? path.resolve(inputPath, bundlerOptions.outbase) : undefined,\n\n // Enabling this automatically marks all import paths that look like npm packages as external.\n packages: !inlined.length && mode === 'library' ? 'external' : undefined,\n\n // These can be either package names or paths/globs (see https://esbuild.github.io/api/#external).\n // For any paths starting with a dot or slash, add relInputPath to the start.\n // TODO: Improve it so we always external all known and unknown packages by default, and only inline the ones we know we need.\n external: inlined.length\n ? external\n .filter((e) => !inlined.includes(e))\n .map((e) => {\n if (e[0] === '/') {\n return `/${relInputPath}${e}`;\n }\n\n if (e[0] === '.') {\n return joinRelativePaths(relInputPath, e);\n }\n\n return e;\n })\n .concat(nodeBuiltins)\n : undefined,\n\n define: {\n global: 'window',\n 'process.env.NODE_ENV': minify ? `\"production\"` : '\"development\"',\n ...bundlerOptions.define,\n },\n\n loader: {\n // By default, ori handles graphql files as data-urls. This is specific to the way graphql is\n // set up in the primary repo ori was designed for, and doesn't apply to most projects.\n // eslint-disable-next-line -- 'none' is valid but missing from types\n '.graphql': 'none' as any,\n ...bundlerOptions.loader,\n },\n\n plugins,\n\n resolveExtensions: mergeArrayDefaults(bundlerOptions.resolveExtensions, resolveExtensions),\n };\n}\n\n/**\n * @returns The options for the ori bundler, with capabilities applied.\n */\nexport async function getOriOptions(\n options: BundleOptions,\n context: Pick<BundleContext, 'config'>,\n): Promise<OriBuildOptions> {\n const bundlerOptions = (options.bundlerOptions || {}) as Partial<OriBuildOptions>;\n\n const capabilitiesOptions: BundlerCapabilitiesOptions = {\n // Enable asset inlining for the specified extensions.\n 'asset-inline': {\n // Filter out the default asset extensions that are already handled by bundlerOptions.\n extensions: base64AssetExtensions.filter((ext) => !bundlerOptions.loader?.[ext]),\n },\n ...options.bundlerCapabilities,\n };\n\n const input = await processCapabilities({\n bundlerName: 'ori',\n baseConfig: getOriOptionsInternal(options, context),\n bundlerCapabilitiesOptions: capabilitiesOptions,\n internalCapabilities: oriCapabilities,\n bundlerCapabilitiesRegistry: context.config.bundlerCapabilitiesRegistry,\n });\n\n return input;\n}\n"]}
1
+ {"version":3,"file":"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M,CAAC,KAAK,UAAU,aAAa,CACjC,OAAsB,EACtB,OAAsC;IAEtC,MAAM,cAAc,GAAG,CAAC,OAAO,CAAC,cAAc,IAAI,EAAE,CAA6B,CAAC;IAElF,MAAM,mBAAmB,GAA+B;QACtD,sDAAsD;QACtD,cAAc,EAAE;YACd,sFAAsF;YACtF,UAAU,EAAE,qBAAqB,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,cAAc,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC;SACjF;QACD,GAAG,OAAO,CAAC,mBAAmB;KAC/B,CAAC;IAEF,MAAM,KAAK,GAAG,MAAM,mBAAmB,CAAC;QACtC,WAAW,EAAE,KAAK;QAClB,UAAU,EAAE,qBAAqB,CAAC,OAAO,EAAE,OAAO,CAAC;QACnD,0BAA0B,EAAE,mBAAmB;QAC/C,oBAAoB,EAAE,eAAe;QACrC,2BAA2B,EAAE,OAAO,CAAC,MAAM,CAAC,2BAA2B;KACxE,CAAC,CAAC;IAEH,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import { processCapabilities } from '@ms-cloudpack/bundler-capabilities';\nimport { base64AssetExtensions, defaultTargetSyntax } from '@ms-cloudpack/bundler-utilities';\nimport type { BundleContext, BundleOptions, BundlerCapabilitiesOptions } from '@ms-cloudpack/common-types';\nimport { mergeArrayDefaults } from '@ms-cloudpack/package-utilities';\nimport { normalizeRelativePath, slash } from '@ms-cloudpack/path-string-parsing';\nimport { findProjectRoot } from '@ms-cloudpack/path-utilities';\nimport { builtinModules } from 'module';\nimport type { BuildOptions, PluginJSONConfig as _PluginJSONConfig } from 'oribuild';\nimport path from 'path';\nimport { oriCapabilities } from './oriCapabilities.js';\n\n/** Ori options with important properties always set by cloudpack marked as required. */\nexport type OriBuildOptions = BuildOptions &\n Required<Pick<BuildOptions, 'absWorkingDir' | 'buildAcknowledgeTimeoutMs'>>;\n\nconst nodeBuiltins = [...builtinModules, ...builtinModules.map((name) => `node:${name}`)];\n\n// The type from ori is now missing the extra properties\ntype PluginJSONConfig = _PluginJSONConfig & Record<string, string | boolean>;\nconst defaultPlugins: PluginJSONConfig[] = [\n {\n plugin: 'css-modules',\n prefixClasses: false,\n },\n {\n plugin: 'sass',\n prefixClasses: false,\n },\n];\n\nconst defaultResolveExtensions = ['.tsx', '.ts', '.jsx', '.js', '.css', '.json'];\n\n/**\n * The intended use of `absWorkingDir` in esbuild is to resolve relative paths from options.\n * However, ori also uses `absWorkingDir` as the virtual FS root for module resolution in plugins.\n * This means if `inputPath` is an individual package in a monorepo, ori won't be able to resolve\n * scss `@import`s from other packages (which are often in `node_modules` at the git root).\n * As a workaround, we use the git root (if available) as `absWorkingDir` and adjust all other paths.\n * https://github.com/microsoft/cloudpack/issues/1174\n */\nexport function getAbsWorkingDir(inputPath: string): string {\n return findProjectRoot(inputPath, { noPackageRoot: true }) || inputPath;\n}\n\n/**\n * Join two relative paths, with forward slashes and removing any extra segments.\n */\nfunction joinRelativePaths(p1: string, p2: string): string {\n return normalizeRelativePath(path.normalize(path.join(p1, p2)));\n}\n\n/**\n * Get a slash-normalized relative path from the calculated `absWorkingDir` to the item.\n */\nfunction getRelativePath(absWorkingDir: string, absItemPath: string): string {\n return slash(path.relative(absWorkingDir, absItemPath));\n}\n\nfunction buildDynamicImportsFilter(dynamicImports: string[]): string {\n // Using the basename works good enough for now, we might want to include the path in the future,\n // but we would need to make sure it matches successfully in the dynamic import plugin.\n const joined = dynamicImports.map((s) => path.basename(s)).join('|');\n // Add the default dynamic import extensions to the list of dynamic imports.\n return `(${joined}|.dynamic.(js|mjs|ts|tsx))$`;\n}\n\n/**\n * @returns The options for the ori bundler, without capabilities applied.\n */\nfunction getOriOptionsInternal(options: BundleOptions, context: Pick<BundleContext, 'config'>): OriBuildOptions {\n const {\n inputPath,\n sourcemap,\n entries,\n outputPath,\n external = [],\n inlined = [],\n minify,\n incremental,\n dynamicImports,\n bundlerCapabilities,\n } = options;\n const { config } = context;\n const { features, mode } = config;\n\n const bundlerOptions = (options.bundlerOptions || {}) as Partial<OriBuildOptions>;\n\n const absWorkingDir = getAbsWorkingDir(inputPath);\n const relInputPath = getRelativePath(absWorkingDir, inputPath);\n\n // Normalize outputPath to be absolute (the passed value can either already be absolute, or be\n // relative to inputPath). Or if it's not specified, use inputPath.\n const finalOutputPath = outputPath ? path.resolve(inputPath, outputPath) : inputPath;\n\n // Enable this if the capability is not set but the feature is to continue supporting the deprecated feature.\n const resolveWebExtensions =\n // eslint-disable-next-line etc/no-deprecated\n !bundlerCapabilities?.['resolve-web-extensions'] && Boolean(features?.resolveWebExtensions);\n const resolveExtensions = resolveWebExtensions\n ? ['.web.tsx', '.web.ts', '.web.jsx', '.web.js', ...defaultResolveExtensions]\n : defaultResolveExtensions;\n\n const plugins = mergeArrayDefaults(bundlerOptions.plugins, defaultPlugins) as PluginJSONConfig[];\n if (dynamicImports?.length) {\n plugins.push({\n plugin: 'dynamic-imports',\n filter: buildDynamicImportsFilter(dynamicImports),\n });\n }\n\n // Translate options into ori config.\n return {\n splitting: true,\n serviceOptions: {},\n buildAcknowledgeTimeoutMs: 10000,\n sourcemap: sourcemap ? 'linked' : 'none',\n // Default to es2022 so top-level await works\n target: defaultTargetSyntax,\n\n // bundlerOptions takes precedence over the defaults above\n ...bundlerOptions,\n\n // BundleOptions values take precedence over bundlerOptions\n incremental,\n minify,\n\n // Critical options that shouldn't be overridden\n metafile: true,\n write: true,\n\n // Calculated or manually merged options\n absWorkingDir,\n\n entryPoints: Object.fromEntries(\n Object.entries(entries).map(([outFile, inFile]) => [\n // outFile is relative to outputPath, which will still be correct because we updated outputPath\n outFile,\n // Either esbuild or ori appears to require entries to be prefixed with ./\n joinRelativePaths(relInputPath, inFile),\n ]),\n ),\n\n outdir: finalOutputPath,\n\n // outbase is probably only relevant for an array of entry point paths, not the full entryPoints\n // mapping (output path to input path) that ori uses, but go ahead and correct it if provided\n outbase: typeof bundlerOptions.outbase === 'string' ? path.resolve(inputPath, bundlerOptions.outbase) : undefined,\n\n // Enabling this automatically marks all import paths that look like npm packages as external.\n packages: !inlined.length && mode === 'library' ? 'external' : undefined,\n\n // These can be either package names or paths/globs (see https://esbuild.github.io/api/#external).\n // For any paths starting with a dot or slash, add relInputPath to the start.\n // TODO: Improve it so we always external all known and unknown packages by default, and only inline the ones we know we need.\n external: inlined.length\n ? external\n .filter((e) => !inlined.includes(e))\n .map((e) => {\n if (e[0] === '/') {\n return `/${relInputPath}${e}`;\n }\n\n if (e[0] === '.') {\n return joinRelativePaths(relInputPath, e);\n }\n\n return e;\n })\n .concat(nodeBuiltins)\n : undefined,\n\n define: {\n global: 'window',\n 'process.env.NODE_ENV': minify ? `\"production\"` : '\"development\"',\n ...bundlerOptions.define,\n },\n\n loader: {\n // By default, ori handles graphql files as data-urls. This is specific to the way graphql is\n // set up in the primary repo ori was designed for, and doesn't apply to most projects.\n // eslint-disable-next-line -- 'none' is valid but missing from types\n '.graphql': 'none' as any,\n ...bundlerOptions.loader,\n },\n\n plugins,\n\n resolveExtensions: mergeArrayDefaults(bundlerOptions.resolveExtensions, resolveExtensions),\n };\n}\n\n/**\n * @returns The options for the ori bundler, with capabilities applied.\n */\nexport async function getOriOptions(\n options: BundleOptions,\n context: Pick<BundleContext, 'config'>,\n): Promise<OriBuildOptions> {\n const bundlerOptions = (options.bundlerOptions || {}) as Partial<OriBuildOptions>;\n\n const capabilitiesOptions: BundlerCapabilitiesOptions = {\n // Enable asset inlining for the specified extensions.\n 'asset-inline': {\n // Filter out the default asset extensions that are already handled by bundlerOptions.\n extensions: base64AssetExtensions.filter((ext) => !bundlerOptions.loader?.[ext]),\n },\n ...options.bundlerCapabilities,\n };\n\n const input = await processCapabilities({\n bundlerName: 'ori',\n baseConfig: getOriOptionsInternal(options, context),\n bundlerCapabilitiesOptions: capabilitiesOptions,\n internalCapabilities: oriCapabilities,\n bundlerCapabilitiesRegistry: context.config.bundlerCapabilitiesRegistry,\n });\n\n return input;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"oriCapabilities.d.ts","sourceRoot":"","sources":["../src/oriCapabilities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wCAAwC,EAAE,MAAM,4BAA4B,CAAC;AAC3F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAG1D,eAAO,MAAM,eAAe,EAAE,wCAAwC,CAAC,eAAe,CAoBrF,CAAC"}
1
+ {"version":3,"file":"oriCapabilities.d.ts","sourceRoot":"","sources":["../src/oriCapabilities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wCAAwC,EAAE,MAAM,4BAA4B,CAAC;AAC3F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAI1D,eAAO,MAAM,eAAe,EAAE,wCAAwC,CAAC,eAAe,CAyBrF,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import { mergeObjects } from '@ms-cloudpack/package-utilities';
2
+ import { webExtensions } from '@ms-cloudpack/bundler-capabilities';
2
3
  export const oriCapabilities = {
3
4
  'asset-inline': (config, options) => {
4
5
  // Make sure that the leading dot exists in the extensions
@@ -14,6 +15,11 @@ export const oriCapabilities = {
14
15
  config.alias = mergeObjects([config.alias || {}, options]);
15
16
  return config;
16
17
  },
18
+ 'resolve-web-extensions': (config) => {
19
+ config.resolveExtensions ??= [];
20
+ config.resolveExtensions.unshift(...webExtensions);
21
+ return config;
22
+ },
17
23
  // This is a placeholder for the density capability. It doesn't do anything in the bundler.
18
24
  // It's just a workaround for a post-bundle task. This will be replaced with 'plugins' in the future.
19
25
  density: (config) => config,
@@ -1 +1 @@
1
- {"version":3,"file":"oriCapabilities.js","sourceRoot":"","sources":["../src/oriCapabilities.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAE/D,MAAM,CAAC,MAAM,eAAe,GAA8D;IACxF,cAAc,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE;QAClC,0DAA0D;QAC1D,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QAE7F,MAAM,CAAC,MAAM,GAAG;YACd,GAAG,MAAM,CAAC,MAAM;YAChB,GAAG,MAAM,CAAC,WAAW,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC;SACjE,CAAC;QAEF,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,KAAK,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE;QACzB,uCAAuC;QACvC,MAAM,CAAC,KAAK,GAAG,YAAY,CAAC,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE,EAAE,OAAO,CAAC,CAAC,CAAC;QAC3D,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,2FAA2F;IAC3F,qGAAqG;IACrG,OAAO,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM;CAC5B,CAAC","sourcesContent":["import type { InternalBundlerCapabilityImplementations } from '@ms-cloudpack/common-types';\nimport type { OriBuildOptions } from './getOriOptions.ts';\nimport { mergeObjects } from '@ms-cloudpack/package-utilities';\n\nexport const oriCapabilities: InternalBundlerCapabilityImplementations<OriBuildOptions> = {\n 'asset-inline': (config, options) => {\n // Make sure that the leading dot exists in the extensions\n const extensions = options.extensions.map((ext) => (!ext.startsWith('.') ? `.${ext}` : ext));\n\n config.loader = {\n ...config.loader,\n ...Object.fromEntries(extensions.map((ext) => [ext, 'dataurl'])),\n };\n\n return config;\n },\n alias: (config, options) => {\n // Add aliases to the ori configuration\n config.alias = mergeObjects([config.alias || {}, options]);\n return config;\n },\n // This is a placeholder for the density capability. It doesn't do anything in the bundler.\n // It's just a workaround for a post-bundle task. This will be replaced with 'plugins' in the future.\n density: (config) => config,\n};\n"]}
1
+ {"version":3,"file":"oriCapabilities.js","sourceRoot":"","sources":["../src/oriCapabilities.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AAEnE,MAAM,CAAC,MAAM,eAAe,GAA8D;IACxF,cAAc,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE;QAClC,0DAA0D;QAC1D,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QAE7F,MAAM,CAAC,MAAM,GAAG;YACd,GAAG,MAAM,CAAC,MAAM;YAChB,GAAG,MAAM,CAAC,WAAW,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC;SACjE,CAAC;QAEF,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,KAAK,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE;QACzB,uCAAuC;QACvC,MAAM,CAAC,KAAK,GAAG,YAAY,CAAC,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE,EAAE,OAAO,CAAC,CAAC,CAAC;QAC3D,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,wBAAwB,EAAE,CAAC,MAAM,EAAE,EAAE;QACnC,MAAM,CAAC,iBAAiB,KAAK,EAAE,CAAC;QAChC,MAAM,CAAC,iBAAiB,CAAC,OAAO,CAAC,GAAG,aAAa,CAAC,CAAC;QACnD,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,2FAA2F;IAC3F,qGAAqG;IACrG,OAAO,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM;CAC5B,CAAC","sourcesContent":["import type { InternalBundlerCapabilityImplementations } from '@ms-cloudpack/common-types';\nimport type { OriBuildOptions } from './getOriOptions.ts';\nimport { mergeObjects } from '@ms-cloudpack/package-utilities';\nimport { webExtensions } from '@ms-cloudpack/bundler-capabilities';\n\nexport const oriCapabilities: InternalBundlerCapabilityImplementations<OriBuildOptions> = {\n 'asset-inline': (config, options) => {\n // Make sure that the leading dot exists in the extensions\n const extensions = options.extensions.map((ext) => (!ext.startsWith('.') ? `.${ext}` : ext));\n\n config.loader = {\n ...config.loader,\n ...Object.fromEntries(extensions.map((ext) => [ext, 'dataurl'])),\n };\n\n return config;\n },\n alias: (config, options) => {\n // Add aliases to the ori configuration\n config.alias = mergeObjects([config.alias || {}, options]);\n return config;\n },\n 'resolve-web-extensions': (config) => {\n config.resolveExtensions ??= [];\n config.resolveExtensions.unshift(...webExtensions);\n return config;\n },\n // This is a placeholder for the density capability. It doesn't do anything in the bundler.\n // It's just a workaround for a post-bundle task. This will be replaced with 'plugins' in the future.\n density: (config) => config,\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ms-cloudpack/bundler-ori",
3
- "version": "0.2.22",
3
+ "version": "0.2.24",
4
4
  "description": "An abstraction to bundle source code using ori.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -14,15 +14,15 @@
14
14
  }
15
15
  },
16
16
  "dependencies": {
17
- "@ms-cloudpack/bundler-capabilities": "^0.2.14",
18
- "@ms-cloudpack/bundler-utilities": "^0.2.3",
19
- "@ms-cloudpack/common-types": "^0.24.9",
17
+ "@ms-cloudpack/bundler-capabilities": "^0.2.15",
18
+ "@ms-cloudpack/bundler-utilities": "^0.2.4",
19
+ "@ms-cloudpack/common-types": "^0.24.10",
20
20
  "@ms-cloudpack/json-utilities": "^0.1.10",
21
- "@ms-cloudpack/package-utilities": "^11.3.6",
21
+ "@ms-cloudpack/package-utilities": "^12.0.0",
22
22
  "@ms-cloudpack/path-string-parsing": "^1.2.6",
23
- "@ms-cloudpack/path-utilities": "^3.0.6",
23
+ "@ms-cloudpack/path-utilities": "^3.0.7",
24
24
  "@ms-cloudpack/retry": "^0.1.3",
25
- "oribuild": "0.0.0-pre-alpha.15-2025022017-fbee66b"
25
+ "oribuild": "0.0.0-pre-alpha.15-2024082214-6bd86a4"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@ms-cloudpack/bundler-tests": "^0.1.0",