@cloudflare/vite-plugin 1.18.0 → 1.19.0
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/index.d.mts
CHANGED
|
@@ -2,6 +2,10 @@ import { Miniflare, Request, Response } from "miniflare";
|
|
|
2
2
|
import { Unstable_Config } from "wrangler";
|
|
3
3
|
import * as vite from "vite";
|
|
4
4
|
|
|
5
|
+
//#region src/utils.d.ts
|
|
6
|
+
|
|
7
|
+
type Defined<T> = Exclude<T, undefined>;
|
|
8
|
+
//#endregion
|
|
5
9
|
//#region src/workers-configs.d.ts
|
|
6
10
|
|
|
7
11
|
type WorkerConfig = Omit<Unstable_Config, keyof NonApplicableConfig>;
|
|
@@ -54,21 +58,28 @@ interface AuxiliaryWorkerFileConfig extends BaseWorkerConfig {
|
|
|
54
58
|
}
|
|
55
59
|
interface AuxiliaryWorkerInlineConfig extends BaseWorkerConfig {
|
|
56
60
|
configPath?: string;
|
|
57
|
-
config: WorkerConfigCustomizer
|
|
61
|
+
config: WorkerConfigCustomizer<false>;
|
|
58
62
|
}
|
|
59
63
|
type AuxiliaryWorkerConfig = AuxiliaryWorkerFileConfig | AuxiliaryWorkerInlineConfig;
|
|
60
64
|
interface Experimental {
|
|
61
65
|
/** Experimental support for handling the _headers and _redirects files during Vite dev mode. */
|
|
62
66
|
headersAndRedirectsDevModeSupport?: boolean;
|
|
63
67
|
}
|
|
64
|
-
type WorkerConfigCustomizer = Partial<WorkerConfig> | ((config: WorkerConfig
|
|
68
|
+
type WorkerConfigCustomizer<TIsEntryWorker extends boolean> = Partial<WorkerConfig> | ((...args: TIsEntryWorker extends true ? [config: WorkerConfig] : [config: WorkerConfig, {
|
|
69
|
+
entryWorkerConfig: ResolvedAssetsOnlyConfig;
|
|
70
|
+
}]) => Partial<WorkerConfig> | void);
|
|
65
71
|
interface PluginConfig extends EntryWorkerConfig {
|
|
66
72
|
auxiliaryWorkers?: AuxiliaryWorkerConfig[];
|
|
67
73
|
persistState?: PersistState;
|
|
68
74
|
inspectorPort?: number | false;
|
|
69
75
|
remoteBindings?: boolean;
|
|
70
76
|
experimental?: Experimental;
|
|
71
|
-
config?: WorkerConfigCustomizer
|
|
77
|
+
config?: WorkerConfigCustomizer<true>;
|
|
78
|
+
}
|
|
79
|
+
interface ResolvedAssetsOnlyConfig extends WorkerConfig {
|
|
80
|
+
topLevelName: Defined<WorkerConfig["topLevelName"]>;
|
|
81
|
+
name: Defined<WorkerConfig["name"]>;
|
|
82
|
+
compatibility_date: Defined<WorkerConfig["compatibility_date"]>;
|
|
72
83
|
}
|
|
73
84
|
//#endregion
|
|
74
85
|
//#region src/index.d.ts
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/workers-configs.ts","../src/plugin-config.ts","../src/index.ts"],"sourcesContent":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/utils.ts","../src/workers-configs.ts","../src/plugin-config.ts","../src/index.ts"],"sourcesContent":[],"mappings":";;;;;;ACkDK,KDIO,OCJP,CAAA,CAAA,CAAA,GDIoB,OCJD,CDIS,CCJT,EAAA,SACrB,CAAA;;;;AADE,KAnBO,YAAA,GAAe,IAmBH,CAnBQ,eAoB7B,EAAA,MApBoD,mBAqBpD,CAAA;KAJE,8BAAA,UAAwC;KAExC,mBAAA,GACF,oCACA;AC7BH,KD+BK,iCAAA,GC/BmB,MDgCjB,8BChCiB,CAAA,gBAAA,CAAA;AAA8B,KDkCjD,8BAAA,GACJ,8BCjCyB,CAAA,aAAA,CAAA,CAAA,MAAA,CAAA;AAAA;AAI0B;AAIQ;AASvD,cDqBQ,0BCpBV,EAAA;EAGO;AAAY;;EAMnB,SAAA,cAAA,EAAA;IAES,SAAA,KAAA,EAAA;MACG,SAAA,eAAA,EAAA,eAAA;MAED,SAAA,QAAA,EAAA,2DAAA;IACa,CAAA;IAEX,SA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AAA,CAAA,EAAA,MAAA,GAAA,KAAA;EAEE,cAAA,CAAa,EAAA,OAAA;EACV,YAAA,CAAA,EAIJ,YAJI;EACJ,MAAA,CAAA,EAIN,sBAJM,CAAA,IAAA,CAAA;;AAIN,UAGO,wBAAA,SAAiC,YAHxC,CAAA;EAN4B,YAAA,EAUvB,OAVuB,CAUf,YAVe,CAAA,cAAA,CAAA,CAAA;EAAiB,IAAA,EAWhD,OAXgD,CAWxC,YAXwC,CAAA,MAAA,CAAA,CAAA;EAStC,kBAAA,EAGI,OAHqB,CAGb,YAHa,CAAA,oBAAA,CAAA,CAAA;;;;;AFjB1C;;;;ACvBA;;AAAuD,iBEYvC,UAAA,CFZuC,YAAA,CAAA,EEYd,YFZc,CAAA,EEYM,IAAA,CAAK,MFZX,EAAA"}
|
package/dist/index.mjs
CHANGED
|
@@ -8434,19 +8434,20 @@ const allowedWranglerConfigExtensions = [
|
|
|
8434
8434
|
|
|
8435
8435
|
//#endregion
|
|
8436
8436
|
//#region src/plugin-config.ts
|
|
8437
|
-
function customizeWorkerConfig(
|
|
8438
|
-
const configResult = typeof
|
|
8439
|
-
if (configResult) return defu(configResult,
|
|
8440
|
-
return
|
|
8437
|
+
function customizeWorkerConfig(options) {
|
|
8438
|
+
const configResult = typeof options.configCustomizer === "function" ? "entryWorkerConfig" in options ? options.configCustomizer(options.workerConfig, { entryWorkerConfig: options.entryWorkerConfig }) : options.configCustomizer(options.workerConfig) : options.configCustomizer;
|
|
8439
|
+
if (configResult) return defu(configResult, options.workerConfig);
|
|
8440
|
+
return options.workerConfig;
|
|
8441
8441
|
}
|
|
8442
8442
|
/**
|
|
8443
8443
|
* Resolves the config for a single worker, applying defaults, file config, and config().
|
|
8444
8444
|
*/
|
|
8445
|
-
function resolveWorkerConfig(
|
|
8445
|
+
function resolveWorkerConfig(options) {
|
|
8446
|
+
const isEntryWorker = !("entryWorkerConfig" in options);
|
|
8446
8447
|
let workerConfig;
|
|
8447
8448
|
let raw;
|
|
8448
8449
|
let nonApplicable;
|
|
8449
|
-
if (configPath) ({raw, config: workerConfig, nonApplicable} = readWorkerConfigFromFile(configPath, env, { visitedConfigPaths }));
|
|
8450
|
+
if (options.configPath) ({raw, config: workerConfig, nonApplicable} = readWorkerConfigFromFile(options.configPath, options.env, { visitedConfigPaths: options.visitedConfigPaths }));
|
|
8450
8451
|
else {
|
|
8451
8452
|
workerConfig = { ...wrangler.unstable_defaultWranglerConfig };
|
|
8452
8453
|
raw = structuredClone(workerConfig);
|
|
@@ -8455,15 +8456,22 @@ function resolveWorkerConfig({ configPath, env, config, visitedConfigPaths, isEn
|
|
|
8455
8456
|
notRelevant: /* @__PURE__ */ new Set()
|
|
8456
8457
|
};
|
|
8457
8458
|
}
|
|
8458
|
-
workerConfig = customizeWorkerConfig(
|
|
8459
|
+
workerConfig = "entryWorkerConfig" in options ? customizeWorkerConfig({
|
|
8460
|
+
workerConfig,
|
|
8461
|
+
configCustomizer: options.configCustomizer,
|
|
8462
|
+
entryWorkerConfig: options.entryWorkerConfig
|
|
8463
|
+
}) : customizeWorkerConfig({
|
|
8464
|
+
workerConfig,
|
|
8465
|
+
configCustomizer: options.configCustomizer
|
|
8466
|
+
});
|
|
8459
8467
|
workerConfig.compatibility_date ??= wrangler.unstable_getDevCompatibilityDate(void 0);
|
|
8460
|
-
if (isEntryWorker) workerConfig.name ??= wrangler.unstable_getWorkerNameFromProject(root);
|
|
8468
|
+
if (isEntryWorker) workerConfig.name ??= wrangler.unstable_getWorkerNameFromProject(options.root);
|
|
8461
8469
|
workerConfig.topLevelName ??= workerConfig.name;
|
|
8462
8470
|
return resolveWorkerType(workerConfig, raw, nonApplicable, {
|
|
8463
8471
|
isEntryWorker,
|
|
8464
|
-
configPath,
|
|
8465
|
-
root,
|
|
8466
|
-
env
|
|
8472
|
+
configPath: options.configPath,
|
|
8473
|
+
root: options.root,
|
|
8474
|
+
env: options.env
|
|
8467
8475
|
});
|
|
8468
8476
|
}
|
|
8469
8477
|
function resolvePluginConfig(pluginConfig, userConfig, viteEnv) {
|
|
@@ -8487,9 +8495,8 @@ function resolvePluginConfig(pluginConfig, userConfig, viteEnv) {
|
|
|
8487
8495
|
root,
|
|
8488
8496
|
configPath: getValidatedWranglerConfigPath(root, pluginConfig.configPath),
|
|
8489
8497
|
env: prefixedEnv.CLOUDFLARE_ENV,
|
|
8490
|
-
|
|
8491
|
-
visitedConfigPaths: configPaths
|
|
8492
|
-
isEntryWorker: true
|
|
8498
|
+
configCustomizer: pluginConfig.config,
|
|
8499
|
+
visitedConfigPaths: configPaths
|
|
8493
8500
|
});
|
|
8494
8501
|
if (entryWorkerResolvedConfig.type === "assets-only") return {
|
|
8495
8502
|
...shared,
|
|
@@ -8511,9 +8518,9 @@ function resolvePluginConfig(pluginConfig, userConfig, viteEnv) {
|
|
|
8511
8518
|
root,
|
|
8512
8519
|
configPath: getValidatedWranglerConfigPath(root, auxiliaryWorker.configPath, true),
|
|
8513
8520
|
env: cloudflareEnv,
|
|
8514
|
-
|
|
8515
|
-
|
|
8516
|
-
|
|
8521
|
+
configCustomizer: "config" in auxiliaryWorker ? auxiliaryWorker.config : void 0,
|
|
8522
|
+
entryWorkerConfig,
|
|
8523
|
+
visitedConfigPaths: configPaths
|
|
8517
8524
|
});
|
|
8518
8525
|
auxiliaryWorkersResolvedConfigs.push(workerResolvedConfig);
|
|
8519
8526
|
const workerEnvironmentName = auxiliaryWorker.viteEnvironment?.name ?? workerNameToEnvironmentName(workerResolvedConfig.config.topLevelName);
|