feat: pass resolved config to plugin.buildStart() (#1961)
This commit is contained in:
+17
-11
@@ -1,6 +1,10 @@
|
||||
import { dirname, fromFileUrl, isAbsolute, join, JSONC } from "./deps.ts";
|
||||
import { FromManifestConfig, Manifest } from "./mod.ts";
|
||||
import { DenoConfig, InternalFreshConfig } from "./types.ts";
|
||||
import {
|
||||
DenoConfig,
|
||||
InternalFreshState,
|
||||
ResolvedFreshConfig,
|
||||
} from "./types.ts";
|
||||
|
||||
export async function readDenoConfig(
|
||||
directory: string,
|
||||
@@ -37,10 +41,10 @@ function isObject(value: unknown) {
|
||||
!Array.isArray(value);
|
||||
}
|
||||
|
||||
export async function getFreshConfigWithDefaults(
|
||||
export async function getInternalFreshState(
|
||||
manifest: Manifest,
|
||||
config: FromManifestConfig,
|
||||
): Promise<InternalFreshConfig> {
|
||||
): Promise<InternalFreshState> {
|
||||
const base = dirname(fromFileUrl(manifest.baseUrl));
|
||||
const { config: denoJson, path: denoJsonPath } = await readDenoConfig(base);
|
||||
|
||||
@@ -50,14 +54,8 @@ export async function getFreshConfigWithDefaults(
|
||||
);
|
||||
}
|
||||
|
||||
const internalConfig: InternalFreshConfig = {
|
||||
loadSnapshot: typeof config.skipSnapshot === "boolean"
|
||||
? !config.skipSnapshot
|
||||
: false,
|
||||
const internalConfig: ResolvedFreshConfig = {
|
||||
dev: config.dev ?? false,
|
||||
denoJsonPath,
|
||||
denoJson,
|
||||
manifest,
|
||||
build: {
|
||||
outDir: "",
|
||||
target: config.build?.target ?? ["chrome99", "firefox99", "safari15"],
|
||||
@@ -102,7 +100,15 @@ export async function getFreshConfigWithDefaults(
|
||||
? parseFileOrUrl(config.staticDir, base)
|
||||
: join(base, "static");
|
||||
|
||||
return internalConfig;
|
||||
return {
|
||||
config: internalConfig,
|
||||
manifest,
|
||||
loadSnapshot: typeof config.skipSnapshot === "boolean"
|
||||
? !config.skipSnapshot
|
||||
: false,
|
||||
denoJsonPath,
|
||||
denoJson,
|
||||
};
|
||||
}
|
||||
|
||||
function parseFileOrUrl(input: string, base: string) {
|
||||
|
||||
Reference in New Issue
Block a user