@vixt/core 0.7.1 → 0.7.3
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/node/index.d.mts +13 -6
- package/dist/node/index.mjs +6 -6
- package/package.json +1 -1
package/dist/node/index.d.mts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { ConfigLayer, ConfigLayerMeta, LoadConfigOptions } from "c12";
|
|
1
|
+
import { ConfigLayer, ConfigLayerMeta, LoadConfigOptions, ResolvedConfig } from "c12";
|
|
3
2
|
import * as vite0 from "vite";
|
|
4
3
|
import { HtmlTagDescriptor, InlineConfig, LogLevel, PluginOption, ServerOptions, UserConfig } from "vite";
|
|
5
4
|
import Legacy from "@vitejs/plugin-legacy";
|
|
@@ -38,7 +37,10 @@ interface VixtModule<T extends ModuleOptions = ModuleOptions> {
|
|
|
38
37
|
declare function defineVitePlugin<Options = any>(pluginFn: (options?: Options) => PluginOption): (options?: Options) => PluginOption;
|
|
39
38
|
declare function defineVixtModule<T extends ModuleOptions>(definition: ModuleDefinition<T> | VixtModule<T>): VixtModule<T>;
|
|
40
39
|
declare function installModule<T extends ModuleOptions = ModuleOptions>(module: VixtModule<T>, inlineOptions: any, vixt: Vixt): PluginOption;
|
|
41
|
-
declare function applyLayerModules(
|
|
40
|
+
declare function applyLayerModules({
|
|
41
|
+
config,
|
|
42
|
+
layers
|
|
43
|
+
}: ResolvedVixtConfig): Promise<VixtModule[]>;
|
|
42
44
|
//#endregion
|
|
43
45
|
//#region src/node/config.d.ts
|
|
44
46
|
interface VixtOptions {
|
|
@@ -257,9 +259,14 @@ interface VixtConfigLayer extends ConfigLayer<VixtOptions, VixtConfigLayerMeta>
|
|
|
257
259
|
/** when layer is in node_modules, layer will copy to `<buildLayersDir>/<layerName>`, and change cwd */
|
|
258
260
|
cwd?: string;
|
|
259
261
|
}
|
|
262
|
+
interface LoadVixtConfigOptions extends LoadConfigOptions<VixtOptions, VixtConfigLayerMeta> {}
|
|
263
|
+
interface ResolvedVixtConfig extends ResolvedConfig<VixtOptions, VixtConfigLayerMeta> {}
|
|
260
264
|
declare function defineVixtConfig(input: VixtOptions): VixtOptions;
|
|
261
|
-
declare function loadVixtConfig(opts?:
|
|
262
|
-
declare function applyLayers(
|
|
265
|
+
declare function loadVixtConfig(opts?: LoadVixtConfigOptions): Promise<ResolvedVixtConfig>;
|
|
266
|
+
declare function applyLayers({
|
|
267
|
+
config,
|
|
268
|
+
layers
|
|
269
|
+
}: ResolvedVixtConfig): VixtConfigLayer[];
|
|
263
270
|
declare function isSamePath(a: string, b: string): boolean;
|
|
264
271
|
declare function resolveLayersDirs(layers?: VixtConfigLayer[]): Record<string, string[] | undefined>;
|
|
265
272
|
declare const VixtClientAutoImports: Record<string, string[]>;
|
|
@@ -307,4 +314,4 @@ declare const virtualModuleIds: {
|
|
|
307
314
|
};
|
|
308
315
|
declare const builtinModules: (VixtModule<ModuleOptions> | VixtModule<AliasOptions> | VixtModule<AppOptions> | VixtModule<BuildOptions> | VixtModule<DevServerOptions> | VixtModule<TypescriptOptions>)[];
|
|
309
316
|
//#endregion
|
|
310
|
-
export { AliasOptions, AppHead, AppHeadAttrs, AppOptions, BuildOptions, DevServerOptions, ExtractPluginOptions, GlobalCLIOptions, ModuleDefinition, ModuleMeta, ModuleOptions, TypescriptOptions, Vixt, VixtClientAutoImports, VixtConfigLayer, VixtConfigLayerMeta, VixtModule, VixtOptions, applyLayerModules, applyLayers, builtinModules, createVixtPlugin, defineVitePlugin, defineVixtConfig, defineVixtModule, findUpWorkspaceDir, installModule, isSamePath, loadCLIOptions, loadEnv, loadMode, loadVixt, loadVixtConfig, loadWorkspaceEnv, resolveLayersDirs, virtualModuleIds };
|
|
317
|
+
export { AliasOptions, AppHead, AppHeadAttrs, AppOptions, BuildOptions, DevServerOptions, ExtractPluginOptions, GlobalCLIOptions, LoadVixtConfigOptions, ModuleDefinition, ModuleMeta, ModuleOptions, ResolvedVixtConfig, TypescriptOptions, Vixt, VixtClientAutoImports, VixtConfigLayer, VixtConfigLayerMeta, VixtModule, VixtOptions, applyLayerModules, applyLayers, builtinModules, createVixtPlugin, defineVitePlugin, defineVixtConfig, defineVixtModule, findUpWorkspaceDir, installModule, isSamePath, loadCLIOptions, loadEnv, loadMode, loadVixt, loadVixtConfig, loadWorkspaceEnv, resolveLayersDirs, virtualModuleIds };
|
package/dist/node/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { loadConfig } from "c12";
|
|
2
2
|
import fs from "fs-extra";
|
|
3
3
|
import path, { normalize, resolve } from "pathe";
|
|
4
|
-
import
|
|
4
|
+
import { cwd, env } from "node:process";
|
|
5
5
|
import { cac } from "cac";
|
|
6
6
|
import { findUpSync } from "find-up";
|
|
7
7
|
import { loadEnv as loadEnv$1, mergeConfig, parseAst } from "vite";
|
|
@@ -73,7 +73,7 @@ async function loadVixtConfig(opts) {
|
|
|
73
73
|
config.pluginsDir ??= resolve(config.srcDir, "plugins");
|
|
74
74
|
return result;
|
|
75
75
|
}
|
|
76
|
-
function applyLayers(
|
|
76
|
+
function applyLayers({ config, layers = [] }) {
|
|
77
77
|
const { rootDir, buildLayersDir, copyLayers = true } = config;
|
|
78
78
|
return layers.filter((e) => e.cwd).map((layer) => {
|
|
79
79
|
layer.config ??= {};
|
|
@@ -151,10 +151,10 @@ function defineVixtModule(definition) {
|
|
|
151
151
|
function installModule(module, inlineOptions, vixt) {
|
|
152
152
|
return module(inlineOptions, vixt);
|
|
153
153
|
}
|
|
154
|
-
async function applyLayerModules(layers) {
|
|
154
|
+
async function applyLayerModules({ config, layers = [] }) {
|
|
155
155
|
const { modules: modulesDirs = [] } = resolveLayersDirs(layers);
|
|
156
156
|
const modules = [];
|
|
157
|
-
const jiti = createJiti(
|
|
157
|
+
const jiti = createJiti(config.rootDir, { moduleCache: false });
|
|
158
158
|
for (const m of modulesDirs.reverse()) if (fs.existsSync(m)) {
|
|
159
159
|
const files = fs.readdirSync(m);
|
|
160
160
|
for (const f of files) try {
|
|
@@ -624,8 +624,8 @@ async function loadVixt(opts) {
|
|
|
624
624
|
cliOptions.force && fs.removeSync(result.config.buildDir);
|
|
625
625
|
result.config.debug = !!cliOptions.debug;
|
|
626
626
|
result.config.dev = env.NODE_ENV !== "production";
|
|
627
|
-
result.layers = applyLayers(result
|
|
628
|
-
const layerModules = await applyLayerModules(result
|
|
627
|
+
result.layers = applyLayers(result);
|
|
628
|
+
const layerModules = await applyLayerModules(result);
|
|
629
629
|
return {
|
|
630
630
|
options: result.config,
|
|
631
631
|
_layers: result.layers ?? [],
|