@ms-cloudpack/bundler-rollup 0.4.16 → 0.4.18

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":"getRollupOptions.d.ts","sourceRoot":"","sources":["../src/getRollupOptions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC/E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAE5E,OAAO,KAAK,EAAgB,aAAa,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAUpF;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE;IACN,OAAO,EAAE,IAAI,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;IACxC,OAAO,EAAE,aAAa,CAAC;CACxB,GAAG,IAAI,CAAC,mBAAmB,EAAE,YAAY,CAAC,GAC1C;IACD,YAAY,EAAE,aAAa,CAAC;IAC5B,aAAa,EAAE,aAAa,CAAC;IAC7B,sFAAsF;IACtF,QAAQ,EAAE,SAAS,EAAE,CAAC;CACvB,CAkEA"}
1
+ {"version":3,"file":"getRollupOptions.d.ts","sourceRoot":"","sources":["../src/getRollupOptions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC/E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAE5E,OAAO,KAAK,EAAgB,aAAa,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAUpF;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE;IACN,OAAO,EAAE,IAAI,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;IACxC,OAAO,EAAE,aAAa,CAAC;CACxB,GAAG,IAAI,CAAC,mBAAmB,EAAE,YAAY,CAAC,GAC1C;IACD,YAAY,EAAE,aAAa,CAAC;IAC5B,aAAa,EAAE,aAAa,CAAC;IAC7B,sFAAsF;IACtF,QAAQ,EAAE,SAAS,EAAE,CAAC;CACvB,CAoEA"}
@@ -39,6 +39,8 @@ export function getRollupOptions(params) {
39
39
  dynamicImports,
40
40
  sourcemap,
41
41
  resolveWebExtensions: !!bundlerCapabilities?.['resolve-web-extensions'],
42
+ config: context.config,
43
+ relay: bundlerCapabilities?.relay,
42
44
  }),
43
45
  onwarn: (warning) => {
44
46
  if (!ignoredWarnings.some((ignored) => warning.message.includes(ignored))) {
@@ -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,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,UAAU,gBAAgB,CAC9B,MAG2C;IAO3C,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC;IAChD,MAAM,EACJ,SAAS,EACT,MAAM,EACN,QAAQ,GAAG,EAAE,EACb,OAAO,GAAG,EAAE,EACZ,cAAc,GAAG,EAAE,EACnB,cAAc,EACd,SAAS,EACT,mBAAmB,GACpB,GAAG,OAAO,CAAC;IACZ,MAAM,QAAQ,GAAgB,EAAE,CAAC;IAEjC,OAAO;QACL,QAAQ;QACR,YAAY,EAAE;YACZ,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,CAC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CAAC,SAAS;YACjF,MAAM,EAAE,IAAI;YACZ,cAAc,EAAE,WAAW;YAC3B,cAAc,EAAE,WAAW;YAC3B,cAAc,EAAE,yBAAyB;YACzC,6EAA6E;YAC7E,wEAAwE;YACxE,mFAAmF;YACnF,sBAAsB,EAAE,CAAC,kBAAkB,EAAE,aAAa,EAAE,EAAE;YAC5D,8DAA8D;YAC9D,WAAW,GAAG,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,kBAAkB,CAAC,CAAC;SACxG;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { shouldExternalizePackage } from '@ms-cloudpack/bundler-utilities';\nimport type { BundleContext, BundleOptions } from '@ms-cloudpack/common-types';\nimport type { WriteESMStubsResult } from '@ms-cloudpack/esm-stub-utilities';\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 function getRollupOptions(\n params: {\n options: Omit<BundleOptions, 'entries'>;\n context: BundleContext;\n } & Pick<WriteESMStubsResult, 'newEntries'>,\n): {\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, context, newEntries } = params;\n const {\n inputPath,\n minify,\n external = [],\n inlined = [],\n bundlerOptions = {},\n dynamicImports,\n sourcemap,\n bundlerCapabilities,\n } = options;\n const warnings: RollupLog[] = [];\n\n return {\n warnings,\n inputOptions: {\n external: (id, parent) =>\n shouldExternalizePackage({\n inputPath,\n id,\n parent,\n inlined,\n external,\n polyfills,\n shouldInlineNodeBuiltins: true,\n targetEnvironment: options.targetEnvironment,\n mode: context.config.mode,\n }),\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: getRollupPlugins({\n isProduction: minify,\n packagePath: inputPath,\n requiresTranspile: context.requiresTranspile,\n dynamicImports,\n sourcemap,\n resolveWebExtensions: !!bundlerCapabilities?.['resolve-web-extensions'],\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 entryFileNames: '[name].js',\n chunkFileNames: '[name].js',\n assetFileNames: 'assets/[name]-[extname]',\n // This is a fix so that the sourcemaps never include the hash in their path,\n // as that invalidates the sourcemap on change and removes break points.\n // ../../../../relative/path/to/src/path/to/file.ts -> rollup://src/path/to/file.ts\n sourcemapPathTransform: (relativeSourcePath, sourcemapPath) =>\n // No need to normalize the path as rollup will do that for us\n 'rollup://' + path.relative(inputPath, path.resolve(path.dirname(sourcemapPath), relativeSourcePath)),\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,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,CAA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EAAE,CAAC,wBAAwB,CAAC;gBACvE,MAAM,EAAE,OAAO,CAAC,MAAM;gBACtB,KAAK,EAAE,mBAAmB,EAAE,KAAK;aAClC,CAAC;YACF,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE;gBAClB,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC;oBAC1E,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;gBACzB,CAAC;YACH,CAAC;SACF;QACD,aAAa,EAAE;YACb,SAAS;YACT,GAAI,cAAc,CAAC,aAA+B;YAClD,8BAA8B;YAC9B,GAAG,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS;YACjF,MAAM,EAAE,IAAI;YACZ,cAAc,EAAE,WAAW;YAC3B,cAAc,EAAE,WAAW;YAC3B,cAAc,EAAE,yBAAyB;YACzC,6EAA6E;YAC7E,wEAAwE;YACxE,mFAAmF;YACnF,sBAAsB,EAAE,CAAC,kBAAkB,EAAE,aAAa,EAAE,EAAE;YAC5D,8DAA8D;YAC9D,WAAW,GAAG,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,kBAAkB,CAAC,CAAC;SACxG;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { shouldExternalizePackage } from '@ms-cloudpack/bundler-utilities';\nimport type { BundleContext, BundleOptions } from '@ms-cloudpack/common-types';\nimport type { WriteESMStubsResult } from '@ms-cloudpack/esm-stub-utilities';\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 function getRollupOptions(\n params: {\n options: Omit<BundleOptions, 'entries'>;\n context: BundleContext;\n } & Pick<WriteESMStubsResult, 'newEntries'>,\n): {\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, context, newEntries } = params;\n const {\n inputPath,\n minify,\n external = [],\n inlined = [],\n bundlerOptions = {},\n dynamicImports,\n sourcemap,\n bundlerCapabilities,\n } = options;\n const warnings: RollupLog[] = [];\n\n return {\n warnings,\n inputOptions: {\n external: (id, parent) =>\n shouldExternalizePackage({\n inputPath,\n id,\n parent,\n inlined,\n external,\n polyfills,\n shouldInlineNodeBuiltins: true,\n targetEnvironment: options.targetEnvironment,\n mode: context.config.mode,\n }),\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: getRollupPlugins({\n isProduction: minify,\n packagePath: inputPath,\n requiresTranspile: context.requiresTranspile,\n dynamicImports,\n sourcemap,\n resolveWebExtensions: !!bundlerCapabilities?.['resolve-web-extensions'],\n config: context.config,\n relay: bundlerCapabilities?.relay,\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 entryFileNames: '[name].js',\n chunkFileNames: '[name].js',\n assetFileNames: 'assets/[name]-[extname]',\n // This is a fix so that the sourcemaps never include the hash in their path,\n // as that invalidates the sourcemap on change and removes break points.\n // ../../../../relative/path/to/src/path/to/file.ts -> rollup://src/path/to/file.ts\n sourcemapPathTransform: (relativeSourcePath, sourcemapPath) =>\n // No need to normalize the path as rollup will do that for us\n 'rollup://' + path.relative(inputPath, path.resolve(path.dirname(sourcemapPath), relativeSourcePath)),\n },\n };\n}\n"]}
@@ -1,10 +1,11 @@
1
1
  import type { Plugin } from 'rollup';
2
- import type { BundleContext } from '@ms-cloudpack/common-types';
3
- export declare function getRollupPlugins(options: Pick<BundleContext, 'requiresTranspile'> & {
2
+ import type { BundleContext, BundlerCapabilitiesOptions } from '@ms-cloudpack/common-types';
3
+ export declare function getRollupPlugins(options: Pick<BundleContext, 'requiresTranspile' | 'config'> & {
4
4
  isProduction: boolean | undefined;
5
5
  packagePath: string;
6
6
  dynamicImports: string[] | undefined;
7
7
  sourcemap: boolean | undefined;
8
8
  resolveWebExtensions: boolean;
9
+ relay: BundlerCapabilitiesOptions['relay'];
9
10
  }): Plugin[];
10
11
  //# sourceMappingURL=getRollupPlugins.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getRollupPlugins.d.ts","sourceRoot":"","sources":["../src/getRollupPlugins.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAKrC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAchE,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,IAAI,CAAC,aAAa,EAAE,mBAAmB,CAAC,GAAG;IAClD,YAAY,EAAE,OAAO,GAAG,SAAS,CAAC;IAClC,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IACrC,SAAS,EAAE,OAAO,GAAG,SAAS,CAAC;IAC/B,oBAAoB,EAAE,OAAO,CAAC;CAC/B,GACA,MAAM,EAAE,CAwHV"}
1
+ {"version":3,"file":"getRollupPlugins.d.ts","sourceRoot":"","sources":["../src/getRollupPlugins.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAKrC,OAAO,KAAK,EAAE,aAAa,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAC;AAgB5F,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,IAAI,CAAC,aAAa,EAAE,mBAAmB,GAAG,QAAQ,CAAC,GAAG;IAC7D,YAAY,EAAE,OAAO,GAAG,SAAS,CAAC;IAClC,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IACrC,SAAS,EAAE,OAAO,GAAG,SAAS,CAAC;IAC/B,oBAAoB,EAAE,OAAO,CAAC;IAC9B,KAAK,EAAE,0BAA0B,CAAC,OAAO,CAAC,CAAC;CAC5C,GACA,MAAM,EAAE,CA2JV"}
@@ -10,7 +10,9 @@ import _nodePolyfills from 'rollup-plugin-polyfill-node';
10
10
  import postcss from './plugins/postcss/index.js';
11
11
  import { normalizeRequireStatements } from './plugins/normalizeRequireStatements.js';
12
12
  import { importAsString } from 'rollup-plugin-string-import';
13
- import { isExternalPackage } from '@ms-cloudpack/path-utilities';
13
+ import { isExternalPackage, resolveModule } from '@ms-cloudpack/path-utilities';
14
+ import { fileURLToPath } from 'url';
15
+ import path from 'path';
14
16
  // Workaround for https://github.com/microsoft/TypeScript/issues/49189#issuecomment-1137756847
15
17
  // (https://arethetypeswrong.github.io/?p=%40rollup%2Fplugin-replace%405.0.2)
16
18
  // At runtime, we should always be using the ESM version of these packages, which use `export default`.
@@ -22,11 +24,33 @@ const nodePolyfills = _nodePolyfills;
22
24
  const dynamicImportVariables = _dynamicImportVariables;
23
25
  const swc = _swc;
24
26
  export function getRollupPlugins(options) {
25
- const { isProduction, packagePath, requiresTranspile, dynamicImports = [], sourcemap, resolveWebExtensions, } = options;
27
+ const { isProduction, packagePath, requiresTranspile, dynamicImports = [], sourcemap, resolveWebExtensions, config: { resolve }, relay, } = options;
26
28
  const isExternal = isExternalPackage(packagePath);
27
29
  // Only get the SWC config and transform code from internal packages, or if there are explicit
28
30
  // typescript or jsx entries
29
- const swcConfigs = !isExternal || requiresTranspile ? getSwcConfig({ packagePath, sourcemap }) : undefined;
31
+ const swcConfigs = !isExternal || requiresTranspile || relay ? getSwcConfig({ packagePath, sourcemap }) : undefined;
32
+ // Add relay plugin to SWC configs if enabled
33
+ if (swcConfigs && !!relay) {
34
+ // Ensure options is always an object before spreading
35
+ const safeOptions = relay && typeof relay === 'object' ? relay : {};
36
+ if (!safeOptions.rootDir) {
37
+ throw new Error('The relay capability requires a rootDir option to be set.');
38
+ }
39
+ // Base plugin options. "eagerEsModules" needs to be set or bundlers may default to "require" instead of inlining
40
+ const relayPluginOptions = { eagerEsModules: true, ...safeOptions, language: 'typescript' };
41
+ console.debug('Relay plugin options:', JSON.stringify(relayPluginOptions, null, 2));
42
+ const relayPlugin = fileURLToPath(resolveModule({ importSpecifier: '@swc/plugin-relay', parentUrl: import.meta.url }));
43
+ // Add relay plugin to tsx config
44
+ swcConfigs.tsx.jsc ??= {};
45
+ swcConfigs.tsx.jsc.experimental ??= {};
46
+ swcConfigs.tsx.jsc.experimental.plugins ??= [];
47
+ swcConfigs.tsx.jsc.experimental.plugins.push([relayPlugin, relayPluginOptions]);
48
+ // Add relay plugin to jsx config with JavaScript language
49
+ swcConfigs.jsx.jsc ??= {};
50
+ swcConfigs.jsx.jsc.experimental ??= {};
51
+ swcConfigs.jsx.jsc.experimental.plugins ??= [];
52
+ swcConfigs.jsx.jsc.experimental.plugins.push([relayPlugin, { ...relayPluginOptions, language: 'javascript' }]);
53
+ }
30
54
  return [
31
55
  // Used to replaces constants in the code.
32
56
  replace({
@@ -87,6 +111,8 @@ export function getRollupPlugins(options) {
87
111
  ...(!isExternal && resolveWebExtensions ? ['.web.ts', '.web.tsx'] : []),
88
112
  ...(!isExternal ? ['.ts', '.tsx'] : []),
89
113
  ],
114
+ moduleDirectories: resolve?.modules?.filter((m) => !path.isAbsolute(m)) ?? ['node_modules'],
115
+ modulePaths: resolve?.modules?.filter((m) => path.isAbsolute(m)) ?? undefined,
90
116
  }),
91
117
  // Used to browserify node globals (process, global, etc.)
92
118
  nodePolyfills(),
@@ -1 +1 @@
1
- {"version":3,"file":"getRollupPlugins.js","sourceRoot":"","sources":["../src/getRollupPlugins.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,uBAAuB,MAAM,oCAAoC,CAAC;AACzE,OAAO,IAAI,MAAM,yBAAyB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,QAAQ,MAAM,wBAAwB,CAAC;AAC9C,OAAO,IAAI,MAAM,oBAAoB,CAAC;AACtC,OAAO,OAAO,MAAM,uBAAuB,CAAC;AAC5C,OAAO,SAAS,MAAM,yBAAyB,CAAC;AAEhD,OAAO,cAAc,MAAM,6BAA6B,CAAC;AACzD,OAAO,OAAO,MAAM,4BAA4B,CAAC;AACjD,OAAO,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAE7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAEjE,8FAA8F;AAC9F,6EAA6E;AAC7E,uGAAuG;AACvG,kHAAkH;AAClH,MAAM,OAAO,GAAG,QAA8C,CAAC;AAC/D,MAAM,MAAM,GAAG,OAA4C,CAAC;AAC5D,MAAM,QAAQ,GAAG,SAAgD,CAAC;AAClE,MAAM,aAAa,GAAG,cAA0D,CAAC;AACjF,MAAM,sBAAsB,GAAG,uBAA4E,CAAC;AAC5G,MAAM,GAAG,GAAG,IAAsC,CAAC;AAEnD,MAAM,UAAU,gBAAgB,CAC9B,OAMC;IAED,MAAM,EACJ,YAAY,EACZ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QAC3C,CAAC,CAAC,YAAY,IAAI,MAAM,EAAE;QAE1B,cAAc,CAAC;YACb,OAAO,EAAE,WAAW;SACrB,CAAC;KACH,CAAC,MAAM,CAAC,CAAC,MAAM,EAAoB,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;AACnD,CAAC","sourcesContent":["import { getSwcConfig } from '@ms-cloudpack/bundler-utilities';\nimport _dynamicImportVariables from '@rollup/plugin-dynamic-import-vars';\nimport json from './plugins/json/index.js';\nimport { nodeResolve } from '@rollup/plugin-node-resolve';\nimport _replace from '@rollup/plugin-replace';\nimport _swc from '@rollup/plugin-swc';\nimport _terser from '@rollup/plugin-terser';\nimport _commonjs from '@rollup/plugin-commonjs';\nimport type { Plugin } from 'rollup';\nimport _nodePolyfills from 'rollup-plugin-polyfill-node';\nimport postcss from './plugins/postcss/index.js';\nimport { normalizeRequireStatements } from './plugins/normalizeRequireStatements.js';\nimport { importAsString } from 'rollup-plugin-string-import';\nimport type { BundleContext } from '@ms-cloudpack/common-types';\nimport { isExternalPackage } from '@ms-cloudpack/path-utilities';\n\n// Workaround for https://github.com/microsoft/TypeScript/issues/49189#issuecomment-1137756847\n// (https://arethetypeswrong.github.io/?p=%40rollup%2Fplugin-replace%405.0.2)\n// At runtime, we should always be using the ESM version of these packages, which use `export default`.\n// However, typescript interprets the types as CJS modules with a `default` property (which will fail at runtime).\nconst replace = _replace as unknown as typeof _replace.default;\nconst terser = _terser as unknown as typeof _terser.default;\nconst commonjs = _commonjs as unknown as typeof _commonjs.default;\nconst nodePolyfills = _nodePolyfills as unknown as typeof _nodePolyfills.default;\nconst dynamicImportVariables = _dynamicImportVariables as unknown as typeof _dynamicImportVariables.default;\nconst swc = _swc as unknown as typeof _swc.default;\n\nexport function getRollupPlugins(\n options: Pick<BundleContext, 'requiresTranspile'> & {\n isProduction: boolean | undefined;\n packagePath: string;\n dynamicImports: string[] | undefined;\n sourcemap: boolean | undefined;\n resolveWebExtensions: boolean;\n },\n): Plugin[] {\n const {\n isProduction,\n packagePath,\n requiresTranspile,\n dynamicImports = [],\n sourcemap,\n resolveWebExtensions,\n } = options;\n\n const isExternal = isExternalPackage(packagePath);\n\n // Only get the SWC config and transform code from internal packages, or if there are explicit\n // typescript or jsx entries\n const swcConfigs = !isExternal || requiresTranspile ? getSwcConfig({ packagePath, sourcemap }) : undefined;\n\n return [\n // Used to replaces constants in the code.\n replace({\n values: {\n 'process.env.NODE_ENV': isProduction ? `\"production\"` : `\"development\"`,\n DEPRECATED_UNIT_TEST: 'true',\n },\n preventAssignment: true,\n }),\n\n normalizeRequireStatements(),\n\n postcss({\n // Use named exports in addition to the default export.\n namedExports: true,\n // Respect the `modules` option regardless of the file extension.\n // Otherwise only *.module.* will be passed through postcss-modules and exports won't work correctly.\n autoModules: false,\n // Options for `postcss-modules` plugin. Note that as of writing, rollup-plugin-postcss\n // uses version 4: https://github.com/madyankin/postcss-modules/tree/v4.3.1\n modules: {\n // Treat .css and .s[ac]ss files as global stylesheets unless they have the `.module` suffix\n globalModulePaths: [/(?<!\\.module)\\.(css|s[ac]ss)$/],\n // Export global classnames in addition to local ones\n exportGlobals: true,\n // Convert non-identifier-friendly class names to exported camelCase identifiers (like css-loader),\n // but keep the original names to use in the default export object too\n localsConvention: 'camelCase',\n },\n // don't load postcss config\n config: false,\n minimize: isProduction,\n sourceMap: sourcemap,\n // spammy, non-actionable warning (types have incorrect extra required props)\n use: { sass: { silenceDeprecations: ['legacy-js-api'] } },\n }),\n\n // Used to parse commonjs.\n commonjs({\n // Treat all dependencies as external esm modules (since we'll be bundling them.)\n esmExternals: true,\n\n // When __esModule is true, the default export is `exports.default`; otherwise it's `module.exports`.\n defaultIsModuleExports: true,\n\n // Convert `require('library')` to `import * as library from 'library'` always, because `import library from\n // 'library' risks runtime failure if the dependency is ESM that doesn't export a default.\n requireReturnsDefault: false,\n }),\n\n // Used to compile json files into javascript exports.\n json({\n extensions: ['.json', '.resjson'],\n }),\n\n // // Used to resolve node_modules.\n nodeResolve({\n preferBuiltins: false,\n browser: true,\n // TODO: Align with other bundlers https://github.com/microsoft/cloudpack/issues/2687\n extensions: [\n ...(resolveWebExtensions ? ['.web.js'] : []),\n '.js',\n '.json',\n ...(!isExternal && resolveWebExtensions ? ['.web.ts', '.web.tsx'] : []),\n ...(!isExternal ? ['.ts', '.tsx'] : []),\n ],\n }),\n\n // Used to browserify node globals (process, global, etc.)\n nodePolyfills(),\n\n swcConfigs &&\n swc({\n include: /\\.[cm]?tsx?$/,\n swc: swcConfigs.tsx,\n }),\n\n // Support .jsx\n swcConfigs &&\n swc({\n include: /\\.[cm]?jsx$/,\n swc: swcConfigs.jsx,\n }),\n\n // Only run this plugin on **/*.dynamic.* files (plus others as specified) to avoid an extra\n // parsing/processing step on all files.\n // Must be done AFTER the TS step because it can only handle JS syntax.\n dynamicImportVariables({\n include: [\n '**/*.dynamic.*',\n // Convert the dynamic imports options to globs starting with **\n // (the plugin seems to be matching against full paths)\n ...dynamicImports.map((d) => (d.startsWith('**/') ? d : d.replace(/^(\\.?\\/)?/, '**/'))),\n ],\n }),\n\n // Minify production builds as a last step.\n !!isProduction && terser(),\n\n importAsString({\n include: '**/*.glsl',\n }),\n ].filter((plugin): plugin is Plugin => !!plugin);\n}\n"]}
1
+ {"version":3,"file":"getRollupPlugins.js","sourceRoot":"","sources":["../src/getRollupPlugins.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,uBAAuB,MAAM,oCAAoC,CAAC;AACzE,OAAO,IAAI,MAAM,yBAAyB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,QAAQ,MAAM,wBAAwB,CAAC;AAC9C,OAAO,IAAI,MAAM,oBAAoB,CAAC;AACtC,OAAO,OAAO,MAAM,uBAAuB,CAAC;AAC5C,OAAO,SAAS,MAAM,yBAAyB,CAAC;AAEhD,OAAO,cAAc,MAAM,6BAA6B,CAAC;A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,YAAY,IAAI,MAAM,EAAE;QAE1B,cAAc,CAAC;YACb,OAAO,EAAE,WAAW;SACrB,CAAC;KACH,CAAC,MAAM,CAAC,CAAC,MAAM,EAAoB,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;AACnD,CAAC","sourcesContent":["import { getSwcConfig } from '@ms-cloudpack/bundler-utilities';\nimport _dynamicImportVariables from '@rollup/plugin-dynamic-import-vars';\nimport json from './plugins/json/index.js';\nimport { nodeResolve } from '@rollup/plugin-node-resolve';\nimport _replace from '@rollup/plugin-replace';\nimport _swc from '@rollup/plugin-swc';\nimport _terser from '@rollup/plugin-terser';\nimport _commonjs from '@rollup/plugin-commonjs';\nimport type { Plugin } from 'rollup';\nimport _nodePolyfills from 'rollup-plugin-polyfill-node';\nimport postcss from './plugins/postcss/index.js';\nimport { normalizeRequireStatements } from './plugins/normalizeRequireStatements.js';\nimport { importAsString } from 'rollup-plugin-string-import';\nimport type { BundleContext, BundlerCapabilitiesOptions } from '@ms-cloudpack/common-types';\nimport { isExternalPackage, resolveModule } from '@ms-cloudpack/path-utilities';\nimport { fileURLToPath } from 'url';\nimport path from 'path';\n\n// Workaround for https://github.com/microsoft/TypeScript/issues/49189#issuecomment-1137756847\n// (https://arethetypeswrong.github.io/?p=%40rollup%2Fplugin-replace%405.0.2)\n// At runtime, we should always be using the ESM version of these packages, which use `export default`.\n// However, typescript interprets the types as CJS modules with a `default` property (which will fail at runtime).\nconst replace = _replace as unknown as typeof _replace.default;\nconst terser = _terser as unknown as typeof _terser.default;\nconst commonjs = _commonjs as unknown as typeof _commonjs.default;\nconst nodePolyfills = _nodePolyfills as unknown as typeof _nodePolyfills.default;\nconst dynamicImportVariables = _dynamicImportVariables as unknown as typeof _dynamicImportVariables.default;\nconst swc = _swc as unknown as typeof _swc.default;\n\nexport function getRollupPlugins(\n options: Pick<BundleContext, 'requiresTranspile' | 'config'> & {\n isProduction: boolean | undefined;\n packagePath: string;\n dynamicImports: string[] | undefined;\n sourcemap: boolean | undefined;\n resolveWebExtensions: boolean;\n relay: BundlerCapabilitiesOptions['relay'];\n },\n): Plugin[] {\n const {\n isProduction,\n packagePath,\n requiresTranspile,\n dynamicImports = [],\n sourcemap,\n resolveWebExtensions,\n config: { resolve },\n relay,\n } = options;\n\n const isExternal = isExternalPackage(packagePath);\n\n // Only get the SWC config and transform code from internal packages, or if there are explicit\n // typescript or jsx entries\n const swcConfigs = !isExternal || requiresTranspile || relay ? getSwcConfig({ packagePath, sourcemap }) : undefined;\n\n // Add relay plugin to SWC configs if enabled\n if (swcConfigs && !!relay) {\n // Ensure options is always an object before spreading\n const safeOptions: Partial<typeof relay> = relay && typeof relay === 'object' ? relay : {};\n\n if (!safeOptions.rootDir) {\n throw new Error('The relay capability requires a rootDir option to be set.');\n }\n\n // Base plugin options. \"eagerEsModules\" needs to be set or bundlers may default to \"require\" instead of inlining\n const relayPluginOptions = { eagerEsModules: true, ...safeOptions, language: 'typescript' };\n\n console.debug('Relay plugin options:', JSON.stringify(relayPluginOptions, null, 2));\n\n const relayPlugin = fileURLToPath(\n resolveModule({ importSpecifier: '@swc/plugin-relay', parentUrl: import.meta.url }),\n );\n\n // Add relay plugin to tsx config\n swcConfigs.tsx.jsc ??= {};\n swcConfigs.tsx.jsc.experimental ??= {};\n swcConfigs.tsx.jsc.experimental.plugins ??= [];\n swcConfigs.tsx.jsc.experimental.plugins.push([relayPlugin, relayPluginOptions]);\n\n // Add relay plugin to jsx config with JavaScript language\n swcConfigs.jsx.jsc ??= {};\n swcConfigs.jsx.jsc.experimental ??= {};\n swcConfigs.jsx.jsc.experimental.plugins ??= [];\n swcConfigs.jsx.jsc.experimental.plugins.push([relayPlugin, { ...relayPluginOptions, language: 'javascript' }]);\n }\n\n return [\n // Used to replaces constants in the code.\n replace({\n values: {\n 'process.env.NODE_ENV': isProduction ? `\"production\"` : `\"development\"`,\n DEPRECATED_UNIT_TEST: 'true',\n },\n preventAssignment: true,\n }),\n\n normalizeRequireStatements(),\n\n postcss({\n // Use named exports in addition to the default export.\n namedExports: true,\n // Respect the `modules` option regardless of the file extension.\n // Otherwise only *.module.* will be passed through postcss-modules and exports won't work correctly.\n autoModules: false,\n // Options for `postcss-modules` plugin. Note that as of writing, rollup-plugin-postcss\n // uses version 4: https://github.com/madyankin/postcss-modules/tree/v4.3.1\n modules: {\n // Treat .css and .s[ac]ss files as global stylesheets unless they have the `.module` suffix\n globalModulePaths: [/(?<!\\.module)\\.(css|s[ac]ss)$/],\n // Export global classnames in addition to local ones\n exportGlobals: true,\n // Convert non-identifier-friendly class names to exported camelCase identifiers (like css-loader),\n // but keep the original names to use in the default export object too\n localsConvention: 'camelCase',\n },\n // don't load postcss config\n config: false,\n minimize: isProduction,\n sourceMap: sourcemap,\n // spammy, non-actionable warning (types have incorrect extra required props)\n use: { sass: { silenceDeprecations: ['legacy-js-api'] } },\n }),\n\n // Used to parse commonjs.\n commonjs({\n // Treat all dependencies as external esm modules (since we'll be bundling them.)\n esmExternals: true,\n\n // When __esModule is true, the default export is `exports.default`; otherwise it's `module.exports`.\n defaultIsModuleExports: true,\n\n // Convert `require('library')` to `import * as library from 'library'` always, because `import library from\n // 'library' risks runtime failure if the dependency is ESM that doesn't export a default.\n requireReturnsDefault: false,\n }),\n\n // Used to compile json files into javascript exports.\n json({\n extensions: ['.json', '.resjson'],\n }),\n\n // // Used to resolve node_modules.\n nodeResolve({\n preferBuiltins: false,\n browser: true,\n // TODO: Align with other bundlers https://github.com/microsoft/cloudpack/issues/2687\n extensions: [\n ...(resolveWebExtensions ? ['.web.js'] : []),\n '.js',\n '.json',\n ...(!isExternal && resolveWebExtensions ? ['.web.ts', '.web.tsx'] : []),\n ...(!isExternal ? ['.ts', '.tsx'] : []),\n ],\n moduleDirectories: resolve?.modules?.filter((m) => !path.isAbsolute(m)) ?? ['node_modules'],\n modulePaths: resolve?.modules?.filter((m) => path.isAbsolute(m)) ?? undefined,\n }),\n\n // Used to browserify node globals (process, global, etc.)\n nodePolyfills(),\n\n swcConfigs &&\n swc({\n include: /\\.[cm]?tsx?$/,\n swc: swcConfigs.tsx,\n }),\n\n // Support .jsx\n swcConfigs &&\n swc({\n include: /\\.[cm]?jsx$/,\n swc: swcConfigs.jsx,\n }),\n\n // Only run this plugin on **/*.dynamic.* files (plus others as specified) to avoid an extra\n // parsing/processing step on all files.\n // Must be done AFTER the TS step because it can only handle JS syntax.\n dynamicImportVariables({\n include: [\n '**/*.dynamic.*',\n // Convert the dynamic imports options to globs starting with **\n // (the plugin seems to be matching against full paths)\n ...dynamicImports.map((d) => (d.startsWith('**/') ? d : d.replace(/^(\\.?\\/)?/, '**/'))),\n ],\n }),\n\n // Minify production builds as a last step.\n !!isProduction && terser(),\n\n importAsString({\n include: '**/*.glsl',\n }),\n ].filter((plugin): plugin is Plugin => !!plugin);\n}\n"]}
@@ -4,7 +4,7 @@ import type { OutputOptions, RollupOptions, RollupOutput, RollupLog } from 'roll
4
4
  * Converts rollup output to a BundlerResult.
5
5
  */
6
6
  export declare function normalizeRollupOutput(params: {
7
- options: Pick<BundleOptions, 'entries' | 'inputPath'>;
7
+ options: Pick<BundleOptions, 'entries' | 'inputPath' | 'bundlerCapabilities'>;
8
8
  inputOptions: RollupOptions;
9
9
  outputOptions: OutputOptions;
10
10
  output: RollupOutput;
@@ -1 +1 @@
1
- {"version":3,"file":"normalizeRollupOutput.d.ts","sourceRoot":"","sources":["../src/normalizeRollupOutput.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAoB,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAEjG,OAAO,KAAK,EAAe,aAAa,EAAE,aAAa,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAGjG;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE;IAC5C,OAAO,EAAE,IAAI,CAAC,aAAa,EAAE,SAAS,GAAG,WAAW,CAAC,CAAC;IACtD,YAAY,EAAE,aAAa,CAAC;IAC5B,aAAa,EAAE,aAAa,CAAC;IAC7B,MAAM,EAAE,YAAY,CAAC;IACrB,QAAQ,EAAE,SAAS,EAAE,CAAC;CACvB,GAAG,aAAa,CAmChB"}
1
+ {"version":3,"file":"normalizeRollupOutput.d.ts","sourceRoot":"","sources":["../src/normalizeRollupOutput.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAoB,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAEjG,OAAO,KAAK,EAAe,aAAa,EAAE,aAAa,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAGjG;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE;IAC5C,OAAO,EAAE,IAAI,CAAC,aAAa,EAAE,SAAS,GAAG,WAAW,GAAG,qBAAqB,CAAC,CAAC;IAC9E,YAAY,EAAE,aAAa,CAAC;IAC5B,aAAa,EAAE,aAAa,CAAC;IAC7B,MAAM,EAAE,YAAY,CAAC;IACrB,QAAQ,EAAE,SAAS,EAAE,CAAC;CACvB,GAAG,aAAa,CA8ChB"}
@@ -26,11 +26,20 @@ export function normalizeRollupOutput(params) {
26
26
  return outFile;
27
27
  }) || [],
28
28
  errors: [],
29
- warnings: warnings.map((warning) => ({
29
+ warnings: warnings
30
+ .map((warning) => ({
30
31
  text: warning.message,
31
32
  location: normalizeRollupLoc({ loc: warning.loc, inputPath: options.inputPath }),
32
33
  source: 'rollup',
33
- })),
34
+ }))
35
+ .filter((warning) => {
36
+ // Skip spammy graphql external warnings when relay is enabled
37
+ if (options.bundlerCapabilities?.relay) {
38
+ return !(warning.text.startsWith('"graphql" is imported from external module') &&
39
+ warning.text.includes('but never used in'));
40
+ }
41
+ return true;
42
+ }),
34
43
  rawInput: { inputOptions, outputOptions },
35
44
  rawOutput: output,
36
45
  };
@@ -1 +1 @@
1
- {"version":3,"file":"normalizeRollupOutput.js","sourceRoot":"","sources":["../src/normalizeRollupOutput.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE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AAM,EAAE,QAAQ;SACjB,CAAC,CAAC;QACH,QAAQ,EAAE,EAAE,YAAY,EAAE,aAAa,EAAE;QACzC,SAAS,EAAE,MAA4C;KACxD,CAAC;AACJ,CAAC","sourcesContent":["import type { BundleOptions, BundleOutputFile, BundlerResult } from '@ms-cloudpack/common-types';\nimport { normalizeRelativePath } from '@ms-cloudpack/path-string-parsing';\nimport type { OutputChunk, OutputOptions, RollupOptions, RollupOutput, RollupLog } from 'rollup';\nimport { normalizeRollupLoc } from './normalizeRollupLoc.js';\n\n/**\n * Converts rollup output to a BundlerResult.\n */\nexport function normalizeRollupOutput(params: {\n options: Pick<BundleOptions, 'entries' | 'inputPath'>;\n inputOptions: RollupOptions;\n outputOptions: OutputOptions;\n output: RollupOutput;\n warnings: RollupLog[];\n}): BundlerResult {\n const { options, inputOptions, outputOptions, output, warnings } = params;\n const outputPath = outputOptions.dir;\n if (!outputPath) {\n throw new Error('Expected outputOptions.dir to be set (this is a bug in Cloudpack)');\n }\n\n return {\n outputPath,\n outputFiles:\n output.output?.map((chunk): BundleOutputFile => {\n const outFile: BundleOutputFile = {\n outputPath: normalizeRelativePath(chunk.fileName),\n exports: (chunk as OutputChunk).exports,\n };\n\n // Rollup doesn't include entry point info in the output, so add manually if applicable\n if (outFile.outputPath.endsWith('.js')) {\n const entryPoint = options.entries[outFile.outputPath.replace(/\\.js$/, '')];\n if (entryPoint) {\n outFile.entryPoint = entryPoint;\n }\n }\n\n return outFile;\n }) || [],\n errors: [],\n warnings: warnings.map((warning) => ({\n text: warning.message,\n location: normalizeRollupLoc({ loc: warning.loc, inputPath: options.inputPath }),\n source: 'rollup',\n })),\n rawInput: { inputOptions, outputOptions },\n rawOutput: output as unknown as Record<string, unknown>,\n };\n}\n"]}
1
+ {"version":3,"file":"normalizeRollupOutput.js","sourceRoot":"","sources":["../src/normalizeRollupOutput.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAE1E,OAA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AC;aACF,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE;YAClB,8DAA8D;YAC9D,IAAI,OAAO,CAAC,mBAAmB,EAAE,KAAK,EAAE,CAAC;gBACvC,OAAO,CAAC,CACN,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,4CAA4C,CAAC;oBACrE,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,mBAAmB,CAAC,CAC3C,CAAC;YACJ,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC,CAAC;QACJ,QAAQ,EAAE,EAAE,YAAY,EAAE,aAAa,EAAE;QACzC,SAAS,EAAE,MAA4C;KACxD,CAAC;AACJ,CAAC","sourcesContent":["import type { BundleOptions, BundleOutputFile, BundlerResult } from '@ms-cloudpack/common-types';\nimport { normalizeRelativePath } from '@ms-cloudpack/path-string-parsing';\nimport type { OutputChunk, OutputOptions, RollupOptions, RollupOutput, RollupLog } from 'rollup';\nimport { normalizeRollupLoc } from './normalizeRollupLoc.js';\n\n/**\n * Converts rollup output to a BundlerResult.\n */\nexport function normalizeRollupOutput(params: {\n options: Pick<BundleOptions, 'entries' | 'inputPath' | 'bundlerCapabilities'>;\n inputOptions: RollupOptions;\n outputOptions: OutputOptions;\n output: RollupOutput;\n warnings: RollupLog[];\n}): BundlerResult {\n const { options, inputOptions, outputOptions, output, warnings } = params;\n const outputPath = outputOptions.dir;\n if (!outputPath) {\n throw new Error('Expected outputOptions.dir to be set (this is a bug in Cloudpack)');\n }\n\n return {\n outputPath,\n outputFiles:\n output.output?.map((chunk): BundleOutputFile => {\n const outFile: BundleOutputFile = {\n outputPath: normalizeRelativePath(chunk.fileName),\n exports: (chunk as OutputChunk).exports,\n };\n\n // Rollup doesn't include entry point info in the output, so add manually if applicable\n if (outFile.outputPath.endsWith('.js')) {\n const entryPoint = options.entries[outFile.outputPath.replace(/\\.js$/, '')];\n if (entryPoint) {\n outFile.entryPoint = entryPoint;\n }\n }\n\n return outFile;\n }) || [],\n errors: [],\n warnings: warnings\n .map((warning) => ({\n text: warning.message,\n location: normalizeRollupLoc({ loc: warning.loc, inputPath: options.inputPath }),\n source: 'rollup' as const,\n }))\n .filter((warning) => {\n // Skip spammy graphql external warnings when relay is enabled\n if (options.bundlerCapabilities?.relay) {\n return !(\n warning.text.startsWith('\"graphql\" is imported from external module') &&\n warning.text.includes('but never used in')\n );\n }\n return true;\n }),\n rawInput: { inputOptions, outputOptions },\n rawOutput: output as unknown as Record<string, unknown>,\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,EAAU,aAAa,EAAE,MAAM,QAAQ,CAAC;AAoBnE,eAAO,MAAM,kBAAkB,EAAE,wCAAwC,CAAC;IACxE,YAAY,EAAE,aAAa,CAAC;IAC5B,aAAa,EAAE,aAAa,CAAC;CAC9B,CAkCA,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,EAAU,aAAa,EAAE,MAAM,QAAQ,CAAC;AAoBnE,eAAO,MAAM,kBAAkB,EAAE,wCAAwC,CAAC;IACxE,YAAY,EAAE,aAAa,CAAC;IAC5B,aAAa,EAAE,aAAa,CAAC;CAC9B,CAoCA,CAAC"}
@@ -40,6 +40,8 @@ export const rollupCapabilities = {
40
40
  }));
41
41
  return config;
42
42
  },
43
+ // This is just a placeholder for the relay capability. It is handled in getRollupPlugins.ts.
44
+ relay: (config) => config,
43
45
  // This is a placeholder for the density capability. It doesn't do anything in the bundler.
44
46
  // It's just a workaround for a post-bundle task. This will be replaced with 'plugins' in the future.
45
47
  density: (config) => config,
@@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/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,8GAA8G;IAC9G,wBAAwB,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM;IAC5C,MAAM,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE;QAC1B,UAAU,CACR,MAAM,CAAC,YAAY,EACnB,OAAO,CAAC;YACN,iBAAiB,EAAE,IAAI;YACvB,MAAM,EAAE,OAAO;SAChB,CAAC,CACH,CAAC;QACF,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, Plugin, RollupOptions } from 'rollup';\nimport { mergeObjects } from '@ms-cloudpack/package-utilities';\nimport _url from '@rollup/plugin-url';\nimport _replace from '@rollup/plugin-replace';\n\n// See more about the type workaround at getRollupPlugins.ts\nconst url = _url as unknown as typeof _url.default;\nconst replace = _replace as unknown as typeof _replace.default;\n\n// Small helper to normalize and push a plugin into RollupOptions.plugins\nfunction pushPlugin(inputOptions: RollupOptions, plugin: Plugin) {\n if (!inputOptions.plugins) {\n inputOptions.plugins = [plugin];\n } else if (Array.isArray(inputOptions.plugins)) {\n inputOptions.plugins.push(plugin);\n } else {\n inputOptions.plugins = [inputOptions.plugins, plugin];\n }\n}\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 pushPlugin(\n config.inputOptions,\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 just a placeholder for the resolve-web-extensions capability. It is handled in getRollupPlugins.ts.\n 'resolve-web-extensions': (config) => config,\n define: (config, options) => {\n pushPlugin(\n config.inputOptions,\n replace({\n preventAssignment: true,\n values: options,\n }),\n );\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;AACtC,OAAO,QAAQ,MAAM,wBAAwB,CAAC;AAE9C,4DAA4D;AAC5D,MAAM,GAAG,GAAG,IAAsC,CAAC;AACnD,MAAM,OAAO,GAAG,QAA8C,CAAC;AAE/D,yEAAyE;AACzE,SAAS,UAAU,CAAC,YAA2B,EAAE,MAAc;IAC7D,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;QAC1B,YAAY,CAAC,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC;IAClC,CAAC;SAAM,IAAI,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,CAAC;QAC/C,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACpC,CAAC;SAAM,CAAC;QACN,YAAY,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C,MAAM,EAAE,EAAE,CAAC,MAAM;IACzB,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, Plugin, RollupOptions } from 'rollup';\nimport { mergeObjects } from '@ms-cloudpack/package-utilities';\nimport _url from '@rollup/plugin-url';\nimport _replace from '@rollup/plugin-replace';\n\n// See more about the type workaround at getRollupPlugins.ts\nconst url = _url as unknown as typeof _url.default;\nconst replace = _replace as unknown as typeof _replace.default;\n\n// Small helper to normalize and push a plugin into RollupOptions.plugins\nfunction pushPlugin(inputOptions: RollupOptions, plugin: Plugin) {\n if (!inputOptions.plugins) {\n inputOptions.plugins = [plugin];\n } else if (Array.isArray(inputOptions.plugins)) {\n inputOptions.plugins.push(plugin);\n } else {\n inputOptions.plugins = [inputOptions.plugins, plugin];\n }\n}\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 pushPlugin(\n config.inputOptions,\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 just a placeholder for the resolve-web-extensions capability. It is handled in getRollupPlugins.ts.\n 'resolve-web-extensions': (config) => config,\n define: (config, options) => {\n pushPlugin(\n config.inputOptions,\n replace({\n preventAssignment: true,\n values: options,\n }),\n );\n return config;\n },\n // This is just a placeholder for the relay capability. It is handled in getRollupPlugins.ts.\n relay: (config) => config,\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.4.16",
3
+ "version": "0.4.18",
4
4
  "description": "Cloudpack's wrapper for the Rollup bundler",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -14,13 +14,13 @@
14
14
  }
15
15
  },
16
16
  "dependencies": {
17
- "@ms-cloudpack/bundler-capabilities": "^0.3.4",
18
- "@ms-cloudpack/bundler-utilities": "^0.5.11",
19
- "@ms-cloudpack/common-types": "^0.28.1",
20
- "@ms-cloudpack/esm-stub-utilities": "^0.15.17",
21
- "@ms-cloudpack/package-utilities": "^12.5.3",
17
+ "@ms-cloudpack/bundler-capabilities": "^0.4.0",
18
+ "@ms-cloudpack/bundler-utilities": "^0.6.0",
19
+ "@ms-cloudpack/common-types": "^0.29.0",
20
+ "@ms-cloudpack/esm-stub-utilities": "^0.15.19",
21
+ "@ms-cloudpack/package-utilities": "^13.0.1",
22
22
  "@ms-cloudpack/path-string-parsing": "^1.2.7",
23
- "@ms-cloudpack/path-utilities": "^3.1.24",
23
+ "@ms-cloudpack/path-utilities": "^3.1.26",
24
24
  "@rollup/plugin-commonjs": "^28.0.4",
25
25
  "@rollup/plugin-dynamic-import-vars": "^2.0.0",
26
26
  "@rollup/plugin-node-resolve": "^16.0.0",
@@ -30,6 +30,7 @@
30
30
  "@rollup/plugin-url": "^8.0.0",
31
31
  "@rollup/pluginutils": "^5.0.1",
32
32
  "@swc/core": "^1.3.0",
33
+ "@swc/plugin-relay": "^6.0.0 || ^7.0.0 || ^8.0.0 || ^9.0.0",
33
34
  "concat-with-sourcemaps": "^1.1.0",
34
35
  "cssnano": "^6.0.0",
35
36
  "magic-string": "^0.30.5",