@powerlines/unplugin 0.0.61 → 0.0.62
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/package.cjs +1 -1
- package/dist/package.mjs +1 -1
- package/dist/rolldown.cjs +0 -1
- package/dist/rolldown.d.cts.map +1 -1
- package/dist/rolldown.d.mts.map +1 -1
- package/dist/rolldown.mjs +0 -1
- package/dist/rolldown.mjs.map +1 -1
- package/package.json +3 -3
package/dist/package.cjs
CHANGED
package/dist/package.mjs
CHANGED
package/dist/rolldown.cjs
CHANGED
|
@@ -100,7 +100,6 @@ function resolveOptions(context) {
|
|
|
100
100
|
resolve: {
|
|
101
101
|
alias: context.alias,
|
|
102
102
|
mainFields: context.config.resolve.mainFields,
|
|
103
|
-
conditions: context.config.resolve.conditions,
|
|
104
103
|
define: context.config.define,
|
|
105
104
|
extensions: context.config.resolve.extensions
|
|
106
105
|
},
|
package/dist/rolldown.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rolldown.d.cts","names":[],"sources":["../src/rolldown.ts"],"mappings":";;;;;;cA6Ca,eAAA;;;;;;;;;;;;;AAeb;iBAAgB,cAAA,kBAAgC,iBAAA,CAAA,CAC9C,OAAA,EAAS,QAAA,GACR,eAAA;;;;;;;;;;;;;AAAe;
|
|
1
|
+
{"version":3,"file":"rolldown.d.cts","names":[],"sources":["../src/rolldown.ts"],"mappings":";;;;;;cA6Ca,eAAA;;;;;;;;;;;;;AAeb;iBAAgB,cAAA,kBAAgC,iBAAA,CAAA,CAC9C,OAAA,EAAS,QAAA,GACR,eAAA;;;;;;;;;;;;;AAAe;AA4PlB;;;;;;;;;iBAAgB,qBAAA,kBAAuC,gBAAA,CAAA,CACrD,OAAA,GAAS,IAAA,CAAK,sBAAA,cACd,QAAA,GAAU,wBAAA,CAAyB,QAAA,IAA8B,eAAA,CAAA,gBAAA,4BAAA,cAAA;;;;;;;;;;;;;;;AAAA;cAuC7D,MAAA,GAAM,OAAA,GAAgD,wBAAA,iBAAhD,MAAA,QAAA,MAAA"}
|
package/dist/rolldown.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rolldown.d.mts","names":[],"sources":["../src/rolldown.ts"],"mappings":";;;;;;cA6Ca,eAAA;;;;;;;;;;;;;AAeb;iBAAgB,cAAA,kBAAgC,iBAAA,CAAA,CAC9C,OAAA,EAAS,QAAA,GACR,eAAA;;;;;;;;;;;;;AAAe;
|
|
1
|
+
{"version":3,"file":"rolldown.d.mts","names":[],"sources":["../src/rolldown.ts"],"mappings":";;;;;;cA6Ca,eAAA;;;;;;;;;;;;;AAeb;iBAAgB,cAAA,kBAAgC,iBAAA,CAAA,CAC9C,OAAA,EAAS,QAAA,GACR,eAAA;;;;;;;;;;;;;AAAe;AA4PlB;;;;;;;;;iBAAgB,qBAAA,kBAAuC,gBAAA,CAAA,CACrD,OAAA,GAAS,IAAA,CAAK,sBAAA,cACd,QAAA,GAAU,wBAAA,CAAyB,QAAA,IAA8B,eAAA,CAAA,gBAAA,4BAAA,cAAA;;;;;;;;;;;;;;;AAAA;cAuC7D,MAAA,GAAM,OAAA,GAAgD,wBAAA,iBAAhD,MAAA,QAAA,MAAA"}
|
package/dist/rolldown.mjs
CHANGED
|
@@ -94,7 +94,6 @@ function resolveOptions(context) {
|
|
|
94
94
|
resolve: {
|
|
95
95
|
alias: context.alias,
|
|
96
96
|
mainFields: context.config.resolve.mainFields,
|
|
97
|
-
conditions: context.config.resolve.conditions,
|
|
98
97
|
define: context.config.define,
|
|
99
98
|
extensions: context.config.resolve.extensions
|
|
100
99
|
},
|
package/dist/rolldown.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rolldown.mjs","names":["defu","alias","dtsBundlePlugin"],"sources":["../src/rolldown.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 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 { appendPath } from \"@stryke/path/append\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport { defu } from \"defu\";\nimport { globSync } from \"glob\";\nimport { builtinModules } from \"node:module\";\nimport type { InputOptions, Plugin } from \"rolldown\";\nimport { RolldownOptions, RollupLog } from \"rolldown\";\nimport { dts as dtsBundlePlugin } from \"rolldown-plugin-dts\";\nimport { viteAliasPlugin as alias } from \"rolldown/experimental\";\nimport typescriptPlugin from \"rollup-plugin-typescript2\";\nimport { createRolldownPlugin } from \"unplugin\";\nimport {\n createUnpluginFactory,\n UnpluginFactoryDecorator,\n UnpluginFactoryOptions\n} from \"./unplugin\";\n\nexport const DEFAULT_OPTIONS = {\n keepNames: true,\n treeshake: true,\n shimMissingExports: true,\n transform: {\n target: \"esnext\"\n }\n};\n\n/**\n * Resolves the options for [rolldown](https://rolldown.rs).\n *\n * @param context - The build context.\n * @returns The resolved options.\n */\nexport function resolveOptions<TContext extends UnresolvedContext>(\n context: TContext\n): RolldownOptions {\n return defu<RolldownOptions, any>(\n {\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 context.config.output.dts &&\n toArray(context.config.output.format).includes(\"esm\")\n ? dtsBundlePlugin({\n tsconfig: appendPath(\n context.tsconfig.tsconfigFilePath,\n context.config.cwd\n )\n })\n : undefined,\n context.config.output.dts &&\n toArray(context.config.output.format).includes(\"cjs\")\n ? dtsBundlePlugin({\n tsconfig: appendPath(\n context.tsconfig.tsconfigFilePath,\n context.config.cwd\n ),\n emitDtsOnly: true,\n cjsDefault: true\n })\n : undefined,\n {\n name: `powerlines:node-protocol`,\n resolveId: {\n order: \"pre\",\n filter: {\n id:\n context.config.output.nodeProtocol === \"strip\"\n ? new RegExp(\n `^node:(${builtinModules\n .filter(mod => !mod.startsWith(\"node:\"))\n .join(\"|\")})$`\n )\n : new RegExp(\n `^(${builtinModules\n .filter(mod => !mod.startsWith(\"node:\"))\n .join(\"|\")})$`\n )\n },\n handler:\n context.config.output.nodeProtocol === \"strip\"\n ? async (id: string, ...args: any[]) => {\n const resolved = await context.resolve(\n id.slice(5),\n ...args\n );\n if (resolved && !resolved.external) {\n return resolved;\n }\n\n return {\n id: id.slice(5), // \"node:\".length\n external: true,\n moduleSideEffects: false\n };\n }\n : id => {\n return {\n id: `node:${id}`,\n external: true,\n moduleSideEffects: false\n };\n }\n }\n } as Plugin\n ].filter(Boolean) as Plugin[],\n resolve: {\n alias: context.alias,\n mainFields: context.config.resolve.mainFields,\n conditions: context.config.resolve.conditions,\n define: context.config.define,\n extensions: context.config.resolve.extensions\n },\n transform: {\n target: context.tsconfig.tsconfigJson?.compilerOptions?.target,\n define: context.config.define,\n inject: context.config.inject\n },\n platform: context.config.platform,\n tsconfig: appendPath(\n context.tsconfig.tsconfigFilePath,\n context.config.cwd\n ),\n cache: !context.config.skipCache\n ? joinPaths(context.cachePath, \"rolldown\")\n : false,\n logLevel:\n context.config.logLevel.general === \"trace\"\n ? \"debug\"\n : context.config.logLevel.general === \"debug\"\n ? \"warn\"\n : \"error\",\n onLog(level: \"info\" | \"debug\" | \"warn\", log: RollupLog) {\n if (\n context.config.logLevel.general !== \"trace\" &&\n level === \"warn\" &&\n log.code === \"PLUGIN_TIMINGS\"\n ) {\n return;\n }\n\n if (log.message?.trim()) {\n if (level === \"info\") {\n context.logger.debug(log.message?.trim() ?? \"\");\n } else {\n context.logger.log(level, log.message?.trim() ?? \"\");\n }\n }\n },\n output: [\n toArray(context.config.output.format).includes(\"esm\")\n ? {\n dir: context.config.output.path,\n format: \"es\",\n sourcemap: context.config.output.sourceMap,\n codeSplitting: true,\n exports: \"named\",\n minify: context.config.output.minify\n ? {\n compress: {\n dropDebugger:\n context.config.mode === \"production\" ? true : undefined,\n unused:\n context.config.mode === \"production\" ? true : undefined,\n treeshake: true\n },\n mangle: true\n }\n : context.config.mode === \"production\"\n ? \"dce-only\"\n : undefined\n }\n : undefined,\n toArray(context.config.output.format).includes(\"cjs\")\n ? {\n dir: context.config.output.path,\n format: \"cjs\",\n sourcemap: context.config.output.sourceMap,\n codeSplitting: true,\n exports: \"auto\",\n minify: context.config.output.minify\n ? {\n compress: {\n dropDebugger:\n context.config.mode === \"production\" ? true : undefined,\n unused:\n context.config.mode === \"production\" ? true : undefined,\n treeshake: true\n },\n mangle: true\n }\n : context.config.mode === \"production\"\n ? \"dce-only\"\n : undefined\n }\n : undefined\n ].filter(Boolean) as RolldownOptions[\"output\"]\n },\n DEFAULT_OPTIONS\n );\n}\n\n/**\n * Creates a Rolldown plugin factory that generates a plugin instance.\n *\n * @see https://rolldown.rs/guide/en/#plugins-overview\n *\n * @example\n * ```ts\n * // rolldown.config.ts\n * import { createRolldownFactory } from \"@powerlines/unplugin/rolldown\";\n *\n * const powerlinesPlugin = createRolldownFactory({ 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 Rolldown plugin instance when called. The generated plugin will invoke the Powerlines API hooks during the build process, allowing you to integrate Powerlines into your Rolldown build.\n */\nexport function createRolldownFactory<TContext extends ExecutionContext>(\n options: Omit<UnpluginFactoryOptions, \"variant\"> = {},\n decorate: UnpluginFactoryDecorator<TContext> = options => options\n) {\n return createUnpluginFactory({ ...options, variant: \"rolldown\" }, unplugin =>\n decorate({\n ...(unplugin as UnpluginOptions<TContext>),\n rolldown: {\n async options(options: InputOptions) {\n const environment = await unplugin.context.getEnvironment();\n\n return defu(\n resolveOptions(environment),\n options,\n (await unplugin.context.callHook(\n \"rolldown:options\",\n { environment },\n options\n )) ?? {}\n );\n }\n }\n })\n );\n}\n\n/**\n * A Rolldown plugin that will invoke the Powerlines API hooks during the build process.\n *\n * @see https://rolldown.rs/guide/en/#plugins-overview\n *\n * @example\n * ```ts\n * // rolldown.config.ts\n * import powerlines from \"@powerlines/unplugin/rolldown\";\n *\n * export default defineConfig({\n * plugins: [powerlines({ name: \"example-app\", ... })],\n * })\n * ```\n */\nconst plugin = createRolldownPlugin(createRolldownFactory());\n\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;;;AA6CA,MAAa,kBAAkB;CAC7B,WAAW;CACX,WAAW;CACX,oBAAoB;CACpB,WAAW,EACT,QAAQ,SACV;AACF;;;;;;;AAQA,SAAgB,eACd,SACiB;CACjB,OAAOA,OACL;EACE,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,IAAI,QAAQ,SAAS,SAAS,MAAM,GAClC,OAAO,QAAQ,OAAO,gBAAgB;GAGxC,OAAO,CAAC,QAAQ,OAAO,QAAQ;EACjC;EACA,SAAS;GACP,iBAAiB;IACf,OAAO;IACP,UAAU,QAAQ,SAAS;GAC7B,CAAC;GACD,QAAQ,OAAO,UACb,OAAO,KAAK,QAAQ,OAAO,MAAM,EAAE,SAAS,KAC5C,QAAQ;IACN,WAAW,QAAQ,OAAO,SAAS;IACnC,mBAAmB;IACnB,GAAI,QAAQ,OAAO,UAAU,CAAC;GAChC,CAAC;GACH,QAAQ,OAAO,UACb,OAAO,KAAK,QAAQ,OAAO,MAAM,EAAE,SAAS,KAC5C,OAAO;IACL,WAAW,QAAQ,OAAO,SAAS;IACnC,GAAG,QAAQ,OAAO;GACpB,CAAC;GACHC,gBAAM,EACJ,SAAS,OAAO,QAAQ,QAAQ,KAAK,EAAE,QACpC,KAAK,CAAC,IAAI,UAAU;IACnB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,IAChD;GACE,KAAK,QAAQ,OAAO,OAAO;GAC3B,QAAQ;GACR,WAAW,QAAQ,OAAO,OAAO;GACjC,eAAe;GACf,SAAS;GACT,QAAQ,QAAQ,OAAO,OAAO,SAC1B;IACE,UAAU;KACR,cACE,QAAQ,OAAO,SAAS,eAAe,OAAO;KAChD,QACE,QAAQ,OAAO,SAAS,eAAe,OAAO;KAChD,WAAW;IACb;IACA,QAAQ;GACV,IACA,QAAQ,OAAO,SAAS,eACtB,aACA;EACR,IACA,MACN,EAAE,OAAO,OAAO;CAClB,GACA,eACF;AACF;;;;;;;;;;;;;;;;;;;;;;;AAwBA,SAAgB,sBACd,UAAmD,CAAC,GACpD,YAA+C,YAAW,SAC1D;CACA,OAAO,sBAAsB;EAAE,GAAG;EAAS,SAAS;CAAW,IAAG,aAChE,SAAS;EACP,GAAI;EACJ,UAAU,EACR,MAAM,QAAQ,SAAuB;GACnC,MAAM,cAAc,MAAM,SAAS,QAAQ,eAAe;GAE1D,OAAOF,OACL,eAAe,WAAW,GAC1B,SACC,MAAM,SAAS,QAAQ,SACtB,oBACA,EAAE,YAAY,GACd,OACF,KAAM,CAAC,CACT;EACF,EACF;CACF,CAAC,CACH;AACF;;;;;;;;;;;;;;;;AAiBA,MAAM,SAAS,qBAAqB,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"rolldown.mjs","names":["defu","alias","dtsBundlePlugin"],"sources":["../src/rolldown.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 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 { appendPath } from \"@stryke/path/append\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport { defu } from \"defu\";\nimport { globSync } from \"glob\";\nimport { builtinModules } from \"node:module\";\nimport type { InputOptions, Plugin } from \"rolldown\";\nimport { RolldownOptions, RollupLog } from \"rolldown\";\nimport { dts as dtsBundlePlugin } from \"rolldown-plugin-dts\";\nimport { viteAliasPlugin as alias } from \"rolldown/experimental\";\nimport typescriptPlugin from \"rollup-plugin-typescript2\";\nimport { createRolldownPlugin } from \"unplugin\";\nimport {\n createUnpluginFactory,\n UnpluginFactoryDecorator,\n UnpluginFactoryOptions\n} from \"./unplugin\";\n\nexport const DEFAULT_OPTIONS = {\n keepNames: true,\n treeshake: true,\n shimMissingExports: true,\n transform: {\n target: \"esnext\"\n }\n};\n\n/**\n * Resolves the options for [rolldown](https://rolldown.rs).\n *\n * @param context - The build context.\n * @returns The resolved options.\n */\nexport function resolveOptions<TContext extends UnresolvedContext>(\n context: TContext\n): RolldownOptions {\n return defu<RolldownOptions, any>(\n {\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 context.config.output.dts &&\n toArray(context.config.output.format).includes(\"esm\")\n ? dtsBundlePlugin({\n tsconfig: appendPath(\n context.tsconfig.tsconfigFilePath,\n context.config.cwd\n )\n })\n : undefined,\n context.config.output.dts &&\n toArray(context.config.output.format).includes(\"cjs\")\n ? dtsBundlePlugin({\n tsconfig: appendPath(\n context.tsconfig.tsconfigFilePath,\n context.config.cwd\n ),\n emitDtsOnly: true,\n cjsDefault: true\n })\n : undefined,\n {\n name: `powerlines:node-protocol`,\n resolveId: {\n order: \"pre\",\n filter: {\n id:\n context.config.output.nodeProtocol === \"strip\"\n ? new RegExp(\n `^node:(${builtinModules\n .filter(mod => !mod.startsWith(\"node:\"))\n .join(\"|\")})$`\n )\n : new RegExp(\n `^(${builtinModules\n .filter(mod => !mod.startsWith(\"node:\"))\n .join(\"|\")})$`\n )\n },\n handler:\n context.config.output.nodeProtocol === \"strip\"\n ? async (id: string, ...args: any[]) => {\n const resolved = await context.resolve(\n id.slice(5),\n ...args\n );\n if (resolved && !resolved.external) {\n return resolved;\n }\n\n return {\n id: id.slice(5), // \"node:\".length\n external: true,\n moduleSideEffects: false\n };\n }\n : id => {\n return {\n id: `node:${id}`,\n external: true,\n moduleSideEffects: false\n };\n }\n }\n } as Plugin\n ].filter(Boolean) as Plugin[],\n resolve: {\n alias: context.alias,\n mainFields: context.config.resolve.mainFields,\n define: context.config.define,\n extensions: context.config.resolve.extensions\n },\n transform: {\n target: context.tsconfig.tsconfigJson?.compilerOptions?.target,\n define: context.config.define,\n inject: context.config.inject\n },\n platform: context.config.platform,\n tsconfig: appendPath(\n context.tsconfig.tsconfigFilePath,\n context.config.cwd\n ),\n cache: !context.config.skipCache\n ? joinPaths(context.cachePath, \"rolldown\")\n : false,\n logLevel:\n context.config.logLevel.general === \"trace\"\n ? \"debug\"\n : context.config.logLevel.general === \"debug\"\n ? \"warn\"\n : \"error\",\n onLog(level: \"info\" | \"debug\" | \"warn\", log: RollupLog) {\n if (\n context.config.logLevel.general !== \"trace\" &&\n level === \"warn\" &&\n log.code === \"PLUGIN_TIMINGS\"\n ) {\n return;\n }\n\n if (log.message?.trim()) {\n if (level === \"info\") {\n context.logger.debug(log.message?.trim() ?? \"\");\n } else {\n context.logger.log(level, log.message?.trim() ?? \"\");\n }\n }\n },\n output: [\n toArray(context.config.output.format).includes(\"esm\")\n ? {\n dir: context.config.output.path,\n format: \"es\",\n sourcemap: context.config.output.sourceMap,\n codeSplitting: true,\n exports: \"named\",\n minify: context.config.output.minify\n ? {\n compress: {\n dropDebugger:\n context.config.mode === \"production\" ? true : undefined,\n unused:\n context.config.mode === \"production\" ? true : undefined,\n treeshake: true\n },\n mangle: true\n }\n : context.config.mode === \"production\"\n ? \"dce-only\"\n : undefined\n }\n : undefined,\n toArray(context.config.output.format).includes(\"cjs\")\n ? {\n dir: context.config.output.path,\n format: \"cjs\",\n sourcemap: context.config.output.sourceMap,\n codeSplitting: true,\n exports: \"auto\",\n minify: context.config.output.minify\n ? {\n compress: {\n dropDebugger:\n context.config.mode === \"production\" ? true : undefined,\n unused:\n context.config.mode === \"production\" ? true : undefined,\n treeshake: true\n },\n mangle: true\n }\n : context.config.mode === \"production\"\n ? \"dce-only\"\n : undefined\n }\n : undefined\n ].filter(Boolean) as RolldownOptions[\"output\"]\n },\n DEFAULT_OPTIONS\n );\n}\n\n/**\n * Creates a Rolldown plugin factory that generates a plugin instance.\n *\n * @see https://rolldown.rs/guide/en/#plugins-overview\n *\n * @example\n * ```ts\n * // rolldown.config.ts\n * import { createRolldownFactory } from \"@powerlines/unplugin/rolldown\";\n *\n * const powerlinesPlugin = createRolldownFactory({ 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 Rolldown plugin instance when called. The generated plugin will invoke the Powerlines API hooks during the build process, allowing you to integrate Powerlines into your Rolldown build.\n */\nexport function createRolldownFactory<TContext extends ExecutionContext>(\n options: Omit<UnpluginFactoryOptions, \"variant\"> = {},\n decorate: UnpluginFactoryDecorator<TContext> = options => options\n) {\n return createUnpluginFactory({ ...options, variant: \"rolldown\" }, unplugin =>\n decorate({\n ...(unplugin as UnpluginOptions<TContext>),\n rolldown: {\n async options(options: InputOptions) {\n const environment = await unplugin.context.getEnvironment();\n\n return defu(\n resolveOptions(environment),\n options,\n (await unplugin.context.callHook(\n \"rolldown:options\",\n { environment },\n options\n )) ?? {}\n );\n }\n }\n })\n );\n}\n\n/**\n * A Rolldown plugin that will invoke the Powerlines API hooks during the build process.\n *\n * @see https://rolldown.rs/guide/en/#plugins-overview\n *\n * @example\n * ```ts\n * // rolldown.config.ts\n * import powerlines from \"@powerlines/unplugin/rolldown\";\n *\n * export default defineConfig({\n * plugins: [powerlines({ name: \"example-app\", ... })],\n * })\n * ```\n */\nconst plugin = createRolldownPlugin(createRolldownFactory());\n\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;;;AA6CA,MAAa,kBAAkB;CAC7B,WAAW;CACX,WAAW;CACX,oBAAoB;CACpB,WAAW,EACT,QAAQ,SACV;AACF;;;;;;;AAQA,SAAgB,eACd,SACiB;CACjB,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N,EAAE,OAAO,OAAO;CAClB,GACA,eACF;AACF;;;;;;;;;;;;;;;;;;;;;;;AAwBA,SAAgB,sBACd,UAAmD,CAAC,GACpD,YAA+C,YAAW,SAC1D;CACA,OAAO,sBAAsB;EAAE,GAAG;EAAS,SAAS;CAAW,IAAG,aAChE,SAAS;EACP,GAAI;EACJ,UAAU,EACR,MAAM,QAAQ,SAAuB;GACnC,MAAM,cAAc,MAAM,SAAS,QAAQ,eAAe;GAE1D,OAAOF,OACL,eAAe,WAAW,GAC1B,SACC,MAAM,SAAS,QAAQ,SACtB,oBACA,EAAE,YAAY,GACd,OACF,KAAM,CAAC,CACT;EACF,EACF;CACF,CAAC,CACH;AACF;;;;;;;;;;;;;;;;AAiBA,MAAM,SAAS,qBAAqB,sBAAsB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerlines/unplugin",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.62",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A package containing a Powerlines plugin to assist in developing other Powerlines plugins.",
|
|
6
6
|
"keywords": [
|
|
@@ -105,7 +105,7 @@
|
|
|
105
105
|
"typings": "dist/index.d.mts",
|
|
106
106
|
"files": ["dist"],
|
|
107
107
|
"dependencies": {
|
|
108
|
-
"@powerlines/core": "^0.48.
|
|
108
|
+
"@powerlines/core": "^0.48.14",
|
|
109
109
|
"@rollup/plugin-alias": "^6.0.0",
|
|
110
110
|
"@rollup/plugin-inject": "^5.0.5",
|
|
111
111
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
@@ -167,5 +167,5 @@
|
|
|
167
167
|
"webpack": { "optional": true }
|
|
168
168
|
},
|
|
169
169
|
"publishConfig": { "access": "public" },
|
|
170
|
-
"gitHead": "
|
|
170
|
+
"gitHead": "bb2fced8516bd420e927eb1b78e1ccfcf6d9bf02"
|
|
171
171
|
}
|