@cloudflare/vite-plugin 1.42.3 → 1.42.4
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.mjs
CHANGED
|
@@ -1506,7 +1506,7 @@ async function assertWranglerVersion() {
|
|
|
1506
1506
|
* The default compatibility date to use when the user omits one.
|
|
1507
1507
|
* This value is injected at build time and remains fixed for each release.
|
|
1508
1508
|
*/
|
|
1509
|
-
const DEFAULT_COMPAT_DATE = "2026-06-
|
|
1509
|
+
const DEFAULT_COMPAT_DATE = "2026-06-30";
|
|
1510
1510
|
|
|
1511
1511
|
//#endregion
|
|
1512
1512
|
//#region src/build-output-env.ts
|
|
@@ -61012,144 +61012,6 @@ var ImageRegistriesService = class {
|
|
|
61012
61012
|
}
|
|
61013
61013
|
};
|
|
61014
61014
|
|
|
61015
|
-
//#endregion
|
|
61016
|
-
//#region ../containers-shared/src/build.ts
|
|
61017
|
-
async function constructBuildCommand(options, logger) {
|
|
61018
|
-
const platform$1 = options.platform ?? "linux/amd64";
|
|
61019
|
-
const buildCmd = [
|
|
61020
|
-
"build",
|
|
61021
|
-
"--load",
|
|
61022
|
-
"-t",
|
|
61023
|
-
options.tag,
|
|
61024
|
-
"--platform",
|
|
61025
|
-
platform$1,
|
|
61026
|
-
"--provenance=false"
|
|
61027
|
-
];
|
|
61028
|
-
if (options.args) for (const arg in options.args) buildCmd.push("--build-arg", `${arg}=${options.args[arg]}`);
|
|
61029
|
-
if (options.setNetworkToHost) buildCmd.push("--network", "host");
|
|
61030
|
-
const dockerfile = readFileSync(options.pathToDockerfile, "utf-8");
|
|
61031
|
-
buildCmd.push("-f", "-");
|
|
61032
|
-
buildCmd.push(options.buildContext);
|
|
61033
|
-
logger?.debug(`Building image with command: ${buildCmd.join(" ")}`);
|
|
61034
|
-
return {
|
|
61035
|
-
buildCmd,
|
|
61036
|
-
dockerfile
|
|
61037
|
-
};
|
|
61038
|
-
}
|
|
61039
|
-
function dockerBuild(dockerPath, options) {
|
|
61040
|
-
let errorHandled = false;
|
|
61041
|
-
let resolve$4;
|
|
61042
|
-
let reject;
|
|
61043
|
-
const ready = new Promise((res, rej) => {
|
|
61044
|
-
resolve$4 = res;
|
|
61045
|
-
reject = rej;
|
|
61046
|
-
});
|
|
61047
|
-
const child = spawn(dockerPath, options.buildCmd, {
|
|
61048
|
-
stdio: [
|
|
61049
|
-
"pipe",
|
|
61050
|
-
"inherit",
|
|
61051
|
-
"inherit"
|
|
61052
|
-
],
|
|
61053
|
-
detached: process.platform !== "win32",
|
|
61054
|
-
windowsHide: true
|
|
61055
|
-
});
|
|
61056
|
-
if (child.stdin !== null) {
|
|
61057
|
-
child.stdin.write(options.dockerfile);
|
|
61058
|
-
child.stdin.end();
|
|
61059
|
-
}
|
|
61060
|
-
child.on("exit", (code) => {
|
|
61061
|
-
if (code === 0) resolve$4();
|
|
61062
|
-
else if (!errorHandled) {
|
|
61063
|
-
errorHandled = true;
|
|
61064
|
-
reject(new UserError(`Docker build exited with code: ${code}`, { telemetryMessage: false }));
|
|
61065
|
-
}
|
|
61066
|
-
});
|
|
61067
|
-
child.on("error", (err) => {
|
|
61068
|
-
if (!errorHandled) {
|
|
61069
|
-
errorHandled = true;
|
|
61070
|
-
reject(err);
|
|
61071
|
-
}
|
|
61072
|
-
});
|
|
61073
|
-
return {
|
|
61074
|
-
abort: () => {
|
|
61075
|
-
child.unref();
|
|
61076
|
-
if (child.pid !== void 0) if (process.platform === "win32") child.kill();
|
|
61077
|
-
else process.kill(-child.pid);
|
|
61078
|
-
},
|
|
61079
|
-
ready
|
|
61080
|
-
};
|
|
61081
|
-
}
|
|
61082
|
-
async function buildImage(dockerPath, options) {
|
|
61083
|
-
const { buildCmd, dockerfile } = await constructBuildCommand({
|
|
61084
|
-
tag: options.image_tag,
|
|
61085
|
-
pathToDockerfile: options.dockerfile,
|
|
61086
|
-
buildContext: options.image_build_context,
|
|
61087
|
-
args: options.image_vars,
|
|
61088
|
-
platform: "linux/amd64"
|
|
61089
|
-
});
|
|
61090
|
-
return dockerBuild(dockerPath, {
|
|
61091
|
-
buildCmd,
|
|
61092
|
-
dockerfile
|
|
61093
|
-
});
|
|
61094
|
-
}
|
|
61095
|
-
|
|
61096
|
-
//#endregion
|
|
61097
|
-
//#region ../containers-shared/src/login.ts
|
|
61098
|
-
function configureOpenAPIForContainerPull(accountId, apiToken, apiBase = "https://api.cloudflare.com/client/v4") {
|
|
61099
|
-
OpenAPI.BASE = `${apiBase}/accounts/${accountId}/containers`;
|
|
61100
|
-
OpenAPI.CREDENTIALS = "omit";
|
|
61101
|
-
OpenAPI.HEADERS = {
|
|
61102
|
-
...typeof OpenAPI.HEADERS === "object" ? OpenAPI.HEADERS : {},
|
|
61103
|
-
Authorization: `Bearer ${apiToken}`
|
|
61104
|
-
};
|
|
61105
|
-
}
|
|
61106
|
-
/**
|
|
61107
|
-
* Gets push and pull credentials for a configured image registry
|
|
61108
|
-
* and runs `docker login`, so subsequent image pushes or pulls are
|
|
61109
|
-
* authenticated
|
|
61110
|
-
*/
|
|
61111
|
-
async function dockerLoginImageRegistry(pathToDocker, domain) {
|
|
61112
|
-
const credentials = await ImageRegistriesService.generateImageRegistryCredentials(domain, {
|
|
61113
|
-
expiration_minutes: 15,
|
|
61114
|
-
permissions: [ImageRegistryPermissions.PUSH, ImageRegistryPermissions.PULL]
|
|
61115
|
-
});
|
|
61116
|
-
const child = spawn(pathToDocker, [
|
|
61117
|
-
"login",
|
|
61118
|
-
"--password-stdin",
|
|
61119
|
-
"--username",
|
|
61120
|
-
credentials.username,
|
|
61121
|
-
domain
|
|
61122
|
-
], { stdio: [
|
|
61123
|
-
"pipe",
|
|
61124
|
-
"inherit",
|
|
61125
|
-
"inherit"
|
|
61126
|
-
] }).on("error", (err) => {
|
|
61127
|
-
throw err;
|
|
61128
|
-
});
|
|
61129
|
-
child.stdin.write(credentials.password);
|
|
61130
|
-
child.stdin.end();
|
|
61131
|
-
await new Promise((resolve$4, reject) => {
|
|
61132
|
-
child.on("close", (code) => {
|
|
61133
|
-
if (code === 0) resolve$4();
|
|
61134
|
-
else reject(new UserError(`Login failed with code: ${code}`, { telemetryMessage: false }));
|
|
61135
|
-
});
|
|
61136
|
-
});
|
|
61137
|
-
}
|
|
61138
|
-
|
|
61139
|
-
//#endregion
|
|
61140
|
-
//#region ../containers-shared/src/registry.ts
|
|
61141
|
-
const MF_DEV_CONTAINER_PREFIX = "cloudflare-dev";
|
|
61142
|
-
|
|
61143
|
-
//#endregion
|
|
61144
|
-
//#region ../containers-shared/src/knobs.ts
|
|
61145
|
-
const getCloudflareContainerRegistry = () => {
|
|
61146
|
-
return process.env.CLOUDFLARE_CONTAINER_REGISTRY ?? (process.env.WRANGLER_API_ENVIRONMENT === "staging" ? "staging.registry.cloudflare.com" : "registry.cloudflare.com");
|
|
61147
|
-
};
|
|
61148
|
-
/** Prefixes with the cloudflare-dev namespace. The name should be the container's DO classname, and the tag a build uuid. */
|
|
61149
|
-
const getDevContainerImageName = (name, tag) => {
|
|
61150
|
-
return `${MF_DEV_CONTAINER_PREFIX}/${name.toLowerCase()}:${tag}`;
|
|
61151
|
-
};
|
|
61152
|
-
|
|
61153
61015
|
//#endregion
|
|
61154
61016
|
//#region ../containers-shared/src/inspect.ts
|
|
61155
61017
|
async function dockerImageInspect(dockerPath, options) {
|
|
@@ -61244,31 +61106,41 @@ const isDockerRunning = async (dockerPath) => {
|
|
|
61244
61106
|
* @throws {UserError} If the Docker CLI cannot be reached.
|
|
61245
61107
|
*
|
|
61246
61108
|
* @param options - Docker verification options.
|
|
61109
|
+
* @param options.dockerPath - Path to the Docker CLI executable.
|
|
61110
|
+
* @param options.operation - Optional human-readable operation description for the error message
|
|
61111
|
+
* headline. When provided, produces "before ${operation}". When omitted, the clause is skipped.
|
|
61112
|
+
* @param options.imageNoun - Noun describing what needs to be built (e.g. "the configured image").
|
|
61113
|
+
* @param options.hint - Optional context-specific hint appended to the error message.
|
|
61247
61114
|
*/
|
|
61248
|
-
const verifyDockerInstalled = async ({ dockerPath,
|
|
61115
|
+
const verifyDockerInstalled = async ({ dockerPath, operation, imageNoun, hint }) => {
|
|
61249
61116
|
if (!await isDockerRunning(dockerPath)) throw new UserError(getFailedToRunDockerErrorMessage({
|
|
61250
|
-
|
|
61251
|
-
|
|
61252
|
-
|
|
61117
|
+
operation,
|
|
61118
|
+
imageNoun,
|
|
61119
|
+
hint
|
|
61253
61120
|
}), { telemetryMessage: false });
|
|
61254
61121
|
};
|
|
61255
61122
|
/**
|
|
61256
61123
|
* Builds the user-facing error message shown when Docker cannot be reached.
|
|
61257
61124
|
*
|
|
61258
|
-
* @param options -
|
|
61125
|
+
* @param options - Options controlling the error message content.
|
|
61126
|
+
* @param options.operation - Optional human-readable operation description for the headline.
|
|
61127
|
+
* @param options.imageNoun - Noun describing what needs to be built.
|
|
61128
|
+
* @param options.hint - Optional context-specific hint paragraph.
|
|
61259
61129
|
*
|
|
61260
61130
|
* @returns The formatted error message string.
|
|
61261
61131
|
*/
|
|
61262
|
-
function getFailedToRunDockerErrorMessage({
|
|
61263
|
-
const headline = `The Docker CLI is needed to build
|
|
61132
|
+
function getFailedToRunDockerErrorMessage({ operation, imageNoun, hint }) {
|
|
61133
|
+
const headline = `The Docker CLI is needed to build ${imageNoun}${operation ? ` before ${operation}` : ""} but could not be launched.`;
|
|
61264
61134
|
let daemonHint;
|
|
61265
61135
|
if (process.platform === "darwin") daemonHint = "open the Docker Desktop app or run `open -a Docker`";
|
|
61266
61136
|
else if (process.platform === "win32") daemonHint = "open the Docker Desktop app";
|
|
61267
61137
|
else daemonHint = "run `sudo systemctl start docker`";
|
|
61268
|
-
|
|
61138
|
+
let message = `${headline}\n${`To fix this, try the following:
|
|
61269
61139
|
- If Docker is not installed, download it from https://docs.docker.com/get-started/get-docker/
|
|
61270
61140
|
- If Docker is installed but the daemon is not running,\n ${daemonHint}.\n - If you use an alternative Docker-compatible CLI (e.g. Podman),
|
|
61271
|
-
set the WRANGLER_DOCKER_BIN environment variable to its path and DOCKER_HOST to its socket.`}\n\nNote: Other container tooling that is compatible with the Docker CLI and engine may work, but is not yet guaranteed to do so
|
|
61141
|
+
set the WRANGLER_DOCKER_BIN environment variable to its path and DOCKER_HOST to its socket.`}\n\nNote: Other container tooling that is compatible with the Docker CLI and engine may work, but is not yet guaranteed to do so.`;
|
|
61142
|
+
if (hint) message += `\n\n${hint}`;
|
|
61143
|
+
return message;
|
|
61272
61144
|
}
|
|
61273
61145
|
/**
|
|
61274
61146
|
* Kills and removes any containers which come from the given image tag
|
|
@@ -61390,6 +61262,176 @@ function getImageTag(imageTag) {
|
|
|
61390
61262
|
return tagSeparatorIndex === -1 ? void 0 : imageTag.slice(tagSeparatorIndex + 1);
|
|
61391
61263
|
}
|
|
61392
61264
|
|
|
61265
|
+
//#endregion
|
|
61266
|
+
//#region ../containers-shared/src/build.ts
|
|
61267
|
+
async function constructBuildCommand(options, logger) {
|
|
61268
|
+
const platform$1 = options.platform ?? "linux/amd64";
|
|
61269
|
+
const buildCmd = [
|
|
61270
|
+
"build",
|
|
61271
|
+
"--load",
|
|
61272
|
+
"-t",
|
|
61273
|
+
options.tag,
|
|
61274
|
+
"--platform",
|
|
61275
|
+
platform$1,
|
|
61276
|
+
"--provenance=false"
|
|
61277
|
+
];
|
|
61278
|
+
if (options.args) for (const arg in options.args) buildCmd.push("--build-arg", `${arg}=${options.args[arg]}`);
|
|
61279
|
+
if (options.setNetworkToHost) buildCmd.push("--network", "host");
|
|
61280
|
+
const dockerfile = readFileSync(options.pathToDockerfile, "utf-8");
|
|
61281
|
+
buildCmd.push("-f", "-");
|
|
61282
|
+
buildCmd.push(options.buildContext);
|
|
61283
|
+
logger?.debug(`Building image with command: ${buildCmd.join(" ")}`);
|
|
61284
|
+
return {
|
|
61285
|
+
buildCmd,
|
|
61286
|
+
dockerfile
|
|
61287
|
+
};
|
|
61288
|
+
}
|
|
61289
|
+
/**
|
|
61290
|
+
* Spawns a Docker build process and returns a handle to abort or await the build.
|
|
61291
|
+
*
|
|
61292
|
+
* By default this function first verifies that the Docker daemon is reachable.
|
|
61293
|
+
* Callers that have already performed this check (e.g. the dev and deploy flows)
|
|
61294
|
+
* should pass `verifyDockerIsRunning: false` to avoid a redundant check.
|
|
61295
|
+
*
|
|
61296
|
+
* @param dockerPath - Path to the Docker CLI executable.
|
|
61297
|
+
* @param options - Build options including the command arguments and Dockerfile content.
|
|
61298
|
+
* @param options.buildCmd - The Docker build command arguments.
|
|
61299
|
+
* @param options.dockerfile - The Dockerfile content to pipe into stdin.
|
|
61300
|
+
* @param options.verifyDockerIsRunning - When `true` (the default), verifies Docker is installed
|
|
61301
|
+
* and the daemon is running before spawning the build. Set to `false` to skip the check.
|
|
61302
|
+
*
|
|
61303
|
+
* @returns An object with an `abort` function and a `ready` promise.
|
|
61304
|
+
*/
|
|
61305
|
+
async function dockerBuild(dockerPath, options) {
|
|
61306
|
+
if (options.verifyDockerIsRunning !== false) await verifyDockerInstalled({
|
|
61307
|
+
dockerPath,
|
|
61308
|
+
imageNoun: "the image"
|
|
61309
|
+
});
|
|
61310
|
+
let errorHandled = false;
|
|
61311
|
+
let resolve$4;
|
|
61312
|
+
let reject;
|
|
61313
|
+
const ready = new Promise((res, rej) => {
|
|
61314
|
+
resolve$4 = res;
|
|
61315
|
+
reject = rej;
|
|
61316
|
+
});
|
|
61317
|
+
const child = spawn(dockerPath, options.buildCmd, {
|
|
61318
|
+
stdio: [
|
|
61319
|
+
"pipe",
|
|
61320
|
+
"inherit",
|
|
61321
|
+
"inherit"
|
|
61322
|
+
],
|
|
61323
|
+
detached: process.platform !== "win32",
|
|
61324
|
+
windowsHide: true
|
|
61325
|
+
});
|
|
61326
|
+
if (child.stdin !== null) {
|
|
61327
|
+
child.stdin.write(options.dockerfile);
|
|
61328
|
+
child.stdin.end();
|
|
61329
|
+
}
|
|
61330
|
+
child.on("exit", (code) => {
|
|
61331
|
+
if (code === 0) resolve$4();
|
|
61332
|
+
else if (!errorHandled) {
|
|
61333
|
+
errorHandled = true;
|
|
61334
|
+
reject(new UserError(`Docker build exited with code: ${code}`, { telemetryMessage: false }));
|
|
61335
|
+
}
|
|
61336
|
+
});
|
|
61337
|
+
child.on("error", (err) => {
|
|
61338
|
+
if (!errorHandled) {
|
|
61339
|
+
errorHandled = true;
|
|
61340
|
+
reject(err);
|
|
61341
|
+
}
|
|
61342
|
+
});
|
|
61343
|
+
return {
|
|
61344
|
+
abort: () => {
|
|
61345
|
+
child.unref();
|
|
61346
|
+
if (child.pid !== void 0) if (process.platform === "win32") child.kill();
|
|
61347
|
+
else process.kill(-child.pid);
|
|
61348
|
+
},
|
|
61349
|
+
ready
|
|
61350
|
+
};
|
|
61351
|
+
}
|
|
61352
|
+
/**
|
|
61353
|
+
* Builds a container image from the given container dev options.
|
|
61354
|
+
*
|
|
61355
|
+
* @param dockerPath - Path to the Docker CLI executable.
|
|
61356
|
+
* @param options - Container configuration including the Dockerfile path, build context, and image tag.
|
|
61357
|
+
* @param verifyDockerIsRunning - When `true` (the default), verifies Docker is installed
|
|
61358
|
+
* and the daemon is running before building. Set to `false` when the caller has already
|
|
61359
|
+
* performed this check.
|
|
61360
|
+
*
|
|
61361
|
+
* @returns An object with an `abort` function and a `ready` promise.
|
|
61362
|
+
*/
|
|
61363
|
+
async function buildImage(dockerPath, options, verifyDockerIsRunning) {
|
|
61364
|
+
const { buildCmd, dockerfile } = await constructBuildCommand({
|
|
61365
|
+
tag: options.image_tag,
|
|
61366
|
+
pathToDockerfile: options.dockerfile,
|
|
61367
|
+
buildContext: options.image_build_context,
|
|
61368
|
+
args: options.image_vars,
|
|
61369
|
+
platform: "linux/amd64"
|
|
61370
|
+
});
|
|
61371
|
+
return dockerBuild(dockerPath, {
|
|
61372
|
+
buildCmd,
|
|
61373
|
+
dockerfile,
|
|
61374
|
+
verifyDockerIsRunning
|
|
61375
|
+
});
|
|
61376
|
+
}
|
|
61377
|
+
|
|
61378
|
+
//#endregion
|
|
61379
|
+
//#region ../containers-shared/src/login.ts
|
|
61380
|
+
function configureOpenAPIForContainerPull(accountId, apiToken, apiBase = "https://api.cloudflare.com/client/v4") {
|
|
61381
|
+
OpenAPI.BASE = `${apiBase}/accounts/${accountId}/containers`;
|
|
61382
|
+
OpenAPI.CREDENTIALS = "omit";
|
|
61383
|
+
OpenAPI.HEADERS = {
|
|
61384
|
+
...typeof OpenAPI.HEADERS === "object" ? OpenAPI.HEADERS : {},
|
|
61385
|
+
Authorization: `Bearer ${apiToken}`
|
|
61386
|
+
};
|
|
61387
|
+
}
|
|
61388
|
+
/**
|
|
61389
|
+
* Gets push and pull credentials for a configured image registry
|
|
61390
|
+
* and runs `docker login`, so subsequent image pushes or pulls are
|
|
61391
|
+
* authenticated
|
|
61392
|
+
*/
|
|
61393
|
+
async function dockerLoginImageRegistry(pathToDocker, domain) {
|
|
61394
|
+
const credentials = await ImageRegistriesService.generateImageRegistryCredentials(domain, {
|
|
61395
|
+
expiration_minutes: 15,
|
|
61396
|
+
permissions: [ImageRegistryPermissions.PUSH, ImageRegistryPermissions.PULL]
|
|
61397
|
+
});
|
|
61398
|
+
const child = spawn(pathToDocker, [
|
|
61399
|
+
"login",
|
|
61400
|
+
"--password-stdin",
|
|
61401
|
+
"--username",
|
|
61402
|
+
credentials.username,
|
|
61403
|
+
domain
|
|
61404
|
+
], { stdio: [
|
|
61405
|
+
"pipe",
|
|
61406
|
+
"inherit",
|
|
61407
|
+
"inherit"
|
|
61408
|
+
] }).on("error", (err) => {
|
|
61409
|
+
throw err;
|
|
61410
|
+
});
|
|
61411
|
+
child.stdin.write(credentials.password);
|
|
61412
|
+
child.stdin.end();
|
|
61413
|
+
await new Promise((resolve$4, reject) => {
|
|
61414
|
+
child.on("close", (code) => {
|
|
61415
|
+
if (code === 0) resolve$4();
|
|
61416
|
+
else reject(new UserError(`Login failed with code: ${code}`, { telemetryMessage: false }));
|
|
61417
|
+
});
|
|
61418
|
+
});
|
|
61419
|
+
}
|
|
61420
|
+
|
|
61421
|
+
//#endregion
|
|
61422
|
+
//#region ../containers-shared/src/registry.ts
|
|
61423
|
+
const MF_DEV_CONTAINER_PREFIX = "cloudflare-dev";
|
|
61424
|
+
|
|
61425
|
+
//#endregion
|
|
61426
|
+
//#region ../containers-shared/src/knobs.ts
|
|
61427
|
+
const getCloudflareContainerRegistry = () => {
|
|
61428
|
+
return process.env.CLOUDFLARE_CONTAINER_REGISTRY ?? (process.env.WRANGLER_API_ENVIRONMENT === "staging" ? "staging.registry.cloudflare.com" : "registry.cloudflare.com");
|
|
61429
|
+
};
|
|
61430
|
+
/** Prefixes with the cloudflare-dev namespace. The name should be the container's DO classname, and the tag a build uuid. */
|
|
61431
|
+
const getDevContainerImageName = (name, tag) => {
|
|
61432
|
+
return `${MF_DEV_CONTAINER_PREFIX}/${name.toLowerCase()}:${tag}`;
|
|
61433
|
+
};
|
|
61434
|
+
|
|
61393
61435
|
//#endregion
|
|
61394
61436
|
//#region ../containers-shared/src/images.ts
|
|
61395
61437
|
const DEFAULT_CONTAINER_EGRESS_INTERCEPTOR_IMAGE = "cloudflare/proxy-everything:3cb1195@sha256:0ef6716c52430096900b150d84a3302057d6cd2319dae7987128c85d0733e3c8";
|
|
@@ -61450,11 +61492,13 @@ async function prepareContainerImagesForDev(args) {
|
|
|
61450
61492
|
if (process.platform === "win32") throw new UserError("Local development with containers is currently not supported on Windows. You should use WSL instead. You can also set `enable_containers` to false if you do not need to develop the container part of your application.", { telemetryMessage: false });
|
|
61451
61493
|
await verifyDockerInstalled({
|
|
61452
61494
|
dockerPath,
|
|
61453
|
-
|
|
61495
|
+
operation: "running dev",
|
|
61496
|
+
imageNoun: containerOptions.length !== 1 ? "the configured images" : "the configured image",
|
|
61497
|
+
hint: "To suppress this error if you do not intend on triggering any container instances, set dev.enable_containers to false in your Wrangler config or pass --enable-containers=false."
|
|
61454
61498
|
});
|
|
61455
61499
|
for (const options of containerOptions) {
|
|
61456
61500
|
if ("dockerfile" in options) {
|
|
61457
|
-
const build$8 = await buildImage(dockerPath, options);
|
|
61501
|
+
const build$8 = await buildImage(dockerPath, options, false);
|
|
61458
61502
|
onContainerImagePreparationStart({
|
|
61459
61503
|
containerOptions: options,
|
|
61460
61504
|
abort: () => {
|
|
@@ -64980,19 +65024,13 @@ const outputConfigPlugin = createPlugin("output-config", (ctx) => {
|
|
|
64980
65024
|
assert(entryChunk, `Expected entry chunk with name "${MAIN_ENTRY_NAME}"`);
|
|
64981
65025
|
const isPrerenderWorker = this.environment.name === ctx.resolvedPluginConfig.prerenderWorkerEnvironmentName;
|
|
64982
65026
|
const isEntryWorker = ctx.resolvedPluginConfig.type === "workers" && this.environment.name === ctx.resolvedPluginConfig.entryWorkerEnvironmentName;
|
|
64983
|
-
outputConfig = {
|
|
64984
|
-
|
|
64985
|
-
|
|
64986
|
-
|
|
64987
|
-
|
|
64988
|
-
|
|
64989
|
-
|
|
64990
|
-
}],
|
|
64991
|
-
assets: isEntryWorker || isPrerenderWorker ? {
|
|
64992
|
-
...inputWorkerConfig.assets,
|
|
64993
|
-
directory: getAssetsDirectory(this.environment.config.build.outDir, ctx.resolvedViteConfig)
|
|
64994
|
-
} : void 0
|
|
64995
|
-
};
|
|
65027
|
+
outputConfig = getOutputConfig({
|
|
65028
|
+
inputWorkerConfig,
|
|
65029
|
+
workerOutputDirectory: this.environment.config.build.outDir,
|
|
65030
|
+
resolvedViteConfig: ctx.resolvedViteConfig,
|
|
65031
|
+
entryFileName: entryChunk.fileName,
|
|
65032
|
+
includeAssets: isEntryWorker || isPrerenderWorker
|
|
65033
|
+
});
|
|
64996
65034
|
if (inputWorkerConfig.upload_source_maps === void 0 && this.environment.config.build.sourcemap) outputConfig.upload_source_maps = true;
|
|
64997
65035
|
if (inputWorkerConfig.configPath) {
|
|
64998
65036
|
const localDevVars = getLocalDevVarsForPreview(inputWorkerConfig, ctx.resolvedPluginConfig.cloudflareEnv);
|
|
@@ -65035,6 +65073,40 @@ const outputConfigPlugin = createPlugin("output-config", (ctx) => {
|
|
|
65035
65073
|
}
|
|
65036
65074
|
};
|
|
65037
65075
|
});
|
|
65076
|
+
function getOutputConfig({ inputWorkerConfig, workerOutputDirectory, resolvedViteConfig, entryFileName, includeAssets }) {
|
|
65077
|
+
const sourceConfigDirectory = inputWorkerConfig.configPath ? nodePath.dirname(inputWorkerConfig.configPath) : resolvedViteConfig.root;
|
|
65078
|
+
const outputDirectory = nodePath.resolve(resolvedViteConfig.root, workerOutputDirectory);
|
|
65079
|
+
return {
|
|
65080
|
+
...inputWorkerConfig,
|
|
65081
|
+
main: entryFileName,
|
|
65082
|
+
no_bundle: true,
|
|
65083
|
+
rules: [{
|
|
65084
|
+
type: "ESModule",
|
|
65085
|
+
globs: ["**/*.js", "**/*.mjs"]
|
|
65086
|
+
}],
|
|
65087
|
+
assets: includeAssets ? {
|
|
65088
|
+
...inputWorkerConfig.assets,
|
|
65089
|
+
directory: getAssetsDirectory(workerOutputDirectory, resolvedViteConfig)
|
|
65090
|
+
} : void 0,
|
|
65091
|
+
d1_databases: inputWorkerConfig.d1_databases.map((database) => {
|
|
65092
|
+
const sourceMigrationsDir = database.migrations_dir ?? "migrations";
|
|
65093
|
+
const sourceMigrationsPath = nodePath.resolve(sourceConfigDirectory, sourceMigrationsDir);
|
|
65094
|
+
const outputMigrationsDir = vite.normalizePath(nodePath.relative(outputDirectory, sourceMigrationsPath) || ".");
|
|
65095
|
+
return {
|
|
65096
|
+
...database,
|
|
65097
|
+
migrations_dir: outputMigrationsDir,
|
|
65098
|
+
migrations_pattern: rewriteMigrationsPattern(database.migrations_pattern, sourceMigrationsDir, outputMigrationsDir)
|
|
65099
|
+
};
|
|
65100
|
+
})
|
|
65101
|
+
};
|
|
65102
|
+
}
|
|
65103
|
+
function rewriteMigrationsPattern(migrationsPattern, fromMigrationsDir, toMigrationsDir) {
|
|
65104
|
+
if (migrationsPattern === void 0) return;
|
|
65105
|
+
const normalizedDir = nodePath.posix.normalize(vite.normalizePath(fromMigrationsDir));
|
|
65106
|
+
const normalizedPattern = nodePath.posix.normalize(vite.normalizePath(migrationsPattern));
|
|
65107
|
+
const suffix = normalizedDir === "." ? normalizedPattern : nodePath.posix.relative(normalizedDir, normalizedPattern);
|
|
65108
|
+
return vite.normalizePath(nodePath.posix.normalize(toMigrationsDir === "." ? suffix : `${toMigrationsDir}/${suffix}`));
|
|
65109
|
+
}
|
|
65038
65110
|
function readAssetsIgnoreFile(assetsIgnorePath) {
|
|
65039
65111
|
const content = fs$1.existsSync(assetsIgnorePath) ? fs$1.readFileSync(assetsIgnorePath, "utf-8") : "";
|
|
65040
65112
|
if (content.length === 0) return "";
|