@ms-cloudpack/bundler-rollup 0.6.1 → 0.6.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.
Files changed (50) hide show
  1. package/lib/getRollupCapabilities.d.ts +9 -0
  2. package/lib/getRollupCapabilities.d.ts.map +1 -0
  3. package/lib/{rollupCapabilities.js → getRollupCapabilities.js} +10 -4
  4. package/lib/getRollupCapabilities.js.map +1 -0
  5. package/lib/getRollupPlugins.d.ts.map +1 -1
  6. package/lib/getRollupPlugins.js +5 -5
  7. package/lib/getRollupPlugins.js.map +1 -1
  8. package/lib/plugins/postcss/index.d.ts +3 -3
  9. package/lib/plugins/postcss/index.d.ts.map +1 -1
  10. package/lib/plugins/postcss/index.js +8 -520
  11. package/lib/plugins/postcss/index.js.map +1 -1
  12. package/lib/plugins/postcss/less-loader.d.ts +9 -0
  13. package/lib/plugins/postcss/less-loader.d.ts.map +1 -0
  14. package/lib/plugins/postcss/less-loader.js +36 -0
  15. package/lib/plugins/postcss/less-loader.js.map +1 -0
  16. package/lib/plugins/postcss/loaders.d.ts +26 -0
  17. package/lib/plugins/postcss/loaders.d.ts.map +1 -0
  18. package/lib/plugins/postcss/loaders.js +93 -0
  19. package/lib/plugins/postcss/loaders.js.map +1 -0
  20. package/lib/plugins/postcss/postcss-loader.d.ts +10 -0
  21. package/lib/plugins/postcss/postcss-loader.d.ts.map +1 -0
  22. package/lib/plugins/postcss/postcss-loader.js +168 -0
  23. package/lib/plugins/postcss/postcss-loader.js.map +1 -0
  24. package/lib/plugins/postcss/sass-loader.d.ts +9 -0
  25. package/lib/plugins/postcss/sass-loader.d.ts.map +1 -0
  26. package/lib/plugins/postcss/sass-loader.js +99 -0
  27. package/lib/plugins/postcss/sass-loader.js.map +1 -0
  28. package/lib/plugins/postcss/types.d.ts +42 -0
  29. package/lib/plugins/postcss/types.d.ts.map +1 -0
  30. package/lib/plugins/postcss/types.js +3 -0
  31. package/lib/plugins/postcss/types.js.map +1 -0
  32. package/lib/plugins/postcss/utils/humanlize-path.d.ts +3 -0
  33. package/lib/plugins/postcss/utils/humanlize-path.d.ts.map +1 -0
  34. package/lib/plugins/postcss/utils/humanlize-path.js +7 -0
  35. package/lib/plugins/postcss/utils/humanlize-path.js.map +1 -0
  36. package/lib/plugins/postcss/utils/load-module.d.ts +7 -0
  37. package/lib/plugins/postcss/utils/load-module.d.ts.map +1 -0
  38. package/lib/plugins/postcss/utils/load-module.js +27 -0
  39. package/lib/plugins/postcss/utils/load-module.js.map +1 -0
  40. package/lib/plugins/postcss/utils/normalize-path.d.ts +3 -0
  41. package/lib/plugins/postcss/utils/normalize-path.d.ts.map +1 -0
  42. package/lib/plugins/postcss/utils/normalize-path.js +4 -0
  43. package/lib/plugins/postcss/utils/normalize-path.js.map +1 -0
  44. package/lib/rollup.d.ts.map +1 -1
  45. package/lib/rollup.js +5 -3
  46. package/lib/rollup.js.map +1 -1
  47. package/package.json +10 -8
  48. package/lib/rollupCapabilities.d.ts +0 -7
  49. package/lib/rollupCapabilities.d.ts.map +0 -1
  50. package/lib/rollupCapabilities.js.map +0 -1
@@ -0,0 +1,9 @@
1
+ import type { BundleContext, InternalBundlerCapabilityImplementations } from '@ms-cloudpack/common-types';
2
+ import type { OutputOptions, RollupOptions } from 'rollup';
3
+ import type { DefineFlags } from '@ms-cloudpack/common-types-browser';
4
+ export declare function toReplaceValues(defs: DefineFlags): Record<string, string>;
5
+ export declare const getRollupCapabilities: (context: Pick<BundleContext, "config">) => InternalBundlerCapabilityImplementations<{
6
+ inputOptions: RollupOptions;
7
+ outputOptions: OutputOptions;
8
+ }>;
9
+ //# sourceMappingURL=getRollupCapabilities.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getRollupCapabilities.d.ts","sourceRoot":"","sources":["../src/getRollupCapabilities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,wCAAwC,EAAE,MAAM,4BAA4B,CAAC;AAC1G,OAAO,KAAK,EAAE,aAAa,EAAU,aAAa,EAAE,MAAM,QAAQ,CAAC;AAKnE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AAiBtE,wBAAgB,eAAe,CAAC,IAAI,EAAE,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAIzE;AAED,eAAO,MAAM,qBAAqB,GAChC,SAAS,IAAI,CAAC,aAAa,EAAE,QAAQ,CAAC,KACrC,wCAAwC,CAAC;IAC1C,YAAY,EAAE,aAAa,CAAC;IAC5B,aAAa,EAAE,aAAa,CAAC;CAC9B,CAwCC,CAAC"}
@@ -17,7 +17,10 @@ function pushPlugin(inputOptions, plugin) {
17
17
  inputOptions.plugins = [inputOptions.plugins, plugin];
18
18
  }
19
19
  }
20
- export const rollupCapabilities = {
20
+ export function toReplaceValues(defs) {
21
+ return Object.fromEntries(Object.entries(defs).map(([k, v]) => [k, typeof v === 'object' ? JSON.stringify(v) : v.toString()]));
22
+ }
23
+ export const getRollupCapabilities = (context) => ({
21
24
  'asset-inline': (config, options) => {
22
25
  // Process extensions based on format (array or object)
23
26
  const extensions = processAssetInlineExtensions(options.extensions);
@@ -38,7 +41,10 @@ export const rollupCapabilities = {
38
41
  define: (config, options) => {
39
42
  pushPlugin(config.inputOptions, replace({
40
43
  preventAssignment: true,
41
- values: options,
44
+ values: {
45
+ ...(context.config.mode === 'production' ? toReplaceValues(context.config.define ?? {}) : {}),
46
+ ...options,
47
+ },
42
48
  }));
43
49
  return config;
44
50
  },
@@ -47,5 +53,5 @@ export const rollupCapabilities = {
47
53
  // This is a placeholder for the density capability. It doesn't do anything in the bundler.
48
54
  // It's just a workaround for a post-bundle task. This will be replaced with 'plugins' in the future.
49
55
  density: (config) => config,
50
- };
51
- //# sourceMappingURL=rollupCapabilities.js.map
56
+ });
57
+ //# sourceMappingURL=getRollupCapabilities.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getRollupCapabilities.js","sourceRoot":"","sources":["../src/get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","sourcesContent":["import type { BundleContext, InternalBundlerCapabilityImplementations } from '@ms-cloudpack/common-types';\nimport type { OutputOptions, Plugin, RollupOptions } from 'rollup';\nimport { mergeObjects } from '@ms-cloudpack/package-utilities';\nimport { processAssetInlineExtensions } from '@ms-cloudpack/bundler-utilities';\nimport _url from '@rollup/plugin-url';\nimport _replace from '@rollup/plugin-replace';\nimport type { DefineFlags } from '@ms-cloudpack/common-types-browser';\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 function toReplaceValues(defs: DefineFlags): Record<string, string> {\n return Object.fromEntries(\n Object.entries(defs).map(([k, v]) => [k, typeof v === 'object' ? JSON.stringify(v) : v.toString()]),\n );\n}\n\nexport const getRollupCapabilities = (\n context: Pick<BundleContext, 'config'>,\n): InternalBundlerCapabilityImplementations<{\n inputOptions: RollupOptions;\n outputOptions: OutputOptions;\n}> => ({\n 'asset-inline': (config, options) => {\n // Process extensions based on format (array or object)\n const extensions = processAssetInlineExtensions(options.extensions);\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: Number.POSITIVE_INFINITY, // 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: {\n ...(context.config.mode === 'production' ? toReplaceValues(context.config.define ?? {}) : {}),\n ...options,\n },\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"]}
@@ -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;AAIrC,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAsC,MAAM,4BAA4B,CAAC;AAmBnH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,aAAa,EAAE,SAAS,CAAC,EAAE,OAAO,EAAE,aAAa,GAAG,MAAM,EAAE,CAoK1G"}
1
+ {"version":3,"file":"getRollupPlugins.d.ts","sourceRoot":"","sources":["../src/getRollupPlugins.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAIrC,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAsC,MAAM,4BAA4B,CAAC;AAyBnH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,aAAa,EAAE,SAAS,CAAC,EAAE,OAAO,EAAE,aAAa,GAAG,MAAM,EAAE,CAoK1G"}
@@ -9,7 +9,7 @@ import _commonjs from '@rollup/plugin-commonjs';
9
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
- import { isExternalPackage, resolveModule } from '@ms-cloudpack/path-utilities';
12
+ import { isExternalPackage, resolveModule, jsxRegex, typescriptRegex, webExtensions, } from '@ms-cloudpack/path-utilities';
13
13
  import { fileURLToPath } from 'url';
14
14
  import path from 'path';
15
15
  import aliasPlugin from '@rollup/plugin-alias';
@@ -116,10 +116,10 @@ export function getRollupPlugins(options, context) {
116
116
  browser: true,
117
117
  // TODO: Align with other bundlers https://github.com/microsoft/cloudpack/issues/2687
118
118
  extensions: [
119
- ...(resolveWebExtensions ? ['.web.js'] : []),
119
+ ...(resolveWebExtensions ? webExtensions.filter((ext) => ext.includes('j')) : []),
120
120
  '.js',
121
121
  '.json',
122
- ...(!isExternal && resolveWebExtensions ? ['.web.ts', '.web.tsx'] : []),
122
+ ...(!isExternal && resolveWebExtensions ? webExtensions.filter((ext) => !ext.includes('j')) : []),
123
123
  ...(!isExternal ? ['.ts', '.tsx'] : []),
124
124
  ],
125
125
  moduleDirectories: resolve?.modules?.filter((m) => !path.isAbsolute(m)) ?? ['node_modules'],
@@ -129,13 +129,13 @@ export function getRollupPlugins(options, context) {
129
129
  nodePolyfills(),
130
130
  swcConfigs &&
131
131
  swc({
132
- include: /\.[cm]?tsx?$/,
132
+ include: typescriptRegex,
133
133
  swc: swcConfigs.tsx,
134
134
  }),
135
135
  // Support .jsx
136
136
  swcConfigs &&
137
137
  swc({
138
- include: /\.[cm]?jsx$/,
138
+ include: jsxRegex,
139
139
  swc: swcConfigs.jsx,
140
140
  }),
141
141
  // Only run this plugin on **/*.dynamic.* files (plus others as specified) to avoid an extra
@@ -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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AU;YACR,GAAG,CAAC;gBACF,OAAO,EAAE,aAAa;gBACtB,GAAG,EAAE,UAAU,CAAC,GAAG;aACpB,CAAC;QAEJ,4FAA4F;QAC5F,wCAAwC;QACxC,uEAAuE;QACvE,sBAAsB,CAAC;YACrB,OAAO,EAAE;gBACP,gBAAgB;gBAChB,gEAAgE;gBAChE,uDAAuD;gBACvD,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC,CAAC;aACxF;SACF,CAAC;QAEF,2CAA2C;QAC3C,CAAC,CAAC,YAAY,IAAI,MAAM,EAAE;QAE1B,YAAY,CAAC;YACX,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 type { BundleContext, BundleOptions, InternalBundlerCapabilitiesOptions } from '@ms-cloudpack/common-types';\nimport { isExternalPackage, resolveModule } from '@ms-cloudpack/path-utilities';\nimport { fileURLToPath } from 'url';\nimport path from 'path';\nimport aliasPlugin from '@rollup/plugin-alias';\nimport stringImport from './plugins/stringImport.js';\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;\nconst alias = aliasPlugin as unknown as typeof aliasPlugin.default;\n\nexport function getRollupPlugins(options: Omit<BundleOptions, 'entries'>, context: BundleContext): Plugin[] {\n const {\n minify: isProduction,\n inputPath: packagePath,\n dynamicImports = [],\n sourcemap,\n dedupeAliases,\n bundlerCapabilities = {},\n } = options;\n const { relay, 'resolve-web-extensions': resolveWebExtensions } =\n bundlerCapabilities as InternalBundlerCapabilitiesOptions;\n const { resolve } = context.config;\n\n const isExternal = isExternalPackage(packagePath);\n\n // Only get the SWC config and transform code if needed\n const swcConfigs = context.requiresTranspile ? 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 // Dedupe alias plugin to redirect imports to app's version\n dedupeAliases &&\n alias({\n entries: Object.entries(dedupeAliases).map(([find, replacement]) => ({\n find,\n replacement,\n })),\n }),\n\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 stringImport({\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,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C,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC;YAC3F,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,SAAS;SAC9E,CAAC;QAEF,0DAA0D;QAC1D,aAAa,EAAE;QAEf,UAAU;YACR,GAAG,CAAC;gBACF,OAAO,EAAE,eAAe;gBACxB,GAAG,EAAE,UAAU,CAAC,GAAG;aACpB,CAAC;QAEJ,eAAe;QACf,UAAU;YACR,GAAG,CAAC;gBACF,OAAO,EAAE,QAAQ;gBACjB,GAAG,EAAE,UAAU,CAAC,GAAG;aACpB,CAAC;QAEJ,4FAA4F;QAC5F,wCAAwC;QACxC,uEAAuE;QACvE,sBAAsB,CAAC;YACrB,OAAO,EAAE;gBACP,gBAAgB;gBAChB,gEAAgE;gBAChE,uDAAuD;gBACvD,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC,CAAC;aACxF;SACF,CAAC;QAEF,2CAA2C;QAC3C,CAAC,CAAC,YAAY,IAAI,MAAM,EAAE;QAE1B,YAAY,CAAC;YACX,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 type { BundleContext, BundleOptions, InternalBundlerCapabilitiesOptions } from '@ms-cloudpack/common-types';\nimport {\n isExternalPackage,\n resolveModule,\n jsxRegex,\n typescriptRegex,\n webExtensions,\n} from '@ms-cloudpack/path-utilities';\nimport { fileURLToPath } from 'url';\nimport path from 'path';\nimport aliasPlugin from '@rollup/plugin-alias';\nimport stringImport from './plugins/stringImport.js';\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;\nconst alias = aliasPlugin as unknown as typeof aliasPlugin.default;\n\nexport function getRollupPlugins(options: Omit<BundleOptions, 'entries'>, context: BundleContext): Plugin[] {\n const {\n minify: isProduction,\n inputPath: packagePath,\n dynamicImports = [],\n sourcemap,\n dedupeAliases,\n bundlerCapabilities = {},\n } = options;\n const { relay, 'resolve-web-extensions': resolveWebExtensions } =\n bundlerCapabilities as InternalBundlerCapabilitiesOptions;\n const { resolve } = context.config;\n\n const isExternal = isExternalPackage(packagePath);\n\n // Only get the SWC config and transform code if needed\n const swcConfigs = context.requiresTranspile ? 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 // Dedupe alias plugin to redirect imports to app's version\n dedupeAliases &&\n alias({\n entries: Object.entries(dedupeAliases).map(([find, replacement]) => ({\n find,\n replacement,\n })),\n }),\n\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 ? webExtensions.filter((ext) => ext.includes('j')) : []),\n '.js',\n '.json',\n ...(!isExternal && resolveWebExtensions ? webExtensions.filter((ext) => !ext.includes('j')) : []),\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: typescriptRegex,\n swc: swcConfigs.tsx,\n }),\n\n // Support .jsx\n swcConfigs &&\n swc({\n include: jsxRegex,\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 stringImport({\n include: '**/*.glsl',\n }),\n ].filter((plugin): plugin is Plugin => !!plugin);\n}\n"]}
@@ -1,11 +1,11 @@
1
- export { index as default };
2
- declare function index(options?: {}): {
1
+ declare const _default: (options?: {}) => {
3
2
  name: string;
4
3
  transform(code: any, id: any): Promise<{
5
- code: string;
4
+ code: any;
6
5
  map: any;
7
6
  } | null>;
8
7
  augmentChunkHash(): string | undefined;
9
8
  generateBundle(options_: any, bundle: any): Promise<void>;
10
9
  };
10
+ export default _default;
11
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/postcss/index.js"],"names":[],"mappings":";AAgoBA;;;;;;;;EAkNC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/postcss/index.ts"],"names":[],"mappings":"yBA6CgB,YAAY;;;;;;;;;AAA5B,wBAgNE"}