@ms-cloudpack/bundler-rollup 0.2.1 → 0.2.3

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,5 +1,5 @@
1
1
  import { shouldExternalizePackage } from '@ms-cloudpack/bundler-utilities';
2
- import { isExternalPackage } from '@ms-cloudpack/package-utilities';
2
+ import { isExternalPackage } from '@ms-cloudpack/path-utilities';
3
3
  import fs from 'fs';
4
4
  import path from 'path';
5
5
  import { getRollupPlugins } from './getRollupPlugins.js';
@@ -1 +1 @@
1
- {"version":3,"file":"getRollupOptions.js","sourceRoot":"","sources":["../src/getRollupOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAG3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,wFAAwF;AACxF,mDAAmD;AACnD,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,WAAW,EAAE,cAAc,CAAC,CAAC,CAAC;AAEnE,yCAAyC;AACzC,MAAM,eAAe,GAAG,CAAC,sBAAsB,CAAC,CAAC;AAEjD;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,MAE2C;IAO3C,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC;IACvC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,GAAG,EAAE,EAAE,OAAO,GAAG,EAAE,EAAE,cAAc,GAAG,EAAE,EAAE,cAAc,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IACnH,MAAM,UAAU,GAAG,iBAAiB,CAAC,SAAS,CAAC,CAAC;IAChD,MAAM,gBAAgB,GAAG,CAAC,UAAU,IA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AAC,CAAC,SAAS;YACjF,MAAM,EAAE,IAAI;SACb;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { shouldExternalizePackage } from '@ms-cloudpack/bundler-utilities';\nimport type { BundleOptions } from '@ms-cloudpack/common-types';\nimport type { WriteESMStubsResult } from '@ms-cloudpack/esm-stub-utilities';\nimport { isExternalPackage } from '@ms-cloudpack/package-utilities';\nimport fs from 'fs';\nimport path from 'path';\nimport type { InputOptions, OutputOptions, RollupLog, RollupOptions } from 'rollup';\nimport { getRollupPlugins } from './getRollupPlugins.js';\n\n// These are the polyfills that we support from the 'rollup-plugin-polyfill-node' plugin\n// that are not included in the node builtins list.\nconst polyfills = new Set(['global', '_inherits', '_buffer_list']);\n\n// Spammy, usually non-actionable warning\nconst ignoredWarnings = ['Circular dependency:'];\n\n/**\n * Converts BundlerOptions to Rollup-specific options.\n */\nexport async function getRollupOptions(\n params: {\n options: Omit<BundleOptions, 'entries'>;\n } & Pick<WriteESMStubsResult, 'newEntries'>,\n): Promise<{\n inputOptions: RollupOptions;\n outputOptions: OutputOptions;\n /** Warnings will be pushed to this array (rollup handles warnings with a callback) */\n warnings: RollupLog[];\n}> {\n const { options, newEntries } = params;\n const { inputPath, minify, external = [], inlined = [], bundlerOptions = {}, dynamicImports, sourcemap } = options;\n const isExternal = isExternalPackage(inputPath);\n const enableTypescript = !isExternal && fs.existsSync(path.resolve(inputPath, 'tsconfig.json'));\n const warnings: RollupLog[] = [];\n\n return {\n warnings,\n inputOptions: {\n external: (id) => shouldExternalizePackage({ id, inlined, external, polyfills, shouldInlineNodeBuiltins: true }),\n ...(bundlerOptions.inputOptions as InputOptions),\n // Don't allow overriding the options below\n\n // Rollup requires entry keys without a leading ./\n input: Object.fromEntries(Object.entries(newEntries).map(([key, value]) => [key.replace(/^\\.\\//, ''), value])),\n // These are not possible to override properly via JSON config\n plugins: await getRollupPlugins({\n isProduction: minify,\n packagePath: inputPath,\n enableTypescript,\n dynamicImports,\n sourcemap,\n }),\n onwarn: (warning) => {\n if (!ignoredWarnings.some((ignored) => warning.message.includes(ignored))) {\n warnings.push(warning);\n }\n },\n },\n outputOptions: {\n sourcemap,\n ...(bundlerOptions.outputOptions as OutputOptions),\n // No overriding these options\n dir: options.outputPath ? path.resolve(inputPath, options.outputPath) : inputPath,\n format: 'es',\n },\n };\n}\n"]}
1
+ {"version":3,"file":"getRollupOptions.js","sourceRoot":"","sources":["../src/getRollupOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAG3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,wFAAwF;AACxF,mDAAmD;AACnD,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,WAAW,EAAE,cAAc,CAAC,CAAC,CAAC;AAEnE,yCAAyC;AACzC,MAAM,eAAe,GAAG,CAAC,sBAAsB,CAAC,CAAC;AAEjD;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,MAE2C;IAO3C,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC;IACvC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,GAAG,EAAE,EAAE,OAAO,GAAG,EAAE,EAAE,cAAc,GAAG,EAAE,EAAE,cAAc,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IACnH,MAAM,UAAU,GAAG,iBAAiB,CAAC,SAAS,CAAC,CAAC;IAChD,MAAM,gBAAgB,GAAG,CAAC,UAAU,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,eAAe,CAAC,CAAC,CAAC;IAChG,MAAM,QAAQ,GAAgB,EAAE,CAAC;IAEjC,OAAO;Q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cloudpack/common-types';\nimport type { WriteESMStubsResult } from '@ms-cloudpack/esm-stub-utilities';\nimport { isExternalPackage } from '@ms-cloudpack/path-utilities';\nimport fs from 'fs';\nimport path from 'path';\nimport type { InputOptions, OutputOptions, RollupLog, RollupOptions } from 'rollup';\nimport { getRollupPlugins } from './getRollupPlugins.js';\n\n// These are the polyfills that we support from the 'rollup-plugin-polyfill-node' plugin\n// that are not included in the node builtins list.\nconst polyfills = new Set(['global', '_inherits', '_buffer_list']);\n\n// Spammy, usually non-actionable warning\nconst ignoredWarnings = ['Circular dependency:'];\n\n/**\n * Converts BundlerOptions to Rollup-specific options.\n */\nexport async function getRollupOptions(\n params: {\n options: Omit<BundleOptions, 'entries'>;\n } & Pick<WriteESMStubsResult, 'newEntries'>,\n): Promise<{\n inputOptions: RollupOptions;\n outputOptions: OutputOptions;\n /** Warnings will be pushed to this array (rollup handles warnings with a callback) */\n warnings: RollupLog[];\n}> {\n const { options, newEntries } = params;\n const { inputPath, minify, external = [], inlined = [], bundlerOptions = {}, dynamicImports, sourcemap } = options;\n const isExternal = isExternalPackage(inputPath);\n const enableTypescript = !isExternal && fs.existsSync(path.resolve(inputPath, 'tsconfig.json'));\n const warnings: RollupLog[] = [];\n\n return {\n warnings,\n inputOptions: {\n external: (id) => shouldExternalizePackage({ id, inlined, external, polyfills, shouldInlineNodeBuiltins: true }),\n ...(bundlerOptions.inputOptions as InputOptions),\n // Don't allow overriding the options below\n\n // Rollup requires entry keys without a leading ./\n input: Object.fromEntries(Object.entries(newEntries).map(([key, value]) => [key.replace(/^\\.\\//, ''), value])),\n // These are not possible to override properly via JSON config\n plugins: await getRollupPlugins({\n isProduction: minify,\n packagePath: inputPath,\n enableTypescript,\n dynamicImports,\n sourcemap,\n }),\n onwarn: (warning) => {\n if (!ignoredWarnings.some((ignored) => warning.message.includes(ignored))) {\n warnings.push(warning);\n }\n },\n },\n outputOptions: {\n sourcemap,\n ...(bundlerOptions.outputOptions as OutputOptions),\n // No overriding these options\n dir: options.outputPath ? path.resolve(inputPath, options.outputPath) : inputPath,\n format: 'es',\n },\n };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"rollup.d.ts","sourceRoot":"","sources":["../src/rollup.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,OAAO,EAA8B,MAAM,4BAA4B,CAAC;AAWrG,eAAO,MAAM,MAAM,EAAE,OAyDpB,CAAC"}
1
+ {"version":3,"file":"rollup.d.ts","sourceRoot":"","sources":["../src/rollup.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,OAAO,EAA8B,MAAM,4BAA4B,CAAC;AAYrG,eAAO,MAAM,MAAM,EAAE,OAsDpB,CAAC"}
package/lib/rollup.js CHANGED
@@ -5,6 +5,7 @@ import { getRollupOptions } from './getRollupOptions.js';
5
5
  import { normalizeRollupLoc } from './normalizeRollupLoc.js';
6
6
  import { normalizeRollupOutput } from './normalizeRollupOutput.js';
7
7
  import { rollupCapabilities } from './rollupCapabilities.js';
8
+ import { base64AssetExtensions } from '@ms-cloudpack/bundler-utilities';
8
9
  const bundlerName = 'rollup';
9
10
  export const rollup = {
10
11
  name: bundlerName,
@@ -15,10 +16,7 @@ export const rollup = {
15
16
  }
16
17
  const { warnings, ...baseConfig } = await getRollupOptions({ options, newEntries });
17
18
  const bundlerCapabilitiesOptions = {
18
- // Enable asset-inline by default for common image types
19
- // The extension are not read from the options because they are not configurable,
20
- // but these are the supported extensions by the plugin
21
- 'asset-inline': { extensions: ['jpg', 'png', 'gif', 'svg', 'webp'] },
19
+ 'asset-inline': { extensions: base64AssetExtensions },
22
20
  ...(options.bundlerCapabilities || {}),
23
21
  };
24
22
  const { inputOptions, outputOptions } = await processCapabilities({
package/lib/rollup.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"rollup.js","sourceRoot":"","sources":["../src/rollup.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,q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ities } from '@ms-cloudpack/bundler-capabilities';\nimport { writeESMStubsInWorker } from '@ms-cloudpack/esm-stub-utilities';\nimport { rollup as runRollup, type RollupError, type RollupOutput } from 'rollup';\nimport { getRollupOptions } from './getRollupOptions.js';\nimport { normalizeRollupLoc } from './normalizeRollupLoc.js';\nimport { normalizeRollupOutput } from './normalizeRollupOutput.js';\nimport { rollupCapabilities } from './rollupCapabilities.js';\n\nconst bundlerName = 'rollup';\n\nexport const rollup: Bundler = {\n name: bundlerName,\n bundle: async function (options, context) {\n const { newEntries, errors } = await writeESMStubsInWorker(options);\n if (errors?.length) {\n return { errors };\n }\n\n const { warnings, ...baseConfig } = await getRollupOptions({ options, newEntries });\n\n const bundlerCapabilitiesOptions: BundlerCapabilitiesOptions = {\n // Enable asset-inline by default for common image types\n // The extension are not read from the options because they are not configurable,\n // but these are the supported extensions by the plugin\n 'asset-inline': { extensions: ['jpg', 'png', 'gif', 'svg', 'webp'] },\n ...(options.bundlerCapabilities || {}),\n };\n\n const { inputOptions, outputOptions } = await processCapabilities({\n bundlerName,\n baseConfig,\n bundlerCapabilitiesOptions,\n internalCapabilities: rollupCapabilities,\n bundlerCapabilitiesRegistry: context.config.bundlerCapabilitiesRegistry,\n });\n\n let output: RollupOutput;\n\n try {\n const result = await runRollup(inputOptions);\n output = await result.write(outputOptions);\n await result.close();\n } catch (e) {\n // This might only be a regular Error, but the extra RollupError properties accessed are optional\n const error = e as RollupError;\n const errorMessage: BundleMessage = {\n text: error.message,\n // remove the message from the stack\n notes: [{ text: error.stack?.includes(error.message) ? error.stack.split(error.message)[1].trim() : '' }],\n source: 'rollup',\n };\n\n if (error.id || error.loc?.file) {\n errorMessage.location = normalizeRollupLoc({\n // contains line, column, and possibly file\n loc: error.loc,\n // some errors only have the file here\n id: error.id,\n inputPath: options.inputPath,\n });\n }\n\n return { errors: [errorMessage] };\n }\n\n return normalizeRollupOutput({ options, inputOptions, outputOptions, output, warnings });\n },\n};\n"]}
1
+ {"version":3,"file":"rollup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["import type { BundleMessage, Bundler, BundlerCapabilitiesOptions } from '@ms-cloudpack/common-types';\nimport { processCapabilities } from '@ms-cloudpack/bundler-capabilities';\nimport { writeESMStubsInWorker } from '@ms-cloudpack/esm-stub-utilities';\nimport { rollup as runRollup, type RollupError, type RollupOutput } from 'rollup';\nimport { getRollupOptions } from './getRollupOptions.js';\nimport { normalizeRollupLoc } from './normalizeRollupLoc.js';\nimport { normalizeRollupOutput } from './normalizeRollupOutput.js';\nimport { rollupCapabilities } from './rollupCapabilities.js';\nimport { base64AssetExtensions } from '@ms-cloudpack/bundler-utilities';\n\nconst bundlerName = 'rollup';\n\nexport const rollup: Bundler = {\n name: bundlerName,\n bundle: async function (options, context) {\n const { newEntries, errors } = await writeESMStubsInWorker(options);\n if (errors?.length) {\n return { errors };\n }\n\n const { warnings, ...baseConfig } = await getRollupOptions({ options, newEntries });\n\n const bundlerCapabilitiesOptions: BundlerCapabilitiesOptions = {\n 'asset-inline': { extensions: base64AssetExtensions },\n ...(options.bundlerCapabilities || {}),\n };\n\n const { inputOptions, outputOptions } = await processCapabilities({\n bundlerName,\n baseConfig,\n bundlerCapabilitiesOptions,\n internalCapabilities: rollupCapabilities,\n bundlerCapabilitiesRegistry: context.config.bundlerCapabilitiesRegistry,\n });\n\n let output: RollupOutput;\n\n try {\n const result = await runRollup(inputOptions);\n output = await result.write(outputOptions);\n await result.close();\n } catch (e) {\n // This might only be a regular Error, but the extra RollupError properties accessed are optional\n const error = e as RollupError;\n const errorMessage: BundleMessage = {\n text: error.message,\n // remove the message from the stack\n notes: [{ text: error.stack?.includes(error.message) ? error.stack.split(error.message)[1].trim() : '' }],\n source: 'rollup',\n };\n\n if (error.id || error.loc?.file) {\n errorMessage.location = normalizeRollupLoc({\n // contains line, column, and possibly file\n loc: error.loc,\n // some errors only have the file here\n id: error.id,\n inputPath: options.inputPath,\n });\n }\n\n return { errors: [errorMessage] };\n }\n\n return normalizeRollupOutput({ options, inputOptions, outputOptions, output, warnings });\n },\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"rollupCapabilities.d.ts","sourceRoot":"","sources":["../src/rollupCapabilities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wCAAwC,EAAE,MAAM,4BAA4B,CAAC;AAC3F,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAO3D,eAAO,MAAM,kBAAkB,EAAE,wCAAwC,CAAC;IACxE,YAAY,EAAE,aAAa,CAAC;IAC5B,aAAa,EAAE,aAAa,CAAC;CAC9B,CAmBA,CAAC"}
1
+ {"version":3,"file":"rollupCapabilities.d.ts","sourceRoot":"","sources":["../src/rollupCapabilities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wCAAwC,EAAE,MAAM,4BAA4B,CAAC;AAC3F,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAO3D,eAAO,MAAM,kBAAkB,EAAE,wCAAwC,CAAC;IACxE,YAAY,EAAE,aAAa,CAAC;IAC5B,aAAa,EAAE,aAAa,CAAC;CAC9B,CA0BA,CAAC"}
@@ -1,9 +1,10 @@
1
1
  import { mergeObjects } from '@ms-cloudpack/package-utilities';
2
- import _image from '@rollup/plugin-image';
2
+ import _url from '@rollup/plugin-url';
3
3
  // See more about the type workaround at getRollupPlugins.ts
4
- const image = _image;
4
+ const url = _url;
5
5
  export const rollupCapabilities = {
6
- 'asset-inline': (config) => {
6
+ 'asset-inline': (config, options) => {
7
+ const extensions = options.extensions.map((ext) => (ext.startsWith('.') ? ext.slice(1) : ext));
7
8
  // Add the image plugin to the rollup configuration
8
9
  if (!config.inputOptions.plugins) {
9
10
  config.inputOptions.plugins = [];
@@ -11,7 +12,10 @@ export const rollupCapabilities = {
11
12
  else if (!Array.isArray(config.inputOptions.plugins)) {
12
13
  config.inputOptions.plugins = [config.inputOptions.plugins];
13
14
  }
14
- config.inputOptions.plugins.push(image());
15
+ config.inputOptions.plugins.push(url({
16
+ include: extensions.map((ext) => `**/*.${ext}`),
17
+ limit: 0, // Inline all files as Base64, regardless of size
18
+ }));
15
19
  return config;
16
20
  },
17
21
  alias: (config, options) => {
@@ -1 +1 @@
1
- {"version":3,"file":"rollupCapabilities.js","sourceRoot":"","sources":["../src/rollupCapabilities.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,MAAM,MAAM,sBAAsB,CAAC;AAE1C,4DAA4D;AAC5D,MAAM,KAAK,GAAG,MAA0C,CAAC;AAEzD,MAAM,CAAC,MAAM,kBAAkB,GAG1B;IACH,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE;QACzB,mDAAmD;QACnD,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;YACjC,MAAM,CAAC,YAAY,CAAC,OAAO,GAAG,EAAE,CAAC;QACnC,CAAC;aAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,CAAC;YACvD,MAAM,CAAC,YAAY,CAAC,OAAO,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QAC9D,CAAC;QACD,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;QAC1C,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,KAAK,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE;QACzB,uCAAuC;QACvC,MAAM,CAAC,aAAa,CAAC,KAAK,GAAG,YAAY,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,IAAI,EAAE,EAAE,OAAO,CAAC,CAAC,CAAC;QACvF,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 { OutputOptions, RollupOptions } from 'rollup';\nimport { mergeObjects } from '@ms-cloudpack/package-utilities';\nimport _image from '@rollup/plugin-image';\n\n// See more about the type workaround at getRollupPlugins.ts\nconst image = _image as unknown as typeof _image.default;\n\nexport const rollupCapabilities: InternalBundlerCapabilityImplementations<{\n inputOptions: RollupOptions;\n outputOptions: OutputOptions;\n}> = {\n 'asset-inline': (config) => {\n // Add the image plugin to the rollup configuration\n if (!config.inputOptions.plugins) {\n config.inputOptions.plugins = [];\n } else if (!Array.isArray(config.inputOptions.plugins)) {\n config.inputOptions.plugins = [config.inputOptions.plugins];\n }\n config.inputOptions.plugins.push(image());\n return config;\n },\n alias: (config, options) => {\n // Add aliases to the ori configuration\n config.outputOptions.paths = mergeObjects([config.outputOptions.paths || {}, 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":"rollupCapabilities.js","sourceRoot":"","sources":["../src/rollupCapabilities.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,IAAI,MAAM,oBAAoB,CAAC;AAEtC,4DAA4D;AAC5D,MAAM,GAAG,GAAG,IAAsC,CAAC;AAEnD,MAAM,CAAC,MAAM,kBAAkB,GAG1B;IACH,cAAc,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE;QAClC,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QAE/F,mDAAmD;QACnD,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;YACjC,MAAM,CAAC,YAAY,CAAC,OAAO,GAAG,EAAE,CAAC;QACnC,CAAC;aAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,CAAC;YACvD,MAAM,CAAC,YAAY,CAAC,OAAO,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QAC9D,CAAC;QACD,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,CAC9B,GAAG,CAAC;YACF,OAAO,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,QAAQ,GAAG,EAAE,CAAC;YAC/C,KAAK,EAAE,CAAC,EAAE,iDAAiD;SAC5D,CAAC,CACH,CAAC;QACF,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,KAAK,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE;QACzB,uCAAuC;QACvC,MAAM,CAAC,aAAa,CAAC,KAAK,GAAG,YAAY,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,IAAI,EAAE,EAAE,OAAO,CAAC,CAAC,CAAC;QACvF,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 { OutputOptions, RollupOptions } from 'rollup';\nimport { mergeObjects } from '@ms-cloudpack/package-utilities';\nimport _url from '@rollup/plugin-url';\n\n// See more about the type workaround at getRollupPlugins.ts\nconst url = _url as unknown as typeof _url.default;\n\nexport const rollupCapabilities: InternalBundlerCapabilityImplementations<{\n inputOptions: RollupOptions;\n outputOptions: OutputOptions;\n}> = {\n 'asset-inline': (config, options) => {\n const extensions = options.extensions.map((ext) => (ext.startsWith('.') ? ext.slice(1) : ext));\n\n // Add the image plugin to the rollup configuration\n if (!config.inputOptions.plugins) {\n config.inputOptions.plugins = [];\n } else if (!Array.isArray(config.inputOptions.plugins)) {\n config.inputOptions.plugins = [config.inputOptions.plugins];\n }\n config.inputOptions.plugins.push(\n url({\n include: extensions.map((ext) => `**/*.${ext}`),\n limit: 0, // Inline all files as Base64, regardless of size\n }),\n );\n return config;\n },\n alias: (config, options) => {\n // Add aliases to the ori configuration\n config.outputOptions.paths = mergeObjects([config.outputOptions.paths || {}, 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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ms-cloudpack/bundler-rollup",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "A cloudpack plugin for abstracting rollup.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -19,20 +19,20 @@
19
19
  }
20
20
  },
21
21
  "dependencies": {
22
- "@ms-cloudpack/bundler-capabilities": "^0.2.3",
23
- "@ms-cloudpack/bundler-utilities": "^0.1.15",
24
- "@ms-cloudpack/common-types": "^0.23.6",
25
- "@ms-cloudpack/esm-stub-utilities": "^0.13.20",
26
- "@ms-cloudpack/package-utilities": "^10.4.2",
27
- "@ms-cloudpack/path-string-parsing": "^1.2.5",
28
- "@ms-cloudpack/path-utilities": "^2.7.56",
22
+ "@ms-cloudpack/bundler-capabilities": "^0.2.4",
23
+ "@ms-cloudpack/bundler-utilities": "^0.1.17",
24
+ "@ms-cloudpack/common-types": "^0.23.7",
25
+ "@ms-cloudpack/esm-stub-utilities": "^0.13.21",
26
+ "@ms-cloudpack/package-utilities": "^11.0.0",
27
+ "@ms-cloudpack/path-string-parsing": "^1.2.6",
28
+ "@ms-cloudpack/path-utilities": "^2.8.0",
29
29
  "@rollup/plugin-dynamic-import-vars": "^2.0.0",
30
- "@rollup/plugin-image": "^3.0.0",
31
30
  "@rollup/plugin-json": "^6.0.0",
32
31
  "@rollup/plugin-node-resolve": "^15.0.0",
33
32
  "@rollup/plugin-replace": "^5.0.0",
34
33
  "@rollup/plugin-swc": "^0.3.0",
35
34
  "@rollup/plugin-terser": "^0.4.0",
35
+ "@rollup/plugin-url": "^8.0.0",
36
36
  "@rollup/pluginutils": "^5.0.0",
37
37
  "@swc/core": "^1.3.0",
38
38
  "commondir": "^1.0.1",
@@ -48,6 +48,7 @@
48
48
  },
49
49
  "devDependencies": {
50
50
  "@ms-cloudpack/bundler-tests": "^0.1.0",
51
+ "@ms-cloudpack/environment": "^0.1.1",
51
52
  "@ms-cloudpack/eslint-plugin-internal": "^0.0.1",
52
53
  "@ms-cloudpack/scripts": "^0.0.1",
53
54
  "@ms-cloudpack/test-utilities": "^0.5.0",
@@ -1,11 +0,0 @@
1
- // This file is read by tools that parse documentation comments conforming to the TSDoc standard.
2
- // It should be published with your NPM package. It should not be tracked by Git.
3
- {
4
- "tsdocVersion": "0.12",
5
- "toolPackages": [
6
- {
7
- "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.47.11"
9
- }
10
- ]
11
- }