@powerlines/unplugin 0.0.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 (119) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +305 -0
  3. package/dist/_virtual/_rolldown/runtime.cjs +45 -0
  4. package/dist/_virtual/_rolldown/runtime.mjs +36 -0
  5. package/dist/astro.cjs +37 -0
  6. package/dist/astro.d.cts +27 -0
  7. package/dist/astro.d.cts.map +1 -0
  8. package/dist/astro.d.mts +27 -0
  9. package/dist/astro.d.mts.map +1 -0
  10. package/dist/astro.mjs +36 -0
  11. package/dist/astro.mjs.map +1 -0
  12. package/dist/esbuild.cjs +155 -0
  13. package/dist/esbuild.d.cts +69 -0
  14. package/dist/esbuild.d.cts.map +1 -0
  15. package/dist/esbuild.d.mts +69 -0
  16. package/dist/esbuild.d.mts.map +1 -0
  17. package/dist/esbuild.mjs +149 -0
  18. package/dist/esbuild.mjs.map +1 -0
  19. package/dist/farm.cjs +56 -0
  20. package/dist/farm.d.cts +51 -0
  21. package/dist/farm.d.cts.map +1 -0
  22. package/dist/farm.d.mts +51 -0
  23. package/dist/farm.d.mts.map +1 -0
  24. package/dist/farm.mjs +54 -0
  25. package/dist/farm.mjs.map +1 -0
  26. package/dist/index.cjs +46 -0
  27. package/dist/index.d.cts +37 -0
  28. package/dist/index.d.cts.map +1 -0
  29. package/dist/index.d.mts +37 -0
  30. package/dist/index.d.mts.map +1 -0
  31. package/dist/index.mjs +39 -0
  32. package/dist/index.mjs.map +1 -0
  33. package/dist/next.cjs +37 -0
  34. package/dist/next.d.cts +25 -0
  35. package/dist/next.d.cts.map +1 -0
  36. package/dist/next.d.mts +25 -0
  37. package/dist/next.d.mts.map +1 -0
  38. package/dist/next.mjs +36 -0
  39. package/dist/next.mjs.map +1 -0
  40. package/dist/nuxt.cjs +44 -0
  41. package/dist/nuxt.d.cts +28 -0
  42. package/dist/nuxt.d.cts.map +1 -0
  43. package/dist/nuxt.d.mts +29 -0
  44. package/dist/nuxt.d.mts.map +1 -0
  45. package/dist/nuxt.mjs +44 -0
  46. package/dist/nuxt.mjs.map +1 -0
  47. package/dist/package.cjs +18 -0
  48. package/dist/package.mjs +7 -0
  49. package/dist/package.mjs.map +1 -0
  50. package/dist/rolldown.cjs +161 -0
  51. package/dist/rolldown.d.cts +65 -0
  52. package/dist/rolldown.d.cts.map +1 -0
  53. package/dist/rolldown.d.mts +65 -0
  54. package/dist/rolldown.d.mts.map +1 -0
  55. package/dist/rolldown.mjs +153 -0
  56. package/dist/rolldown.mjs.map +1 -0
  57. package/dist/rollup.cjs +159 -0
  58. package/dist/rollup.d.cts +64 -0
  59. package/dist/rollup.d.cts.map +1 -0
  60. package/dist/rollup.d.mts +64 -0
  61. package/dist/rollup.d.mts.map +1 -0
  62. package/dist/rollup.mjs +149 -0
  63. package/dist/rollup.mjs.map +1 -0
  64. package/dist/rspack.cjs +95 -0
  65. package/dist/rspack.d.cts +58 -0
  66. package/dist/rspack.d.cts.map +1 -0
  67. package/dist/rspack.d.mts +58 -0
  68. package/dist/rspack.d.mts.map +1 -0
  69. package/dist/rspack.mjs +90 -0
  70. package/dist/rspack.mjs.map +1 -0
  71. package/dist/tsdown.cjs +217 -0
  72. package/dist/tsdown.d.cts +63 -0
  73. package/dist/tsdown.d.cts.map +1 -0
  74. package/dist/tsdown.d.mts +63 -0
  75. package/dist/tsdown.d.mts.map +1 -0
  76. package/dist/tsdown.mjs +209 -0
  77. package/dist/tsdown.mjs.map +1 -0
  78. package/dist/tsup.cjs +116 -0
  79. package/dist/tsup.d.cts +49 -0
  80. package/dist/tsup.d.cts.map +1 -0
  81. package/dist/tsup.d.mts +49 -0
  82. package/dist/tsup.d.mts.map +1 -0
  83. package/dist/tsup.mjs +110 -0
  84. package/dist/tsup.mjs.map +1 -0
  85. package/dist/types.cjs +0 -0
  86. package/dist/types.d.cts +12 -0
  87. package/dist/types.d.cts.map +1 -0
  88. package/dist/types.d.mts +12 -0
  89. package/dist/types.d.mts.map +1 -0
  90. package/dist/types.mjs +1 -0
  91. package/dist/unloader.cjs +52 -0
  92. package/dist/unloader.d.cts +46 -0
  93. package/dist/unloader.d.cts.map +1 -0
  94. package/dist/unloader.d.mts +46 -0
  95. package/dist/unloader.d.mts.map +1 -0
  96. package/dist/unloader.mjs +49 -0
  97. package/dist/unloader.mjs.map +1 -0
  98. package/dist/unplugin.cjs +239 -0
  99. package/dist/unplugin.d.cts +60 -0
  100. package/dist/unplugin.d.cts.map +1 -0
  101. package/dist/unplugin.d.mts +60 -0
  102. package/dist/unplugin.d.mts.map +1 -0
  103. package/dist/unplugin.mjs +234 -0
  104. package/dist/unplugin.mjs.map +1 -0
  105. package/dist/vite.cjs +161 -0
  106. package/dist/vite.d.cts +59 -0
  107. package/dist/vite.d.cts.map +1 -0
  108. package/dist/vite.d.mts +59 -0
  109. package/dist/vite.d.mts.map +1 -0
  110. package/dist/vite.mjs +155 -0
  111. package/dist/vite.mjs.map +1 -0
  112. package/dist/webpack.cjs +94 -0
  113. package/dist/webpack.d.cts +58 -0
  114. package/dist/webpack.d.cts.map +1 -0
  115. package/dist/webpack.d.mts +58 -0
  116. package/dist/webpack.d.mts.map +1 -0
  117. package/dist/webpack.mjs +89 -0
  118. package/dist/webpack.mjs.map +1 -0
  119. package/package.json +163 -0
@@ -0,0 +1,27 @@
1
+ import { AstroUserConfig } from "astro";
2
+
3
+ //#region src/astro.d.ts
4
+ /**
5
+ * An Astro plugin that will invoke the Powerlines API hooks during the build process.
6
+ *
7
+ * @see https://docs.astro.build/en/guides/integrations-guide/#creating-an-integration
8
+ *
9
+ * @example
10
+ * ```js
11
+ * // astro.config.mjs
12
+ * import { defineConfig } from "astro/config";
13
+ * import powerlines from "@powerlines/unplugin/astro";
14
+ *
15
+ * export default defineConfig({
16
+ * integrations: [powerlines({ name: "example-app", ... })]
17
+ * });
18
+ *
19
+ * ```
20
+ *
21
+ * @param options - The Astro options to merge with the Powerlines configuration.
22
+ * @returns The merged Astro configuration options.
23
+ */
24
+ declare function withPlugin(options: AstroUserConfig): AstroUserConfig;
25
+ //#endregion
26
+ export { withPlugin as default, withPlugin };
27
+ //# sourceMappingURL=astro.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"astro.d.mts","names":[],"sources":["../src/astro.ts"],"mappings":";;;;;AAyCA;;;;;;;;;;;;;;;;;;iBAAgB,UAAA,CAAW,OAAA,EAAS,eAAA,GAAkB,eAAA"}
package/dist/astro.mjs ADDED
@@ -0,0 +1,36 @@
1
+ import plugin from "./vite.mjs";
2
+
3
+ //#region src/astro.ts
4
+ /**
5
+ * An Astro plugin that will invoke the Powerlines API hooks during the build process.
6
+ *
7
+ * @see https://docs.astro.build/en/guides/integrations-guide/#creating-an-integration
8
+ *
9
+ * @example
10
+ * ```js
11
+ * // astro.config.mjs
12
+ * import { defineConfig } from "astro/config";
13
+ * import powerlines from "@powerlines/unplugin/astro";
14
+ *
15
+ * export default defineConfig({
16
+ * integrations: [powerlines({ name: "example-app", ... })]
17
+ * });
18
+ *
19
+ * ```
20
+ *
21
+ * @param options - The Astro options to merge with the Powerlines configuration.
22
+ * @returns The merged Astro configuration options.
23
+ */
24
+ function withPlugin(options) {
25
+ return {
26
+ ...options,
27
+ vite: {
28
+ ...options.vite,
29
+ plugins: [...options.vite?.plugins ?? [], plugin()]
30
+ }
31
+ };
32
+ }
33
+
34
+ //#endregion
35
+ export { withPlugin as default, withPlugin };
36
+ //# sourceMappingURL=astro.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"astro.mjs","names":["vite"],"sources":["../src/astro.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { AstroUserConfig } from \"astro\";\nimport vite from \"./vite\";\n\n/**\n * An Astro plugin that will invoke the Powerlines API hooks during the build process.\n *\n * @see https://docs.astro.build/en/guides/integrations-guide/#creating-an-integration\n *\n * @example\n * ```js\n * // astro.config.mjs\n * import { defineConfig } from \"astro/config\";\n * import powerlines from \"@powerlines/unplugin/astro\";\n *\n * export default defineConfig({\n * integrations: [powerlines({ name: \"example-app\", ... })]\n * });\n *\n * ```\n *\n * @param options - The Astro options to merge with the Powerlines configuration.\n * @returns The merged Astro configuration options.\n */\nexport function withPlugin(options: AstroUserConfig): AstroUserConfig {\n return {\n ...options,\n vite: {\n ...options.vite,\n plugins: [...(options.vite?.plugins ?? []), vite()] as NonNullable<\n AstroUserConfig[\"vite\"]\n >[\"plugins\"]\n }\n };\n}\n\nexport default withPlugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAyCA,SAAgB,WAAW,SAA2C;CACpE,OAAO;EACL,GAAG;EACH,MAAM;GACJ,GAAG,QAAQ;GACX,SAAS,CAAC,GAAI,QAAQ,MAAM,WAAW,EAAE,EAAGA,QAAM,CAAC;GAGpD;EACF"}
@@ -0,0 +1,155 @@
1
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
2
+ const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
3
+ const require_unplugin = require('./unplugin.cjs');
4
+ let _stryke_path_join_paths = require("@stryke/path/join-paths");
5
+ let defu = require("defu");
6
+ defu = require_runtime.__toESM(defu, 1);
7
+ let unplugin = require("unplugin");
8
+ let _powerlines_core_lib_entry = require("@powerlines/core/lib/entry");
9
+ let _stryke_path_replace = require("@stryke/path/replace");
10
+ let _stryke_string_format_camel_case = require("@stryke/string-format/camel-case");
11
+ let _stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
12
+ let _stryke_type_checks_is_undefined = require("@stryke/type-checks/is-undefined");
13
+
14
+ //#region src/esbuild.ts
15
+ const DEFAULT_OPTIONS = {
16
+ target: "esnext",
17
+ platform: "neutral",
18
+ format: "esm",
19
+ write: true,
20
+ minify: true,
21
+ sourcemap: false,
22
+ bundle: true,
23
+ treeShaking: true,
24
+ keepNames: true,
25
+ splitting: true,
26
+ logLevel: "silent"
27
+ };
28
+ /**
29
+ * Resolves the entry options for esbuild.
30
+ *
31
+ * @param context - The build context.
32
+ * @param entryPoints - The entry points to resolve.
33
+ * @returns The resolved entry options.
34
+ */
35
+ function resolveEntry(context, entryPoints = []) {
36
+ return entryPoints.reduce((ret, entry) => {
37
+ if ((0, _stryke_type_checks_is_string.isString)(entry)) ret[(0, _stryke_path_replace.replaceExtension)((0, _stryke_path_replace.replacePath)(entry, context.config.root))] = (0, _stryke_path_replace.replacePath)(entry, context.config.root);
38
+ else ret[entry.output || (0, _powerlines_core_lib_entry.resolveEntryOutput)(context, entry)] = entry.file;
39
+ return ret;
40
+ }, {});
41
+ }
42
+ /**
43
+ * Resolves the esbuild options.
44
+ *
45
+ * @param context - The build context.
46
+ * @param override - Optional esbuild options to override the resolved options.
47
+ * @returns The resolved esbuild options.
48
+ */
49
+ function resolveOptions(context, override = {}) {
50
+ if (context.config.inject && Object.keys(context.config.inject).length > 0) context.fs.writeSync((0, _stryke_path_join_paths.joinPaths)(context.config.cwd, context.config.root, context.artifactsPath, "inject-shim.js"), Object.entries(context.config.inject).map(([key, value]) => {
51
+ if (value) if (Array.isArray(value)) {
52
+ if ((0, _stryke_string_format_camel_case.camelCase)(key) !== key) {
53
+ if (value.length === 1) return `
54
+ import ${(0, _stryke_string_format_camel_case.camelCase)(key)} from "${value[0]}";
55
+ export { ${(0, _stryke_string_format_camel_case.camelCase)(key)} as "${key}" }`;
56
+ else if (value.length > 1) return `
57
+ import ${value[1] === "*" ? `* as ${(0, _stryke_string_format_camel_case.camelCase)(key)}` : `{ ${value[1]} as ${(0, _stryke_string_format_camel_case.camelCase)(key)} }`} from "${value[0]}";
58
+ export { ${(0, _stryke_string_format_camel_case.camelCase)(key)} as "${key}" }`;
59
+ } else if (value.length === 1) return `
60
+ import ${key} from "${value[0]}";
61
+ export { ${key} };`;
62
+ else if (value.length > 1) return `
63
+ import ${value[1] === "*" ? `* as ${key}` : `{ ${value[1]} as ${key} }`} from "${value[0]}";
64
+ export { ${key} };`;
65
+ } else if ((0, _stryke_string_format_camel_case.camelCase)(key) !== key) return `
66
+ import ${(0, _stryke_string_format_camel_case.camelCase)(key)} from "${value[0]}";
67
+ export { ${(0, _stryke_string_format_camel_case.camelCase)(key)} as "${key}" }`;
68
+ else return `
69
+ import ${key} from "${value}";
70
+ export { ${key} };`;
71
+ return "";
72
+ }).join("\n"));
73
+ return (0, defu.default)({
74
+ alias: context.alias,
75
+ inject: context.config.inject && Object.keys(context.config.inject).length > 0 ? [(0, _stryke_path_join_paths.joinPaths)(context.config.cwd, context.config.root, context.artifactsPath, "inject-shim.js")] : void 0
76
+ }, override, {
77
+ mainFields: context.config.resolve.mainFields,
78
+ conditions: context.config.resolve.conditions,
79
+ define: context.config.define,
80
+ resolveExtensions: context.config.resolve.extensions,
81
+ packages: context.config.resolve.skipNodeModulesBundle ? "external" : "bundle",
82
+ format: Array.isArray(context.config.output.format) ? context.config.output.format[0] : context.config.output.format,
83
+ platform: context.config.platform,
84
+ outdir: context.config.output.path,
85
+ tsconfig: context.tsconfig.tsconfigFilePath,
86
+ minify: context.config.output.minify,
87
+ metafile: context.config.mode === "development",
88
+ sourcemap: context.config.output.sourceMap
89
+ }, DEFAULT_OPTIONS);
90
+ }
91
+ /**
92
+ * Creates an ESBuild plugin factory that generates a plugin instance.
93
+ *
94
+ * @see https://esbuild.github.io/plugins/
95
+ *
96
+ * @example
97
+ * ```ts
98
+ * // esbuild.config.ts
99
+ * import { createEsbuildFactory } from "@powerlines/unplugin/esbuild";
100
+ *
101
+ * const powerlinesPlugin = createEsbuildFactory({ name: "example-app", ... });
102
+ *
103
+ * export default defineConfig({
104
+ * plugins: [powerlinesPlugin()],
105
+ * });
106
+ *
107
+ * ```
108
+ *
109
+ * @param options - The options to create the plugin factory with.
110
+ * @param decorate - A function to decorate the plugin options with additional properties or hooks. This can be used to add custom behavior to the plugin instance, such as additional hooks or configuration options. The function receives the generated plugin options and should return an object containing any additional properties or hooks to be merged into the final plugin options.
111
+ * @returns A function that generates an ESBuild plugin instance when called. The generated plugin will invoke the Powerlines API hooks during the build process, allowing you to integrate Powerlines into your ESBuild build.
112
+ */
113
+ function createEsbuildFactory(options = {}, decorate = (options) => options) {
114
+ return require_unplugin.createUnpluginFactory({
115
+ ...options,
116
+ variant: "esbuild"
117
+ }, (unplugin$1) => decorate({
118
+ ...unplugin$1,
119
+ esbuild: {
120
+ config: (opts) => {
121
+ opts ??= {};
122
+ const result = resolveOptions(unplugin$1.context);
123
+ for (const key in result) if ((0, _stryke_type_checks_is_undefined.isUndefined)(opts[key]) && !(0, _stryke_type_checks_is_undefined.isUndefined)(result[key])) opts[key] = result[key];
124
+ },
125
+ setup: async (build) => {
126
+ const environment = await unplugin$1.context.getEnvironment();
127
+ return unplugin$1.context.callHook("esbuild:setup", { environment }, build);
128
+ }
129
+ }
130
+ }));
131
+ }
132
+ /**
133
+ * An ESBuild plugin that will invoke the Powerlines API hooks during the build process.
134
+ *
135
+ * @see https://esbuild.github.io/plugins/
136
+ *
137
+ * @example
138
+ * ```js
139
+ * // esbuild.config.js
140
+ * import powerlines from "@powerlines/unplugin/esbuild";
141
+ *
142
+ * export default {
143
+ * plugins: [powerlines({ name: "example-app", ... })],
144
+ * };
145
+ *
146
+ * ```
147
+ */
148
+ const plugin = (0, unplugin.createEsbuildPlugin)(createEsbuildFactory());
149
+
150
+ //#endregion
151
+ exports.DEFAULT_OPTIONS = DEFAULT_OPTIONS;
152
+ exports.createEsbuildFactory = createEsbuildFactory;
153
+ exports.default = plugin;
154
+ exports.resolveEntry = resolveEntry;
155
+ exports.resolveOptions = resolveOptions;
@@ -0,0 +1,69 @@
1
+ import { UnpluginExecutionOptions, UnpluginFactory } from "./types.cjs";
2
+ import { UnpluginFactoryDecorator, UnpluginFactoryOptions } from "./unplugin.cjs";
3
+ import * as _$_powerlines_core0 from "@powerlines/core";
4
+ import { Context, ExecutionContext, ResolvedEntryTypeDefinition } from "@powerlines/core";
5
+ import { DeepPartial } from "@stryke/types/base";
6
+ import * as _$esbuild from "esbuild";
7
+ import { BuildOptions } from "esbuild";
8
+
9
+ //#region src/esbuild.d.ts
10
+ declare const DEFAULT_OPTIONS: Partial<BuildOptions>;
11
+ /**
12
+ * Resolves the entry options for esbuild.
13
+ *
14
+ * @param context - The build context.
15
+ * @param entryPoints - The entry points to resolve.
16
+ * @returns The resolved entry options.
17
+ */
18
+ declare function resolveEntry(context: Context, entryPoints?: ResolvedEntryTypeDefinition[] | string[]): BuildOptions["entryPoints"];
19
+ /**
20
+ * Resolves the esbuild options.
21
+ *
22
+ * @param context - The build context.
23
+ * @param override - Optional esbuild options to override the resolved options.
24
+ * @returns The resolved esbuild options.
25
+ */
26
+ declare function resolveOptions(context: Context, override?: DeepPartial<BuildOptions>): BuildOptions;
27
+ /**
28
+ * Creates an ESBuild plugin factory that generates a plugin instance.
29
+ *
30
+ * @see https://esbuild.github.io/plugins/
31
+ *
32
+ * @example
33
+ * ```ts
34
+ * // esbuild.config.ts
35
+ * import { createEsbuildFactory } from "@powerlines/unplugin/esbuild";
36
+ *
37
+ * const powerlinesPlugin = createEsbuildFactory({ name: "example-app", ... });
38
+ *
39
+ * export default defineConfig({
40
+ * plugins: [powerlinesPlugin()],
41
+ * });
42
+ *
43
+ * ```
44
+ *
45
+ * @param options - The options to create the plugin factory with.
46
+ * @param decorate - A function to decorate the plugin options with additional properties or hooks. This can be used to add custom behavior to the plugin instance, such as additional hooks or configuration options. The function receives the generated plugin options and should return an object containing any additional properties or hooks to be merged into the final plugin options.
47
+ * @returns A function that generates an ESBuild plugin instance when called. The generated plugin will invoke the Powerlines API hooks during the build process, allowing you to integrate Powerlines into your ESBuild build.
48
+ */
49
+ declare function createEsbuildFactory<TContext extends ExecutionContext>(options?: Omit<UnpluginFactoryOptions, "variant">, decorate?: UnpluginFactoryDecorator<TContext>): UnpluginFactory<ExecutionContext<_$_powerlines_core0.ResolvedConfig, unknown>>;
50
+ /**
51
+ * An ESBuild plugin that will invoke the Powerlines API hooks during the build process.
52
+ *
53
+ * @see https://esbuild.github.io/plugins/
54
+ *
55
+ * @example
56
+ * ```js
57
+ * // esbuild.config.js
58
+ * import powerlines from "@powerlines/unplugin/esbuild";
59
+ *
60
+ * export default {
61
+ * plugins: [powerlines({ name: "example-app", ... })],
62
+ * };
63
+ *
64
+ * ```
65
+ */
66
+ declare const plugin: (options?: UnpluginExecutionOptions | undefined) => _$esbuild.Plugin;
67
+ //#endregion
68
+ export { DEFAULT_OPTIONS, createEsbuildFactory, plugin as default, resolveEntry, resolveOptions };
69
+ //# sourceMappingURL=esbuild.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"esbuild.d.cts","names":[],"sources":["../src/esbuild.ts"],"mappings":";;;;;;;;;cAyCa,eAAA,EAAiB,OAAA,CAAQ,YAAA;;;;;AAAtC;;;iBAqBgB,YAAA,CACd,OAAA,EAAS,OAAA,EACT,WAAA,GAAa,2BAAA,gBACZ,YAAA;;AAHH;;;;;;iBA0BgB,cAAA,CACd,OAAA,EAAS,OAAA,EACT,QAAA,GAAU,WAAA,CAAY,YAAA,IACrB,YAAA;;;;;;;;;AAHH;;;;;;;;;;;;;;iBAgHgB,oBAAA,kBAAsC,gBAAA,CAAA,CACpD,OAAA,GAAS,IAAA,CAAK,sBAAA,cACd,QAAA,GAAU,wBAAA,CAAyB,QAAA,IAA8B,eAAA,CAAA,gBAAA,CAA/B,mBAAA,CAA+B,cAAA;;;AAFnE;;;;;;;;;;;;;;cAqDM,MAAA,GAAM,OAAA,GAA8C,wBAAA,iBAA9C,SAAA,CAAA,MAAA"}
@@ -0,0 +1,69 @@
1
+ import { UnpluginExecutionOptions, UnpluginFactory } from "./types.mjs";
2
+ import { UnpluginFactoryDecorator, UnpluginFactoryOptions } from "./unplugin.mjs";
3
+ import * as _$_powerlines_core0 from "@powerlines/core";
4
+ import { Context, ExecutionContext, ResolvedEntryTypeDefinition } from "@powerlines/core";
5
+ import { DeepPartial } from "@stryke/types/base";
6
+ import * as _$esbuild from "esbuild";
7
+ import { BuildOptions } from "esbuild";
8
+
9
+ //#region src/esbuild.d.ts
10
+ declare const DEFAULT_OPTIONS: Partial<BuildOptions>;
11
+ /**
12
+ * Resolves the entry options for esbuild.
13
+ *
14
+ * @param context - The build context.
15
+ * @param entryPoints - The entry points to resolve.
16
+ * @returns The resolved entry options.
17
+ */
18
+ declare function resolveEntry(context: Context, entryPoints?: ResolvedEntryTypeDefinition[] | string[]): BuildOptions["entryPoints"];
19
+ /**
20
+ * Resolves the esbuild options.
21
+ *
22
+ * @param context - The build context.
23
+ * @param override - Optional esbuild options to override the resolved options.
24
+ * @returns The resolved esbuild options.
25
+ */
26
+ declare function resolveOptions(context: Context, override?: DeepPartial<BuildOptions>): BuildOptions;
27
+ /**
28
+ * Creates an ESBuild plugin factory that generates a plugin instance.
29
+ *
30
+ * @see https://esbuild.github.io/plugins/
31
+ *
32
+ * @example
33
+ * ```ts
34
+ * // esbuild.config.ts
35
+ * import { createEsbuildFactory } from "@powerlines/unplugin/esbuild";
36
+ *
37
+ * const powerlinesPlugin = createEsbuildFactory({ name: "example-app", ... });
38
+ *
39
+ * export default defineConfig({
40
+ * plugins: [powerlinesPlugin()],
41
+ * });
42
+ *
43
+ * ```
44
+ *
45
+ * @param options - The options to create the plugin factory with.
46
+ * @param decorate - A function to decorate the plugin options with additional properties or hooks. This can be used to add custom behavior to the plugin instance, such as additional hooks or configuration options. The function receives the generated plugin options and should return an object containing any additional properties or hooks to be merged into the final plugin options.
47
+ * @returns A function that generates an ESBuild plugin instance when called. The generated plugin will invoke the Powerlines API hooks during the build process, allowing you to integrate Powerlines into your ESBuild build.
48
+ */
49
+ declare function createEsbuildFactory<TContext extends ExecutionContext>(options?: Omit<UnpluginFactoryOptions, "variant">, decorate?: UnpluginFactoryDecorator<TContext>): UnpluginFactory<ExecutionContext<_$_powerlines_core0.ResolvedConfig, unknown>>;
50
+ /**
51
+ * An ESBuild plugin that will invoke the Powerlines API hooks during the build process.
52
+ *
53
+ * @see https://esbuild.github.io/plugins/
54
+ *
55
+ * @example
56
+ * ```js
57
+ * // esbuild.config.js
58
+ * import powerlines from "@powerlines/unplugin/esbuild";
59
+ *
60
+ * export default {
61
+ * plugins: [powerlines({ name: "example-app", ... })],
62
+ * };
63
+ *
64
+ * ```
65
+ */
66
+ declare const plugin: (options?: UnpluginExecutionOptions | undefined) => _$esbuild.Plugin;
67
+ //#endregion
68
+ export { DEFAULT_OPTIONS, createEsbuildFactory, plugin as default, resolveEntry, resolveOptions };
69
+ //# sourceMappingURL=esbuild.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"esbuild.d.mts","names":[],"sources":["../src/esbuild.ts"],"mappings":";;;;;;;;;cAyCa,eAAA,EAAiB,OAAA,CAAQ,YAAA;;;;;AAAtC;;;iBAqBgB,YAAA,CACd,OAAA,EAAS,OAAA,EACT,WAAA,GAAa,2BAAA,gBACZ,YAAA;;AAHH;;;;;;iBA0BgB,cAAA,CACd,OAAA,EAAS,OAAA,EACT,QAAA,GAAU,WAAA,CAAY,YAAA,IACrB,YAAA;;;;;;;;;AAHH;;;;;;;;;;;;;;iBAgHgB,oBAAA,kBAAsC,gBAAA,CAAA,CACpD,OAAA,GAAS,IAAA,CAAK,sBAAA,cACd,QAAA,GAAU,wBAAA,CAAyB,QAAA,IAA8B,eAAA,CAAA,gBAAA,CAA/B,mBAAA,CAA+B,cAAA;;;AAFnE;;;;;;;;;;;;;;cAqDM,MAAA,GAAM,OAAA,GAA8C,wBAAA,iBAA9C,SAAA,CAAA,MAAA"}
@@ -0,0 +1,149 @@
1
+ import { createUnpluginFactory } from "./unplugin.mjs";
2
+ import { joinPaths } from "@stryke/path/join-paths";
3
+ import defu from "defu";
4
+ import { createEsbuildPlugin } from "unplugin";
5
+ import { resolveEntryOutput } from "@powerlines/core/lib/entry";
6
+ import { replaceExtension, replacePath } from "@stryke/path/replace";
7
+ import { camelCase } from "@stryke/string-format/camel-case";
8
+ import { isString } from "@stryke/type-checks/is-string";
9
+ import { isUndefined } from "@stryke/type-checks/is-undefined";
10
+
11
+ //#region src/esbuild.ts
12
+ const DEFAULT_OPTIONS = {
13
+ target: "esnext",
14
+ platform: "neutral",
15
+ format: "esm",
16
+ write: true,
17
+ minify: true,
18
+ sourcemap: false,
19
+ bundle: true,
20
+ treeShaking: true,
21
+ keepNames: true,
22
+ splitting: true,
23
+ logLevel: "silent"
24
+ };
25
+ /**
26
+ * Resolves the entry options for esbuild.
27
+ *
28
+ * @param context - The build context.
29
+ * @param entryPoints - The entry points to resolve.
30
+ * @returns The resolved entry options.
31
+ */
32
+ function resolveEntry(context, entryPoints = []) {
33
+ return entryPoints.reduce((ret, entry) => {
34
+ if (isString(entry)) ret[replaceExtension(replacePath(entry, context.config.root))] = replacePath(entry, context.config.root);
35
+ else ret[entry.output || resolveEntryOutput(context, entry)] = entry.file;
36
+ return ret;
37
+ }, {});
38
+ }
39
+ /**
40
+ * Resolves the esbuild options.
41
+ *
42
+ * @param context - The build context.
43
+ * @param override - Optional esbuild options to override the resolved options.
44
+ * @returns The resolved esbuild options.
45
+ */
46
+ function resolveOptions(context, override = {}) {
47
+ if (context.config.inject && Object.keys(context.config.inject).length > 0) context.fs.writeSync(joinPaths(context.config.cwd, context.config.root, context.artifactsPath, "inject-shim.js"), Object.entries(context.config.inject).map(([key, value]) => {
48
+ if (value) if (Array.isArray(value)) {
49
+ if (camelCase(key) !== key) {
50
+ if (value.length === 1) return `
51
+ import ${camelCase(key)} from "${value[0]}";
52
+ export { ${camelCase(key)} as "${key}" }`;
53
+ else if (value.length > 1) return `
54
+ import ${value[1] === "*" ? `* as ${camelCase(key)}` : `{ ${value[1]} as ${camelCase(key)} }`} from "${value[0]}";
55
+ export { ${camelCase(key)} as "${key}" }`;
56
+ } else if (value.length === 1) return `
57
+ import ${key} from "${value[0]}";
58
+ export { ${key} };`;
59
+ else if (value.length > 1) return `
60
+ import ${value[1] === "*" ? `* as ${key}` : `{ ${value[1]} as ${key} }`} from "${value[0]}";
61
+ export { ${key} };`;
62
+ } else if (camelCase(key) !== key) return `
63
+ import ${camelCase(key)} from "${value[0]}";
64
+ export { ${camelCase(key)} as "${key}" }`;
65
+ else return `
66
+ import ${key} from "${value}";
67
+ export { ${key} };`;
68
+ return "";
69
+ }).join("\n"));
70
+ return defu({
71
+ alias: context.alias,
72
+ inject: context.config.inject && Object.keys(context.config.inject).length > 0 ? [joinPaths(context.config.cwd, context.config.root, context.artifactsPath, "inject-shim.js")] : void 0
73
+ }, override, {
74
+ mainFields: context.config.resolve.mainFields,
75
+ conditions: context.config.resolve.conditions,
76
+ define: context.config.define,
77
+ resolveExtensions: context.config.resolve.extensions,
78
+ packages: context.config.resolve.skipNodeModulesBundle ? "external" : "bundle",
79
+ format: Array.isArray(context.config.output.format) ? context.config.output.format[0] : context.config.output.format,
80
+ platform: context.config.platform,
81
+ outdir: context.config.output.path,
82
+ tsconfig: context.tsconfig.tsconfigFilePath,
83
+ minify: context.config.output.minify,
84
+ metafile: context.config.mode === "development",
85
+ sourcemap: context.config.output.sourceMap
86
+ }, DEFAULT_OPTIONS);
87
+ }
88
+ /**
89
+ * Creates an ESBuild plugin factory that generates a plugin instance.
90
+ *
91
+ * @see https://esbuild.github.io/plugins/
92
+ *
93
+ * @example
94
+ * ```ts
95
+ * // esbuild.config.ts
96
+ * import { createEsbuildFactory } from "@powerlines/unplugin/esbuild";
97
+ *
98
+ * const powerlinesPlugin = createEsbuildFactory({ name: "example-app", ... });
99
+ *
100
+ * export default defineConfig({
101
+ * plugins: [powerlinesPlugin()],
102
+ * });
103
+ *
104
+ * ```
105
+ *
106
+ * @param options - The options to create the plugin factory with.
107
+ * @param decorate - A function to decorate the plugin options with additional properties or hooks. This can be used to add custom behavior to the plugin instance, such as additional hooks or configuration options. The function receives the generated plugin options and should return an object containing any additional properties or hooks to be merged into the final plugin options.
108
+ * @returns A function that generates an ESBuild plugin instance when called. The generated plugin will invoke the Powerlines API hooks during the build process, allowing you to integrate Powerlines into your ESBuild build.
109
+ */
110
+ function createEsbuildFactory(options = {}, decorate = (options) => options) {
111
+ return createUnpluginFactory({
112
+ ...options,
113
+ variant: "esbuild"
114
+ }, (unplugin) => decorate({
115
+ ...unplugin,
116
+ esbuild: {
117
+ config: (opts) => {
118
+ opts ??= {};
119
+ const result = resolveOptions(unplugin.context);
120
+ for (const key in result) if (isUndefined(opts[key]) && !isUndefined(result[key])) opts[key] = result[key];
121
+ },
122
+ setup: async (build) => {
123
+ const environment = await unplugin.context.getEnvironment();
124
+ return unplugin.context.callHook("esbuild:setup", { environment }, build);
125
+ }
126
+ }
127
+ }));
128
+ }
129
+ /**
130
+ * An ESBuild plugin that will invoke the Powerlines API hooks during the build process.
131
+ *
132
+ * @see https://esbuild.github.io/plugins/
133
+ *
134
+ * @example
135
+ * ```js
136
+ * // esbuild.config.js
137
+ * import powerlines from "@powerlines/unplugin/esbuild";
138
+ *
139
+ * export default {
140
+ * plugins: [powerlines({ name: "example-app", ... })],
141
+ * };
142
+ *
143
+ * ```
144
+ */
145
+ const plugin = createEsbuildPlugin(createEsbuildFactory());
146
+
147
+ //#endregion
148
+ export { DEFAULT_OPTIONS, createEsbuildFactory, plugin as default, resolveEntry, resolveOptions };
149
+ //# sourceMappingURL=esbuild.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"esbuild.mjs","names":[],"sources":["../src/esbuild.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type {\n Context,\n ExecutionContext,\n ResolvedEntryTypeDefinition,\n UnpluginOptions\n} from \"@powerlines/core\";\nimport { resolveEntryOutput } from \"@powerlines/core/lib/entry\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { replaceExtension, replacePath } from \"@stryke/path/replace\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport { isUndefined } from \"@stryke/type-checks/is-undefined\";\nimport { DeepPartial } from \"@stryke/types/base\";\nimport defu from \"defu\";\nimport type { BuildOptions, PluginBuild } from \"esbuild\";\nimport { Format } from \"esbuild\";\nimport { createEsbuildPlugin } from \"unplugin\";\nimport {\n createUnpluginFactory,\n UnpluginFactoryDecorator,\n UnpluginFactoryOptions\n} from \"./unplugin\";\n\nexport const DEFAULT_OPTIONS: Partial<BuildOptions> = {\n target: \"esnext\",\n platform: \"neutral\",\n format: \"esm\",\n write: true,\n minify: true,\n sourcemap: false,\n bundle: true,\n treeShaking: true,\n keepNames: true,\n splitting: true,\n logLevel: \"silent\"\n};\n\n/**\n * Resolves the entry options for esbuild.\n *\n * @param context - The build context.\n * @param entryPoints - The entry points to resolve.\n * @returns The resolved entry options.\n */\nexport function resolveEntry(\n context: Context,\n entryPoints: ResolvedEntryTypeDefinition[] | string[] = []\n): BuildOptions[\"entryPoints\"] {\n return entryPoints.reduce(\n (ret, entry) => {\n if (isString(entry)) {\n ret[replaceExtension(replacePath(entry, context.config.root))] =\n replacePath(entry, context.config.root);\n } else {\n ret[entry.output || resolveEntryOutput(context, entry)] = entry.file;\n }\n\n return ret;\n },\n {} as Record<string, string>\n );\n}\n\n/**\n * Resolves the esbuild options.\n *\n * @param context - The build context.\n * @param override - Optional esbuild options to override the resolved options.\n * @returns The resolved esbuild options.\n */\nexport function resolveOptions(\n context: Context,\n override: DeepPartial<BuildOptions> = {}\n): BuildOptions {\n if (context.config.inject && Object.keys(context.config.inject).length > 0) {\n context.fs.writeSync(\n joinPaths(\n context.config.cwd,\n context.config.root,\n context.artifactsPath,\n \"inject-shim.js\"\n ),\n Object.entries(context.config.inject)\n .map(([key, value]) => {\n if (value) {\n if (Array.isArray(value)) {\n if (camelCase(key) !== key) {\n if (value.length === 1) {\n return `\nimport ${camelCase(key)} from \"${value[0]}\";\nexport { ${camelCase(key)} as \"${key}\" }`;\n } else if (value.length > 1) {\n return `\nimport ${value[1] === \"*\" ? `* as ${camelCase(key)}` : `{ ${value[1]} as ${camelCase(key)} }`} from \"${value[0]}\";\nexport { ${camelCase(key)} as \"${key}\" }`;\n }\n } else if (value.length === 1) {\n return `\nimport ${key} from \"${value[0]}\";\nexport { ${key} };`;\n } else if (value.length > 1) {\n return `\nimport ${value[1] === \"*\" ? `* as ${key}` : `{ ${value[1]} as ${key} }`} from \"${value[0]}\";\nexport { ${key} };`;\n }\n } else if (camelCase(key) !== key) {\n return `\nimport ${camelCase(key)} from \"${value[0]}\";\nexport { ${camelCase(key)} as \"${key}\" }`;\n } else {\n return `\nimport ${key} from \"${value}\";\nexport { ${key} };`;\n }\n }\n\n return \"\";\n })\n .join(\"\\n\")\n );\n }\n\n return defu(\n {\n alias: context.alias,\n inject:\n context.config.inject && Object.keys(context.config.inject).length > 0\n ? [\n joinPaths(\n context.config.cwd,\n context.config.root,\n context.artifactsPath,\n \"inject-shim.js\"\n )\n ]\n : undefined\n },\n override,\n {\n mainFields: context.config.resolve.mainFields,\n conditions: context.config.resolve.conditions,\n define: context.config.define,\n resolveExtensions: context.config.resolve.extensions,\n packages: context.config.resolve.skipNodeModulesBundle\n ? \"external\"\n : \"bundle\",\n format: (Array.isArray(context.config.output.format)\n ? context.config.output.format[0]\n : context.config.output.format) as Format,\n platform: context.config.platform,\n outdir: context.config.output.path,\n tsconfig: context.tsconfig.tsconfigFilePath,\n minify: context.config.output.minify,\n metafile: context.config.mode === \"development\",\n sourcemap: context.config.output.sourceMap\n },\n DEFAULT_OPTIONS\n ) as BuildOptions;\n}\n\n/**\n * Creates an ESBuild plugin factory that generates a plugin instance.\n *\n * @see https://esbuild.github.io/plugins/\n *\n * @example\n * ```ts\n * // esbuild.config.ts\n * import { createEsbuildFactory } from \"@powerlines/unplugin/esbuild\";\n *\n * const powerlinesPlugin = createEsbuildFactory({ name: \"example-app\", ... });\n *\n * export default defineConfig({\n * plugins: [powerlinesPlugin()],\n * });\n *\n * ```\n *\n * @param options - The options to create the plugin factory with.\n * @param decorate - A function to decorate the plugin options with additional properties or hooks. This can be used to add custom behavior to the plugin instance, such as additional hooks or configuration options. The function receives the generated plugin options and should return an object containing any additional properties or hooks to be merged into the final plugin options.\n * @returns A function that generates an ESBuild plugin instance when called. The generated plugin will invoke the Powerlines API hooks during the build process, allowing you to integrate Powerlines into your ESBuild build.\n */\nexport function createEsbuildFactory<TContext extends ExecutionContext>(\n options: Omit<UnpluginFactoryOptions, \"variant\"> = {},\n decorate: UnpluginFactoryDecorator<TContext> = options => options\n) {\n return createUnpluginFactory({ ...options, variant: \"esbuild\" }, unplugin =>\n decorate({\n ...(unplugin as UnpluginOptions<TContext>),\n esbuild: {\n config: opts => {\n opts ??= {};\n\n const result = resolveOptions(unplugin.context);\n for (const key in result) {\n if (\n isUndefined(opts[key as keyof BuildOptions]) &&\n !isUndefined(result[key as keyof BuildOptions])\n ) {\n opts[key as keyof BuildOptions] = result[\n key as keyof BuildOptions\n ] as any;\n }\n }\n },\n setup: async (build: PluginBuild) => {\n const environment = await unplugin.context.getEnvironment();\n\n return unplugin.context.callHook(\n \"esbuild:setup\",\n { environment },\n build\n );\n }\n }\n })\n );\n}\n\n/**\n * An ESBuild plugin that will invoke the Powerlines API hooks during the build process.\n *\n * @see https://esbuild.github.io/plugins/\n *\n * @example\n * ```js\n * // esbuild.config.js\n * import powerlines from \"@powerlines/unplugin/esbuild\";\n *\n * export default {\n * plugins: [powerlines({ name: \"example-app\", ... })],\n * };\n *\n * ```\n */\nconst plugin = createEsbuildPlugin(createEsbuildFactory());\n\nexport default plugin;\n"],"mappings":"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"}
package/dist/farm.cjs ADDED
@@ -0,0 +1,56 @@
1
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
2
+ const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
3
+ const require_unplugin = require('./unplugin.cjs');
4
+ let unplugin = require("unplugin");
5
+
6
+ //#region src/farm.ts
7
+ /**
8
+ * Creates a Farm plugin factory that generates a plugin instance.
9
+ *
10
+ * @see https://farmjs.dev/plugins/writing-plugins
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * // farm.config.ts
15
+ * import { createFarmFactory } from "@powerlines/unplugin/farm";
16
+ *
17
+ * const powerlinesPlugin = createFarmFactory({ name: "example-app", ... });
18
+ *
19
+ * export default defineConfig({
20
+ * plugins: [powerlinesPlugin()],
21
+ * });
22
+ *
23
+ * ```
24
+ *
25
+ * @param options - The options to create the plugin factory with.
26
+ * @param decorate - A function to decorate the plugin options with additional properties or hooks. This can be used to add custom behavior to the plugin instance, such as additional hooks or configuration options. The function receives the generated plugin options and should return an object containing any additional properties or hooks to be merged into the final plugin options.
27
+ * @returns A function that generates a Farm plugin instance when called. The generated plugin will invoke the Powerlines API hooks during the build process, allowing you to integrate Powerlines into your Farm build.
28
+ */
29
+ function createFarmFactory(options = {}, decorate = (options) => options) {
30
+ return require_unplugin.createUnpluginFactory({
31
+ ...options,
32
+ variant: "farm"
33
+ }, (unplugin$1) => decorate(unplugin$1));
34
+ }
35
+ /**
36
+ * A Farm plugin that will invoke the Powerlines API hooks during the build process.
37
+ *
38
+ * @see https://farmjs.dev/plugins/writing-plugins
39
+ *
40
+ * @example
41
+ * ```ts
42
+ * // farm.config.ts
43
+ * import powerlines from "@powerlines/unplugin/farm";
44
+ * import { defineConfig } from "@farmfe/core";
45
+ *
46
+ * export default defineConfig({
47
+ * plugins: [powerlines({ name: "example-app", ... })],
48
+ * });
49
+ *
50
+ * ```
51
+ */
52
+ const farm = (0, unplugin.createFarmPlugin)(createFarmFactory());
53
+
54
+ //#endregion
55
+ exports.createFarmFactory = createFarmFactory;
56
+ exports.default = farm;
@@ -0,0 +1,51 @@
1
+ import { UnpluginExecutionOptions, UnpluginFactory } from "./types.cjs";
2
+ import { UnpluginFactoryDecorator, UnpluginFactoryOptions } from "./unplugin.cjs";
3
+ import * as _$_powerlines_core0 from "@powerlines/core";
4
+ import { ExecutionContext } from "@powerlines/core";
5
+ import * as _$_farmfe_core0 from "@farmfe/core";
6
+
7
+ //#region src/farm.d.ts
8
+ /**
9
+ * Creates a Farm plugin factory that generates a plugin instance.
10
+ *
11
+ * @see https://farmjs.dev/plugins/writing-plugins
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * // farm.config.ts
16
+ * import { createFarmFactory } from "@powerlines/unplugin/farm";
17
+ *
18
+ * const powerlinesPlugin = createFarmFactory({ name: "example-app", ... });
19
+ *
20
+ * export default defineConfig({
21
+ * plugins: [powerlinesPlugin()],
22
+ * });
23
+ *
24
+ * ```
25
+ *
26
+ * @param options - The options to create the plugin factory with.
27
+ * @param decorate - A function to decorate the plugin options with additional properties or hooks. This can be used to add custom behavior to the plugin instance, such as additional hooks or configuration options. The function receives the generated plugin options and should return an object containing any additional properties or hooks to be merged into the final plugin options.
28
+ * @returns A function that generates a Farm plugin instance when called. The generated plugin will invoke the Powerlines API hooks during the build process, allowing you to integrate Powerlines into your Farm build.
29
+ */
30
+ declare function createFarmFactory<TContext extends ExecutionContext>(options?: Omit<UnpluginFactoryOptions, "variant">, decorate?: UnpluginFactoryDecorator<TContext>): UnpluginFactory<ExecutionContext<_$_powerlines_core0.ResolvedConfig, unknown>>;
31
+ /**
32
+ * A Farm plugin that will invoke the Powerlines API hooks during the build process.
33
+ *
34
+ * @see https://farmjs.dev/plugins/writing-plugins
35
+ *
36
+ * @example
37
+ * ```ts
38
+ * // farm.config.ts
39
+ * import powerlines from "@powerlines/unplugin/farm";
40
+ * import { defineConfig } from "@farmfe/core";
41
+ *
42
+ * export default defineConfig({
43
+ * plugins: [powerlines({ name: "example-app", ... })],
44
+ * });
45
+ *
46
+ * ```
47
+ */
48
+ declare const farm: (options?: UnpluginExecutionOptions | undefined) => _$_farmfe_core0.JsPlugin;
49
+ //#endregion
50
+ export { createFarmFactory, farm as default };
51
+ //# sourceMappingURL=farm.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"farm.d.cts","names":[],"sources":["../src/farm.ts"],"mappings":";;;;;;;;;;;;AAgDA;;;;;;;;;;;;;;;;;iBAAgB,iBAAA,kBAAmC,gBAAA,CAAA,CACjD,OAAA,GAAS,IAAA,CAAK,sBAAA,cACd,QAAA,GAAU,wBAAA,CAAyB,QAAA,IAA8B,eAAA,CAAA,gBAAA,CAA/B,mBAAA,CAA+B,cAAA;;;;;;;;;AAKlE;;;;;;;;;cAmBK,IAAA,GAAI,OAAA,GAAwC,wBAAA,iBAAxC,eAAA,CAAA,QAAA"}