@powerlines/plugin-nitro 0.1.348 → 0.1.350
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 +29 -1
- package/dist/index.cjs +80 -1
- package/dist/index.mjs +76 -1
- package/dist/index.mjs.map +1 -1
- package/dist/types/index.mjs +1 -1
- package/dist/types/plugin.mjs +1 -1
- package/package.json +4 -4
|
@@ -1 +1,29 @@
|
|
|
1
|
-
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
+
__defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
+
value: mod,
|
|
24
|
+
enumerable: true
|
|
25
|
+
}) : target, mod));
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
|
|
29
|
+
exports.__toESM = __toESM;
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1,80 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value
|
|
1
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
2
|
+
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
let _stryke_path_append = require("@stryke/path/append");
|
|
4
|
+
let defu = require("defu");
|
|
5
|
+
defu = require_runtime.__toESM(defu, 1);
|
|
6
|
+
let nitro_builder = require("nitro/builder");
|
|
7
|
+
let powerlines_plugin_utils = require("powerlines/plugin-utils");
|
|
8
|
+
|
|
9
|
+
//#region src/index.ts
|
|
10
|
+
/**
|
|
11
|
+
* A Powerlines plugin to integrate with Nitro.
|
|
12
|
+
*/
|
|
13
|
+
const plugin = (options = {}) => {
|
|
14
|
+
return [
|
|
15
|
+
{
|
|
16
|
+
name: "nitro:config",
|
|
17
|
+
async config() {
|
|
18
|
+
this.debug("Providing default configuration for the Powerlines `nitro` plugin.");
|
|
19
|
+
let configFile = options.configFile;
|
|
20
|
+
if (!configFile) configFile = (0, powerlines_plugin_utils.getConfigPath)(this, "nitro");
|
|
21
|
+
return { nitro: {
|
|
22
|
+
configFile: configFile ? (0, _stryke_path_append.appendPath)(configFile, this.config.cwd) : void 0,
|
|
23
|
+
...options
|
|
24
|
+
} };
|
|
25
|
+
},
|
|
26
|
+
configResolved() {
|
|
27
|
+
this.config.nitro.compatibilityDate = this.config.compatibilityDate;
|
|
28
|
+
this.config.nitro.workspaceDir = this.config.cwd;
|
|
29
|
+
this.config.nitro.alias = this.config.resolve.alias;
|
|
30
|
+
switch (this.config.logLevel) {
|
|
31
|
+
case "error":
|
|
32
|
+
this.config.nitro.logLevel = 1;
|
|
33
|
+
break;
|
|
34
|
+
case "warn":
|
|
35
|
+
this.config.nitro.logLevel = 2;
|
|
36
|
+
break;
|
|
37
|
+
case "info":
|
|
38
|
+
this.config.nitro.logLevel = 3;
|
|
39
|
+
break;
|
|
40
|
+
case "debug":
|
|
41
|
+
this.config.nitro.logLevel = 4;
|
|
42
|
+
break;
|
|
43
|
+
case "trace":
|
|
44
|
+
this.config.nitro.logLevel = 5;
|
|
45
|
+
break;
|
|
46
|
+
case null:
|
|
47
|
+
this.config.nitro.logLevel = 0;
|
|
48
|
+
break;
|
|
49
|
+
default:
|
|
50
|
+
this.config.nitro.logLevel = 2;
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: "nitro:init",
|
|
57
|
+
configResolved: {
|
|
58
|
+
order: "post",
|
|
59
|
+
async handler() {
|
|
60
|
+
this.nitro ??= {};
|
|
61
|
+
this.nitro.nitro = await (0, nitro_builder.createNitro)(this.config.nitro);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
name: "nitro:vite",
|
|
67
|
+
vite: { config(config, configEnv) {
|
|
68
|
+
config.nitro ??= {};
|
|
69
|
+
config.nitro.dev = configEnv.command === "serve";
|
|
70
|
+
config.nitro.builder = "vite";
|
|
71
|
+
config.nitro.rootDir = config.root;
|
|
72
|
+
config.nitro = (0, defu.default)(config.nitro, config);
|
|
73
|
+
} }
|
|
74
|
+
}
|
|
75
|
+
];
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
//#endregion
|
|
79
|
+
exports.default = plugin;
|
|
80
|
+
exports.plugin = plugin;
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,77 @@
|
|
|
1
|
-
import{appendPath
|
|
1
|
+
import { appendPath } from "@stryke/path/append";
|
|
2
|
+
import defu from "defu";
|
|
3
|
+
import { createNitro } from "nitro/builder";
|
|
4
|
+
import { getConfigPath } from "powerlines/plugin-utils";
|
|
5
|
+
|
|
6
|
+
//#region src/index.ts
|
|
7
|
+
/**
|
|
8
|
+
* A Powerlines plugin to integrate with Nitro.
|
|
9
|
+
*/
|
|
10
|
+
const plugin = (options = {}) => {
|
|
11
|
+
return [
|
|
12
|
+
{
|
|
13
|
+
name: "nitro:config",
|
|
14
|
+
async config() {
|
|
15
|
+
this.debug("Providing default configuration for the Powerlines `nitro` plugin.");
|
|
16
|
+
let configFile = options.configFile;
|
|
17
|
+
if (!configFile) configFile = getConfigPath(this, "nitro");
|
|
18
|
+
return { nitro: {
|
|
19
|
+
configFile: configFile ? appendPath(configFile, this.config.cwd) : void 0,
|
|
20
|
+
...options
|
|
21
|
+
} };
|
|
22
|
+
},
|
|
23
|
+
configResolved() {
|
|
24
|
+
this.config.nitro.compatibilityDate = this.config.compatibilityDate;
|
|
25
|
+
this.config.nitro.workspaceDir = this.config.cwd;
|
|
26
|
+
this.config.nitro.alias = this.config.resolve.alias;
|
|
27
|
+
switch (this.config.logLevel) {
|
|
28
|
+
case "error":
|
|
29
|
+
this.config.nitro.logLevel = 1;
|
|
30
|
+
break;
|
|
31
|
+
case "warn":
|
|
32
|
+
this.config.nitro.logLevel = 2;
|
|
33
|
+
break;
|
|
34
|
+
case "info":
|
|
35
|
+
this.config.nitro.logLevel = 3;
|
|
36
|
+
break;
|
|
37
|
+
case "debug":
|
|
38
|
+
this.config.nitro.logLevel = 4;
|
|
39
|
+
break;
|
|
40
|
+
case "trace":
|
|
41
|
+
this.config.nitro.logLevel = 5;
|
|
42
|
+
break;
|
|
43
|
+
case null:
|
|
44
|
+
this.config.nitro.logLevel = 0;
|
|
45
|
+
break;
|
|
46
|
+
default:
|
|
47
|
+
this.config.nitro.logLevel = 2;
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
name: "nitro:init",
|
|
54
|
+
configResolved: {
|
|
55
|
+
order: "post",
|
|
56
|
+
async handler() {
|
|
57
|
+
this.nitro ??= {};
|
|
58
|
+
this.nitro.nitro = await createNitro(this.config.nitro);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
name: "nitro:vite",
|
|
64
|
+
vite: { config(config, configEnv) {
|
|
65
|
+
config.nitro ??= {};
|
|
66
|
+
config.nitro.dev = configEnv.command === "serve";
|
|
67
|
+
config.nitro.builder = "vite";
|
|
68
|
+
config.nitro.rootDir = config.root;
|
|
69
|
+
config.nitro = defu(config.nitro, config);
|
|
70
|
+
} }
|
|
71
|
+
}
|
|
72
|
+
];
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
//#endregion
|
|
76
|
+
export { plugin as default, plugin };
|
|
2
77
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.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 { appendPath } from \"@stryke/path/append\";\nimport defu from \"defu\";\nimport { createNitro } from \"nitro/builder\";\nimport { NitroConfig } from \"nitro/types\";\nimport { Plugin } from \"powerlines\";\nimport { getConfigPath } from \"powerlines/plugin-utils\";\nimport {\n NitroContext,\n NitroPluginContext,\n NitroPluginOptions,\n NitroPluginUserConfig\n} from \"./types/plugin\";\n\nexport * from \"./types\";\n\ndeclare module \"powerlines\" {\n interface Config {\n nitro?: NitroPluginOptions;\n }\n}\n\n/**\n * A Powerlines plugin to integrate with Nitro.\n */\nexport const plugin = <\n TContext extends NitroPluginContext = NitroPluginContext\n>(\n options: NitroPluginOptions = {}\n) => {\n return [\n // nitroInit(options),\n // nitroEnv(options),\n // nitroMain(options),\n // nitroPrepare(options),\n // nitroService(options),\n // nitroPreviewPlugin(options),\n {\n name: \"nitro:config\",\n async config() {\n this.debug(\n \"Providing default configuration for the Powerlines `nitro` plugin.\"\n );\n\n let configFile = options.configFile;\n if (!configFile) {\n configFile = getConfigPath(this, \"nitro\");\n }\n\n return {\n nitro: {\n configFile: configFile\n ? appendPath(configFile, this.config.cwd)\n : undefined,\n ...options\n }\n };\n },\n configResolved() {\n this.config.nitro.compatibilityDate = this.config.compatibilityDate;\n this.config.nitro.workspaceDir = this.config.cwd;\n\n this.config.nitro.alias = this.config.resolve\n .alias as NitroConfig[\"alias\"];\n\n switch (this.config.logLevel) {\n case \"error\":\n this.config.nitro.logLevel = 1;\n break;\n case \"warn\":\n this.config.nitro.logLevel = 2;\n break;\n case \"info\":\n this.config.nitro.logLevel = 3;\n break;\n case \"debug\":\n this.config.nitro.logLevel = 4;\n break;\n case \"trace\":\n this.config.nitro.logLevel = 5;\n break;\n case null:\n this.config.nitro.logLevel = 0;\n break;\n default:\n this.config.nitro.logLevel = 2;\n break;\n }\n }\n },\n {\n name: \"nitro:init\",\n configResolved: {\n order: \"post\",\n async handler() {\n this.nitro ??= {} as NitroContext;\n this.nitro.nitro = await createNitro(this.config.nitro);\n }\n }\n },\n {\n name: \"nitro:vite\",\n vite: {\n config(config: NitroPluginUserConfig, configEnv: { command: string }) {\n config.nitro ??= {};\n config.nitro.dev = configEnv.command === \"serve\";\n config.nitro.builder = \"vite\";\n config.nitro.rootDir = config.root;\n config.nitro = defu(config.nitro, config) as NitroConfig;\n }\n }\n }\n ] as Plugin<TContext>[];\n};\n\nexport default plugin;\n\n// function nitroInit(\n// options: NitroPluginOptions = {}\n// ): Plugin<NitroPluginContext> {\n// return {\n// name: \"nitro:init\",\n// sharedDuringBuild: true,\n\n// async config(config, configEnv) {\n// this.isRolldown = !!(this.meta as Record<string, string>).rolldownVersion;\n// if (!this.isInitialized) {\n// debug(\"[init] Initializing nitro\");\n// this.isInitialized = true;\n// await setupNitroContext(this, configEnv, config);\n// }\n// },\n\n// applyToEnvironment(env) {\n// if (env.name === \"nitro\" && ctx.nitro?.options.dev) {\n// debug(\"[init] Adding rollup plugins for dev\");\n// return [...((ctx.rollupConfig?.config.plugins as VitePlugin[]) || [])];\n// }\n// },\n// vite: {\n// apply: (_, configEnv) => !configEnv.isPreview\n// }\n// };\n// }\n\n// function nitroEnv(ctx: NitroPluginContext): VitePlugin {\n// return {\n// name: \"nitro:env\",\n// sharedDuringBuild: true,\n// apply: (_config, configEnv) => !configEnv.isPreview,\n\n// async config(userConfig, _configEnv) {\n// debug(\"[env] Extending config (environments)\");\n// const environments: Record<string, EnvironmentOptions> = {\n// ...createServiceEnvironments(ctx),\n// nitro: createNitroEnvironment(ctx)\n// };\n// environments.client = {\n// consumer: userConfig.environments?.client?.consumer ?? \"client\",\n// build: {\n// rollupOptions: {\n// input:\n// userConfig.environments?.client?.build?.rollupOptions?.input ??\n// useNitro(ctx).options.renderer?.template\n// }\n// }\n// };\n// debug(\"[env] Environments:\", Object.keys(environments).join(\", \"));\n// return {\n// environments\n// };\n// },\n\n// configEnvironment(name, config) {\n// if (config.consumer === \"client\") {\n// debug(\n// \"[env] Configuring client environment\",\n// name === \"client\" ? \"\" : ` (${name})`\n// );\n// config.build!.emptyOutDir = false;\n// config.build!.outDir = useNitro(ctx).options.output.publicDir;\n// }\n// }\n// };\n// }\n\n// function nitroMain(ctx: NitroPluginContext): VitePlugin {\n// return {\n// name: \"nitro:main\",\n// sharedDuringBuild: true,\n// apply: (_config, configEnv) => !configEnv.isPreview,\n\n// async config(userConfig, _configEnv) {\n// debug(\"[main] Extending config (appType, resolve, server)\");\n// if (!ctx.rollupConfig) {\n// throw new Error(\"Nitro rollup config is not initialized yet.\");\n// }\n// return {\n// appType: userConfig.appType || \"custom\",\n// resolve: {\n// // TODO: environment specific aliases not working\n// // https://github.com/vitejs/vite/pull/17583 (seems not effective)\n// alias: ctx.rollupConfig.base.aliases\n// },\n// builder: {\n// sharedConfigBuild: true\n// },\n// server: {\n// port:\n// Number.parseInt(process.env.PORT || \"\") ||\n// userConfig.server?.port ||\n// useNitro(ctx).options.devServer?.port ||\n// 3000,\n// // #3673, disable Vite's `cors` by default as Nitro handles all requests\n// cors: false\n// }\n// };\n// },\n\n// buildApp: {\n// order: \"post\",\n// handler(builder) {\n// debug(\"[main] Building environments\");\n// return buildEnvironments(ctx, builder);\n// }\n// },\n\n// generateBundle: {\n// handler(_options, bundle) {\n// const environment = this.environment;\n// debug(\n// \"[main] Generating manifest and entry points for environment:\",\n// environment.name\n// );\n// const serviceNames = Object.keys(ctx.services);\n// const isRegisteredService = serviceNames.includes(environment.name);\n\n// // Find entry point of this service\n// let entryFile: string | undefined;\n// for (const [_name, file] of Object.entries(bundle)) {\n// if (file.type === \"chunk\" && isRegisteredService && file.isEntry) {\n// if (entryFile === undefined) {\n// entryFile = file.fileName;\n// } else {\n// this.warn(\n// `Multiple entry points found for service \"${environment.name}\"`\n// );\n// }\n// }\n// }\n// if (isRegisteredService) {\n// if (entryFile === undefined) {\n// this.error(\n// `No entry point found for service \"${this.environment.name}\".`\n// );\n// }\n// ctx._entryPoints![this.environment.name] = entryFile!;\n// }\n// }\n// },\n\n// configureServer: server => {\n// debug(\"[main] Configuring dev server\");\n// return configureViteDevServer(ctx, server);\n// },\n\n// // Automatically reload the client when a server module is updated\n// // see: https://github.com/vitejs/vite/issues/19114\n// async hotUpdate({ server, modules, timestamp }) {\n// const env = this.environment;\n// if (\n// ctx.pluginConfig.experimental?.vite.serverReload === false ||\n// env.config.consumer === \"client\"\n// ) {\n// return;\n// }\n// const clientEnvs = Object.values(server.environments).filter(\n// env => env.config.consumer === \"client\"\n// );\n// let hasServerOnlyModule = false;\n// const invalidated = new Set<EnvironmentModuleNode>();\n// for (const mod of modules) {\n// if (\n// mod.id &&\n// !clientEnvs.some(env => env.moduleGraph.getModuleById(mod.id))\n// ) {\n// hasServerOnlyModule = true;\n// env.moduleGraph.invalidateModule(mod, invalidated, timestamp, false);\n// }\n// }\n// if (hasServerOnlyModule) {\n// env.hot.send({ type: \"full-reload\" });\n// server.ws.send({ type: \"full-reload\" });\n// return [];\n// }\n// }\n// };\n// }\n\n// function nitroPrepare(ctx: NitroPluginContext): VitePlugin {\n// return {\n// name: \"nitro:prepare\",\n// sharedDuringBuild: true,\n// applyToEnvironment: env => env.name === \"nitro\",\n\n// buildApp: {\n// // Clean the output directory before any environment is built\n// order: \"pre\",\n// async handler() {\n// debug(\"[prepare] Preparing output directory\");\n// const nitro = ctx.nitro;\n// await prepare(nitro);\n// }\n// }\n// };\n// }\n\n// function nitroService(ctx: NitroPluginContext): VitePlugin {\n// return {\n// name: \"nitro:service\",\n// enforce: \"pre\",\n// sharedDuringBuild: true,\n// applyToEnvironment: env => env.name === \"nitro\",\n\n// resolveId: {\n// filter: { id: /^#nitro-vite-setup$/ },\n// async handler(id) {\n// // Virtual modules\n// if (id === \"#nitro-vite-setup\") {\n// return { id, moduleSideEffects: true };\n// }\n// }\n// },\n\n// load: {\n// filter: { id: /^#nitro-vite-setup$/ },\n// async handler(id) {\n// // Virtual modules\n// if (id === \"#nitro-vite-setup\") {\n// return prodSetup(ctx);\n// }\n// }\n// }\n// };\n// }\n"],"mappings":"yKA0CA,MAAa,GAGX,EAA8B,EAAE,GAEzB,CAOL,CACE,KAAM,eACN,MAAM,QAAS,CACb,KAAK,MACH,qEACD,CAED,IAAI,EAAa,EAAQ,WAKzB,MAJA,CACE,IAAa,EAAc,KAAM,QAAQ,CAGpC,CACL,MAAO,CACL,WAAY,EACR,EAAW,EAAY,KAAK,OAAO,IAAI,CACvC,IAAA,GACJ,GAAG,EACJ,CACF,EAEH,gBAAiB,CAOf,OANA,KAAK,OAAO,MAAM,kBAAoB,KAAK,OAAO,kBAClD,KAAK,OAAO,MAAM,aAAe,KAAK,OAAO,IAE7C,KAAK,OAAO,MAAM,MAAQ,KAAK,OAAO,QACnC,MAEK,KAAK,OAAO,SAApB,CACE,IAAK,QACH,KAAK,OAAO,MAAM,SAAW,EAC7B,MACF,IAAK,OACH,KAAK,OAAO,MAAM,SAAW,EAC7B,MACF,IAAK,OACH,KAAK,OAAO,MAAM,SAAW,EAC7B,MACF,IAAK,QACH,KAAK,OAAO,MAAM,SAAW,EAC7B,MACF,IAAK,QACH,KAAK,OAAO,MAAM,SAAW,EAC7B,MACF,KAAK,KACH,KAAK,OAAO,MAAM,SAAW,EAC7B,MACF,QACE,KAAK,OAAO,MAAM,SAAW,EAC7B,QAGP,CACD,CACE,KAAM,aACN,eAAgB,CACd,MAAO,OACP,MAAM,SAAU,CACd,KAAK,QAAU,EAAE,CACjB,KAAK,MAAM,MAAQ,MAAM,EAAY,KAAK,OAAO,MAAM,EAE1D,CACF,CACD,CACE,KAAM,aACN,KAAM,CACJ,OAAO,EAA+B,EAAgC,CACpE,EAAO,QAAU,EAAE,CACnB,EAAO,MAAM,IAAM,EAAU,UAAY,QACzC,EAAO,MAAM,QAAU,OACvB,EAAO,MAAM,QAAU,EAAO,KAC9B,EAAO,MAAQ,EAAK,EAAO,MAAO,EAAO,EAE5C,CACF,CACF"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.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 { appendPath } from \"@stryke/path/append\";\nimport defu from \"defu\";\nimport { createNitro } from \"nitro/builder\";\nimport { NitroConfig } from \"nitro/types\";\nimport { Plugin } from \"powerlines\";\nimport { getConfigPath } from \"powerlines/plugin-utils\";\nimport {\n NitroContext,\n NitroPluginContext,\n NitroPluginOptions,\n NitroPluginUserConfig\n} from \"./types/plugin\";\n\nexport * from \"./types\";\n\ndeclare module \"powerlines\" {\n interface Config {\n nitro?: NitroPluginOptions;\n }\n}\n\n/**\n * A Powerlines plugin to integrate with Nitro.\n */\nexport const plugin = <\n TContext extends NitroPluginContext = NitroPluginContext\n>(\n options: NitroPluginOptions = {}\n) => {\n return [\n // nitroInit(options),\n // nitroEnv(options),\n // nitroMain(options),\n // nitroPrepare(options),\n // nitroService(options),\n // nitroPreviewPlugin(options),\n {\n name: \"nitro:config\",\n async config() {\n this.debug(\n \"Providing default configuration for the Powerlines `nitro` plugin.\"\n );\n\n let configFile = options.configFile;\n if (!configFile) {\n configFile = getConfigPath(this, \"nitro\");\n }\n\n return {\n nitro: {\n configFile: configFile\n ? appendPath(configFile, this.config.cwd)\n : undefined,\n ...options\n }\n };\n },\n configResolved() {\n this.config.nitro.compatibilityDate = this.config.compatibilityDate;\n this.config.nitro.workspaceDir = this.config.cwd;\n\n this.config.nitro.alias = this.config.resolve\n .alias as NitroConfig[\"alias\"];\n\n switch (this.config.logLevel) {\n case \"error\":\n this.config.nitro.logLevel = 1;\n break;\n case \"warn\":\n this.config.nitro.logLevel = 2;\n break;\n case \"info\":\n this.config.nitro.logLevel = 3;\n break;\n case \"debug\":\n this.config.nitro.logLevel = 4;\n break;\n case \"trace\":\n this.config.nitro.logLevel = 5;\n break;\n case null:\n this.config.nitro.logLevel = 0;\n break;\n default:\n this.config.nitro.logLevel = 2;\n break;\n }\n }\n },\n {\n name: \"nitro:init\",\n configResolved: {\n order: \"post\",\n async handler() {\n this.nitro ??= {} as NitroContext;\n this.nitro.nitro = await createNitro(this.config.nitro);\n }\n }\n },\n {\n name: \"nitro:vite\",\n vite: {\n config(config: NitroPluginUserConfig, configEnv: { command: string }) {\n config.nitro ??= {};\n config.nitro.dev = configEnv.command === \"serve\";\n config.nitro.builder = \"vite\";\n config.nitro.rootDir = config.root;\n config.nitro = defu(config.nitro, config) as NitroConfig;\n }\n }\n }\n ] as Plugin<TContext>[];\n};\n\nexport default plugin;\n\n// function nitroInit(\n// options: NitroPluginOptions = {}\n// ): Plugin<NitroPluginContext> {\n// return {\n// name: \"nitro:init\",\n// sharedDuringBuild: true,\n\n// async config(config, configEnv) {\n// this.isRolldown = !!(this.meta as Record<string, string>).rolldownVersion;\n// if (!this.isInitialized) {\n// debug(\"[init] Initializing nitro\");\n// this.isInitialized = true;\n// await setupNitroContext(this, configEnv, config);\n// }\n// },\n\n// applyToEnvironment(env) {\n// if (env.name === \"nitro\" && ctx.nitro?.options.dev) {\n// debug(\"[init] Adding rollup plugins for dev\");\n// return [...((ctx.rollupConfig?.config.plugins as VitePlugin[]) || [])];\n// }\n// },\n// vite: {\n// apply: (_, configEnv) => !configEnv.isPreview\n// }\n// };\n// }\n\n// function nitroEnv(ctx: NitroPluginContext): VitePlugin {\n// return {\n// name: \"nitro:env\",\n// sharedDuringBuild: true,\n// apply: (_config, configEnv) => !configEnv.isPreview,\n\n// async config(userConfig, _configEnv) {\n// debug(\"[env] Extending config (environments)\");\n// const environments: Record<string, EnvironmentOptions> = {\n// ...createServiceEnvironments(ctx),\n// nitro: createNitroEnvironment(ctx)\n// };\n// environments.client = {\n// consumer: userConfig.environments?.client?.consumer ?? \"client\",\n// build: {\n// rollupOptions: {\n// input:\n// userConfig.environments?.client?.build?.rollupOptions?.input ??\n// useNitro(ctx).options.renderer?.template\n// }\n// }\n// };\n// debug(\"[env] Environments:\", Object.keys(environments).join(\", \"));\n// return {\n// environments\n// };\n// },\n\n// configEnvironment(name, config) {\n// if (config.consumer === \"client\") {\n// debug(\n// \"[env] Configuring client environment\",\n// name === \"client\" ? \"\" : ` (${name})`\n// );\n// config.build!.emptyOutDir = false;\n// config.build!.outDir = useNitro(ctx).options.output.publicDir;\n// }\n// }\n// };\n// }\n\n// function nitroMain(ctx: NitroPluginContext): VitePlugin {\n// return {\n// name: \"nitro:main\",\n// sharedDuringBuild: true,\n// apply: (_config, configEnv) => !configEnv.isPreview,\n\n// async config(userConfig, _configEnv) {\n// debug(\"[main] Extending config (appType, resolve, server)\");\n// if (!ctx.rollupConfig) {\n// throw new Error(\"Nitro rollup config is not initialized yet.\");\n// }\n// return {\n// appType: userConfig.appType || \"custom\",\n// resolve: {\n// // TODO: environment specific aliases not working\n// // https://github.com/vitejs/vite/pull/17583 (seems not effective)\n// alias: ctx.rollupConfig.base.aliases\n// },\n// builder: {\n// sharedConfigBuild: true\n// },\n// server: {\n// port:\n// Number.parseInt(process.env.PORT || \"\") ||\n// userConfig.server?.port ||\n// useNitro(ctx).options.devServer?.port ||\n// 3000,\n// // #3673, disable Vite's `cors` by default as Nitro handles all requests\n// cors: false\n// }\n// };\n// },\n\n// buildApp: {\n// order: \"post\",\n// handler(builder) {\n// debug(\"[main] Building environments\");\n// return buildEnvironments(ctx, builder);\n// }\n// },\n\n// generateBundle: {\n// handler(_options, bundle) {\n// const environment = this.environment;\n// debug(\n// \"[main] Generating manifest and entry points for environment:\",\n// environment.name\n// );\n// const serviceNames = Object.keys(ctx.services);\n// const isRegisteredService = serviceNames.includes(environment.name);\n\n// // Find entry point of this service\n// let entryFile: string | undefined;\n// for (const [_name, file] of Object.entries(bundle)) {\n// if (file.type === \"chunk\" && isRegisteredService && file.isEntry) {\n// if (entryFile === undefined) {\n// entryFile = file.fileName;\n// } else {\n// this.warn(\n// `Multiple entry points found for service \"${environment.name}\"`\n// );\n// }\n// }\n// }\n// if (isRegisteredService) {\n// if (entryFile === undefined) {\n// this.error(\n// `No entry point found for service \"${this.environment.name}\".`\n// );\n// }\n// ctx._entryPoints![this.environment.name] = entryFile!;\n// }\n// }\n// },\n\n// configureServer: server => {\n// debug(\"[main] Configuring dev server\");\n// return configureViteDevServer(ctx, server);\n// },\n\n// // Automatically reload the client when a server module is updated\n// // see: https://github.com/vitejs/vite/issues/19114\n// async hotUpdate({ server, modules, timestamp }) {\n// const env = this.environment;\n// if (\n// ctx.pluginConfig.experimental?.vite.serverReload === false ||\n// env.config.consumer === \"client\"\n// ) {\n// return;\n// }\n// const clientEnvs = Object.values(server.environments).filter(\n// env => env.config.consumer === \"client\"\n// );\n// let hasServerOnlyModule = false;\n// const invalidated = new Set<EnvironmentModuleNode>();\n// for (const mod of modules) {\n// if (\n// mod.id &&\n// !clientEnvs.some(env => env.moduleGraph.getModuleById(mod.id))\n// ) {\n// hasServerOnlyModule = true;\n// env.moduleGraph.invalidateModule(mod, invalidated, timestamp, false);\n// }\n// }\n// if (hasServerOnlyModule) {\n// env.hot.send({ type: \"full-reload\" });\n// server.ws.send({ type: \"full-reload\" });\n// return [];\n// }\n// }\n// };\n// }\n\n// function nitroPrepare(ctx: NitroPluginContext): VitePlugin {\n// return {\n// name: \"nitro:prepare\",\n// sharedDuringBuild: true,\n// applyToEnvironment: env => env.name === \"nitro\",\n\n// buildApp: {\n// // Clean the output directory before any environment is built\n// order: \"pre\",\n// async handler() {\n// debug(\"[prepare] Preparing output directory\");\n// const nitro = ctx.nitro;\n// await prepare(nitro);\n// }\n// }\n// };\n// }\n\n// function nitroService(ctx: NitroPluginContext): VitePlugin {\n// return {\n// name: \"nitro:service\",\n// enforce: \"pre\",\n// sharedDuringBuild: true,\n// applyToEnvironment: env => env.name === \"nitro\",\n\n// resolveId: {\n// filter: { id: /^#nitro-vite-setup$/ },\n// async handler(id) {\n// // Virtual modules\n// if (id === \"#nitro-vite-setup\") {\n// return { id, moduleSideEffects: true };\n// }\n// }\n// },\n\n// load: {\n// filter: { id: /^#nitro-vite-setup$/ },\n// async handler(id) {\n// // Virtual modules\n// if (id === \"#nitro-vite-setup\") {\n// return prodSetup(ctx);\n// }\n// }\n// }\n// };\n// }\n"],"mappings":";;;;;;;;;AA0CA,MAAa,UAGX,UAA8B,EAAE,KAC7B;AACH,QAAO;EAOL;GACE,MAAM;GACN,MAAM,SAAS;AACb,SAAK,MACH,qEACD;IAED,IAAI,aAAa,QAAQ;AACzB,QAAI,CAAC,WACH,cAAa,cAAc,MAAM,QAAQ;AAG3C,WAAO,EACL,OAAO;KACL,YAAY,aACR,WAAW,YAAY,KAAK,OAAO,IAAI,GACvC;KACJ,GAAG;KACJ,EACF;;GAEH,iBAAiB;AACf,SAAK,OAAO,MAAM,oBAAoB,KAAK,OAAO;AAClD,SAAK,OAAO,MAAM,eAAe,KAAK,OAAO;AAE7C,SAAK,OAAO,MAAM,QAAQ,KAAK,OAAO,QACnC;AAEH,YAAQ,KAAK,OAAO,UAApB;KACE,KAAK;AACH,WAAK,OAAO,MAAM,WAAW;AAC7B;KACF,KAAK;AACH,WAAK,OAAO,MAAM,WAAW;AAC7B;KACF,KAAK;AACH,WAAK,OAAO,MAAM,WAAW;AAC7B;KACF,KAAK;AACH,WAAK,OAAO,MAAM,WAAW;AAC7B;KACF,KAAK;AACH,WAAK,OAAO,MAAM,WAAW;AAC7B;KACF,KAAK;AACH,WAAK,OAAO,MAAM,WAAW;AAC7B;KACF;AACE,WAAK,OAAO,MAAM,WAAW;AAC7B;;;GAGP;EACD;GACE,MAAM;GACN,gBAAgB;IACd,OAAO;IACP,MAAM,UAAU;AACd,UAAK,UAAU,EAAE;AACjB,UAAK,MAAM,QAAQ,MAAM,YAAY,KAAK,OAAO,MAAM;;IAE1D;GACF;EACD;GACE,MAAM;GACN,MAAM,EACJ,OAAO,QAA+B,WAAgC;AACpE,WAAO,UAAU,EAAE;AACnB,WAAO,MAAM,MAAM,UAAU,YAAY;AACzC,WAAO,MAAM,UAAU;AACvB,WAAO,MAAM,UAAU,OAAO;AAC9B,WAAO,QAAQ,KAAK,OAAO,OAAO,OAAO;MAE5C;GACF;EACF"}
|
package/dist/types/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{};
|
|
1
|
+
export { };
|
package/dist/types/plugin.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{};
|
|
1
|
+
export { };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerlines/plugin-nitro",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.350",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A package containing a Powerlines plugin for creating a server application that runs on Nitro.",
|
|
6
6
|
"repository": {
|
|
@@ -93,15 +93,15 @@
|
|
|
93
93
|
"@stryke/path": "^0.28.2",
|
|
94
94
|
"defu": "^6.1.7",
|
|
95
95
|
"nitro": "3.0.1-alpha.1",
|
|
96
|
-
"powerlines": "^0.46.
|
|
96
|
+
"powerlines": "^0.46.5"
|
|
97
97
|
},
|
|
98
98
|
"devDependencies": {
|
|
99
|
-
"@powerlines/plugin-plugin": "^0.12.
|
|
99
|
+
"@powerlines/plugin-plugin": "^0.12.409",
|
|
100
100
|
"@types/node": "^25.6.0"
|
|
101
101
|
},
|
|
102
102
|
"publishConfig": { "access": "public" },
|
|
103
103
|
"main": "./dist/index.cjs",
|
|
104
104
|
"module": "./dist/index.mjs",
|
|
105
105
|
"types": "./dist/index.d.cts",
|
|
106
|
-
"gitHead": "
|
|
106
|
+
"gitHead": "9af888c54e58a82744cc334a6b80da52429fa0ac"
|
|
107
107
|
}
|