@powerlines/unplugin 0.0.72 → 0.0.74
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.
- package/dist/_virtual/_rolldown/runtime.cjs +8 -0
- package/dist/_virtual/_rolldown/runtime.mjs +8 -0
- package/dist/astro.cjs +8 -0
- package/dist/astro.d.mts +2 -0
- package/dist/astro.d.mts.map +1 -1
- package/dist/astro.mjs +8 -0
- package/dist/astro.mjs.map +1 -1
- package/dist/esbuild.cjs +8 -0
- package/dist/esbuild.d.mts +2 -0
- package/dist/esbuild.d.mts.map +1 -1
- package/dist/esbuild.mjs +8 -0
- package/dist/esbuild.mjs.map +1 -1
- package/dist/farm.cjs +8 -0
- package/dist/farm.d.mts +2 -0
- package/dist/farm.d.mts.map +1 -1
- package/dist/farm.mjs +8 -0
- package/dist/farm.mjs.map +1 -1
- package/dist/index.cjs +8 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +8 -0
- package/dist/index.mjs.map +1 -1
- package/dist/next.cjs +8 -0
- package/dist/next.d.mts +2 -0
- package/dist/next.d.mts.map +1 -1
- package/dist/next.mjs +8 -0
- package/dist/next.mjs.map +1 -1
- package/dist/nuxt.cjs +8 -0
- package/dist/nuxt.d.mts +2 -0
- package/dist/nuxt.d.mts.map +1 -1
- package/dist/nuxt.mjs +8 -0
- package/dist/nuxt.mjs.map +1 -1
- package/dist/package.cjs +9 -1
- package/dist/package.mjs +9 -1
- package/dist/rolldown.cjs +8 -0
- package/dist/rolldown.d.mts +2 -0
- package/dist/rolldown.d.mts.map +1 -1
- package/dist/rolldown.mjs +8 -0
- package/dist/rolldown.mjs.map +1 -1
- package/dist/rollup.cjs +8 -0
- package/dist/rollup.d.mts +2 -0
- package/dist/rollup.d.mts.map +1 -1
- package/dist/rollup.mjs +8 -0
- package/dist/rollup.mjs.map +1 -1
- package/dist/rspack.cjs +8 -0
- package/dist/rspack.d.mts +2 -0
- package/dist/rspack.d.mts.map +1 -1
- package/dist/rspack.mjs +8 -0
- package/dist/rspack.mjs.map +1 -1
- package/dist/tsdown.cjs +8 -0
- package/dist/tsdown.d.mts +2 -0
- package/dist/tsdown.d.mts.map +1 -1
- package/dist/tsdown.mjs +8 -0
- package/dist/tsdown.mjs.map +1 -1
- package/dist/tsup.cjs +8 -0
- package/dist/tsup.d.mts +2 -0
- package/dist/tsup.d.mts.map +1 -1
- package/dist/tsup.mjs +8 -0
- package/dist/tsup.mjs.map +1 -1
- package/dist/types.cjs +8 -0
- package/dist/types.d.mts +2 -0
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs +8 -0
- package/dist/unloader.cjs +8 -0
- package/dist/unloader.d.mts +2 -0
- package/dist/unloader.d.mts.map +1 -1
- package/dist/unloader.mjs +8 -0
- package/dist/unloader.mjs.map +1 -1
- package/dist/unplugin.cjs +9 -2
- package/dist/unplugin.d.mts +2 -0
- package/dist/unplugin.d.mts.map +1 -1
- package/dist/unplugin.mjs +10 -3
- package/dist/unplugin.mjs.map +1 -1
- package/dist/vite.cjs +8 -0
- package/dist/vite.d.mts +2 -0
- package/dist/vite.d.mts.map +1 -1
- package/dist/vite.mjs +8 -0
- package/dist/vite.mjs.map +1 -1
- package/dist/webpack.cjs +8 -0
- package/dist/webpack.d.mts +2 -0
- package/dist/webpack.d.mts.map +1 -1
- package/dist/webpack.mjs +8 -0
- package/dist/webpack.mjs.map +1 -1
- package/package.json +5 -5
package/dist/rollup.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rollup.mjs","names":["defu"],"sources":["../src/rollup.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 ExecutionContext,\n UnpluginOptions,\n UnresolvedContext\n} from \"@powerlines/core\";\nimport alias from \"@rollup/plugin-alias\";\nimport inject from \"@rollup/plugin-inject\";\nimport resolve from \"@rollup/plugin-node-resolve\";\nimport replace from \"@rollup/plugin-replace\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport { defu } from \"defu\";\nimport { globSync } from \"node:fs\";\nimport type { InputOptions, RollupOptions } from \"rollup\";\nimport { Plugin } from \"rollup\";\nimport typescriptPlugin from \"rollup-plugin-typescript2\";\nimport { createRollupPlugin } from \"unplugin\";\nimport {\n createUnpluginFactory,\n UnpluginFactoryDecorator,\n UnpluginFactoryOptions\n} from \"./unplugin\";\n\n/**\n * A Rollup plugin to bundle TypeScript declaration files (.d.ts) alongside the JavaScript output files.\n *\n * @remarks\n * This plugin generates .d.ts files for each entry point in the bundle, ensuring that type definitions are available for consumers of the library.\n */\nexport const dtsBundlePlugin: Plugin = {\n name: \"powerlines:dts-bundle\",\n async generateBundle(_opts, bundle) {\n for (const [, file] of Object.entries(bundle)) {\n if (\n file.type === \"asset\" ||\n !file.isEntry ||\n file.facadeModuleId == null\n ) {\n continue;\n }\n\n // Replace various JavaScript file extensions (e.g., .js, .cjs, .mjs, .cjs.js, .mjs.js) with .d.ts for generating type definition file names.\n const dtsFileName = file.fileName.replace(\n /(?:\\.cjs|\\.mjs|\\.esm\\.js|\\.cjs\\.js|\\.mjs\\.js|\\.js)$/,\n \".d.ts\"\n );\n\n const relativeSourceDtsName = JSON.stringify(\n `./${file.facadeModuleId.replace(/\\.[cm]?[jt]sx?$/, \"\")}`\n );\n\n this.emitFile({\n type: \"asset\",\n fileName: dtsFileName,\n source: file.exports.includes(\"default\")\n ? `export * from ${relativeSourceDtsName};\\nexport { default } from ${relativeSourceDtsName};\\n`\n : `export * from ${relativeSourceDtsName};\\n`\n });\n }\n }\n};\n\n/**\n * Resolves the options for [rollup](https://rollupjs.org).\n *\n * @param context - The build context.\n * @returns The resolved options.\n */\nexport function resolveOptions<TContext extends UnresolvedContext>(\n context: TContext\n): RollupOptions {\n return {\n input: globSync(\n toArray(context.entry).map(entry =>\n isString(entry) ? entry : entry.file\n )\n ).flat(),\n external: (source: string) => {\n if (\n context.config.resolve.external &&\n toArray(context.config.resolve.external).includes(source)\n ) {\n return true;\n }\n\n if (\n context.config.resolve.noExternal &&\n toArray(context.config.resolve.noExternal).includes(source)\n ) {\n return false;\n }\n\n if (context.builtins.includes(source)) {\n return context.config.projectType !== \"application\";\n }\n\n return !context.config.resolve.skipNodeModulesBundle;\n },\n plugins: [\n typescriptPlugin({\n check: false,\n tsconfig: context.tsconfig.tsconfigFilePath\n }),\n context.config.define &&\n Object.keys(context.config.define).length > 0 &&\n replace({\n sourceMap: context.config.mode === \"development\",\n preventAssignment: true,\n ...(context.config.define ?? {})\n }),\n context.config.inject &&\n Object.keys(context.config.inject).length > 0 &&\n inject({\n sourceMap: context.config.mode === \"development\",\n ...context.config.inject\n }),\n alias({\n entries: Object.entries(context.alias).reduce(\n (ret, [id, path]) => {\n if (!ret.find(e => e.find === id)) {\n ret.push({\n find: id,\n replacement: path\n });\n } else {\n context.warn(\n `Duplicate alias entry for '${id}' detected. The first entry will be used.`\n );\n }\n\n return ret;\n },\n [] as { find: string; replacement: string }[]\n )\n }),\n resolve({\n moduleDirectories: [\"node_modules\"],\n preferBuiltins: true\n }),\n dtsBundlePlugin\n ].filter(Boolean) as Plugin[],\n cache: !context.config.skipCache ? undefined : false,\n logLevel:\n context.config.logLevel.general === \"trace\"\n ? \"debug\"\n : context.config.logLevel.general === \"debug\"\n ? \"warn\"\n : \"silent\",\n output: [\n {\n dir: context.config.output.path,\n format: \"es\",\n entryFileNames: \"[name].js\",\n preserveModules: true,\n sourcemap: context.config.output.sourceMap\n },\n {\n dir: context.config.output.path,\n format: \"cjs\",\n entryFileNames: \"[name].cjs\",\n preserveModules: true,\n sourcemap: context.config.output.sourceMap\n }\n ]\n };\n}\n\n/**\n * Creates a Rollup plugin factory that generates a plugin instance.\n *\n * @see https://rollupjs.org/guide/en/#plugins-overview\n *\n * @example\n * ```ts\n * // rollup.config.ts\n * import { createRollupFactory } from \"@powerlines/unplugin/rollup\";\n *\n * const powerlinesPlugin = createRollupFactory({ 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 a Rollup plugin instance when called. The generated plugin will invoke the Powerlines API hooks during the build process, allowing you to integrate Powerlines into your Rollup build.\n */\nexport function createRollupFactory<TContext extends ExecutionContext>(\n options: Omit<UnpluginFactoryOptions, \"variant\"> = {},\n decorate: UnpluginFactoryDecorator<TContext> = options => options\n) {\n return createUnpluginFactory({ ...options, variant: \"rollup\" }, unplugin =>\n decorate({\n ...(unplugin as UnpluginOptions<TContext>),\n rollup: {\n async options(opts: InputOptions) {\n const environment = await unplugin.context.getEnvironment();\n\n return defu(\n resolveOptions(environment),\n opts,\n unplugin.context.callHook(\n \"rollup:options\",\n { environment },\n opts\n ) ?? {}\n );\n }\n }\n })\n );\n}\n\n/**\n * A Rollup plugin that will invoke the Powerlines API hooks during the build process.\n *\n * @see https://rollupjs.org/guide/en/#plugins-overview\n *\n * @example\n * ```ts\n * // rollup.config.ts\n *\n * import powerlines from \"@powerlines/unplugin/rollup\";\n *\n * export default defineConfig({\n * plugins: [powerlines({ name: \"example-app\", ... })],\n * })\n * ```\n */\nexport const plugin = createRollupPlugin(createRollupFactory());\n\nexport { plugin as default };\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA+CA,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ACF;CACF,CAAC,CACH;AACF;;;;;;;;;;;;;;;;;AAkBA,MAAa,SAAS,mBAAmB,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"rollup.mjs","names":["defu"],"sources":["../src/rollup.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 ExecutionContext,\n UnpluginOptions,\n UnresolvedContext\n} from \"@powerlines/core\";\nimport alias from \"@rollup/plugin-alias\";\nimport inject from \"@rollup/plugin-inject\";\nimport resolve from \"@rollup/plugin-node-resolve\";\nimport replace from \"@rollup/plugin-replace\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport { defu } from \"defu\";\nimport { globSync } from \"node:fs\";\nimport type { InputOptions, RollupOptions } from \"rollup\";\nimport { Plugin } from \"rollup\";\nimport typescriptPlugin from \"rollup-plugin-typescript2\";\nimport { createRollupPlugin } from \"unplugin\";\nimport {\n createUnpluginFactory,\n UnpluginFactoryDecorator,\n UnpluginFactoryOptions\n} from \"./unplugin\";\n\n/**\n * A Rollup plugin to bundle TypeScript declaration files (.d.ts) alongside the JavaScript output files.\n *\n * @remarks\n * This plugin generates .d.ts files for each entry point in the bundle, ensuring that type definitions are available for consumers of the library.\n */\nexport const dtsBundlePlugin: Plugin = {\n name: \"powerlines:dts-bundle\",\n async generateBundle(_opts, bundle) {\n for (const [, file] of Object.entries(bundle)) {\n if (\n file.type === \"asset\" ||\n !file.isEntry ||\n file.facadeModuleId == null\n ) {\n continue;\n }\n\n // Replace various JavaScript file extensions (e.g., .js, .cjs, .mjs, .cjs.js, .mjs.js) with .d.ts for generating type definition file names.\n const dtsFileName = file.fileName.replace(\n /(?:\\.cjs|\\.mjs|\\.esm\\.js|\\.cjs\\.js|\\.mjs\\.js|\\.js)$/,\n \".d.ts\"\n );\n\n const relativeSourceDtsName = JSON.stringify(\n `./${file.facadeModuleId.replace(/\\.[cm]?[jt]sx?$/, \"\")}`\n );\n\n this.emitFile({\n type: \"asset\",\n fileName: dtsFileName,\n source: file.exports.includes(\"default\")\n ? `export * from ${relativeSourceDtsName};\\nexport { default } from ${relativeSourceDtsName};\\n`\n : `export * from ${relativeSourceDtsName};\\n`\n });\n }\n }\n};\n\n/**\n * Resolves the options for [rollup](https://rollupjs.org).\n *\n * @param context - The build context.\n * @returns The resolved options.\n */\nexport function resolveOptions<TContext extends UnresolvedContext>(\n context: TContext\n): RollupOptions {\n return {\n input: globSync(\n toArray(context.entry).map(entry =>\n isString(entry) ? entry : entry.file\n )\n ).flat(),\n external: (source: string) => {\n if (\n context.config.resolve.external &&\n toArray(context.config.resolve.external).includes(source)\n ) {\n return true;\n }\n\n if (\n context.config.resolve.noExternal &&\n toArray(context.config.resolve.noExternal).includes(source)\n ) {\n return false;\n }\n\n if (context.builtins.includes(source)) {\n return context.config.projectType !== \"application\";\n }\n\n return !context.config.resolve.skipNodeModulesBundle;\n },\n plugins: [\n typescriptPlugin({\n check: false,\n tsconfig: context.tsconfig.tsconfigFilePath\n }),\n context.config.define &&\n Object.keys(context.config.define).length > 0 &&\n replace({\n sourceMap: context.config.mode === \"development\",\n preventAssignment: true,\n ...(context.config.define ?? {})\n }),\n context.config.inject &&\n Object.keys(context.config.inject).length > 0 &&\n inject({\n sourceMap: context.config.mode === \"development\",\n ...context.config.inject\n }),\n alias({\n entries: Object.entries(context.alias).reduce(\n (ret, [id, path]) => {\n if (!ret.find(e => e.find === id)) {\n ret.push({\n find: id,\n replacement: path\n });\n } else {\n context.warn(\n `Duplicate alias entry for '${id}' detected. The first entry will be used.`\n );\n }\n\n return ret;\n },\n [] as { find: string; replacement: string }[]\n )\n }),\n resolve({\n moduleDirectories: [\"node_modules\"],\n preferBuiltins: true\n }),\n dtsBundlePlugin\n ].filter(Boolean) as Plugin[],\n cache: !context.config.skipCache ? undefined : false,\n logLevel:\n context.config.logLevel.general === \"trace\"\n ? \"debug\"\n : context.config.logLevel.general === \"debug\"\n ? \"warn\"\n : \"silent\",\n output: [\n {\n dir: context.config.output.path,\n format: \"es\",\n entryFileNames: \"[name].js\",\n preserveModules: true,\n sourcemap: context.config.output.sourceMap\n },\n {\n dir: context.config.output.path,\n format: \"cjs\",\n entryFileNames: \"[name].cjs\",\n preserveModules: true,\n sourcemap: context.config.output.sourceMap\n }\n ]\n };\n}\n\n/**\n * Creates a Rollup plugin factory that generates a plugin instance.\n *\n * @see https://rollupjs.org/guide/en/#plugins-overview\n *\n * @example\n * ```ts\n * // rollup.config.ts\n * import { createRollupFactory } from \"@powerlines/unplugin/rollup\";\n *\n * const powerlinesPlugin = createRollupFactory({ 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 a Rollup plugin instance when called. The generated plugin will invoke the Powerlines API hooks during the build process, allowing you to integrate Powerlines into your Rollup build.\n */\nexport function createRollupFactory<TContext extends ExecutionContext>(\n options: Omit<UnpluginFactoryOptions, \"variant\"> = {},\n decorate: UnpluginFactoryDecorator<TContext> = options => options\n) {\n return createUnpluginFactory({ ...options, variant: \"rollup\" }, unplugin =>\n decorate({\n ...(unplugin as UnpluginOptions<TContext>),\n rollup: {\n async options(opts: InputOptions) {\n const environment = await unplugin.context.getEnvironment();\n\n return defu(\n resolveOptions(environment),\n opts,\n unplugin.context.callHook(\n \"rollup:options\",\n { environment },\n opts\n ) ?? {}\n );\n }\n }\n })\n );\n}\n\n/**\n * A Rollup plugin that will invoke the Powerlines API hooks during the build process.\n *\n * @see https://rollupjs.org/guide/en/#plugins-overview\n *\n * @example\n * ```ts\n * // rollup.config.ts\n *\n * import powerlines from \"@powerlines/unplugin/rollup\";\n *\n * export default defineConfig({\n * plugins: [powerlines({ name: \"example-app\", ... })],\n * })\n * ```\n */\nexport const plugin = createRollupPlugin(createRollupFactory());\n\nexport { plugin as default };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CA,MAAa,kBAA0B;CACrC,MAAM;CACN,MAAM,eAAe,OAAO,QAAQ;EAClC,KAAK,MAAM,GAAG,SAAS,OAAO,QAAQ,MAAM,GAAG;GAC7C,IACE,KAAK,SAAS,WACd,CAAC,KAAK,WACN,KAAK,kBAAkB,MAEvB;GAIF,MAAM,cAAc,KAAK,SAAS,QAChC,uDACA,OACF;GAEA,MAAM,wBAAwB,KAAK,UACjC,KAAK,KAAK,eAAe,QAAQ,mBAAmB,EAAE,GACxD;GAEA,KAAK,SAAS;IACZ,MAAM;IACN,UAAU;IACV,QAAQ,KAAK,QAAQ,SAAS,SAAS,IACnC,iBAAiB,sBAAsB,6BAA6B,sBAAsB,OAC1F,iBAAiB,sBAAsB;GAC7C,CAAC;EACH;CACF;AACF;;;;;;;AAQA,SAAgB,eACd,SACe;CACf,OAAO;EACL,OAAO,SACL,QAAQ,QAAQ,KAAK,EAAE,KAAI,UACzB,SAAS,KAAK,IAAI,QAAQ,MAAM,IAClC,CACF,EAAE,KAAK;EACP,WAAW,WAAmB;GAC5B,IACE,QAAQ,OAAO,QAAQ,YACvB,QAAQ,QAAQ,OAAO,QAAQ,QAAQ,EAAE,SAAS,MAAM,GAExD,OAAO;GAGT,IACE,QAAQ,OAAO,QAAQ,cACvB,QAAQ,QAAQ,OAAO,QAAQ,UAAU,EAAE,SAAS,MAAM,GAE1D,OAAO;GAGT,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ACnC,CACF;CACF;AACF;;;;;;;;;;;;;;;;;;;;;;;AAwBA,SAAgB,oBACd,UAAmD,CAAC,GACpD,YAA+C,YAAW,SAC1D;CACA,OAAO,sBAAsB;EAAE,GAAG;EAAS,SAAS;CAAS,IAAG,aAC9D,SAAS;EACP,GAAI;EACJ,QAAQ,EACN,MAAM,QAAQ,MAAoB;GAChC,MAAM,cAAc,MAAM,SAAS,QAAQ,eAAe;GAE1D,OAAOA,OACL,eAAe,WAAW,GAC1B,MACA,SAAS,QAAQ,SACf,kBACA,EAAE,YAAY,GACd,IACF,KAAK,CAAC,CACR;EACF,EACF;CACF,CAAC,CACH;AACF;;;;;;;;;;;;;;;;;AAkBA,MAAa,SAAS,mBAAmB,oBAAoB,CAAC"}
|
package/dist/rspack.cjs
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
import __tsdown_shims_path from 'node:path'
|
|
4
|
+
import __tsdown_shims_url from 'node:url'
|
|
5
|
+
|
|
6
|
+
const __TSDOWN_SHIM_FILENAME__ = /* @__PURE__ */ __tsdown_shims_url.fileURLToPath(import.meta.url)
|
|
7
|
+
const __TSDOWN_SHIM_DIRNAME__ = /* @__PURE__ */ __tsdown_shims_path.dirname(__TSDOWN_SHIM_FILENAME__)
|
|
8
|
+
|
|
1
9
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
2
10
|
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
3
11
|
const require_unplugin = require('./unplugin.cjs');
|
package/dist/rspack.d.mts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import __tsdown_shims_path from 'node:path';
|
|
2
|
+
import __tsdown_shims_url from 'node:url';
|
|
1
3
|
import { UnpluginExecutionOptions, UnpluginFactory } from "./types.mjs";
|
|
2
4
|
import { UnpluginFactoryDecorator, UnpluginFactoryOptions } from "./unplugin.mjs";
|
|
3
5
|
import { ExecutionContext, UnresolvedContext } from "@powerlines/core";
|
package/dist/rspack.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rspack.d.mts","names":[],"sources":["../src/rspack.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"rspack.d.mts","names":[],"sources":["../src/rspack.ts"],"mappings":";;;;;;;;;;;;;;iBAuCgB,cAAA,kBAAgC,iBAAA,CAAA,CAC9C,OAAA,EAAS,QAAA,GACR,OAAA,CAAQ,uBAAA;;;;;AAFX;;;;;;;;;;;;;;;;AAEkC;AAoElC;iBAAgB,mBAAA,kBAAqC,gBAAA,CAAA,CACnD,OAAA,GAAS,IAAA,CAAK,sBAAA,cACd,QAAA,GAAU,wBAAA,CAAyB,QAAA,IAA8B,eAAA,CAAA,gBAAA,4BAAA,cAAA;;;;;;;;;;;;;;;;;cAiCtD,MAAA,GAAM,OAAA,GAA4C,wBAA5C,oCAAA,oBAAA"}
|
package/dist/rspack.mjs
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
import __tsdown_shims_path from 'node:path'
|
|
4
|
+
import __tsdown_shims_url from 'node:url'
|
|
5
|
+
|
|
6
|
+
const __TSDOWN_SHIM_FILENAME__ = /* @__PURE__ */ __tsdown_shims_url.fileURLToPath(import.meta.url)
|
|
7
|
+
const __TSDOWN_SHIM_DIRNAME__ = /* @__PURE__ */ __tsdown_shims_path.dirname(__TSDOWN_SHIM_FILENAME__)
|
|
8
|
+
|
|
1
9
|
import { createUnpluginFactory } from "./unplugin.mjs";
|
|
2
10
|
import { joinPaths } from "@stryke/path/join-paths";
|
|
3
11
|
import defu from "defu";
|
package/dist/rspack.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rspack.mjs","names":[],"sources":["../src/rspack.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 {\n ExecutionContext,\n UnpluginOptions,\n UnresolvedContext\n} from \"@powerlines/core\";\nimport { RspackOptionsNormalized } from \"@rspack/core\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport defu from \"defu\";\nimport { createRspackPlugin, RspackCompiler } from \"unplugin\";\nimport {\n createUnpluginFactory,\n UnpluginFactoryDecorator,\n UnpluginFactoryOptions\n} from \"./unplugin\";\n\n/**\n * Resolves the options for [rspack](https://rspack.rs/).\n *\n * @param context - The build context.\n * @returns The resolved options.\n */\nexport function resolveOptions<TContext extends UnresolvedContext>(\n context: TContext\n): Partial<RspackOptionsNormalized> {\n return {\n output: {\n path: context.config.output.path\n },\n name: context.config.name,\n resolve: {\n alias: context.alias\n },\n external: context.config.resolve.external,\n noExternal: [\n ...(context.config.resolve.noExternal ?? []),\n ...(context.builtins ?? [])\n ],\n skipNodeModulesBundle: context.config.resolve.skipNodeModulesBundle,\n node:\n context.config.platform === \"node\"\n ? {\n __dirname: true,\n __filename: true,\n global: true\n }\n : false,\n mode:\n context.config.mode === \"development\"\n ? (\"development\" as const)\n : (\"production\" as const),\n recordsInputPath: joinPaths(\n context.cachePath,\n \"rspack\",\n \".rspack-records.json\"\n ),\n recordsOutputPath: joinPaths(\n context.cachePath,\n \"rspack\",\n \".rspack-records.json\"\n ),\n context: joinPaths(context.config.cwd, context.config.root),\n cache: context.config.mode === \"development\",\n devtool: context.config.output.sourceMap ? \"source-map\" : false,\n optimization: {\n minimize: context.config.output.minify\n }\n } as Partial<RspackOptionsNormalized>;\n}\n\n/**\n * Creates a Rspack plugin factory that generates a plugin instance.\n *\n * @see https://rspack.dev/concepts/plugins\n *\n * @example\n * ```ts\n * // rspack.config.ts\n * import { createRspackFactory } from \"@powerlines/unplugin/rspack\";\n *\n * const powerlinesPlugin = createRspackFactory({ 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 a Rspack plugin instance when called. The generated plugin will invoke the Powerlines API hooks during the build process, allowing you to integrate Powerlines into your Rspack build.\n */\nexport function createRspackFactory<TContext extends ExecutionContext>(\n options: Omit<UnpluginFactoryOptions, \"variant\"> = {},\n decorate: UnpluginFactoryDecorator<TContext> = options => options\n) {\n return createUnpluginFactory({ ...options, variant: \"rspack\" }, unplugin =>\n decorate({\n ...(unplugin as UnpluginOptions<TContext>),\n rspack(compiler: RspackCompiler) {\n compiler.hooks.beforeRun.tap(\"PowerlinesRspackPlugin\", compiler => {\n compiler.options = defu(\n resolveOptions(unplugin.context),\n compiler.options\n ) as RspackOptionsNormalized;\n });\n }\n })\n );\n}\n\n/**\n * An Rspack plugin that will invoke the Powerlines API hooks during the build process.\n *\n * @see https://rspack.dev/concepts/plugins\n *\n * @example\n * ```ts\n * // rspack.config.ts\n *\n * import powerlines from \"@powerlines/unplugin/rspack\";\n *\n * export default {\n * plugins: [powerlines({ name: \"example-app\", ... })],\n * }\n * ```\n */\nexport const plugin = createRspackPlugin(createRspackFactory());\n\nexport default plugin;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"rspack.mjs","names":[],"sources":["../src/rspack.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 {\n ExecutionContext,\n UnpluginOptions,\n UnresolvedContext\n} from \"@powerlines/core\";\nimport { RspackOptionsNormalized } from \"@rspack/core\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport defu from \"defu\";\nimport { createRspackPlugin, RspackCompiler } from \"unplugin\";\nimport {\n createUnpluginFactory,\n UnpluginFactoryDecorator,\n UnpluginFactoryOptions\n} from \"./unplugin\";\n\n/**\n * Resolves the options for [rspack](https://rspack.rs/).\n *\n * @param context - The build context.\n * @returns The resolved options.\n */\nexport function resolveOptions<TContext extends UnresolvedContext>(\n context: TContext\n): Partial<RspackOptionsNormalized> {\n return {\n output: {\n path: context.config.output.path\n },\n name: context.config.name,\n resolve: {\n alias: context.alias\n },\n external: context.config.resolve.external,\n noExternal: [\n ...(context.config.resolve.noExternal ?? []),\n ...(context.builtins ?? [])\n ],\n skipNodeModulesBundle: context.config.resolve.skipNodeModulesBundle,\n node:\n context.config.platform === \"node\"\n ? {\n __dirname: true,\n __filename: true,\n global: true\n }\n : false,\n mode:\n context.config.mode === \"development\"\n ? (\"development\" as const)\n : (\"production\" as const),\n recordsInputPath: joinPaths(\n context.cachePath,\n \"rspack\",\n \".rspack-records.json\"\n ),\n recordsOutputPath: joinPaths(\n context.cachePath,\n \"rspack\",\n \".rspack-records.json\"\n ),\n context: joinPaths(context.config.cwd, context.config.root),\n cache: context.config.mode === \"development\",\n devtool: context.config.output.sourceMap ? \"source-map\" : false,\n optimization: {\n minimize: context.config.output.minify\n }\n } as Partial<RspackOptionsNormalized>;\n}\n\n/**\n * Creates a Rspack plugin factory that generates a plugin instance.\n *\n * @see https://rspack.dev/concepts/plugins\n *\n * @example\n * ```ts\n * // rspack.config.ts\n * import { createRspackFactory } from \"@powerlines/unplugin/rspack\";\n *\n * const powerlinesPlugin = createRspackFactory({ 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 a Rspack plugin instance when called. The generated plugin will invoke the Powerlines API hooks during the build process, allowing you to integrate Powerlines into your Rspack build.\n */\nexport function createRspackFactory<TContext extends ExecutionContext>(\n options: Omit<UnpluginFactoryOptions, \"variant\"> = {},\n decorate: UnpluginFactoryDecorator<TContext> = options => options\n) {\n return createUnpluginFactory({ ...options, variant: \"rspack\" }, unplugin =>\n decorate({\n ...(unplugin as UnpluginOptions<TContext>),\n rspack(compiler: RspackCompiler) {\n compiler.hooks.beforeRun.tap(\"PowerlinesRspackPlugin\", compiler => {\n compiler.options = defu(\n resolveOptions(unplugin.context),\n compiler.options\n ) as RspackOptionsNormalized;\n });\n }\n })\n );\n}\n\n/**\n * An Rspack plugin that will invoke the Powerlines API hooks during the build process.\n *\n * @see https://rspack.dev/concepts/plugins\n *\n * @example\n * ```ts\n * // rspack.config.ts\n *\n * import powerlines from \"@powerlines/unplugin/rspack\";\n *\n * export default {\n * plugins: [powerlines({ name: \"example-app\", ... })],\n * }\n * ```\n */\nexport const plugin = createRspackPlugin(createRspackFactory());\n\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAuCA,SAAgB,eACd,SACkC;CAClC,OAAO;EACL,QAAQ,EACN,MAAM,QAAQ,OAAO,OAAO,KAC9B;EACA,MAAM,QAAQ,OAAO;EACrB,SAAS,EACP,OAAO,QAAQ,MACjB;EACA,UAAU,QAAQ,OAAO,QAAQ;EACjC,YAAY,CACV,GAAI,QAAQ,OAAO,QAAQ,cAAc,CAAC,GAC1C,GAAI,QAAQ,YAAY,CAAC,CAC3B;EACA,uBAAuB,QAAQ,OAAO,QAAQ;EAC9C,MACE,QAAQ,OAAO,aAAa,SACxB;GACE,WAAW;GACX,YAAY;GACZ,QAAQ;EACV,IACA;EACN,MACE,QAAQ,OAAO,SAAS,gBACnB,gBACA;EACP,kBAAkB,UAChB,QAAQ,WACR,UACA,sBACF;EACA,mBAAmB,UACjB,QAAQ,WACR,UACA,sBACF;EACA,SAAS,UAAU,QAAQ,OAAO,KAAK,QAAQ,OAAO,IAAI;EAC1D,OAAO,QAAQ,OAAO,SAAS;EAC/B,SAAS,QAAQ,OAAO,OAAO,YAAY,eAAe;EAC1D,cAAc,EACZ,UAAU,QAAQ,OAAO,OAAO,OAClC;CACF;AACF;;;;;;;;;;;;;;;;;;;;;;;AAwBA,SAAgB,oBACd,UAAmD,CAAC,GACpD,YAA+C,YAAW,SAC1D;CACA,OAAO,sBAAsB;EAAE,GAAG;EAAS,SAAS;CAAS,IAAG,aAC9D,SAAS;EACP,GAAI;EACJ,OAAO,UAA0B;GAC/B,SAAS,MAAM,UAAU,IAAI,2BAA0B,aAAY;IACjE,SAAS,UAAU,KACjB,eAAe,SAAS,OAAO,GAC/B,SAAS,OACX;GACF,CAAC;EACH;CACF,CAAC,CACH;AACF;;;;;;;;;;;;;;;;;AAkBA,MAAa,SAAS,mBAAmB,oBAAoB,CAAC"}
|
package/dist/tsdown.cjs
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
import __tsdown_shims_path from 'node:path'
|
|
4
|
+
import __tsdown_shims_url from 'node:url'
|
|
5
|
+
|
|
6
|
+
const __TSDOWN_SHIM_FILENAME__ = /* @__PURE__ */ __tsdown_shims_url.fileURLToPath(import.meta.url)
|
|
7
|
+
const __TSDOWN_SHIM_DIRNAME__ = /* @__PURE__ */ __tsdown_shims_path.dirname(__TSDOWN_SHIM_FILENAME__)
|
|
8
|
+
|
|
1
9
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
2
10
|
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
3
11
|
const require_rolldown = require('./rolldown.cjs');
|
package/dist/tsdown.d.mts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import __tsdown_shims_path from 'node:path';
|
|
2
|
+
import __tsdown_shims_url from 'node:url';
|
|
1
3
|
import { UnresolvedContext } from "@powerlines/core";
|
|
2
4
|
import { GetDependencyConfigResult } from "@powerlines/core/plugin-utils";
|
|
3
5
|
import { Format } from "@storm-software/build-tools/types";
|
package/dist/tsdown.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tsdown.d.mts","names":[],"sources":["../src/tsdown.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"tsdown.d.mts","names":[],"sources":["../src/tsdown.ts"],"mappings":";;;;;;;;;;;;;;;iBAgDgB,mBAAA,kBAAqC,iBAAA,CAAA,CACnD,OAAA,EAAS,QAAA,GACR,yBAAA;AAAA,cAqBU,eAAA,EAAiB,OAAO,CAAC,YAAA;;;AAvBtC;;;;iBAoCgB,aAAA,CAAc,OAAA,GAAU,MAAA,GAAS,MAAA,KAAW,QAAA;;;;;;;iBAoB5C,iBAAA,CACd,OAAA,GAAU,QAAA,GAAe,QAAA,KACxB,MAAA;;;AAxDyB;AAqB5B;;;iBAwEgB,cAAA,kBAAgC,iBAAA,CAAA,CAC9C,OAAA,EAAS,QAAA,GACR,YAAA;AA1E+C;AAalD;;;;;;;;;;;;;AAAwE;AAoBxE;;;;;;;;AAjCkD,iBA+PlC,MAAA,CAAO,OAAA,GAAS,YAAA,GAAkB,YAAU"}
|
package/dist/tsdown.mjs
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
import __tsdown_shims_path from 'node:path'
|
|
4
|
+
import __tsdown_shims_url from 'node:url'
|
|
5
|
+
|
|
6
|
+
const __TSDOWN_SHIM_FILENAME__ = /* @__PURE__ */ __tsdown_shims_url.fileURLToPath(import.meta.url)
|
|
7
|
+
const __TSDOWN_SHIM_DIRNAME__ = /* @__PURE__ */ __tsdown_shims_path.dirname(__TSDOWN_SHIM_FILENAME__)
|
|
8
|
+
|
|
1
9
|
import plugin$1 from "./rolldown.mjs";
|
|
2
10
|
import { appendPath } from "@stryke/path/append";
|
|
3
11
|
import { relativePath } from "@stryke/path/file-path-fns";
|
package/dist/tsdown.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tsdown.mjs","names":["_getDependencyConfig","rolldown"],"sources":["../src/tsdown.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 CopyConfig,\n ResolveConfig,\n UnresolvedContext\n} from \"@powerlines/core\";\nimport type { GetDependencyConfigResult } from \"@powerlines/core/plugin-utils\";\nimport { getDependencyConfig as _getDependencyConfig } from \"@powerlines/core/plugin-utils\";\nimport type { Format } from \"@storm-software/build-tools/types\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { relativePath } from \"@stryke/path/file-path-fns\";\nimport { globToRegex } from \"@stryke/path/glob-to-regex\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { replaceExtension, replacePath } from \"@stryke/path/replace\";\nimport { isFunction } from \"@stryke/type-checks/is-function\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport defu from \"defu\";\nimport { ModuleFormat } from \"rolldown\";\nimport { UserConfig as BuildOptions, Format as TsdownFormat } from \"tsdown\";\nimport type { UserConfig } from \"tsdown/config\";\nimport rolldown from \"./rolldown\";\nimport { UnpluginExecutionOptions } from \"./types\";\n\n/**\n * Get the {@link ResolveConfig.external | external} and {@link ResolveConfig.noExternal | noExternal} dependencies for the build configuration.\n *\n * @param context - The build context.\n * @returns The dependency configuration.\n */\nexport function getDependencyConfig<TContext extends UnresolvedContext>(\n context: TContext\n): GetDependencyConfigResult {\n const { external, noExternal } = _getDependencyConfig(context);\n\n return {\n external:\n !external || external.length === 0\n ? undefined\n : external.map(ext =>\n isSetString(ext) && ext.includes(\"*\") ? globToRegex(ext) : ext\n ),\n noExternal:\n !noExternal || noExternal.length === 0\n ? undefined\n : noExternal.map(noExt =>\n isSetString(noExt) && noExt.includes(\"*\")\n ? globToRegex(noExt)\n : noExt\n )\n };\n}\n\nexport const DEFAULT_OPTIONS: Partial<BuildOptions> = {\n platform: \"neutral\",\n target: \"esnext\",\n fixedExtension: true,\n clean: false\n} as const;\n\n/**\n * Resolves the entry options for [tsdown](https://github.com/rolldown/tsdown).\n *\n * @param formats - The formats to resolve.\n * @returns The resolved entry options.\n */\nexport function resolveFormat(formats?: Format | Format[]): TsdownFormat[] {\n return toArray(formats).map(format => {\n switch (format) {\n case \"cjs\":\n return \"cjs\";\n case \"iife\":\n return \"iife\";\n case \"esm\":\n default:\n return \"esm\";\n }\n });\n}\n\n/**\n * Resolves the entry options for [tsdown](https://github.com/rolldown/tsdown).\n *\n * @param formats - The formats to resolve.\n * @returns The resolved entry options.\n */\nexport function resolveFromFormat(\n formats?: TsdownFormat | TsdownFormat[]\n): Format[] {\n return toArray(formats).map(format => {\n switch (format) {\n case \"cjs\":\n case \"commonjs\":\n return \"cjs\";\n case \"iife\":\n return \"iife\";\n case \"esm\":\n case \"es\":\n case \"module\":\n case \"umd\":\n default:\n return \"esm\";\n }\n });\n}\n\nconst formatMessage = <TContext extends UnresolvedContext>(\n context: TContext,\n ...msgs: any[]\n) =>\n msgs\n .filter(Boolean)\n .join(\" \")\n .trim()\n .replace(new RegExp(`\\\\[${context.config.name}\\\\]`, \"g\"), \"\")\n .replaceAll(/^\\s+/g, \"\")\n .replaceAll(/\\s+$/g, \"\")\n .trim();\n\n/**\n * Resolves the options for [tsdown](https://github.com/rolldown/tsdown).\n *\n * @param context - The build context.\n * @returns The resolved options.\n */\nexport function resolveOptions<TContext extends UnresolvedContext>(\n context: TContext\n): BuildOptions {\n const { external, noExternal } = getDependencyConfig(context);\n\n return defu(\n {\n name: context.config.name,\n cwd: appendPath(context.config.root, context.config.cwd),\n entry:\n context.entry.filter(entry => entry?.file).length > 0\n ? Object.fromEntries(\n context.entry\n .filter(entry => entry?.file)\n .map(entry => [\n entry.output ||\n replaceExtension(\n replacePath(\n replacePath(\n entry.file,\n joinPaths(context.config.root, \"src\")\n ),\n context.entryPath\n )\n ),\n entry.file\n ])\n )\n : [\n joinPaths(\n context.config.cwd,\n context.config.root,\n \"src\",\n \"**/*.ts\"\n ),\n joinPaths(\n context.config.cwd,\n context.config.root,\n \"src\",\n \"**/*.tsx\"\n )\n ],\n exports: {\n customExports: (exports: Record<string, any>) => {\n const result = Object.fromEntries(\n Object.entries(exports).map(([key, value]) => {\n if (isSetString(value)) {\n return [key, value];\n }\n\n const currentExport = {} as Record<string, any>;\n if (isSetString(value.require)) {\n currentExport.require = {\n types: replaceExtension(value.require, \".d.cts\", {\n fullExtension: true\n }),\n default: value.require\n };\n }\n\n if (isSetString(value.import)) {\n currentExport.import = {\n types: replaceExtension(value.import, \".d.mts\", {\n fullExtension: true\n }),\n default: value.import\n };\n }\n\n if (!isSetObject(value.default)) {\n if (isSetObject(currentExport.import)) {\n currentExport.default = currentExport.import;\n } else if (isSetObject(currentExport.require)) {\n currentExport.default = currentExport.require;\n }\n }\n\n return [key, currentExport];\n })\n );\n\n return Object.keys(result)\n .sort()\n .reduce(\n (ret, key) => {\n ret[key] = result[key];\n return ret;\n },\n {} as Record<string, any>\n );\n }\n },\n define: context.config.define,\n inputOptions: {\n transform: {\n define: context.config.define,\n inject: context.config.inject,\n typescript: {\n target: context.tsconfig.tsconfigJson?.compilerOptions?.target\n }\n }\n },\n deps: {\n neverBundle: external,\n alwaysBundle: context.config.resolve.skipNodeModulesBundle\n ? undefined\n : noExternal,\n onlyBundle: context.config.resolve.skipNodeModulesBundle\n ? noExternal\n : undefined,\n skipNodeModulesBundle: context.config.resolve.skipNodeModulesBundle\n },\n alias: context.alias,\n resolve: {\n alias: context.alias\n },\n platform: context.config.platform,\n dts: context.config.output.dts,\n outDir: relativePath(\n appendPath(context.config.root, context.config.cwd),\n context.config.output.path\n ),\n tsconfig: appendPath(\n context.tsconfig.tsconfigFilePath,\n context.config.cwd\n ),\n format: resolveFormat(context.config.output.format).filter(Boolean),\n mode: context.config.mode,\n minify: context.config.output.minify,\n metafile: context.config.mode === \"development\",\n sourcemap: context.config.output.sourceMap,\n nodeProtocol: context.config.output.nodeProtocol,\n debug: context.config.mode === \"development\",\n silent:\n context.config.logLevel.general === \"silent\" ||\n context.config.mode === \"production\",\n logLevel: context.config.logLevel.general === \"trace\" ? \"debug\" : \"error\",\n customLogger: {\n level: context.config.logLevel.general === \"trace\" ? \"debug\" : \"error\",\n info: (...msgs: any[]) =>\n isSetString(formatMessage(context, ...msgs).replace(/\\s+/g, \"\")) &&\n context.trace(formatMessage(context, ...msgs)),\n warn: (...msgs: any[]) =>\n isSetString(formatMessage(context, ...msgs).replace(/\\s+/g, \"\")) &&\n context.warn(formatMessage(context, ...msgs)),\n warnOnce: (...msgs: any[]) =>\n isSetString(formatMessage(context, ...msgs).replace(/\\s+/g, \"\")) &&\n context.warn(formatMessage(context, ...msgs)),\n error: (...msgs: any[]) =>\n isSetString(formatMessage(context, ...msgs).replace(/\\s+/g, \"\")) &&\n context.error(formatMessage(context, ...msgs)),\n success: (...msgs: any[]) =>\n isSetString(formatMessage(context, ...msgs).replace(/\\s+/g, \"\")) &&\n context.trace(formatMessage(context, ...msgs))\n }\n },\n DEFAULT_OPTIONS\n ) as BuildOptions;\n}\n\n/**\n * A Tsdown configuration function that integrates Powerlines into the build process.\n *\n * @see https://github.com/rolldown/tsdown\n *\n * @example\n * ```ts\n * // tsdown.config.ts\n * import withPowerlines from \"@powerlines/unplugin/tsdown\";\n *\n * export default withPowerlines({\n * entry: [\"src/index.ts\"],\n * format: [\"cjs\", \"esm\"],\n * dts: true,\n * sourcemap: true,\n * clean: true,\n * });\n *\n * ```\n *\n * @param options - The Tsdown options to merge with the Powerlines configuration.\n * @returns The merged Tsdown configuration options.\n */\nexport function plugin(options: UserConfig = {}): UserConfig {\n return {\n ...options,\n entry: options.entry,\n plugins: [\n rolldown({\n ...options,\n output: {\n path: options.outDir,\n format: resolveFromFormat(\n options.format as ModuleFormat | ModuleFormat[]\n ),\n copy: {\n path: options.outDir!,\n assets: toArray(options.copy)\n .map(copy => {\n if (!copy) {\n return undefined;\n }\n if (isSetString(copy)) {\n return copy;\n }\n if (isFunction(copy)) {\n // eslint-disable-next-line no-console\n console.warn(\n \"Function-based copy options are not supported in Powerlines.\"\n );\n return undefined;\n }\n return {\n input: copy.from,\n output: copy.to\n };\n })\n .filter(Boolean) as CopyConfig[\"assets\"]\n }\n },\n resolve: {\n external: options.deps?.neverBundle\n ? (toArray(options.deps?.neverBundle)\n .map(external => {\n if (isFunction(external)) {\n // eslint-disable-next-line no-console\n console.warn(\n \"Function-based external options are not supported in Powerlines.\"\n );\n return undefined;\n }\n return external;\n })\n .filter(Boolean) as ResolveConfig[\"external\"])\n : undefined,\n noExternal:\n (options.deps?.skipNodeModulesBundle && options.deps?.onlyBundle) ||\n (!options.deps?.skipNodeModulesBundle && options.deps?.alwaysBundle)\n ? (toArray(\n options.deps?.skipNodeModulesBundle\n ? options.deps?.onlyBundle\n : options.deps?.alwaysBundle\n )\n .map(noExternal => {\n if (isFunction(noExternal)) {\n // eslint-disable-next-line no-console\n console.warn(\n \"Function-based noExternal options are not supported in Powerlines.\"\n );\n return undefined;\n }\n return noExternal;\n })\n .filter(Boolean) as ResolveConfig[\"noExternal\"])\n : undefined\n },\n tsconfig: isSetString(options.tsconfig) ? options.tsconfig : undefined\n } as UnpluginExecutionOptions)\n ]\n };\n}\n\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAgDA,SAAgB,oBACd,SAC2B;CAC3B,MAAM,EAAE,UAAU,eAAeA,sBAAqB,OAAO;CAE7D,OAAO;EACL,UACE,CAAC,YAAY,SAAS,WAAW,IAC7B,SACA,SAAS,KAAI,QACX,YAAY,GAAG,KAAK,IAAI,SAAS,GAAG,IAAI,YAAY,GAAG,IAAI,GAC7D;EACN,YACE,CAAC,cAAc,WAAW,WAAW,IACjC,SACA,WAAW,KAAI,UACb,YAAY,KAAK,KAAK,MAAM,SAAS,GAAG,IACpC,YAAY,KAAK,IACjB,KACN;CACR;AACF;AAEA,MAAa,kBAAyC;CACpD,UAAU;CACV,QAAQ;CACR,gBAAgB;CAChB,OAAO;AACT;;;;;;;AAQA,SAAgB,cAAc,SAA6C;CACzE,OAAO,QAAQ,OAAO,EAAE,KAAI,WAAU;EACpC,QAAQ,QAAR;GACE,KAAK,OACH,OAAO;GACT,KAAK,QACH,OAAO;GAET,SACE,OAAO;EACX;CACF,CAAC;AACH;;;;;;;AAQA,SAAgB,kBACd,SACU;CACV,OAAO,QAAQ,OAAO,EAAE,KAAI,WAAU;EACpC,QAAQ,QAAR;GACE,KAAK;GACL,KAAK,YACH,OAAO;GACT,KAAK,QACH,OAAO;GAKT,SACE,OAAO;EACX;CACF,CAAC;AACH;AAEA,MAAM,iBACJ,SACA,GAAG,SAEH,KACG,OAAO,OAAO,EACd,KAAK,GAAG,EACR,KAAK,EACL,QAAQ,IAAI,OAAO,MAAM,QAAQ,OAAO,KAAK,MAAM,GAAG,GAAG,EAAE,EAC3D,WAAW,SAAS,EAAE,EACtB,WAAW,SAAS,EAAE,EACtB,KAAK;;;;;;;AAQ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;MACA;KACF;KACA,OAAO;IACT,CAAC,EACA,OAAO,OAAO,IACjB;IACJ,YACG,QAAQ,MAAM,yBAAyB,QAAQ,MAAM,cACrD,CAAC,QAAQ,MAAM,yBAAyB,QAAQ,MAAM,eAClD,QACC,QAAQ,MAAM,wBACV,QAAQ,MAAM,aACd,QAAQ,MAAM,YACpB,EACG,KAAI,eAAc;KACjB,IAAI,WAAW,UAAU,GAAG;MAE1B,QAAQ,KACN,oEACF;MACA;KACF;KACA,OAAO;IACT,CAAC,EACA,OAAO,OAAO,IACjB;GACR;GACA,UAAU,YAAY,QAAQ,QAAQ,IAAI,QAAQ,WAAW;EAC/D,CAA6B,CAC/B;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"tsdown.mjs","names":["_getDependencyConfig","rolldown"],"sources":["../src/tsdown.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 CopyConfig,\n ResolveConfig,\n UnresolvedContext\n} from \"@powerlines/core\";\nimport type { GetDependencyConfigResult } from \"@powerlines/core/plugin-utils\";\nimport { getDependencyConfig as _getDependencyConfig } from \"@powerlines/core/plugin-utils\";\nimport type { Format } from \"@storm-software/build-tools/types\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { relativePath } from \"@stryke/path/file-path-fns\";\nimport { globToRegex } from \"@stryke/path/glob-to-regex\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { replaceExtension, replacePath } from \"@stryke/path/replace\";\nimport { isFunction } from \"@stryke/type-checks/is-function\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport defu from \"defu\";\nimport { ModuleFormat } from \"rolldown\";\nimport { UserConfig as BuildOptions, Format as TsdownFormat } from \"tsdown\";\nimport type { UserConfig } from \"tsdown/config\";\nimport rolldown from \"./rolldown\";\nimport { UnpluginExecutionOptions } from \"./types\";\n\n/**\n * Get the {@link ResolveConfig.external | external} and {@link ResolveConfig.noExternal | noExternal} dependencies for the build configuration.\n *\n * @param context - The build context.\n * @returns The dependency configuration.\n */\nexport function getDependencyConfig<TContext extends UnresolvedContext>(\n context: TContext\n): GetDependencyConfigResult {\n const { external, noExternal } = _getDependencyConfig(context);\n\n return {\n external:\n !external || external.length === 0\n ? undefined\n : external.map(ext =>\n isSetString(ext) && ext.includes(\"*\") ? globToRegex(ext) : ext\n ),\n noExternal:\n !noExternal || noExternal.length === 0\n ? undefined\n : noExternal.map(noExt =>\n isSetString(noExt) && noExt.includes(\"*\")\n ? globToRegex(noExt)\n : noExt\n )\n };\n}\n\nexport const DEFAULT_OPTIONS: Partial<BuildOptions> = {\n platform: \"neutral\",\n target: \"esnext\",\n fixedExtension: true,\n clean: false\n} as const;\n\n/**\n * Resolves the entry options for [tsdown](https://github.com/rolldown/tsdown).\n *\n * @param formats - The formats to resolve.\n * @returns The resolved entry options.\n */\nexport function resolveFormat(formats?: Format | Format[]): TsdownFormat[] {\n return toArray(formats).map(format => {\n switch (format) {\n case \"cjs\":\n return \"cjs\";\n case \"iife\":\n return \"iife\";\n case \"esm\":\n default:\n return \"esm\";\n }\n });\n}\n\n/**\n * Resolves the entry options for [tsdown](https://github.com/rolldown/tsdown).\n *\n * @param formats - The formats to resolve.\n * @returns The resolved entry options.\n */\nexport function resolveFromFormat(\n formats?: TsdownFormat | TsdownFormat[]\n): Format[] {\n return toArray(formats).map(format => {\n switch (format) {\n case \"cjs\":\n case \"commonjs\":\n return \"cjs\";\n case \"iife\":\n return \"iife\";\n case \"esm\":\n case \"es\":\n case \"module\":\n case \"umd\":\n default:\n return \"esm\";\n }\n });\n}\n\nconst formatMessage = <TContext extends UnresolvedContext>(\n context: TContext,\n ...msgs: any[]\n) =>\n msgs\n .filter(Boolean)\n .join(\" \")\n .trim()\n .replace(new RegExp(`\\\\[${context.config.name}\\\\]`, \"g\"), \"\")\n .replaceAll(/^\\s+/g, \"\")\n .replaceAll(/\\s+$/g, \"\")\n .trim();\n\n/**\n * Resolves the options for [tsdown](https://github.com/rolldown/tsdown).\n *\n * @param context - The build context.\n * @returns The resolved options.\n */\nexport function resolveOptions<TContext extends UnresolvedContext>(\n context: TContext\n): BuildOptions {\n const { external, noExternal } = getDependencyConfig(context);\n\n return defu(\n {\n name: context.config.name,\n cwd: appendPath(context.config.root, context.config.cwd),\n entry:\n context.entry.filter(entry => entry?.file).length > 0\n ? Object.fromEntries(\n context.entry\n .filter(entry => entry?.file)\n .map(entry => [\n entry.output ||\n replaceExtension(\n replacePath(\n replacePath(\n entry.file,\n joinPaths(context.config.root, \"src\")\n ),\n context.entryPath\n )\n ),\n entry.file\n ])\n )\n : [\n joinPaths(\n context.config.cwd,\n context.config.root,\n \"src\",\n \"**/*.ts\"\n ),\n joinPaths(\n context.config.cwd,\n context.config.root,\n \"src\",\n \"**/*.tsx\"\n )\n ],\n exports: {\n customExports: (exports: Record<string, any>) => {\n const result = Object.fromEntries(\n Object.entries(exports).map(([key, value]) => {\n if (isSetString(value)) {\n return [key, value];\n }\n\n const currentExport = {} as Record<string, any>;\n if (isSetString(value.require)) {\n currentExport.require = {\n types: replaceExtension(value.require, \".d.cts\", {\n fullExtension: true\n }),\n default: value.require\n };\n }\n\n if (isSetString(value.import)) {\n currentExport.import = {\n types: replaceExtension(value.import, \".d.mts\", {\n fullExtension: true\n }),\n default: value.import\n };\n }\n\n if (!isSetObject(value.default)) {\n if (isSetObject(currentExport.import)) {\n currentExport.default = currentExport.import;\n } else if (isSetObject(currentExport.require)) {\n currentExport.default = currentExport.require;\n }\n }\n\n return [key, currentExport];\n })\n );\n\n return Object.keys(result)\n .sort()\n .reduce(\n (ret, key) => {\n ret[key] = result[key];\n return ret;\n },\n {} as Record<string, any>\n );\n }\n },\n define: context.config.define,\n inputOptions: {\n transform: {\n define: context.config.define,\n inject: context.config.inject,\n typescript: {\n target: context.tsconfig.tsconfigJson?.compilerOptions?.target\n }\n }\n },\n deps: {\n neverBundle: external,\n alwaysBundle: context.config.resolve.skipNodeModulesBundle\n ? undefined\n : noExternal,\n onlyBundle: context.config.resolve.skipNodeModulesBundle\n ? noExternal\n : undefined,\n skipNodeModulesBundle: context.config.resolve.skipNodeModulesBundle\n },\n alias: context.alias,\n resolve: {\n alias: context.alias\n },\n platform: context.config.platform,\n dts: context.config.output.dts,\n outDir: relativePath(\n appendPath(context.config.root, context.config.cwd),\n context.config.output.path\n ),\n tsconfig: appendPath(\n context.tsconfig.tsconfigFilePath,\n context.config.cwd\n ),\n format: resolveFormat(context.config.output.format).filter(Boolean),\n mode: context.config.mode,\n minify: context.config.output.minify,\n metafile: context.config.mode === \"development\",\n sourcemap: context.config.output.sourceMap,\n nodeProtocol: context.config.output.nodeProtocol,\n debug: context.config.mode === \"development\",\n silent:\n context.config.logLevel.general === \"silent\" ||\n context.config.mode === \"production\",\n logLevel: context.config.logLevel.general === \"trace\" ? \"debug\" : \"error\",\n customLogger: {\n level: context.config.logLevel.general === \"trace\" ? \"debug\" : \"error\",\n info: (...msgs: any[]) =>\n isSetString(formatMessage(context, ...msgs).replace(/\\s+/g, \"\")) &&\n context.trace(formatMessage(context, ...msgs)),\n warn: (...msgs: any[]) =>\n isSetString(formatMessage(context, ...msgs).replace(/\\s+/g, \"\")) &&\n context.warn(formatMessage(context, ...msgs)),\n warnOnce: (...msgs: any[]) =>\n isSetString(formatMessage(context, ...msgs).replace(/\\s+/g, \"\")) &&\n context.warn(formatMessage(context, ...msgs)),\n error: (...msgs: any[]) =>\n isSetString(formatMessage(context, ...msgs).replace(/\\s+/g, \"\")) &&\n context.error(formatMessage(context, ...msgs)),\n success: (...msgs: any[]) =>\n isSetString(formatMessage(context, ...msgs).replace(/\\s+/g, \"\")) &&\n context.trace(formatMessage(context, ...msgs))\n }\n },\n DEFAULT_OPTIONS\n ) as BuildOptions;\n}\n\n/**\n * A Tsdown configuration function that integrates Powerlines into the build process.\n *\n * @see https://github.com/rolldown/tsdown\n *\n * @example\n * ```ts\n * // tsdown.config.ts\n * import withPowerlines from \"@powerlines/unplugin/tsdown\";\n *\n * export default withPowerlines({\n * entry: [\"src/index.ts\"],\n * format: [\"cjs\", \"esm\"],\n * dts: true,\n * sourcemap: true,\n * clean: true,\n * });\n *\n * ```\n *\n * @param options - The Tsdown options to merge with the Powerlines configuration.\n * @returns The merged Tsdown configuration options.\n */\nexport function plugin(options: UserConfig = {}): UserConfig {\n return {\n ...options,\n entry: options.entry,\n plugins: [\n rolldown({\n ...options,\n output: {\n path: options.outDir,\n format: resolveFromFormat(\n options.format as ModuleFormat | ModuleFormat[]\n ),\n copy: {\n path: options.outDir!,\n assets: toArray(options.copy)\n .map(copy => {\n if (!copy) {\n return undefined;\n }\n if (isSetString(copy)) {\n return copy;\n }\n if (isFunction(copy)) {\n // eslint-disable-next-line no-console\n console.warn(\n \"Function-based copy options are not supported in Powerlines.\"\n );\n return undefined;\n }\n return {\n input: copy.from,\n output: copy.to\n };\n })\n .filter(Boolean) as CopyConfig[\"assets\"]\n }\n },\n resolve: {\n external: options.deps?.neverBundle\n ? (toArray(options.deps?.neverBundle)\n .map(external => {\n if (isFunction(external)) {\n // eslint-disable-next-line no-console\n console.warn(\n \"Function-based external options are not supported in Powerlines.\"\n );\n return undefined;\n }\n return external;\n })\n .filter(Boolean) as ResolveConfig[\"external\"])\n : undefined,\n noExternal:\n (options.deps?.skipNodeModulesBundle && options.deps?.onlyBundle) ||\n (!options.deps?.skipNodeModulesBundle && options.deps?.alwaysBundle)\n ? (toArray(\n options.deps?.skipNodeModulesBundle\n ? options.deps?.onlyBundle\n : options.deps?.alwaysBundle\n )\n .map(noExternal => {\n if (isFunction(noExternal)) {\n // eslint-disable-next-line no-console\n console.warn(\n \"Function-based noExternal options are not supported in Powerlines.\"\n );\n return undefined;\n }\n return noExternal;\n })\n .filter(Boolean) as ResolveConfig[\"noExternal\"])\n : undefined\n },\n tsconfig: isSetString(options.tsconfig) ? options.tsconfig : undefined\n } as UnpluginExecutionOptions)\n ]\n };\n}\n\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDA,SAAgB,oBACd,SAC2B;CAC3B,MAAM,EAAE,UAAU,eAAeA,sBAAqB,OAAO;CAE7D,OAAO;EACL,UACE,CAAC,YAAY,SAAS,WAAW,IAC7B,SACA,SAAS,KAAI,QACX,YAAY,GAAG,KAAK,IAAI,SAAS,GAAG,IAAI,YAAY,GAAG,IAAI,GAC7D;EACN,YACE,CAAC,cAAc,WAAW,WAAW,IACjC,SACA,WAAW,KAAI,UACb,YAAY,KAAK,KAAK,MAAM,SAAS,GAAG,IACpC,YAAY,KAAK,IACjB,KACN;CACR;AACF;AAEA,MAAa,kBAAyC;CACpD,UAAU;CACV,QAAQ;CACR,gBAAgB;CAChB,OAAO;AACT;;;;;;;AAQA,SAAgB,cAAc,SAA6C;CACzE,OAAO,QAAQ,OAAO,EAAE,KAAI,WAAU;EACpC,QAAQ,QAAR;GACE,KAAK,OACH,OAAO;GACT,KAAK,QACH,OAAO;GAET,SACE,OAAO;EACX;CACF,CAAC;AACH;;;;;;;AAQA,SAAgB,kBACd,SACU;CACV,OAAO,QAAQ,OAAO,EAAE,KAAI,WAAU;EACpC,QAAQ,QAAR;GACE,KAAK;GACL,KAAK,YACH,OAAO;GACT,KAAK,QACH,OAAO;GAKT,SACE,OAAO;EACX;CACF,CAAC;AACH;AAEA,MAAM,iBACJ,SACA,GAAG,SAEH,KACG,OAAO,OAAO,EACd,KAAK,GAAG,EACR,KAAK,EACL,QAAQ,IAAI,OAAO,MAAM,QAAQ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AAM,cACnB,QAAQ,QAAQ,MAAM,WAAW,EAC/B,KAAI,aAAY;KACf,IAAI,WAAW,QAAQ,GAAG;MAExB,QAAQ,KACN,kEACF;MACA;KACF;KACA,OAAO;IACT,CAAC,EACA,OAAO,OAAO,IACjB;IACJ,YACG,QAAQ,MAAM,yBAAyB,QAAQ,MAAM,cACrD,CAAC,QAAQ,MAAM,yBAAyB,QAAQ,MAAM,eAClD,QACC,QAAQ,MAAM,wBACV,QAAQ,MAAM,aACd,QAAQ,MAAM,YACpB,EACG,KAAI,eAAc;KACjB,IAAI,WAAW,UAAU,GAAG;MAE1B,QAAQ,KACN,oEACF;MACA;KACF;KACA,OAAO;IACT,CAAC,EACA,OAAO,OAAO,IACjB;GACR;GACA,UAAU,YAAY,QAAQ,QAAQ,IAAI,QAAQ,WAAW;EAC/D,CAA6B,CAC/B;CACF;AACF"}
|
package/dist/tsup.cjs
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
import __tsdown_shims_path from 'node:path'
|
|
4
|
+
import __tsdown_shims_url from 'node:url'
|
|
5
|
+
|
|
6
|
+
const __TSDOWN_SHIM_FILENAME__ = /* @__PURE__ */ __tsdown_shims_url.fileURLToPath(import.meta.url)
|
|
7
|
+
const __TSDOWN_SHIM_DIRNAME__ = /* @__PURE__ */ __tsdown_shims_path.dirname(__TSDOWN_SHIM_FILENAME__)
|
|
8
|
+
|
|
1
9
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
2
10
|
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
3
11
|
const require_esbuild = require('./esbuild.cjs');
|
package/dist/tsup.d.mts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import __tsdown_shims_path from 'node:path';
|
|
2
|
+
import __tsdown_shims_url from 'node:url';
|
|
1
3
|
import { ResolvedEntryFileReference, UnresolvedContext } from "@powerlines/core";
|
|
2
4
|
import { Entry } from "@storm-software/build-tools/types";
|
|
3
5
|
import { resolveOptions as resolveOptions$1 } from "@storm-software/tsup";
|
package/dist/tsup.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tsup.d.mts","names":[],"sources":["../src/tsup.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"tsup.d.mts","names":[],"sources":["../src/tsup.ts"],"mappings":";;;;;;;;cAiCa,eAAA,EAAiB,OAAO,CAAC,SAAA;;;;;;;;iBAwBtB,YAAA,kBAA8B,iBAAA,CAAA,CAC5C,OAAA,EAAS,QAAA,EACT,WAAA,EAAa,0BAAA,gBACZ,KAAA;;AA3BH;;;;AAA6C;iBAyC7B,cAAA,kBAAgC,iBAAA,CAAA,CAC9C,OAAA,EAAS,QAAA,GACR,UAAA,QAAkB,gBAAA;;;;;;;;;;;;;;;;;AAhBb;AAcR;;;;;;iBAwFgB,UAAA,CAAW,OAAA,EAAS,SAAA,GAAU,SAAO"}
|
package/dist/tsup.mjs
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
import __tsdown_shims_path from 'node:path'
|
|
4
|
+
import __tsdown_shims_url from 'node:url'
|
|
5
|
+
|
|
6
|
+
const __TSDOWN_SHIM_FILENAME__ = /* @__PURE__ */ __tsdown_shims_url.fileURLToPath(import.meta.url)
|
|
7
|
+
const __TSDOWN_SHIM_DIRNAME__ = /* @__PURE__ */ __tsdown_shims_path.dirname(__TSDOWN_SHIM_FILENAME__)
|
|
8
|
+
|
|
1
9
|
import plugin, { resolveEntry as resolveEntry$1 } from "./esbuild.mjs";
|
|
2
10
|
import { appendPath } from "@stryke/path/append";
|
|
3
11
|
import { relativePath } from "@stryke/path/file-path-fns";
|
package/dist/tsup.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tsup.mjs","names":["resolveEsbuildEntry","esbuild"],"sources":["../src/tsup.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 {\n ResolvedEntryFileReference,\n UnresolvedContext\n} from \"@powerlines/core\";\nimport { AssetGlob, Entry } from \"@storm-software/build-tools/types\";\nimport { resolveOptions as resolveOptionsBase } from \"@storm-software/tsup\";\nimport { DEFAULT_BUILD_OPTIONS } from \"@storm-software/tsup/constants\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { getUnique } from \"@stryke/helpers/get-unique\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { relativePath } from \"@stryke/path/file-path-fns\";\nimport defu from \"defu\";\nimport type { Options } from \"tsup\";\nimport esbuild, { resolveEntry as resolveEsbuildEntry } from \"./esbuild\";\n\nexport const DEFAULT_OPTIONS: Partial<Options> = {\n ...DEFAULT_BUILD_OPTIONS,\n target: \"esnext\",\n config: false,\n minify: true,\n sourcemap: false,\n cjsInterop: true,\n bundle: true,\n dts: true,\n shims: true,\n silent: true,\n treeshake: true,\n keepNames: true,\n splitting: true,\n banner: {}\n};\n\n/**\n * Resolves the entry options for [tsup](https://github.com/egoist/tsup).\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<TContext extends UnresolvedContext>(\n context: TContext,\n entryPoints: ResolvedEntryFileReference[] | string[]\n): Entry {\n return resolveEsbuildEntry(context, entryPoints) as Entry;\n}\n\ntype TsupEsbuildOptionsHandler = NonNullable<Options[\"esbuildOptions\"]>;\ntype TsupEsbuildOptionsArgs = Parameters<TsupEsbuildOptionsHandler>;\ntype TsupEsbuildOptions = TsupEsbuildOptionsArgs[0];\n\n/**\n * Resolves the options for [tsup](https://github.com/egoist/tsup).\n *\n * @param context - The build context.\n * @returns The resolved options.\n */\nexport function resolveOptions<TContext extends UnresolvedContext>(\n context: TContext\n): Parameters<typeof resolveOptionsBase>[0] {\n const result = defu(\n {\n entry: Object.fromEntries(\n Object.entries(resolveEntry(context, context.entry)).map(\n ([key, value]) => [key, appendPath(value, context.config.root)]\n )\n ),\n esbuildOptions: (options: TsupEsbuildOptions) => {\n options.alias = {\n ...context.alias,\n ...context.builtins.reduce(\n (ret, id) => {\n const path = context.fs.paths[id];\n if (path) {\n ret[id] = path;\n }\n\n return ret;\n },\n {} as Record<string, string>\n ),\n ...options.alias\n };\n },\n noExternal: context.builtins\n },\n {\n name: context.config.name,\n root: context.config.root,\n projectRoot: context.config.root,\n assets: context.config.output.copy\n ? (context.config.output.copy.assets as (string | AssetGlob)[])\n : undefined,\n resolveExtensions: context.config.resolve.extensions,\n outputPath: relativePath(\n appendPath(context.config.root, context.config.cwd),\n context.config.output.path\n ),\n tsconfig: context.tsconfig.tsconfigFilePath,\n dts: {\n compilerOptions: context.tsconfig.tsconfigJson.compilerOptions\n },\n format: context.config.output.format,\n mode: context.config.mode,\n minify: context.config.output.minify,\n metafile: context.config.mode === \"development\",\n sourcemap: context.config.output.sourceMap,\n silent:\n context.config.logLevel.general === \"silent\" ||\n context.config.mode === \"production\",\n verbose:\n context.config.logLevel.general === \"trace\" ||\n context.config.mode === \"development\",\n workspaceConfig: { workspaceRoot: context.config.cwd }\n },\n DEFAULT_OPTIONS\n );\n\n result.format = getUnique(toArray(result.format));\n return result as Parameters<typeof resolveOptionsBase>[0];\n}\n\n/**\n * A Tsup configuration function that integrates Powerlines into the build process.\n *\n * @see https://tsup.egoist.dev/#/config\n *\n * @example\n * ```ts\n * // tsup.config.ts\n * import withPowerlines from \"@powerlines/unplugin/tsup\";\n *\n * export default withPowerlines({\n * entry: [\"src/index.ts\"],\n * format: [\"cjs\", \"esm\"],\n * dts: true,\n * sourcemap: true,\n * clean: true,\n * });\n *\n * ```\n *\n * @param options - The Tsup options to merge with the Powerlines configuration.\n * @returns The merged Tsup configuration options.\n */\nexport function withPlugin(options: Options): Options {\n return {\n ...options,\n esbuildPlugins: [...(options.esbuildPlugins ?? []), esbuild()]\n };\n}\n\nexport default withPlugin;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"tsup.mjs","names":["resolveEsbuildEntry","esbuild"],"sources":["../src/tsup.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 {\n ResolvedEntryFileReference,\n UnresolvedContext\n} from \"@powerlines/core\";\nimport { AssetGlob, Entry } from \"@storm-software/build-tools/types\";\nimport { resolveOptions as resolveOptionsBase } from \"@storm-software/tsup\";\nimport { DEFAULT_BUILD_OPTIONS } from \"@storm-software/tsup/constants\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { getUnique } from \"@stryke/helpers/get-unique\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { relativePath } from \"@stryke/path/file-path-fns\";\nimport defu from \"defu\";\nimport type { Options } from \"tsup\";\nimport esbuild, { resolveEntry as resolveEsbuildEntry } from \"./esbuild\";\n\nexport const DEFAULT_OPTIONS: Partial<Options> = {\n ...DEFAULT_BUILD_OPTIONS,\n target: \"esnext\",\n config: false,\n minify: true,\n sourcemap: false,\n cjsInterop: true,\n bundle: true,\n dts: true,\n shims: true,\n silent: true,\n treeshake: true,\n keepNames: true,\n splitting: true,\n banner: {}\n};\n\n/**\n * Resolves the entry options for [tsup](https://github.com/egoist/tsup).\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<TContext extends UnresolvedContext>(\n context: TContext,\n entryPoints: ResolvedEntryFileReference[] | string[]\n): Entry {\n return resolveEsbuildEntry(context, entryPoints) as Entry;\n}\n\ntype TsupEsbuildOptionsHandler = NonNullable<Options[\"esbuildOptions\"]>;\ntype TsupEsbuildOptionsArgs = Parameters<TsupEsbuildOptionsHandler>;\ntype TsupEsbuildOptions = TsupEsbuildOptionsArgs[0];\n\n/**\n * Resolves the options for [tsup](https://github.com/egoist/tsup).\n *\n * @param context - The build context.\n * @returns The resolved options.\n */\nexport function resolveOptions<TContext extends UnresolvedContext>(\n context: TContext\n): Parameters<typeof resolveOptionsBase>[0] {\n const result = defu(\n {\n entry: Object.fromEntries(\n Object.entries(resolveEntry(context, context.entry)).map(\n ([key, value]) => [key, appendPath(value, context.config.root)]\n )\n ),\n esbuildOptions: (options: TsupEsbuildOptions) => {\n options.alias = {\n ...context.alias,\n ...context.builtins.reduce(\n (ret, id) => {\n const path = context.fs.paths[id];\n if (path) {\n ret[id] = path;\n }\n\n return ret;\n },\n {} as Record<string, string>\n ),\n ...options.alias\n };\n },\n noExternal: context.builtins\n },\n {\n name: context.config.name,\n root: context.config.root,\n projectRoot: context.config.root,\n assets: context.config.output.copy\n ? (context.config.output.copy.assets as (string | AssetGlob)[])\n : undefined,\n resolveExtensions: context.config.resolve.extensions,\n outputPath: relativePath(\n appendPath(context.config.root, context.config.cwd),\n context.config.output.path\n ),\n tsconfig: context.tsconfig.tsconfigFilePath,\n dts: {\n compilerOptions: context.tsconfig.tsconfigJson.compilerOptions\n },\n format: context.config.output.format,\n mode: context.config.mode,\n minify: context.config.output.minify,\n metafile: context.config.mode === \"development\",\n sourcemap: context.config.output.sourceMap,\n silent:\n context.config.logLevel.general === \"silent\" ||\n context.config.mode === \"production\",\n verbose:\n context.config.logLevel.general === \"trace\" ||\n context.config.mode === \"development\",\n workspaceConfig: { workspaceRoot: context.config.cwd }\n },\n DEFAULT_OPTIONS\n );\n\n result.format = getUnique(toArray(result.format));\n return result as Parameters<typeof resolveOptionsBase>[0];\n}\n\n/**\n * A Tsup configuration function that integrates Powerlines into the build process.\n *\n * @see https://tsup.egoist.dev/#/config\n *\n * @example\n * ```ts\n * // tsup.config.ts\n * import withPowerlines from \"@powerlines/unplugin/tsup\";\n *\n * export default withPowerlines({\n * entry: [\"src/index.ts\"],\n * format: [\"cjs\", \"esm\"],\n * dts: true,\n * sourcemap: true,\n * clean: true,\n * });\n *\n * ```\n *\n * @param options - The Tsup options to merge with the Powerlines configuration.\n * @returns The merged Tsup configuration options.\n */\nexport function withPlugin(options: Options): Options {\n return {\n ...options,\n esbuildPlugins: [...(options.esbuildPlugins ?? []), esbuild()]\n };\n}\n\nexport default withPlugin;\n"],"mappings":";;;;;;;;;;;;;;;;;AAiCA,MAAa,kBAAoC;CAC/C,GAAG;CACH,QAAQ;CACR,QAAQ;CACR,QAAQ;CACR,WAAW;CACX,YAAY;CACZ,QAAQ;CACR,KAAK;CACL,OAAO;CACP,QAAQ;CACR,WAAW;CACX,WAAW;CACX,WAAW;CACX,QAAQ,CAAC;AACX;;;;;;;;AASA,SAAgB,aACd,SACA,aACO;CACP,OAAOA,eAAoB,SAAS,WAAW;AACjD;;;;;;;AAYA,SAAgB,eACd,SAC0C;CAC1C,MAAM,SAAS,KACb;EACE,OAAO,OAAO,YACZ,OAAO,QAAQ,aAAa,SAAS,QAAQ,KAAK,CAAC,EAAE,KAClD,CAAC,KAAK,WAAW,CAAC,KAAK,WAAW,OAAO,QAAQ,OAAO,IAAI,CAAC,CAChE,CACF;EACA,iBAAiB,YAAgC;GAC/C,QAAQ,QAAQ;IACd,GAAG,QAAQ;IACX,GAAG,QAAQ,SAAS,QACjB,KAAK,OAAO;KACX,MAAM,OAAO,QAAQ,GAAG,MAAM;KAC9B,IAAI,MACF,IAAI,M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fileURLToPath(import.meta.url)
|
|
7
|
+
const __TSDOWN_SHIM_DIRNAME__ = /* @__PURE__ */ __tsdown_shims_path.dirname(__TSDOWN_SHIM_FILENAME__)
|
|
8
|
+
|
package/dist/types.d.mts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import __tsdown_shims_path from 'node:path';
|
|
2
|
+
import __tsdown_shims_url from 'node:url';
|
|
1
3
|
import { UnpluginContextMeta } from "unplugin";
|
|
2
4
|
import { BuildInlineConfig, ExecutionContext, ExecutionOptions, UnpluginOptions } from "@powerlines/core";
|
|
3
5
|
import { PartialKeys } from "@stryke/types/base";
|
package/dist/types.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.mts","names":[],"sources":["../src/types.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.d.mts","names":[],"sources":["../src/types.ts"],"mappings":";;;;;;;;KA6BY,4BAAA,GAA+B,IAAA,CACzC,WAAA,CACE,gBAAA;AAAA,KAMQ,wBAAA,GAA2B,IAAA,CAAK,iBAAA,eAC1C,4BAAA;AAAA,KAEU,eAAA,kBAAiC,gBAAA,KAC3C,OAAA,EAAS,wBAAA,cACT,IAAA,EAAM,mBAAA,KACH,eAAA,CAAgB,QAAA"}
|
package/dist/types.mjs
CHANGED
|
@@ -1 +1,9 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
import __tsdown_shims_path from 'node:path'
|
|
4
|
+
import __tsdown_shims_url from 'node:url'
|
|
5
|
+
|
|
6
|
+
const __TSDOWN_SHIM_FILENAME__ = /* @__PURE__ */ __tsdown_shims_url.fileURLToPath(import.meta.url)
|
|
7
|
+
const __TSDOWN_SHIM_DIRNAME__ = /* @__PURE__ */ __tsdown_shims_path.dirname(__TSDOWN_SHIM_FILENAME__)
|
|
8
|
+
|
|
1
9
|
export { };
|
package/dist/unloader.cjs
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
import __tsdown_shims_path from 'node:path'
|
|
4
|
+
import __tsdown_shims_url from 'node:url'
|
|
5
|
+
|
|
6
|
+
const __TSDOWN_SHIM_FILENAME__ = /* @__PURE__ */ __tsdown_shims_url.fileURLToPath(import.meta.url)
|
|
7
|
+
const __TSDOWN_SHIM_DIRNAME__ = /* @__PURE__ */ __tsdown_shims_path.dirname(__TSDOWN_SHIM_FILENAME__)
|
|
8
|
+
|
|
1
9
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
2
10
|
const require_unplugin = require('./unplugin.cjs');
|
|
3
11
|
let unplugin = require("unplugin");
|
package/dist/unloader.d.mts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import __tsdown_shims_path from 'node:path';
|
|
2
|
+
import __tsdown_shims_url from 'node:url';
|
|
1
3
|
import { UnpluginExecutionOptions, UnpluginFactory } from "./types.mjs";
|
|
2
4
|
import { UnpluginFactoryDecorator, UnpluginFactoryOptions } from "./unplugin.mjs";
|
|
3
5
|
import { ExecutionContext } from "@powerlines/core";
|
package/dist/unloader.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unloader.d.mts","names":[],"sources":["../src/unloader.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"unloader.d.mts","names":[],"sources":["../src/unloader.ts"],"mappings":";;;;;;;;;;;;;;;;;;AA8CA;;;;;;;;;iBAAgB,qBAAA,kBAAuC,gBAAA,CAAA,CACrD,OAAA,GAAS,IAAA,CAAK,sBAAA,cACd,QAAA,GAAU,wBAAA,CAAyB,QAAA,IAA8B,eAAA,CAAA,gBAAA,4BAAA,cAAA;;;;;;;;;;;;;;;cAqBtD,MAAA,GAAM,OAAA,GAAgD,wBAAhD,oCAAA,MAAA,sBAAA,MAAA"}
|
package/dist/unloader.mjs
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
import __tsdown_shims_path from 'node:path'
|
|
4
|
+
import __tsdown_shims_url from 'node:url'
|
|
5
|
+
|
|
6
|
+
const __TSDOWN_SHIM_FILENAME__ = /* @__PURE__ */ __tsdown_shims_url.fileURLToPath(import.meta.url)
|
|
7
|
+
const __TSDOWN_SHIM_DIRNAME__ = /* @__PURE__ */ __tsdown_shims_path.dirname(__TSDOWN_SHIM_FILENAME__)
|
|
8
|
+
|
|
1
9
|
import { createUnpluginFactory } from "./unplugin.mjs";
|
|
2
10
|
import { createUnloaderPlugin } from "unplugin";
|
|
3
11
|
|
package/dist/unloader.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unloader.mjs","names":[],"sources":["../src/unloader.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 { ExecutionContext, UnpluginOptions } from \"@powerlines/core\";\nimport { createUnloaderPlugin } from \"unplugin\";\nimport {\n createUnpluginFactory,\n UnpluginFactoryDecorator,\n UnpluginFactoryOptions\n} from \"./unplugin\";\n\n/**\n * Creates a Unloader plugin factory that generates a plugin instance.\n *\n * @example\n * ```js\n * // unloader.config.js\n * import { createUnloaderFactory } from \"@powerlines/unplugin/unloader\";\n *\n * const powerlinesPlugin = createUnloaderFactory({ 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 a Unloader plugin instance when called. The generated plugin will invoke the Powerlines API hooks during the build process, allowing you to integrate Powerlines into your Unloader build.\n */\nexport function createUnloaderFactory<TContext extends ExecutionContext>(\n options: Omit<UnpluginFactoryOptions, \"variant\"> = {},\n decorate: UnpluginFactoryDecorator<TContext> = options => options\n) {\n return createUnpluginFactory({ ...options, variant: \"unloader\" }, unplugin =>\n decorate(unplugin as UnpluginOptions<TContext>)\n );\n}\n\n/**\n * An Unloader plugin that will invoke the Powerlines API hooks during processing.\n *\n * @example\n * ```js\n * // unloader.config.js\n * import powerlines from \"@powerlines/unplugin/unloader\";\n *\n * export default defineConfig({\n * plugins: [powerlines({ name: \"example-app\", ... })],\n * });\n *\n * ```\n */\nexport const plugin = createUnloaderPlugin(createUnloaderFactory());\n\nexport default plugin;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"unloader.mjs","names":[],"sources":["../src/unloader.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 { ExecutionContext, UnpluginOptions } from \"@powerlines/core\";\nimport { createUnloaderPlugin } from \"unplugin\";\nimport {\n createUnpluginFactory,\n UnpluginFactoryDecorator,\n UnpluginFactoryOptions\n} from \"./unplugin\";\n\n/**\n * Creates a Unloader plugin factory that generates a plugin instance.\n *\n * @example\n * ```js\n * // unloader.config.js\n * import { createUnloaderFactory } from \"@powerlines/unplugin/unloader\";\n *\n * const powerlinesPlugin = createUnloaderFactory({ 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 a Unloader plugin instance when called. The generated plugin will invoke the Powerlines API hooks during the build process, allowing you to integrate Powerlines into your Unloader build.\n */\nexport function createUnloaderFactory<TContext extends ExecutionContext>(\n options: Omit<UnpluginFactoryOptions, \"variant\"> = {},\n decorate: UnpluginFactoryDecorator<TContext> = options => options\n) {\n return createUnpluginFactory({ ...options, variant: \"unloader\" }, unplugin =>\n decorate(unplugin as UnpluginOptions<TContext>)\n );\n}\n\n/**\n * An Unloader plugin that will invoke the Powerlines API hooks during processing.\n *\n * @example\n * ```js\n * // unloader.config.js\n * import powerlines from \"@powerlines/unplugin/unloader\";\n *\n * export default defineConfig({\n * plugins: [powerlines({ name: \"example-app\", ... })],\n * });\n *\n * ```\n */\nexport const plugin = createUnloaderPlugin(createUnloaderFactory());\n\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CA,SAAgB,sBACd,UAAmD,CAAC,GACpD,YAA+C,YAAW,SAC1D;CACA,OAAO,sBAAsB;EAAE,GAAG;EAAS,SAAS;CAAW,IAAG,aAChE,SAAS,QAAqC,CAChD;AACF;;;;;;;;;;;;;;;AAgBA,MAAa,SAAS,qBAAqB,sBAAsB,CAAC"}
|
package/dist/unplugin.cjs
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
import __tsdown_shims_path from 'node:path'
|
|
4
|
+
import __tsdown_shims_url from 'node:url'
|
|
5
|
+
|
|
6
|
+
const __TSDOWN_SHIM_FILENAME__ = /* @__PURE__ */ __tsdown_shims_url.fileURLToPath(import.meta.url)
|
|
7
|
+
const __TSDOWN_SHIM_DIRNAME__ = /* @__PURE__ */ __tsdown_shims_path.dirname(__TSDOWN_SHIM_FILENAME__)
|
|
8
|
+
|
|
1
9
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
10
|
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
3
11
|
let _stryke_path_replace = require("@stryke/path/replace");
|
|
@@ -17,7 +25,6 @@ let _stryke_type_checks_is_function = require("@stryke/type-checks/is-function")
|
|
|
17
25
|
let _stryke_type_checks_is_object = require("@stryke/type-checks/is-object");
|
|
18
26
|
let _stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
|
|
19
27
|
let _stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
|
|
20
|
-
let _stryke_unique_id_uuid = require("@stryke/unique-id/uuid");
|
|
21
28
|
|
|
22
29
|
//#region src/unplugin.ts
|
|
23
30
|
/**
|
|
@@ -69,7 +76,7 @@ function createUnpluginFactory(options, decorate = (options) => options) {
|
|
|
69
76
|
...params,
|
|
70
77
|
command: "build",
|
|
71
78
|
configFile: config.configFile,
|
|
72
|
-
executionId: (0,
|
|
79
|
+
executionId: (0, _powerlines_core_plugin_utils.formatExecutionId)(config.config.name || root, "build", 0),
|
|
73
80
|
configIndex: 0
|
|
74
81
|
};
|
|
75
82
|
context = await _powerlines_core_context_execution_context.PowerlinesExecutionContext.from({
|
package/dist/unplugin.d.mts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import __tsdown_shims_path from 'node:path';
|
|
2
|
+
import __tsdown_shims_url from 'node:url';
|
|
1
3
|
import { UnpluginFactory } from "./types.mjs";
|
|
2
4
|
import { CustomLogger, ExecutionContext, Options, UnpluginBuilderVariant, UnpluginOptions } from "@powerlines/core";
|
|
3
5
|
export * from "@powerlines/core/lib/unplugin";
|
package/dist/unplugin.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unplugin.d.mts","names":[],"sources":["../src/unplugin.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"unplugin.d.mts","names":[],"sources":["../src/unplugin.ts"],"mappings":";;;;;;;;;;UAuEiB,sBAAA,SAA+B,OAAA;;;;;;;EAO9C,OAAA,EAAS,sBAAA;;AAPX;;;;EAcE,mBAAA;EAd8C;;;;;;EAsB9C,YAAA,GAAe,YAAA;AAAA;AAAA,KAGL,wBAAA,kBAA0C,gBAAA,KACpD,OAAA,EAAS,eAAA,CAAgB,QAAA,MACtB,OAAA,CAAQ,eAAA,CAAgB,QAAA;;AALA;AAG7B;;;;;;;;;;;;;;;;;;;;AAEqC;AA2BrC;;iBAAgB,qBAAA,kBACG,gBAAA,GAAmB,gBAAA,CAAA,CAEpC,OAAA,EAAS,sBAAA,EACT,QAAA,GAAU,wBAAA,CAAyB,QAAA,IAClC,eAAA,CAAgB,QAAA"}
|
package/dist/unplugin.mjs
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
import __tsdown_shims_path from 'node:path'
|
|
4
|
+
import __tsdown_shims_url from 'node:url'
|
|
5
|
+
|
|
6
|
+
const __TSDOWN_SHIM_FILENAME__ = /* @__PURE__ */ __tsdown_shims_url.fileURLToPath(import.meta.url)
|
|
7
|
+
const __TSDOWN_SHIM_DIRNAME__ = /* @__PURE__ */ __tsdown_shims_path.dirname(__TSDOWN_SHIM_FILENAME__)
|
|
8
|
+
|
|
1
9
|
import { __exportAll, __reExport } from "./_virtual/_rolldown/runtime.mjs";
|
|
2
10
|
import { replacePath } from "@stryke/path/replace";
|
|
3
11
|
import { formatFolder, handleTypes, initializeTsconfig, installDependencies, isUnpluginBuilderVariant, loadParsedConfig, resolveRoot, resolveTsconfig, writeMetaFile } from "@powerlines/core";
|
|
@@ -6,7 +14,7 @@ import { PowerlinesExecutionContext } from "@powerlines/core/context/execution-c
|
|
|
6
14
|
import { resolvePluginConfig } from "@powerlines/core/lib/context-helpers";
|
|
7
15
|
import { executeEnvironments } from "@powerlines/core/lib/environment";
|
|
8
16
|
import { getString } from "@powerlines/core/lib/utilities/source-file";
|
|
9
|
-
import { VIRTUAL_MODULE_PREFIX_REGEX, addVirtualPrefix, formatConfig, removeVirtualPrefix } from "@powerlines/core/plugin-utils";
|
|
17
|
+
import { VIRTUAL_MODULE_PREFIX_REGEX, addVirtualPrefix, formatConfig, formatExecutionId, removeVirtualPrefix } from "@powerlines/core/plugin-utils";
|
|
10
18
|
import { toArray } from "@stryke/convert/to-array";
|
|
11
19
|
import { getWorkspaceRoot } from "@stryke/fs/get-workspace-root";
|
|
12
20
|
import { createDirectory } from "@stryke/fs/helpers";
|
|
@@ -16,7 +24,6 @@ import { isFunction } from "@stryke/type-checks/is-function";
|
|
|
16
24
|
import { isObject } from "@stryke/type-checks/is-object";
|
|
17
25
|
import { isSetObject } from "@stryke/type-checks/is-set-object";
|
|
18
26
|
import { isSetString } from "@stryke/type-checks/is-set-string";
|
|
19
|
-
import { uuid } from "@stryke/unique-id/uuid";
|
|
20
27
|
|
|
21
28
|
export * from "@powerlines/core/lib/unplugin"
|
|
22
29
|
|
|
@@ -70,7 +77,7 @@ function createUnpluginFactory(options, decorate = (options) => options) {
|
|
|
70
77
|
...params,
|
|
71
78
|
command: "build",
|
|
72
79
|
configFile: config.configFile,
|
|
73
|
-
executionId:
|
|
80
|
+
executionId: formatExecutionId(config.config.name || root, "build", 0),
|
|
74
81
|
configIndex: 0
|
|
75
82
|
};
|
|
76
83
|
context = await PowerlinesExecutionContext.from({
|