@ms-cloudpack/bundler-rollup 0.6.2 → 0.6.4

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 (53) hide show
  1. package/NOTICE.txt +61 -0
  2. package/lib/getRollupCapabilities.d.ts +9 -0
  3. package/lib/getRollupCapabilities.d.ts.map +1 -0
  4. package/lib/{rollupCapabilities.js → getRollupCapabilities.js} +10 -4
  5. package/lib/getRollupCapabilities.js.map +1 -0
  6. package/lib/getRollupPlugins.d.ts.map +1 -1
  7. package/lib/getRollupPlugins.js +7 -1
  8. package/lib/getRollupPlugins.js.map +1 -1
  9. package/lib/plugins/json/index.js +1 -1
  10. package/lib/plugins/json/index.js.map +1 -1
  11. package/lib/plugins/postcss/index.d.ts +3 -10
  12. package/lib/plugins/postcss/index.d.ts.map +1 -1
  13. package/lib/plugins/postcss/index.js +37 -48
  14. package/lib/plugins/postcss/index.js.map +1 -1
  15. package/lib/plugins/postcss/less-loader.d.ts +2 -8
  16. package/lib/plugins/postcss/less-loader.d.ts.map +1 -1
  17. package/lib/plugins/postcss/less-loader.js +8 -11
  18. package/lib/plugins/postcss/less-loader.js.map +1 -1
  19. package/lib/plugins/postcss/loaders.d.ts +15 -21
  20. package/lib/plugins/postcss/loaders.d.ts.map +1 -1
  21. package/lib/plugins/postcss/loaders.js +14 -34
  22. package/lib/plugins/postcss/loaders.js.map +1 -1
  23. package/lib/plugins/postcss/postcss-loader.d.ts +2 -9
  24. package/lib/plugins/postcss/postcss-loader.d.ts.map +1 -1
  25. package/lib/plugins/postcss/postcss-loader.js +30 -36
  26. package/lib/plugins/postcss/postcss-loader.js.map +1 -1
  27. package/lib/plugins/postcss/sass-loader.d.ts +5 -8
  28. package/lib/plugins/postcss/sass-loader.d.ts.map +1 -1
  29. package/lib/plugins/postcss/sass-loader.js +50 -52
  30. package/lib/plugins/postcss/sass-loader.js.map +1 -1
  31. package/lib/plugins/postcss/types.d.ts +96 -25
  32. package/lib/plugins/postcss/types.d.ts.map +1 -1
  33. package/lib/plugins/postcss/types.js +0 -1
  34. package/lib/plugins/postcss/types.js.map +1 -1
  35. package/lib/plugins/postcss/utils/load-module.d.ts +10 -4
  36. package/lib/plugins/postcss/utils/load-module.d.ts.map +1 -1
  37. package/lib/plugins/postcss/utils/load-module.js +10 -11
  38. package/lib/plugins/postcss/utils/load-module.js.map +1 -1
  39. package/lib/plugins/postcss/utils/normalize-path.d.ts +7 -2
  40. package/lib/plugins/postcss/utils/normalize-path.d.ts.map +1 -1
  41. package/lib/plugins/postcss/utils/normalize-path.js +12 -3
  42. package/lib/plugins/postcss/utils/normalize-path.js.map +1 -1
  43. package/lib/rollup.d.ts.map +1 -1
  44. package/lib/rollup.js +4 -2
  45. package/lib/rollup.js.map +1 -1
  46. package/package.json +5 -3
  47. package/lib/plugins/postcss/utils/humanlize-path.d.ts +0 -3
  48. package/lib/plugins/postcss/utils/humanlize-path.d.ts.map +0 -1
  49. package/lib/plugins/postcss/utils/humanlize-path.js +0 -7
  50. package/lib/plugins/postcss/utils/humanlize-path.js.map +0 -1
  51. package/lib/rollupCapabilities.d.ts +0 -7
  52. package/lib/rollupCapabilities.d.ts.map +0 -1
  53. package/lib/rollupCapabilities.js.map +0 -1
@@ -1,42 +1,113 @@
1
+ import type { WithRequired } from '@ms-cloudpack/common-types';
1
2
  import type { CreateFilter } from '@rollup/pluginutils';
2
- type FunctionType<T = any, U = any> = (...args: readonly T[]) => U;
3
- type onExtract = (asset: Readonly<{
4
- code: any;
5
- map: any;
3
+ import type { Options as CssNanoOptions } from 'cssnano';
4
+ import type postcss from 'postcss';
5
+ import type postcssModulesPlugin from 'postcss-modules';
6
+ import type { SourceMapInput, TransformPluginContext } from 'rollup';
7
+ import type * as Sass from 'sass';
8
+ /** Partial `less` options (can use real type if we add official less support) */
9
+ export type LessOptions = {
10
+ sourceMap?: object | false;
11
+ filename: string;
12
+ [key: string]: unknown;
13
+ };
14
+ /** Partial `less` module (can use real type if we add official less support) */
15
+ export type LessModule = {
16
+ render: (code: string, options: LessOptions, callback: (err: Error | null, output: {
17
+ css: string;
18
+ map?: string;
19
+ imports: string[];
20
+ }) => void) => void;
21
+ };
22
+ export type Resource = {
23
+ code: string;
24
+ map?: SourceMapInput;
25
+ };
26
+ export type ResourceResult = {
27
+ code: string;
28
+ map?: SourceMapInput;
29
+ extracted?: ExtractResult;
30
+ };
31
+ export type ExtractResult = {
32
+ id: string;
33
+ code: string;
34
+ map?: SourceMapInput;
35
+ };
36
+ export type ExtractedAsset = {
37
+ code: string;
38
+ map: string | undefined;
6
39
  codeFileName: string;
7
40
  mapFileName: string;
8
- }>) => boolean;
41
+ };
42
+ /** Definition of `*-loader.ts` or custom loaders */
43
+ export type Loader<TOptions> = {
44
+ name: string;
45
+ test?: RegExp | ((filepath: string) => boolean);
46
+ alwaysProcess?: boolean;
47
+ process(this: LoaderContext<TOptions>, resource: Resource): Promise<ResourceResult>;
48
+ };
49
+ export type BaseLoaderContext = Pick<TransformPluginContext, 'warn'> & WithRequired<Pick<PostCSSPluginConf, 'resolveCwd' | 'inputCwd' | 'sourceMap'>, 'resolveCwd' | 'inputCwd'> & {
50
+ /** Absolute path to the resource */
51
+ id: string;
52
+ /** A set of dependencies to watch */
53
+ dependencies: Set<string>;
54
+ plugin: TransformPluginContext;
55
+ };
56
+ export type LoaderContext<TOptions = unknown> = BaseLoaderContext & {
57
+ options: TOptions;
58
+ };
9
59
  export type PostCSSPluginConf = {
60
+ /**
61
+ * Working directory for input files.
62
+ * @default process.cwd()
63
+ */
64
+ inputCwd?: string;
65
+ /**
66
+ * Working directory for resolving dependencies/peers such as `sass` or `less` (defaults to `inputCwd`).
67
+ * Note that resolution will be tried from the `bundler-rollup` package context first, then fall back
68
+ * to this directory.
69
+ */
70
+ resolveCwd?: string;
71
+ /** Inject CSS as `<style>` to `<head>` */
10
72
  inject?: boolean | Record<string, any> | ((cssVariableName: string, id: string) => string);
73
+ /** Extract CSS */
11
74
  extract?: boolean | string;
12
- onExtract?: onExtract;
13
- modules?: boolean | Record<string, any>;
14
- extensions?: string[];
15
- plugins?: any[];
75
+ onExtract?: (asset: Readonly<ExtractedAsset>) => boolean | Promise<boolean>;
76
+ /** CSS modules options */
77
+ modules?: boolean | Parameters<typeof postcssModulesPlugin>[0];
78
+ /** If true, only treat `.module.xxx` files as CSS modules. */
16
79
  autoModules?: boolean;
80
+ onlyModules?: boolean;
81
+ /** Extensions to process as postcss files */
82
+ extensions?: string[];
83
+ plugins?: postcss.AcceptedPlugin[];
17
84
  namedExports?: boolean | ((id: string) => string);
18
- minimize?: boolean | any;
19
- parser?: string | FunctionType;
20
- stringifier?: string | FunctionType;
21
- syntax?: string | FunctionType;
85
+ /** Options for cssnano */
86
+ minimize?: boolean | CssNanoOptions;
87
+ parser?: string | postcss.ProcessOptions['parser'];
88
+ stringifier?: string | postcss.ProcessOptions['stringifier'];
89
+ syntax?: string | postcss.ProcessOptions['syntax'];
22
90
  exec?: boolean;
23
- config?: boolean | {
24
- path: string;
25
- ctx: any;
26
- };
91
+ /** postcss config file, disabled in this fork */
92
+ config?: false;
93
+ /** PostCSS target filename hint, for plugins that are relying on it */
27
94
  to?: string;
28
- name?: any[] | any[][];
29
- loaders?: any[];
95
+ /** Additional custom loaders */
96
+ loaders?: Loader<unknown>[];
30
97
  onImport?: (id: string) => void;
31
- use?: string[] | {
32
- [key in 'sass' | 'less']: any;
98
+ use?: Array<string | [name: string, options?: object]> | {
99
+ less?: Partial<LessOptions>;
100
+ sass?: Partial<Sass.LegacyOptions<'async'>>;
33
101
  };
34
- /**
35
- * @default: false
36
- **/
102
+ /** @default false */
37
103
  sourceMap?: boolean | 'inline';
38
104
  include?: Parameters<CreateFilter>[0];
39
105
  exclude?: Parameters<CreateFilter>[1];
40
106
  };
41
- export {};
107
+ /** Options for `postcss-loader.ts` */
108
+ export type InternalPostCSSLoaderOptions = Required<Pick<PostCSSPluginConf, 'inject' | 'extract' | 'onlyModules' | 'config'>> & Pick<PostCSSPluginConf, 'namedExports' | 'autoModules' | 'to'> & {
109
+ [k in 'minimize' | 'modules']: Exclude<PostCSSPluginConf[k], true>;
110
+ } & {
111
+ postcss: Pick<PostCSSPluginConf, 'parser' | 'syntax' | 'stringifier' | 'exec' | 'plugins'>;
112
+ };
42
113
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/plugins/postcss/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,KAAK,YAAY,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,IAAI,EAAE,SAAS,CAAC,EAAE,KAAK,CAAC,CAAC;AAEnE,KAAK,SAAS,GAAG,CACf,KAAK,EAAE,QAAQ,CAAC;IACd,IAAI,EAAE,GAAG,CAAC;IACV,GAAG,EAAE,GAAG,CAAC;IACT,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC,KACC,OAAO,CAAC;AAEb,MAAM,MAAM,iBAAiB,GAAG;IAC9B,MAAM,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,eAAe,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,KAAK,MAAM,CAAC,CAAC;IAC3F,OAAO,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAC3B,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,OAAO,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACxC,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC;IAChB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,YAAY,CAAC,EAAE,OAAO,GAAG,CAAC,CAAC,EAAE,EAAE,MAAM,KAAK,MAAM,C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AAC,OAAO,CAAC,CAAC,CAAC;KAC7C,CAAC;IACN,qBAAqB;IACrB,SAAS,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;IAC/B,OAAO,CAAC,EAAE,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;IACtC,OAAO,CAAC,EAAE,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;CACvC,CAAC;AAEF,sCAAsC;AACtC,MAAM,MAAM,4BAA4B,GAAG,QAAQ,CACjD,IAAI,CAAC,iBAAiB,EAAE,QAAQ,GAAG,SAAS,GAAG,aAAa,GAAG,QAAQ,CAAC,CACzE,GACC,IAAI,CAAC,iBAAiB,EAAE,cAAc,GAAG,aAAa,GAAG,IAAI,CAAC,GAAG;KAC9D,CAAC,IAAI,UAAU,GAAG,SAAS,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC;CACnE,GAAG;IACF,OAAO,EAAE,IAAI,CAAC,iBAAiB,EAAE,QAAQ,GAAG,QAAQ,GAAG,aAAa,GAAG,MAAM,GAAG,SAAS,CAAC,CAAC;CAC5F,CAAC"}
@@ -1,3 +1,2 @@
1
1
  export {};
2
- // export default function (options?: Readonly<PostCSSPluginConf>): Plugin;
3
2
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/plugins/postcss/types.ts"],"names":[],"mappings":";AA+CA,2EAA2E","sourcesContent":["/* eslint-disable */\nimport type { CreateFilter } from '@rollup/pluginutils';\n\ntype FunctionType<T = any, U = any> = (...args: readonly T[]) => U;\n\ntype onExtract = (\n asset: Readonly<{\n code: any;\n map: any;\n codeFileName: string;\n mapFileName: string;\n }>,\n) => boolean;\n\nexport type PostCSSPluginConf = {\n inject?: boolean | Record<string, any> | ((cssVariableName: string, id: string) => string);\n extract?: boolean | string;\n onExtract?: onExtract;\n modules?: boolean | Record<string, any>;\n extensions?: string[];\n plugins?: any[];\n autoModules?: boolean;\n namedExports?: boolean | ((id: string) => string);\n minimize?: boolean | any;\n parser?: string | FunctionType;\n stringifier?: string | FunctionType;\n syntax?: string | FunctionType;\n exec?: boolean;\n config?:\n | boolean\n | {\n path: string;\n ctx: any;\n };\n to?: string;\n name?: any[] | any[][];\n loaders?: any[];\n onImport?: (id: string) => void;\n use?: string[] | { [key in 'sass' | 'less']: any };\n /**\n * @default: false\n **/\n sourceMap?: boolean | 'inline';\n include?: Parameters<CreateFilter>[0];\n exclude?: Parameters<CreateFilter>[1];\n};\n\n// export default function (options?: Readonly<PostCSSPluginConf>): Plugin;\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/plugins/postcss/types.ts"],"names":[],"mappings":"","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { WithRequired } from '@ms-cloudpack/common-types';\nimport type { CreateFilter } from '@rollup/pluginutils';\nimport type { Options as CssNanoOptions } from 'cssnano';\nimport type postcss from 'postcss';\nimport type postcssModulesPlugin from 'postcss-modules';\nimport type { SourceMapInput, TransformPluginContext } from 'rollup';\nimport type * as Sass from 'sass';\n\n/** Partial `less` options (can use real type if we add official less support) */\nexport type LessOptions = {\n sourceMap?: object | false;\n filename: string;\n [key: string]: unknown;\n};\n/** Partial `less` module (can use real type if we add official less support) */\nexport type LessModule = {\n render: (\n code: string,\n options: LessOptions,\n callback: (err: Error | null, output: { css: string; map?: string; imports: string[] }) => void,\n ) => void;\n};\n\nexport type Resource = { code: string; map?: SourceMapInput };\nexport type ResourceResult = { code: string; map?: SourceMapInput; extracted?: ExtractResult };\nexport type ExtractResult = { id: string; code: string; map?: SourceMapInput };\nexport type ExtractedAsset = { code: string; map: string | undefined; codeFileName: string; mapFileName: string };\n\n/** Definition of `*-loader.ts` or custom loaders */\nexport type Loader<TOptions> = {\n name: string;\n test?: RegExp | ((filepath: string) => boolean);\n alwaysProcess?: boolean;\n process(this: LoaderContext<TOptions>, resource: Resource): Promise<ResourceResult>;\n};\n\nexport type BaseLoaderContext = Pick<TransformPluginContext, 'warn'> &\n WithRequired<Pick<PostCSSPluginConf, 'resolveCwd' | 'inputCwd' | 'sourceMap'>, 'resolveCwd' | 'inputCwd'> & {\n /** Absolute path to the resource */\n id: string;\n /** A set of dependencies to watch */\n dependencies: Set<string>;\n plugin: TransformPluginContext;\n };\n\nexport type LoaderContext<TOptions = unknown> = BaseLoaderContext & {\n options: TOptions;\n};\n\nexport type PostCSSPluginConf = {\n /**\n * Working directory for input files.\n * @default process.cwd()\n */\n inputCwd?: string;\n /**\n * Working directory for resolving dependencies/peers such as `sass` or `less` (defaults to `inputCwd`).\n * Note that resolution will be tried from the `bundler-rollup` package context first, then fall back\n * to this directory.\n */\n resolveCwd?: string;\n /** Inject CSS as `<style>` to `<head>` */\n inject?: boolean | Record<string, any> | ((cssVariableName: string, id: string) => string);\n /** Extract CSS */\n extract?: boolean | string;\n onExtract?: (asset: Readonly<ExtractedAsset>) => boolean | Promise<boolean>;\n /** CSS modules options */\n modules?: boolean | Parameters<typeof postcssModulesPlugin>[0];\n /** If true, only treat `.module.xxx` files as CSS modules. */\n autoModules?: boolean;\n onlyModules?: boolean;\n /** Extensions to process as postcss files */\n extensions?: string[];\n plugins?: postcss.AcceptedPlugin[];\n namedExports?: boolean | ((id: string) => string);\n /** Options for cssnano */\n minimize?: boolean | CssNanoOptions;\n parser?: string | postcss.ProcessOptions['parser'];\n stringifier?: string | postcss.ProcessOptions['stringifier'];\n syntax?: string | postcss.ProcessOptions['syntax'];\n exec?: boolean;\n /** postcss config file, disabled in this fork */\n config?: false; // boolean | { path: string; ctx: any; };\n /** PostCSS target filename hint, for plugins that are relying on it */\n to?: string;\n /** Additional custom loaders */\n loaders?: Loader<unknown>[];\n onImport?: (id: string) => void;\n use?:\n | Array<string | [name: string, options?: object]>\n | {\n less?: Partial<LessOptions>;\n // eslint-disable-next-line etc/no-deprecated\n sass?: Partial<Sass.LegacyOptions<'async'>>;\n };\n /** @default false */\n sourceMap?: boolean | 'inline';\n include?: Parameters<CreateFilter>[0];\n exclude?: Parameters<CreateFilter>[1];\n};\n\n/** Options for `postcss-loader.ts` */\nexport type InternalPostCSSLoaderOptions = Required<\n Pick<PostCSSPluginConf, 'inject' | 'extract' | 'onlyModules' | 'config'>\n> &\n Pick<PostCSSPluginConf, 'namedExports' | 'autoModules' | 'to'> & {\n [k in 'minimize' | 'modules']: Exclude<PostCSSPluginConf[k], true>;\n } & {\n postcss: Pick<PostCSSPluginConf, 'parser' | 'syntax' | 'stringifier' | 'exec' | 'plugins'>;\n };\n"]}
@@ -1,7 +1,13 @@
1
1
  /**
2
- * Load a module using modern ESM dynamic imports
3
- * @param {string} moduleId - The module to load
4
- * @returns {Promise<any>} The loaded module
2
+ * Load a module using modern ESM dynamic imports. It will try to import from the `bundler-rollup`
3
+ * package context first, or fall back to importing from `cwd`.
4
+ * @returns The loaded module, or null if not found. Depending on the module format, the expected
5
+ * contents may be either at the top level or under `default`.
5
6
  */
6
- export declare function loadModule(moduleId: any): Promise<any>;
7
+ export declare function loadModule<TModule>(params: {
8
+ moduleId: string;
9
+ cwd: string;
10
+ }): Promise<TModule | {
11
+ default: TModule;
12
+ } | null>;
7
13
  //# sourceMappingURL=load-module.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"load-module.d.ts","sourceRoot":"","sources":["../../../../src/plugins/postcss/utils/load-module.ts"],"names":[],"mappings":"AAMA;;;;GAIG;AACH,wBAAsB,UAAU,CAAC,QAAQ,KAAA,gBAcxC"}
1
+ {"version":3,"file":"load-module.d.ts","sourceRoot":"","sources":["../../../../src/plugins/postcss/utils/load-module.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,wBAAsB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE;IAChD,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;CACb,GAAG,OAAO,CAAC,OAAO,GAAG;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,CAAC,CAgBjD"}
@@ -1,22 +1,21 @@
1
- /* eslint-disable */
2
- // @ts-nocheck
3
- import { createRequire } from 'module';
4
- const require = createRequire(import.meta.url);
1
+ import { resolveModule } from '@ms-cloudpack/path-utilities';
5
2
  /**
6
- * Load a module using modern ESM dynamic imports
7
- * @param {string} moduleId - The module to load
8
- * @returns {Promise<any>} The loaded module
3
+ * Load a module using modern ESM dynamic imports. It will try to import from the `bundler-rollup`
4
+ * package context first, or fall back to importing from `cwd`.
5
+ * @returns The loaded module, or null if not found. Depending on the module format, the expected
6
+ * contents may be either at the top level or under `default`.
9
7
  */
10
- export async function loadModule(moduleId) {
8
+ export async function loadModule(params) {
9
+ const { moduleId, cwd } = params;
11
10
  try {
12
11
  // Try to import the module directly
13
- return await import(moduleId);
12
+ return (await import(moduleId));
14
13
  }
15
14
  catch {
16
15
  // If direct import fails, try resolving from current working directory
17
16
  try {
18
- const resolvedPath = require.resolve(moduleId);
19
- return await import(resolvedPath);
17
+ const resolvedUrl = resolveModule({ importSpecifier: moduleId, parentPath: cwd });
18
+ return (await import(resolvedUrl.toString()));
20
19
  }
21
20
  catch {
22
21
  // Return null if module cannot be loaded
@@ -1 +1 @@
1
- {"version":3,"file":"load-module.js","sourceRoot":"","sources":["../../../../src/plugins/postcss/utils/load-module.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,cAAc;AACd,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAEvC,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAE/C;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,QAAQ;IACvC,IAAI,CAAC;QACH,oCAAoC;QACpC,OAAO,MAAM,MAAM,CAAC,QAAQ,CAAC,CAAC;IAChC,CAAC;IAAC,MAAM,CAAC;QACP,uEAAuE;QACvE,IAAI,CAAC;YACH,MAAM,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;YAC/C,OAAO,MAAM,MAAM,CAAC,YAAY,CAAC,CAAC;QACpC,CAAC;QAAC,MAAM,CAAC;YACP,yCAAyC;YACzC,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["/* eslint-disable */\n// @ts-nocheck\nimport { createRequire } from 'module';\n\nconst require = createRequire(import.meta.url);\n\n/**\n * Load a module using modern ESM dynamic imports\n * @param {string} moduleId - The module to load\n * @returns {Promise<any>} The loaded module\n */\nexport async function loadModule(moduleId) {\n try {\n // Try to import the module directly\n return await import(moduleId);\n } catch {\n // If direct import fails, try resolving from current working directory\n try {\n const resolvedPath = require.resolve(moduleId);\n return await import(resolvedPath);\n } catch {\n // Return null if module cannot be loaded\n return null;\n }\n }\n}\n"]}
1
+ {"version":3,"file":"load-module.js","sourceRoot":"","sources":["../../../../src/plugins/postcss/utils/load-module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAE7D;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAU,MAGzC;IACC,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,MAAM,CAAC;IAEjC,IAAI,CAAC;QACH,oCAAoC;QACpC,OAAO,CAAC,MAAM,MAAM,CAAC,QAAQ,CAAC,CAAmC,CAAC;IACpE,CAAC;IAAC,MAAM,CAAC;QACP,uEAAuE;QACvE,IAAI,CAAC;YACH,MAAM,WAAW,GAAG,aAAa,CAAC,EAAE,eAAe,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC,CAAC;YAClF,OAAO,CAAC,MAAM,MAAM,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC,CAAmC,CAAC;QAClF,CAAC;QAAC,MAAM,CAAC;YACP,yCAAyC;YACzC,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import { resolveModule } from '@ms-cloudpack/path-utilities';\n\n/**\n * Load a module using modern ESM dynamic imports. It will try to import from the `bundler-rollup`\n * package context first, or fall back to importing from `cwd`.\n * @returns The loaded module, or null if not found. Depending on the module format, the expected\n * contents may be either at the top level or under `default`.\n */\nexport async function loadModule<TModule>(params: {\n moduleId: string;\n cwd: string;\n}): Promise<TModule | { default: TModule } | null> {\n const { moduleId, cwd } = params;\n\n try {\n // Try to import the module directly\n return (await import(moduleId)) as TModule | { default: TModule };\n } catch {\n // If direct import fails, try resolving from current working directory\n try {\n const resolvedUrl = resolveModule({ importSpecifier: moduleId, parentPath: cwd });\n return (await import(resolvedUrl.toString())) as TModule | { default: TModule };\n } catch {\n // Return null if module cannot be loaded\n return null;\n }\n }\n}\n"]}
@@ -1,3 +1,8 @@
1
- declare const _default: (path: any) => any;
2
- export default _default;
1
+ /**
2
+ * Normalize separators to forward slashes, and normalize multiple backslashes to a single forward slash.
3
+ */
4
+ export declare function normalizePath(p: string, options?: {
5
+ /** Convert `p` from an absolute path to being relative to this directory */
6
+ relativeTo?: string;
7
+ }): string;
3
8
  //# sourceMappingURL=normalize-path.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"normalize-path.d.ts","sourceRoot":"","sources":["../../../../src/plugins/postcss/utils/normalize-path.ts"],"names":[],"mappings":"yBAEgB,SAAI;AAApB,wBAA2D"}
1
+ {"version":3,"file":"normalize-path.d.ts","sourceRoot":"","sources":["../../../../src/plugins/postcss/utils/normalize-path.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,wBAAgB,aAAa,CAC3B,CAAC,EAAE,MAAM,EACT,OAAO,CAAC,EAAE;IACR,4EAA4E;IAC5E,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,GACA,MAAM,CAQR"}
@@ -1,4 +1,13 @@
1
- /* eslint-disable */
2
- // @ts-nocheck
3
- export default (path) => path && path.replace(/\\+/g, '/');
1
+ import path from 'path';
2
+ /**
3
+ * Normalize separators to forward slashes, and normalize multiple backslashes to a single forward slash.
4
+ */
5
+ export function normalizePath(p, options) {
6
+ if (options?.relativeTo) {
7
+ p = path.relative(options.relativeTo, p);
8
+ }
9
+ // Keep the original logic including the falsey check and multi-slash replacement for now
10
+ // (not clear if either is necessary)
11
+ return p && p.replace(/\\+/g, '/');
12
+ }
4
13
  //# sourceMappingURL=normalize-path.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"normalize-path.js","sourceRoot":"","sources":["../../../../src/plugins/postcss/utils/normalize-path.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,cAAc;AACd,eAAe,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC","sourcesContent":["/* eslint-disable */\n// @ts-nocheck\nexport default (path) => path && path.replace(/\\\\+/g, '/');\n"]}
1
+ {"version":3,"file":"normalize-path.js","sourceRoot":"","sources":["../../../../src/plugins/postcss/utils/normalize-path.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB;;GAEG;AACH,MAAM,UAAU,aAAa,CAC3B,CAAS,EACT,OAGC;IAED,IAAI,OAAO,EAAE,UAAU,EAAE,CAAC;QACxB,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;IAC3C,CAAC;IAED,yFAAyF;IACzF,qCAAqC;IACrC,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AACrC,CAAC","sourcesContent":["import path from 'path';\n\n/**\n * Normalize separators to forward slashes, and normalize multiple backslashes to a single forward slash.\n */\nexport function normalizePath(\n p: string,\n options?: {\n /** Convert `p` from an absolute path to being relative to this directory */\n relativeTo?: string;\n },\n): string {\n if (options?.relativeTo) {\n p = path.relative(options.relativeTo, p);\n }\n\n // Keep the original logic including the falsey check and multi-slash replacement for now\n // (not clear if either is necessary)\n return p && p.replace(/\\\\+/g, '/');\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"rollup.d.ts","sourceRoot":"","sources":["../src/rollup.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,OAAO,EAGR,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EAKL,KAAK,aAAa,EAClB,KAAK,aAAa,EACnB,MAAM,QAAQ,CAAC;AAOhB,MAAM,MAAM,sBAAsB,GAAG;IACnC,YAAY,EAAE,aAAa,CAAC;IAC5B,aAAa,EAAE,aAAa,CAAC;CAC9B,CAAC;AAIF,eAAO,MAAM,MAAM,EAAE,OAuDpB,CAAC"}
1
+ {"version":3,"file":"rollup.d.ts","sourceRoot":"","sources":["../src/rollup.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,OAAO,EAGR,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EAKL,KAAK,aAAa,EAClB,KAAK,aAAa,EACnB,MAAM,QAAQ,CAAC;AAOhB,MAAM,MAAM,sBAAsB,GAAG;IACnC,YAAY,EAAE,aAAa,CAAC;IAC5B,aAAa,EAAE,aAAa,CAAC;CAC9B,CAAC;AAIF,eAAO,MAAM,MAAM,EAAE,OAyDpB,CAAC"}
package/lib/rollup.js CHANGED
@@ -4,7 +4,7 @@ import { rollup as runRollup, VERSION, } from 'rollup';
4
4
  import { getRollupOptions } from './getRollupOptions.js';
5
5
  import { normalizeRollupLoc } from './normalizeRollupLoc.js';
6
6
  import { normalizeRollupOutput } from './normalizeRollupOutput.js';
7
- import { rollupCapabilities } from './rollupCapabilities.js';
7
+ import { getRollupCapabilities } from './getRollupCapabilities.js';
8
8
  import { base64AssetExtensions } from '@ms-cloudpack/path-utilities';
9
9
  const bundlerName = 'rollup';
10
10
  export const rollup = {
@@ -18,13 +18,15 @@ export const rollup = {
18
18
  const { warnings, ...baseConfig } = getRollupOptions({ options, context, newEntries });
19
19
  const bundlerCapabilitiesOptions = {
20
20
  'asset-inline': { extensions: base64AssetExtensions },
21
+ // Enable define capability by default
22
+ define: true,
21
23
  ...(options.bundlerCapabilities || {}),
22
24
  };
23
25
  const { inputOptions, outputOptions } = await processCapabilities({
24
26
  bundlerName,
25
27
  baseConfig,
26
28
  bundlerCapabilitiesOptions,
27
- internalCapabilities: rollupCapabilities,
29
+ internalCapabilities: getRollupCapabilities(context),
28
30
  bundlerCapabilitiesRegistry: context.config.bundlerCapabilitiesRegistry,
29
31
  });
30
32
  let output;
package/lib/rollup.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"rollup.js","sourceRoot":"","sources":["../src/rollup.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,EACL,MAAM,IAAI,SAAS,EAGnB,OAAO,GAGR,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAOrE,MAAM,WAAW,GAAG,QAAQ,CAAC;AAE7B,MAAM,CAAC,MAAM,MAAM,GAAY;IAC7B,IAAI,EAAE,WAAW;IACjB,OAAO,EAAE,OAAO;IAChB,MAAM,EAAE,KAAK,WAAW,OAAO,EAAE,OAAO;QACtC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,MAAM,qBAAqB,CAAC,OAAO,CAAC,CAAC;QACpE,IAAI,MAAM,EAAE,MAAM,EAAE,CAAC;YACnB,OAAO,EAAE,MAAM,EAAE,CAAC;QACpB,CAAC;QAED,MAAM,EAAE,QAAQ,EAAE,GAAG,UAAU,EAAE,GAAG,gBAAgB,CAAC,EAAE,OAAO,EAAE,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,KAAK,CAAC,GAAG;oBACd,sCAAsC;oBACtC,EAAE,EAAE,KAAK,CAAC,EAAE;oBACZ,SAAS,EAAE,OAAO,CAAC,SAAS;iBAC7B,CAAC,CAAC;YACL,CAAC;YAED,OAAO,EAAE,MAAM,EAAE,CAAC,YAAY,CAAC,EAAE,CAAC;QACpC,CAAC;QAED,OAAO,qBAAqB,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;IAC3F,CAAC;CACF,CAAC","sourcesContent":["import type {\n BundleMessage,\n Bundler,\n BundlerCapabilitiesOptions,\n InternalBundlerCapabilitiesOptions,\n} from '@ms-cloudpack/common-types';\nimport { processCapabilities } from '@ms-cloudpack/bundler-capabilities';\nimport { writeESMStubsInWorker } from '@ms-cloudpack/esm-stub-utilities';\nimport {\n rollup as runRollup,\n type RollupError,\n type RollupOutput,\n VERSION,\n type RollupOptions,\n type OutputOptions,\n} 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/path-utilities';\n\nexport type RollupCapabilityConfig = {\n inputOptions: RollupOptions;\n outputOptions: OutputOptions;\n};\n\nconst bundlerName = 'rollup';\n\nexport const rollup: Bundler = {\n name: bundlerName,\n version: VERSION,\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 } = getRollupOptions({ options, context, newEntries });\n\n const bundlerCapabilitiesOptions: BundlerCapabilitiesOptions = {\n 'asset-inline': { extensions: base64AssetExtensions },\n ...(options.bundlerCapabilities || {}),\n } satisfies InternalBundlerCapabilitiesOptions;\n\n const { inputOptions, outputOptions } = await processCapabilities<RollupCapabilityConfig>({\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.js","sourceRoot":"","sources":["../src/rollup.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,EACL,MAAM,IAAI,SAAS,EAGnB,OAAO,GAGR,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAOrE,MAAM,WAAW,GAAG,QAAQ,CAAC;AAE7B,MAAM,CAAC,MAAM,MAAM,GAAY;IAC7B,IAAI,EAAE,WAAW;IACjB,OAAO,EAAE,OAAO;IAChB,MAAM,EAAE,KAAK,WAAW,OAAO,EAAE,OAAO;Q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KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;gBACzG,MAAM,EAAE,QAAQ;aACjB,CAAC;YAEF,IAAI,KAAK,CAAC,EAAE,IAAI,KAAK,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC;gBAChC,YAAY,CAAC,QAAQ,GAAG,kBAAkB,CAAC;oBACzC,2CAA2C;oBAC3C,GAAG,EAAE,KAAK,CAAC,GAAG;oBACd,sCAAsC;oBACtC,EAAE,EAAE,KAAK,CAAC,EAAE;oBACZ,SAAS,EAAE,OAAO,CAAC,SAAS;iBAC7B,CAAC,CAAC;YACL,CAAC;YAED,OAAO,EAAE,MAAM,EAAE,CAAC,YAAY,CAAC,EAAE,CAAC;QACpC,CAAC;QAED,OAAO,qBAAqB,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;IAC3F,CAAC;CACF,CAAC","sourcesContent":["import type {\n BundleMessage,\n Bundler,\n BundlerCapabilitiesOptions,\n InternalBundlerCapabilitiesOptions,\n} from '@ms-cloudpack/common-types';\nimport { processCapabilities } from '@ms-cloudpack/bundler-capabilities';\nimport { writeESMStubsInWorker } from '@ms-cloudpack/esm-stub-utilities';\nimport {\n rollup as runRollup,\n type RollupError,\n type RollupOutput,\n VERSION,\n type RollupOptions,\n type OutputOptions,\n} from 'rollup';\nimport { getRollupOptions } from './getRollupOptions.js';\nimport { normalizeRollupLoc } from './normalizeRollupLoc.js';\nimport { normalizeRollupOutput } from './normalizeRollupOutput.js';\nimport { getRollupCapabilities } from './getRollupCapabilities.js';\nimport { base64AssetExtensions } from '@ms-cloudpack/path-utilities';\n\nexport type RollupCapabilityConfig = {\n inputOptions: RollupOptions;\n outputOptions: OutputOptions;\n};\n\nconst bundlerName = 'rollup';\n\nexport const rollup: Bundler = {\n name: bundlerName,\n version: VERSION,\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 } = getRollupOptions({ options, context, newEntries });\n\n const bundlerCapabilitiesOptions: BundlerCapabilitiesOptions = {\n 'asset-inline': { extensions: base64AssetExtensions },\n // Enable define capability by default\n define: true,\n ...(options.bundlerCapabilities || {}),\n } satisfies InternalBundlerCapabilitiesOptions;\n\n const { inputOptions, outputOptions } = await processCapabilities<RollupCapabilityConfig>({\n bundlerName,\n baseConfig,\n bundlerCapabilitiesOptions,\n internalCapabilities: getRollupCapabilities(context),\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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ms-cloudpack/bundler-rollup",
3
- "version": "0.6.2",
3
+ "version": "0.6.4",
4
4
  "description": "Cloudpack's wrapper for the Rollup bundler",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -28,6 +28,7 @@
28
28
  "@ms-cloudpack/bundler-capabilities": "^0.5.0",
29
29
  "@ms-cloudpack/bundler-utilities": "^0.8.0",
30
30
  "@ms-cloudpack/common-types": "^0.33.1",
31
+ "@ms-cloudpack/common-types-browser": "^0.6.4",
31
32
  "@ms-cloudpack/esm-stub-utilities": "^0.15.35",
32
33
  "@ms-cloudpack/package-utilities": "^13.2.5",
33
34
  "@ms-cloudpack/path-string-parsing": "^1.2.7",
@@ -42,7 +43,7 @@
42
43
  "@rollup/plugin-url": "^8.0.0",
43
44
  "@rollup/pluginutils": "^5.0.1",
44
45
  "@swc/core": "^1.3.0",
45
- "@swc/plugin-relay": "^6.0.0 || ^7.0.0 || ^8.0.0 || ^9.0.0",
46
+ "@swc/plugin-relay": ">= 6.0.0",
46
47
  "concat-with-sourcemaps": "^1.1.0",
47
48
  "cssnano": "^6.0.0",
48
49
  "magic-string": "^0.30.5",
@@ -66,6 +67,7 @@
66
67
  "lodash": "^4.17.21"
67
68
  },
68
69
  "files": [
69
- "lib/**/!(*.test.*)"
70
+ "lib/**/!(*.test.*)",
71
+ "NOTICE.txt"
70
72
  ]
71
73
  }
@@ -1,3 +0,0 @@
1
- declare const humanlizePath: (filepath: any) => any;
2
- export default humanlizePath;
3
- //# sourceMappingURL=humanlize-path.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"humanlize-path.d.ts","sourceRoot":"","sources":["../../../../src/plugins/postcss/utils/humanlize-path.ts"],"names":[],"mappings":"AAKA,QAAA,MAAM,aAAa,GAAI,aAAQ,QAA0D,CAAC;AAE1F,eAAe,aAAa,CAAC"}
@@ -1,7 +0,0 @@
1
- /* eslint-disable */
2
- // @ts-nocheck
3
- import path from 'path';
4
- import normalizePath from './normalize-path.js';
5
- const humanlizePath = (filepath) => normalizePath(path.relative(process.cwd(), filepath));
6
- export default humanlizePath;
7
- //# sourceMappingURL=humanlize-path.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"humanlize-path.js","sourceRoot":"","sources":["../../../../src/plugins/postcss/utils/humanlize-path.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,cAAc;AACd,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,aAAa,MAAM,qBAAqB,CAAC;AAEhD,MAAM,aAAa,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,QAAQ,CAAC,CAAC,CAAC;AAE1F,eAAe,aAAa,CAAC","sourcesContent":["/* eslint-disable */\n// @ts-nocheck\nimport path from 'path';\nimport normalizePath from './normalize-path.js';\n\nconst humanlizePath = (filepath) => normalizePath(path.relative(process.cwd(), filepath));\n\nexport default humanlizePath;\n"]}
@@ -1,7 +0,0 @@
1
- import type { InternalBundlerCapabilityImplementations } from '@ms-cloudpack/common-types';
2
- import type { OutputOptions, RollupOptions } from 'rollup';
3
- export declare const rollupCapabilities: InternalBundlerCapabilityImplementations<{
4
- inputOptions: RollupOptions;
5
- outputOptions: OutputOptions;
6
- }>;
7
- //# sourceMappingURL=rollupCapabilities.d.ts.map
@@ -1 +0,0 @@
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;AAqBnE,eAAO,MAAM,kBAAkB,EAAE,wCAAwC,CAAC;IACxE,YAAY,EAAE,aAAa,CAAC;IAC5B,aAAa,EAAE,aAAa,CAAC;CAC9B,CAqCA,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"rollupCapabilities.js","sourceRoot":"","sources":["../src/rollupCapabilities.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,4BAA4B,EAAE,MAAM,iCAAiC,CAAC;AAC/E,OAAO,IAAI,MAAM,oBAAoB,CAAC;AACtC,OAAO,QAAQ,MAAM,wBAAwB,CAAC;AAE9C,4DAA4D;AAC5D,MAAM,GAAG,GAAG,IAAsC,CAAC;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C,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,6FAA6F;IAC7F,KAAK,EAAE,CAAC,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 { processAssetInlineExtensions } from '@ms-cloudpack/bundler-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 // 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: 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"]}