@cloudflare/vite-plugin 1.10.0 → 1.10.1
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.js +184 -203
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -248,17 +248,17 @@ var require_ignore = __commonJS({
|
|
|
248
248
|
var throwError = (message, Ctor) => {
|
|
249
249
|
throw new Ctor(message);
|
|
250
250
|
};
|
|
251
|
-
var checkPath = (
|
|
252
|
-
if (!isString2(
|
|
251
|
+
var checkPath = (path13, originalPath, doThrow) => {
|
|
252
|
+
if (!isString2(path13)) {
|
|
253
253
|
return doThrow(
|
|
254
254
|
`path must be a string, but got \`${originalPath}\``,
|
|
255
255
|
TypeError
|
|
256
256
|
);
|
|
257
257
|
}
|
|
258
|
-
if (!
|
|
258
|
+
if (!path13) {
|
|
259
259
|
return doThrow(`path must not be empty`, TypeError);
|
|
260
260
|
}
|
|
261
|
-
if (checkPath.isNotRelative(
|
|
261
|
+
if (checkPath.isNotRelative(path13)) {
|
|
262
262
|
const r2 = "`path.relative()`d";
|
|
263
263
|
return doThrow(
|
|
264
264
|
`path should be a ${r2} string, but got "${originalPath}"`,
|
|
@@ -267,7 +267,7 @@ var require_ignore = __commonJS({
|
|
|
267
267
|
}
|
|
268
268
|
return true;
|
|
269
269
|
};
|
|
270
|
-
var isNotRelative = (
|
|
270
|
+
var isNotRelative = (path13) => REGEX_TEST_INVALID_PATH.test(path13);
|
|
271
271
|
checkPath.isNotRelative = isNotRelative;
|
|
272
272
|
checkPath.convert = (p) => p;
|
|
273
273
|
var Ignore = class {
|
|
@@ -326,7 +326,7 @@ var require_ignore = __commonJS({
|
|
|
326
326
|
// setting `checkUnignored` to `false` could reduce additional
|
|
327
327
|
// path matching.
|
|
328
328
|
// @returns {TestResult} true if a file is ignored
|
|
329
|
-
_testOne(
|
|
329
|
+
_testOne(path13, checkUnignored) {
|
|
330
330
|
let ignored = false;
|
|
331
331
|
let unignored = false;
|
|
332
332
|
this._rules.forEach((rule) => {
|
|
@@ -334,7 +334,7 @@ var require_ignore = __commonJS({
|
|
|
334
334
|
if (unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored) {
|
|
335
335
|
return;
|
|
336
336
|
}
|
|
337
|
-
const matched = rule.regex.test(
|
|
337
|
+
const matched = rule.regex.test(path13);
|
|
338
338
|
if (matched) {
|
|
339
339
|
ignored = !negative;
|
|
340
340
|
unignored = negative;
|
|
@@ -347,24 +347,24 @@ var require_ignore = __commonJS({
|
|
|
347
347
|
}
|
|
348
348
|
// @returns {TestResult}
|
|
349
349
|
_test(originalPath, cache2, checkUnignored, slices) {
|
|
350
|
-
const
|
|
350
|
+
const path13 = originalPath && checkPath.convert(originalPath);
|
|
351
351
|
checkPath(
|
|
352
|
-
|
|
352
|
+
path13,
|
|
353
353
|
originalPath,
|
|
354
354
|
this._allowRelativePaths ? RETURN_FALSE : throwError
|
|
355
355
|
);
|
|
356
|
-
return this._t(
|
|
356
|
+
return this._t(path13, cache2, checkUnignored, slices);
|
|
357
357
|
}
|
|
358
|
-
_t(
|
|
359
|
-
if (
|
|
360
|
-
return cache2[
|
|
358
|
+
_t(path13, cache2, checkUnignored, slices) {
|
|
359
|
+
if (path13 in cache2) {
|
|
360
|
+
return cache2[path13];
|
|
361
361
|
}
|
|
362
362
|
if (!slices) {
|
|
363
|
-
slices =
|
|
363
|
+
slices = path13.split(SLASH);
|
|
364
364
|
}
|
|
365
365
|
slices.pop();
|
|
366
366
|
if (!slices.length) {
|
|
367
|
-
return cache2[
|
|
367
|
+
return cache2[path13] = this._testOne(path13, checkUnignored);
|
|
368
368
|
}
|
|
369
369
|
const parent = this._t(
|
|
370
370
|
slices.join(SLASH) + SLASH,
|
|
@@ -372,24 +372,24 @@ var require_ignore = __commonJS({
|
|
|
372
372
|
checkUnignored,
|
|
373
373
|
slices
|
|
374
374
|
);
|
|
375
|
-
return cache2[
|
|
375
|
+
return cache2[path13] = parent.ignored ? parent : this._testOne(path13, checkUnignored);
|
|
376
376
|
}
|
|
377
|
-
ignores(
|
|
378
|
-
return this._test(
|
|
377
|
+
ignores(path13) {
|
|
378
|
+
return this._test(path13, this._ignoreCache, false).ignored;
|
|
379
379
|
}
|
|
380
380
|
createFilter() {
|
|
381
|
-
return (
|
|
381
|
+
return (path13) => !this.ignores(path13);
|
|
382
382
|
}
|
|
383
383
|
filter(paths) {
|
|
384
384
|
return makeArray(paths).filter(this.createFilter());
|
|
385
385
|
}
|
|
386
386
|
// @returns {TestResult}
|
|
387
|
-
test(
|
|
388
|
-
return this._test(
|
|
387
|
+
test(path13) {
|
|
388
|
+
return this._test(path13, this._testCache, true);
|
|
389
389
|
}
|
|
390
390
|
};
|
|
391
391
|
var factory = (options) => new Ignore(options);
|
|
392
|
-
var isPathValid = (
|
|
392
|
+
var isPathValid = (path13) => checkPath(path13 && checkPath.convert(path13), path13, RETURN_FALSE);
|
|
393
393
|
factory.isPathValid = isPathValid;
|
|
394
394
|
factory.default = factory;
|
|
395
395
|
module.exports = factory;
|
|
@@ -400,7 +400,7 @@ var require_ignore = __commonJS({
|
|
|
400
400
|
const makePosix = (str) => /^\\\\\?\\/.test(str) || /["<>|\u0000-\u001F]+/u.test(str) ? str : str.replace(/\\/g, "/");
|
|
401
401
|
checkPath.convert = makePosix;
|
|
402
402
|
const REGIX_IS_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
|
|
403
|
-
checkPath.isNotRelative = (
|
|
403
|
+
checkPath.isNotRelative = (path13) => REGIX_IS_WINDOWS_PATH_ABSOLUTE.test(path13) || isNotRelative(path13);
|
|
404
404
|
}
|
|
405
405
|
}
|
|
406
406
|
});
|
|
@@ -443,11 +443,11 @@ var require_Mime = __commonJS({
|
|
|
443
443
|
}
|
|
444
444
|
}
|
|
445
445
|
};
|
|
446
|
-
Mime.prototype.getType = function(
|
|
447
|
-
|
|
448
|
-
let last =
|
|
446
|
+
Mime.prototype.getType = function(path13) {
|
|
447
|
+
path13 = String(path13);
|
|
448
|
+
let last = path13.replace(/^.*[/\\]/, "").toLowerCase();
|
|
449
449
|
let ext = last.replace(/^.*\./, "").toLowerCase();
|
|
450
|
-
let hasPath = last.length <
|
|
450
|
+
let hasPath = last.length < path13.length;
|
|
451
451
|
let hasDot = ext.length < last.length - 1;
|
|
452
452
|
return (hasDot || !hasPath) && this._types[ext] || null;
|
|
453
453
|
};
|
|
@@ -487,13 +487,12 @@ var require_mime = __commonJS({
|
|
|
487
487
|
// src/index.ts
|
|
488
488
|
import assert11 from "node:assert";
|
|
489
489
|
import * as fsp2 from "node:fs/promises";
|
|
490
|
-
import * as
|
|
490
|
+
import * as path12 from "node:path";
|
|
491
491
|
|
|
492
492
|
// ../containers-shared/src/build.ts
|
|
493
493
|
import { spawn } from "child_process";
|
|
494
494
|
import { readFileSync } from "fs";
|
|
495
|
-
|
|
496
|
-
async function constructBuildCommand(options, configPath, logger) {
|
|
495
|
+
async function constructBuildCommand(options, logger) {
|
|
497
496
|
const platform = options.platform ?? "linux/amd64";
|
|
498
497
|
const buildCmd = [
|
|
499
498
|
"build",
|
|
@@ -511,12 +510,9 @@ async function constructBuildCommand(options, configPath, logger) {
|
|
|
511
510
|
if (options.setNetworkToHost) {
|
|
512
511
|
buildCmd.push("--network", "host");
|
|
513
512
|
}
|
|
514
|
-
const
|
|
515
|
-
const absDockerfilePath = path.resolve(baseDir, options.pathToDockerfile);
|
|
516
|
-
const dockerfile = readFileSync(absDockerfilePath, "utf-8");
|
|
517
|
-
const absBuildContext = options.buildContext ? path.resolve(baseDir, options.buildContext) : path.dirname(absDockerfilePath);
|
|
513
|
+
const dockerfile = readFileSync(options.pathToDockerfile, "utf-8");
|
|
518
514
|
buildCmd.push("-f", "-");
|
|
519
|
-
buildCmd.push(
|
|
515
|
+
buildCmd.push(options.buildContext);
|
|
520
516
|
logger?.debug(`Building image with command: ${buildCmd.join(" ")}`);
|
|
521
517
|
return { buildCmd, dockerfile };
|
|
522
518
|
}
|
|
@@ -563,17 +559,14 @@ function dockerBuild(dockerPath, options) {
|
|
|
563
559
|
ready
|
|
564
560
|
};
|
|
565
561
|
}
|
|
566
|
-
async function buildImage(dockerPath, options
|
|
567
|
-
const { buildCmd, dockerfile } = await constructBuildCommand(
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
},
|
|
575
|
-
configPath
|
|
576
|
-
);
|
|
562
|
+
async function buildImage(dockerPath, options) {
|
|
563
|
+
const { buildCmd, dockerfile } = await constructBuildCommand({
|
|
564
|
+
tag: options.image_tag,
|
|
565
|
+
pathToDockerfile: options.dockerfile,
|
|
566
|
+
buildContext: options.image_build_context,
|
|
567
|
+
args: options.image_vars,
|
|
568
|
+
platform: "linux/amd64"
|
|
569
|
+
});
|
|
577
570
|
return dockerBuild(dockerPath, { buildCmd, dockerfile });
|
|
578
571
|
}
|
|
579
572
|
|
|
@@ -957,13 +950,13 @@ var getQueryString = (params) => {
|
|
|
957
950
|
};
|
|
958
951
|
var getUrl = (config, options) => {
|
|
959
952
|
const encoder = config.ENCODE_PATH || encodeURI;
|
|
960
|
-
const
|
|
953
|
+
const path13 = options.url.replace("{api-version}", config.VERSION).replace(/{(.*?)}/g, (substring, group) => {
|
|
961
954
|
if (options.path?.hasOwnProperty(group)) {
|
|
962
955
|
return encoder(String(options.path[group]));
|
|
963
956
|
}
|
|
964
957
|
return substring;
|
|
965
958
|
});
|
|
966
|
-
const url = `${config.BASE}${
|
|
959
|
+
const url = `${config.BASE}${path13}`;
|
|
967
960
|
if (options.query) {
|
|
968
961
|
return `${url}${getQueryString(options.query)}`;
|
|
969
962
|
}
|
|
@@ -1381,7 +1374,7 @@ async function dockerLoginManagedRegistry(pathToDocker) {
|
|
|
1381
1374
|
import { execFile, spawn as spawn4 } from "child_process";
|
|
1382
1375
|
import { randomUUID } from "crypto";
|
|
1383
1376
|
import { existsSync, statSync } from "fs";
|
|
1384
|
-
import
|
|
1377
|
+
import path from "path";
|
|
1385
1378
|
|
|
1386
1379
|
// ../containers-shared/src/inspect.ts
|
|
1387
1380
|
import { spawn as spawn3 } from "child_process";
|
|
@@ -1450,7 +1443,7 @@ var runDockerCmd = (dockerPath, args, stdio) => {
|
|
|
1450
1443
|
}
|
|
1451
1444
|
},
|
|
1452
1445
|
ready,
|
|
1453
|
-
then: async (
|
|
1446
|
+
then: async (onResolve, onReject) => ready.then(onResolve).catch(onReject)
|
|
1454
1447
|
};
|
|
1455
1448
|
};
|
|
1456
1449
|
var runDockerCmdWithOutput = async (dockerPath, args) => {
|
|
@@ -1477,13 +1470,13 @@ Other container tooling that is compatible with the Docker CLI and engine may wo
|
|
|
1477
1470
|
);
|
|
1478
1471
|
}
|
|
1479
1472
|
};
|
|
1480
|
-
function isDir(
|
|
1481
|
-
const stats = statSync(
|
|
1473
|
+
function isDir(inputPath) {
|
|
1474
|
+
const stats = statSync(inputPath);
|
|
1482
1475
|
return stats.isDirectory();
|
|
1483
1476
|
}
|
|
1484
1477
|
var isDockerfile = (image, configPath) => {
|
|
1485
|
-
const baseDir = configPath ?
|
|
1486
|
-
const maybeDockerfile =
|
|
1478
|
+
const baseDir = configPath ? path.dirname(configPath) : process.cwd();
|
|
1479
|
+
const maybeDockerfile = path.resolve(baseDir, image);
|
|
1487
1480
|
if (existsSync(maybeDockerfile)) {
|
|
1488
1481
|
if (isDir(maybeDockerfile)) {
|
|
1489
1482
|
throw new Error(
|
|
@@ -1539,7 +1532,7 @@ var getContainerIdsFromImage = async (dockerPath, ancestorImage) => {
|
|
|
1539
1532
|
};
|
|
1540
1533
|
async function checkExposedPorts(dockerPath, options) {
|
|
1541
1534
|
const output = await dockerImageInspect(dockerPath, {
|
|
1542
|
-
imageTag: options.
|
|
1535
|
+
imageTag: options.image_tag,
|
|
1543
1536
|
formatString: "{{ len .Config.ExposedPorts }}"
|
|
1544
1537
|
});
|
|
1545
1538
|
if (output === "0") {
|
|
@@ -1559,14 +1552,18 @@ async function pullImage(dockerPath, options) {
|
|
|
1559
1552
|
await dockerLoginManagedRegistry(dockerPath);
|
|
1560
1553
|
const pull = runDockerCmd(dockerPath, [
|
|
1561
1554
|
"pull",
|
|
1562
|
-
options.
|
|
1555
|
+
options.image_uri,
|
|
1563
1556
|
// All containers running on our platform need to be built for amd64 architecture, but by default docker pull seems to look for an image matching the host system, so we need to specify this here
|
|
1564
1557
|
"--platform",
|
|
1565
1558
|
"linux/amd64"
|
|
1566
1559
|
]);
|
|
1567
1560
|
const ready = pull.ready.then(async ({ aborted }) => {
|
|
1568
1561
|
if (!aborted) {
|
|
1569
|
-
await runDockerCmd(dockerPath, [
|
|
1562
|
+
await runDockerCmd(dockerPath, [
|
|
1563
|
+
"tag",
|
|
1564
|
+
options.image_uri,
|
|
1565
|
+
options.image_tag
|
|
1566
|
+
]);
|
|
1570
1567
|
}
|
|
1571
1568
|
});
|
|
1572
1569
|
return {
|
|
@@ -1576,14 +1573,13 @@ async function pullImage(dockerPath, options) {
|
|
|
1576
1573
|
ready
|
|
1577
1574
|
};
|
|
1578
1575
|
}
|
|
1579
|
-
async function prepareContainerImagesForDev(
|
|
1576
|
+
async function prepareContainerImagesForDev(args) {
|
|
1580
1577
|
const {
|
|
1581
1578
|
dockerPath,
|
|
1582
|
-
configPath,
|
|
1583
1579
|
containerOptions,
|
|
1584
1580
|
onContainerImagePreparationStart,
|
|
1585
1581
|
onContainerImagePreparationEnd
|
|
1586
|
-
} =
|
|
1582
|
+
} = args;
|
|
1587
1583
|
let aborted = false;
|
|
1588
1584
|
if (process.platform === "win32") {
|
|
1589
1585
|
throw new Error(
|
|
@@ -1591,11 +1587,11 @@ async function prepareContainerImagesForDev(options) {
|
|
|
1591
1587
|
);
|
|
1592
1588
|
}
|
|
1593
1589
|
await verifyDockerInstalled(dockerPath);
|
|
1594
|
-
for (const
|
|
1595
|
-
if (
|
|
1596
|
-
const build = await buildImage(dockerPath,
|
|
1590
|
+
for (const options of containerOptions) {
|
|
1591
|
+
if ("dockerfile" in options) {
|
|
1592
|
+
const build = await buildImage(dockerPath, options);
|
|
1597
1593
|
onContainerImagePreparationStart({
|
|
1598
|
-
containerOptions:
|
|
1594
|
+
containerOptions: options,
|
|
1599
1595
|
abort: () => {
|
|
1600
1596
|
aborted = true;
|
|
1601
1597
|
build.abort();
|
|
@@ -1603,18 +1599,18 @@ async function prepareContainerImagesForDev(options) {
|
|
|
1603
1599
|
});
|
|
1604
1600
|
await build.ready;
|
|
1605
1601
|
onContainerImagePreparationEnd({
|
|
1606
|
-
containerOptions:
|
|
1602
|
+
containerOptions: options
|
|
1607
1603
|
});
|
|
1608
1604
|
} else {
|
|
1609
|
-
if (!isCloudflareRegistryLink(
|
|
1605
|
+
if (!isCloudflareRegistryLink(options.image_uri)) {
|
|
1610
1606
|
throw new Error(
|
|
1611
|
-
`Image "${
|
|
1607
|
+
`Image "${options.image_uri}" is a registry link but does not point to the Cloudflare container registry.
|
|
1612
1608
|
To use an existing image from another repository, see https://developers.cloudflare.com/containers/image-management/#using-existing-images`
|
|
1613
1609
|
);
|
|
1614
1610
|
}
|
|
1615
|
-
const pull = await pullImage(dockerPath,
|
|
1611
|
+
const pull = await pullImage(dockerPath, options);
|
|
1616
1612
|
onContainerImagePreparationStart({
|
|
1617
|
-
containerOptions:
|
|
1613
|
+
containerOptions: options,
|
|
1618
1614
|
abort: () => {
|
|
1619
1615
|
aborted = true;
|
|
1620
1616
|
pull.abort();
|
|
@@ -1622,11 +1618,11 @@ To use an existing image from another repository, see https://developers.cloudfl
|
|
|
1622
1618
|
});
|
|
1623
1619
|
await pull.ready;
|
|
1624
1620
|
onContainerImagePreparationEnd({
|
|
1625
|
-
containerOptions:
|
|
1621
|
+
containerOptions: options
|
|
1626
1622
|
});
|
|
1627
1623
|
}
|
|
1628
1624
|
if (!aborted) {
|
|
1629
|
-
await checkExposedPorts(dockerPath,
|
|
1625
|
+
await checkExposedPorts(dockerPath, options);
|
|
1630
1626
|
}
|
|
1631
1627
|
}
|
|
1632
1628
|
}
|
|
@@ -2761,7 +2757,7 @@ function createModuleReference(type, id) {
|
|
|
2761
2757
|
}
|
|
2762
2758
|
|
|
2763
2759
|
// src/asset-config.ts
|
|
2764
|
-
import * as
|
|
2760
|
+
import * as path2 from "node:path";
|
|
2765
2761
|
|
|
2766
2762
|
// ../workers-shared/utils/configuration/constructConfiguration.ts
|
|
2767
2763
|
import { relative } from "node:path";
|
|
@@ -2897,11 +2893,11 @@ ${invalidHeaderRulesList}`
|
|
|
2897
2893
|
}
|
|
2898
2894
|
|
|
2899
2895
|
// ../workers-shared/utils/configuration/validateURL.ts
|
|
2900
|
-
var extractPathname = (
|
|
2901
|
-
if (!
|
|
2902
|
-
|
|
2896
|
+
var extractPathname = (path13 = "/", includeSearch, includeHash) => {
|
|
2897
|
+
if (!path13.startsWith("/")) {
|
|
2898
|
+
path13 = `/${path13}`;
|
|
2903
2899
|
}
|
|
2904
|
-
const url = new URL(`//${
|
|
2900
|
+
const url = new URL(`//${path13}`, "relative://");
|
|
2905
2901
|
return `${url.pathname}${includeSearch ? url.search : ""}${includeHash ? url.hash : ""}`;
|
|
2906
2902
|
};
|
|
2907
2903
|
var URL_REGEX = /^https:\/\/+(?<host>[^/]+)\/?(?<path>.*)/;
|
|
@@ -2934,8 +2930,8 @@ var validateUrl = (token, onlyRelative = false, disallowPorts = false, includeSe
|
|
|
2934
2930
|
if (!token.startsWith("/") && onlyRelative) {
|
|
2935
2931
|
token = `/${token}`;
|
|
2936
2932
|
}
|
|
2937
|
-
const
|
|
2938
|
-
if (
|
|
2933
|
+
const path13 = PATH_REGEX.exec(token);
|
|
2934
|
+
if (path13) {
|
|
2939
2935
|
try {
|
|
2940
2936
|
return [extractPathname(token, includeSearch, includeHash), void 0];
|
|
2941
2937
|
} catch {
|
|
@@ -2996,7 +2992,7 @@ function parseHeaders(input, {
|
|
|
2996
2992
|
});
|
|
2997
2993
|
}
|
|
2998
2994
|
}
|
|
2999
|
-
const [
|
|
2995
|
+
const [path13, pathError] = validateUrl(line, false, true);
|
|
3000
2996
|
if (pathError) {
|
|
3001
2997
|
invalid.push({
|
|
3002
2998
|
line,
|
|
@@ -3007,7 +3003,7 @@ function parseHeaders(input, {
|
|
|
3007
3003
|
continue;
|
|
3008
3004
|
}
|
|
3009
3005
|
rule = {
|
|
3010
|
-
path:
|
|
3006
|
+
path: path13,
|
|
3011
3007
|
line,
|
|
3012
3008
|
headers: {},
|
|
3013
3009
|
unsetHeaders: []
|
|
@@ -3582,8 +3578,8 @@ function getErrorMap() {
|
|
|
3582
3578
|
return overrideErrorMap;
|
|
3583
3579
|
}
|
|
3584
3580
|
var makeIssue = (params) => {
|
|
3585
|
-
const { data: data2, path:
|
|
3586
|
-
const fullPath = [...
|
|
3581
|
+
const { data: data2, path: path13, errorMaps, issueData } = params;
|
|
3582
|
+
const fullPath = [...path13, ...issueData.path || []];
|
|
3587
3583
|
const fullIssue = {
|
|
3588
3584
|
...issueData,
|
|
3589
3585
|
path: fullPath
|
|
@@ -3682,11 +3678,11 @@ var errorUtil;
|
|
|
3682
3678
|
errorUtil2.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message;
|
|
3683
3679
|
})(errorUtil || (errorUtil = {}));
|
|
3684
3680
|
var ParseInputLazyPath = class {
|
|
3685
|
-
constructor(parent, value,
|
|
3681
|
+
constructor(parent, value, path13, key) {
|
|
3686
3682
|
this._cachedPath = [];
|
|
3687
3683
|
this.parent = parent;
|
|
3688
3684
|
this.data = value;
|
|
3689
|
-
this._path =
|
|
3685
|
+
this._path = path13;
|
|
3690
3686
|
this._key = key;
|
|
3691
3687
|
}
|
|
3692
3688
|
get path() {
|
|
@@ -7082,22 +7078,22 @@ function getAssetsConfig(resolvedPluginConfig, entryWorkerConfig, resolvedConfig
|
|
|
7082
7078
|
};
|
|
7083
7079
|
}
|
|
7084
7080
|
function getRedirectsConfigPath(config) {
|
|
7085
|
-
return
|
|
7081
|
+
return path2.join(config.publicDir, REDIRECTS_FILENAME);
|
|
7086
7082
|
}
|
|
7087
7083
|
function getHeadersConfigPath(config) {
|
|
7088
|
-
return
|
|
7084
|
+
return path2.join(config.publicDir, HEADERS_FILENAME);
|
|
7089
7085
|
}
|
|
7090
7086
|
|
|
7091
7087
|
// src/build.ts
|
|
7092
7088
|
import assert from "node:assert";
|
|
7093
7089
|
import * as fs from "node:fs";
|
|
7094
|
-
import * as
|
|
7090
|
+
import * as path3 from "node:path";
|
|
7095
7091
|
import colors from "picocolors";
|
|
7096
7092
|
function createBuildApp(resolvedPluginConfig) {
|
|
7097
7093
|
return async (builder) => {
|
|
7098
7094
|
const clientEnvironment = builder.environments.client;
|
|
7099
7095
|
assert(clientEnvironment, `No "client" environment`);
|
|
7100
|
-
const defaultHtmlPath =
|
|
7096
|
+
const defaultHtmlPath = path3.resolve(builder.config.root, "index.html");
|
|
7101
7097
|
const hasClientEntry = clientEnvironment.config.build.rollupOptions.input || fs.existsSync(defaultHtmlPath);
|
|
7102
7098
|
if (resolvedPluginConfig.type === "assets-only") {
|
|
7103
7099
|
if (hasClientEntry) {
|
|
@@ -7123,7 +7119,7 @@ function createBuildApp(resolvedPluginConfig) {
|
|
|
7123
7119
|
entryWorkerEnvironment,
|
|
7124
7120
|
`No "${entryWorkerEnvironmentName}" environment`
|
|
7125
7121
|
);
|
|
7126
|
-
const entryWorkerBuildDirectory =
|
|
7122
|
+
const entryWorkerBuildDirectory = path3.resolve(
|
|
7127
7123
|
builder.config.root,
|
|
7128
7124
|
entryWorkerEnvironment.config.build.outDir
|
|
7129
7125
|
);
|
|
@@ -7134,7 +7130,7 @@ function createBuildApp(resolvedPluginConfig) {
|
|
|
7134
7130
|
} else if (importedAssetPaths.size || getHasPublicAssets(builder.config)) {
|
|
7135
7131
|
await fallbackBuild(builder, clientEnvironment);
|
|
7136
7132
|
} else {
|
|
7137
|
-
const entryWorkerConfigPath =
|
|
7133
|
+
const entryWorkerConfigPath = path3.join(
|
|
7138
7134
|
entryWorkerBuildDirectory,
|
|
7139
7135
|
"wrangler.json"
|
|
7140
7136
|
);
|
|
@@ -7145,21 +7141,21 @@ function createBuildApp(resolvedPluginConfig) {
|
|
|
7145
7141
|
fs.writeFileSync(entryWorkerConfigPath, JSON.stringify(workerConfig));
|
|
7146
7142
|
return;
|
|
7147
7143
|
}
|
|
7148
|
-
const clientBuildDirectory =
|
|
7144
|
+
const clientBuildDirectory = path3.resolve(
|
|
7149
7145
|
builder.config.root,
|
|
7150
7146
|
clientEnvironment.config.build.outDir
|
|
7151
7147
|
);
|
|
7152
7148
|
const movedAssetPaths = [];
|
|
7153
7149
|
for (const assetPath of importedAssetPaths) {
|
|
7154
|
-
const src =
|
|
7155
|
-
const dest =
|
|
7150
|
+
const src = path3.join(entryWorkerBuildDirectory, assetPath);
|
|
7151
|
+
const dest = path3.join(clientBuildDirectory, assetPath);
|
|
7156
7152
|
if (!fs.existsSync(src)) {
|
|
7157
7153
|
continue;
|
|
7158
7154
|
}
|
|
7159
7155
|
if (fs.existsSync(dest)) {
|
|
7160
7156
|
fs.unlinkSync(src);
|
|
7161
7157
|
} else {
|
|
7162
|
-
const destDir =
|
|
7158
|
+
const destDir = path3.dirname(dest);
|
|
7163
7159
|
fs.mkdirSync(destDir, { recursive: true });
|
|
7164
7160
|
fs.renameSync(src, dest);
|
|
7165
7161
|
movedAssetPaths.push(dest);
|
|
@@ -7170,7 +7166,7 @@ function createBuildApp(resolvedPluginConfig) {
|
|
|
7170
7166
|
[
|
|
7171
7167
|
`${colors.green("\u2713")} ${movedAssetPaths.length} asset${movedAssetPaths.length > 1 ? "s" : ""} moved from "${entryWorkerEnvironmentName}" to "client" build output.`,
|
|
7172
7168
|
...movedAssetPaths.map(
|
|
7173
|
-
(assetPath) => colors.dim(
|
|
7169
|
+
(assetPath) => colors.dim(path3.relative(builder.config.root, assetPath))
|
|
7174
7170
|
)
|
|
7175
7171
|
].join("\n")
|
|
7176
7172
|
);
|
|
@@ -7200,7 +7196,7 @@ async function fallbackBuild(builder, environment) {
|
|
|
7200
7196
|
}
|
|
7201
7197
|
};
|
|
7202
7198
|
await builder.build(environment);
|
|
7203
|
-
const fallbackEntryPath =
|
|
7199
|
+
const fallbackEntryPath = path3.resolve(
|
|
7204
7200
|
builder.config.root,
|
|
7205
7201
|
environment.config.build.outDir,
|
|
7206
7202
|
fallbackEntryName
|
|
@@ -7209,7 +7205,7 @@ async function fallbackBuild(builder, environment) {
|
|
|
7209
7205
|
}
|
|
7210
7206
|
function loadViteManifest(directory) {
|
|
7211
7207
|
const contents = fs.readFileSync(
|
|
7212
|
-
|
|
7208
|
+
path3.resolve(directory, ".vite", "manifest.json"),
|
|
7213
7209
|
"utf-8"
|
|
7214
7210
|
);
|
|
7215
7211
|
return JSON.parse(contents);
|
|
@@ -7228,7 +7224,7 @@ import * as vite2 from "vite";
|
|
|
7228
7224
|
// src/node-js-compat.ts
|
|
7229
7225
|
import assert3 from "node:assert";
|
|
7230
7226
|
import { builtinModules as builtinModules2 } from "node:module";
|
|
7231
|
-
import
|
|
7227
|
+
import path5 from "node:path";
|
|
7232
7228
|
import { cloudflare } from "@cloudflare/unenv-preset";
|
|
7233
7229
|
import { getNodeCompat } from "miniflare";
|
|
7234
7230
|
|
|
@@ -12780,17 +12776,17 @@ function withTrailingSlash(input = "", respectQueryAndFragment) {
|
|
|
12780
12776
|
if (hasTrailingSlash(input, true)) {
|
|
12781
12777
|
return input || "/";
|
|
12782
12778
|
}
|
|
12783
|
-
let
|
|
12779
|
+
let path13 = input;
|
|
12784
12780
|
let fragment = "";
|
|
12785
12781
|
const fragmentIndex = input.indexOf("#");
|
|
12786
12782
|
if (fragmentIndex >= 0) {
|
|
12787
|
-
|
|
12783
|
+
path13 = input.slice(0, fragmentIndex);
|
|
12788
12784
|
fragment = input.slice(fragmentIndex);
|
|
12789
|
-
if (!
|
|
12785
|
+
if (!path13) {
|
|
12790
12786
|
return fragment;
|
|
12791
12787
|
}
|
|
12792
12788
|
}
|
|
12793
|
-
const [s0, ...s] =
|
|
12789
|
+
const [s0, ...s] = path13.split("?");
|
|
12794
12790
|
return s0 + "/" + (s.length > 0 ? `?${s.join("?")}` : "") + fragment;
|
|
12795
12791
|
}
|
|
12796
12792
|
function isNonEmptyURL(url) {
|
|
@@ -12820,12 +12816,12 @@ var isAbsolute = function(p) {
|
|
|
12820
12816
|
import { fileURLToPath as fileURLToPath$1, URL as URL$1, pathToFileURL as pathToFileURL$1 } from "node:url";
|
|
12821
12817
|
import assert2 from "node:assert";
|
|
12822
12818
|
import process$1 from "node:process";
|
|
12823
|
-
import
|
|
12819
|
+
import path4, { dirname as dirname3 } from "node:path";
|
|
12824
12820
|
import v8 from "node:v8";
|
|
12825
12821
|
import { format as format2, inspect } from "node:util";
|
|
12826
12822
|
var BUILTIN_MODULES = new Set(builtinModules);
|
|
12827
|
-
function normalizeSlash(
|
|
12828
|
-
return
|
|
12823
|
+
function normalizeSlash(path13) {
|
|
12824
|
+
return path13.replace(/\\/g, "/");
|
|
12829
12825
|
}
|
|
12830
12826
|
var own$1 = {}.hasOwnProperty;
|
|
12831
12827
|
var classRegExp = /^([A-Z][a-z\d]*)+$/;
|
|
@@ -12938,8 +12934,8 @@ codes.ERR_INVALID_PACKAGE_CONFIG = createError(
|
|
|
12938
12934
|
* @param {string} [base]
|
|
12939
12935
|
* @param {string} [message]
|
|
12940
12936
|
*/
|
|
12941
|
-
(
|
|
12942
|
-
return `Invalid package config ${
|
|
12937
|
+
(path13, base, message) => {
|
|
12938
|
+
return `Invalid package config ${path13}${base ? ` while importing ${base}` : ""}${message ? `. ${message}` : ""}`;
|
|
12943
12939
|
},
|
|
12944
12940
|
Error
|
|
12945
12941
|
);
|
|
@@ -12971,8 +12967,8 @@ codes.ERR_MODULE_NOT_FOUND = createError(
|
|
|
12971
12967
|
* @param {string} base
|
|
12972
12968
|
* @param {boolean} [exactUrl]
|
|
12973
12969
|
*/
|
|
12974
|
-
(
|
|
12975
|
-
return `Cannot find ${exactUrl ? "module" : "package"} '${
|
|
12970
|
+
(path13, base, exactUrl = false) => {
|
|
12971
|
+
return `Cannot find ${exactUrl ? "module" : "package"} '${path13}' imported from ${base}`;
|
|
12976
12972
|
},
|
|
12977
12973
|
Error
|
|
12978
12974
|
);
|
|
@@ -13023,8 +13019,8 @@ codes.ERR_UNKNOWN_FILE_EXTENSION = createError(
|
|
|
13023
13019
|
* @param {string} extension
|
|
13024
13020
|
* @param {string} path
|
|
13025
13021
|
*/
|
|
13026
|
-
(extension,
|
|
13027
|
-
return `Unknown file extension "${extension}" for ${
|
|
13022
|
+
(extension, path13) => {
|
|
13023
|
+
return `Unknown file extension "${extension}" for ${path13}`;
|
|
13028
13024
|
},
|
|
13029
13025
|
TypeError
|
|
13030
13026
|
);
|
|
@@ -13169,7 +13165,7 @@ function read(jsonPath, { base, specifier }) {
|
|
|
13169
13165
|
}
|
|
13170
13166
|
let string;
|
|
13171
13167
|
try {
|
|
13172
|
-
string = fs2.readFileSync(
|
|
13168
|
+
string = fs2.readFileSync(path4.toNamespacedPath(jsonPath), "utf8");
|
|
13173
13169
|
} catch (error) {
|
|
13174
13170
|
const exception = (
|
|
13175
13171
|
/** @type {ErrnoException} */
|
|
@@ -13385,7 +13381,7 @@ Default "index" lookups for the main are deprecated for ES modules.`,
|
|
|
13385
13381
|
"DeprecationWarning",
|
|
13386
13382
|
"DEP0151"
|
|
13387
13383
|
);
|
|
13388
|
-
} else if (
|
|
13384
|
+
} else if (path4.resolve(packagePath, main) !== urlPath) {
|
|
13389
13385
|
process$1.emitWarning(
|
|
13390
13386
|
`Package ${packagePath} has a "main" field set to "${main}", excluding the full filename and extension to the resolved file at "${urlPath.slice(
|
|
13391
13387
|
packagePath.length
|
|
@@ -13396,9 +13392,9 @@ Default "index" lookups for the main are deprecated for ES modules.`,
|
|
|
13396
13392
|
);
|
|
13397
13393
|
}
|
|
13398
13394
|
}
|
|
13399
|
-
function tryStatSync(
|
|
13395
|
+
function tryStatSync(path13) {
|
|
13400
13396
|
try {
|
|
13401
|
-
return statSync2(
|
|
13397
|
+
return statSync2(path13);
|
|
13402
13398
|
} catch {
|
|
13403
13399
|
}
|
|
13404
13400
|
}
|
|
@@ -13492,7 +13488,7 @@ function finalizeResolution(resolved, base, preserveSymlinks) {
|
|
|
13492
13488
|
{
|
|
13493
13489
|
const real = realpathSync(filePath);
|
|
13494
13490
|
const { search, hash } = resolved;
|
|
13495
|
-
resolved = pathToFileURL$1(real + (filePath.endsWith(
|
|
13491
|
+
resolved = pathToFileURL$1(real + (filePath.endsWith(path4.sep) ? "/" : ""));
|
|
13496
13492
|
resolved.search = search;
|
|
13497
13493
|
resolved.hash = hash;
|
|
13498
13494
|
}
|
|
@@ -14203,8 +14199,8 @@ function isNodeAls(workerConfig) {
|
|
|
14203
14199
|
workerConfig.compatibility_flags ?? []
|
|
14204
14200
|
).mode === "als";
|
|
14205
14201
|
}
|
|
14206
|
-
function isNodeAlsModule(
|
|
14207
|
-
return /^(node:)?async_hooks$/.test(
|
|
14202
|
+
function isNodeAlsModule(path13) {
|
|
14203
|
+
return /^(node:)?async_hooks$/.test(path13);
|
|
14208
14204
|
}
|
|
14209
14205
|
var injectsByModule = /* @__PURE__ */ new Map();
|
|
14210
14206
|
var virtualModulePathToSpecifier = /* @__PURE__ */ new Map();
|
|
@@ -14311,7 +14307,7 @@ var NodeJsCompatWarnings = class {
|
|
|
14311
14307
|
`;
|
|
14312
14308
|
this.sources.forEach((importers, source) => {
|
|
14313
14309
|
importers.forEach((importer) => {
|
|
14314
|
-
message += ` - "${source}" imported from "${
|
|
14310
|
+
message += ` - "${source}" imported from "${path5.relative(this.resolvedViteConfig.root, importer)}"
|
|
14315
14311
|
`;
|
|
14316
14312
|
});
|
|
14317
14313
|
});
|
|
@@ -14335,7 +14331,7 @@ var additionalModuleGlobalRE = new RegExp(
|
|
|
14335
14331
|
var VITE_DEV_METADATA_HEADER = "__VITE_DEV_METADATA__";
|
|
14336
14332
|
|
|
14337
14333
|
// src/utils.ts
|
|
14338
|
-
import * as
|
|
14334
|
+
import * as path6 from "node:path";
|
|
14339
14335
|
import { createRequest, sendResponse } from "@mjackson/node-fetch-server";
|
|
14340
14336
|
import {
|
|
14341
14337
|
Request as MiniflareRequest,
|
|
@@ -14343,14 +14339,14 @@ import {
|
|
|
14343
14339
|
} from "miniflare";
|
|
14344
14340
|
function getOutputDirectory(userConfig, environmentName) {
|
|
14345
14341
|
const rootOutputDirectory = userConfig.build?.outDir ?? "dist";
|
|
14346
|
-
return userConfig.environments?.[environmentName]?.build?.outDir ??
|
|
14342
|
+
return userConfig.environments?.[environmentName]?.build?.outDir ?? path6.join(rootOutputDirectory, environmentName);
|
|
14347
14343
|
}
|
|
14348
14344
|
var postfixRE = /[?#].*$/;
|
|
14349
14345
|
function cleanUrl(url) {
|
|
14350
14346
|
return url.replace(postfixRE, "");
|
|
14351
14347
|
}
|
|
14352
|
-
function withTrailingSlash2(
|
|
14353
|
-
return
|
|
14348
|
+
function withTrailingSlash2(path13) {
|
|
14349
|
+
return path13.endsWith("/") ? path13 : `${path13}/`;
|
|
14354
14350
|
}
|
|
14355
14351
|
function createRequestHandler(handler) {
|
|
14356
14352
|
return async (req, res, next) => {
|
|
@@ -14645,11 +14641,11 @@ function getDebugPathHtml(workerNames, inspectorPort) {
|
|
|
14645
14641
|
// src/deploy-config.ts
|
|
14646
14642
|
import assert6 from "node:assert";
|
|
14647
14643
|
import * as fs3 from "node:fs";
|
|
14648
|
-
import * as
|
|
14644
|
+
import * as path7 from "node:path";
|
|
14649
14645
|
import "vite";
|
|
14650
14646
|
import { unstable_readConfig } from "wrangler";
|
|
14651
14647
|
function getDeployConfigPath(root) {
|
|
14652
|
-
return
|
|
14648
|
+
return path7.resolve(root, ".wrangler", "deploy", "config.json");
|
|
14653
14649
|
}
|
|
14654
14650
|
function getWorkerConfigs(root) {
|
|
14655
14651
|
const deployConfigPath = getDeployConfigPath(root);
|
|
@@ -14660,22 +14656,22 @@ function getWorkerConfigs(root) {
|
|
|
14660
14656
|
{ configPath: deployConfig.configPath },
|
|
14661
14657
|
...deployConfig.auxiliaryWorkers
|
|
14662
14658
|
].map(({ configPath }) => {
|
|
14663
|
-
const resolvedConfigPath =
|
|
14664
|
-
|
|
14659
|
+
const resolvedConfigPath = path7.resolve(
|
|
14660
|
+
path7.dirname(deployConfigPath),
|
|
14665
14661
|
configPath
|
|
14666
14662
|
);
|
|
14667
14663
|
return unstable_readConfig({ config: resolvedConfigPath });
|
|
14668
14664
|
});
|
|
14669
14665
|
}
|
|
14670
14666
|
function getRelativePathToWorkerConfig(deployConfigDirectory, root, outputDirectory) {
|
|
14671
|
-
return
|
|
14667
|
+
return path7.relative(
|
|
14672
14668
|
deployConfigDirectory,
|
|
14673
|
-
|
|
14669
|
+
path7.resolve(root, outputDirectory, "wrangler.json")
|
|
14674
14670
|
);
|
|
14675
14671
|
}
|
|
14676
14672
|
function writeDeployConfig(resolvedPluginConfig, resolvedViteConfig) {
|
|
14677
14673
|
const deployConfigPath = getDeployConfigPath(resolvedViteConfig.root);
|
|
14678
|
-
const deployConfigDirectory =
|
|
14674
|
+
const deployConfigDirectory = path7.dirname(deployConfigPath);
|
|
14679
14675
|
fs3.mkdirSync(deployConfigDirectory, { recursive: true });
|
|
14680
14676
|
if (resolvedPluginConfig.type === "assets-only") {
|
|
14681
14677
|
const clientOutputDirectory = resolvedViteConfig.environments.client?.build.outDir;
|
|
@@ -14726,9 +14722,9 @@ function writeDeployConfig(resolvedPluginConfig, resolvedViteConfig) {
|
|
|
14726
14722
|
|
|
14727
14723
|
// src/dev-vars.ts
|
|
14728
14724
|
import * as fs4 from "node:fs";
|
|
14729
|
-
import * as
|
|
14725
|
+
import * as path8 from "node:path";
|
|
14730
14726
|
function getDotDevDotVarsContent(configPath, cloudflareEnv) {
|
|
14731
|
-
const configDir =
|
|
14727
|
+
const configDir = path8.dirname(configPath);
|
|
14732
14728
|
const defaultDotDevDotVarsPath = `${configDir}/.dev.vars`;
|
|
14733
14729
|
const inputDotDevDotVarsPath = `${defaultDotDevDotVarsPath}${cloudflareEnv ? `.${cloudflareEnv}` : ""}`;
|
|
14734
14730
|
const targetPath = fs4.existsSync(inputDotDevDotVarsPath) ? inputDotDevDotVarsPath : fs4.existsSync(defaultDotDevDotVarsPath) ? defaultDotDevDotVarsPath : null;
|
|
@@ -14740,7 +14736,7 @@ function getDotDevDotVarsContent(configPath, cloudflareEnv) {
|
|
|
14740
14736
|
}
|
|
14741
14737
|
function hasDotDevDotVarsFileChanged(resolvedPluginConfig, changedFilePath) {
|
|
14742
14738
|
return [...resolvedPluginConfig.configPaths].some((configPath) => {
|
|
14743
|
-
const dotDevDotVars =
|
|
14739
|
+
const dotDevDotVars = path8.join(path8.dirname(configPath), ".dev.vars");
|
|
14744
14740
|
if (dotDevDotVars === changedFilePath) {
|
|
14745
14741
|
return true;
|
|
14746
14742
|
}
|
|
@@ -14756,7 +14752,7 @@ function hasDotDevDotVarsFileChanged(resolvedPluginConfig, changedFilePath) {
|
|
|
14756
14752
|
import assert7 from "node:assert";
|
|
14757
14753
|
import * as fs5 from "node:fs";
|
|
14758
14754
|
import * as fsp from "node:fs/promises";
|
|
14759
|
-
import * as
|
|
14755
|
+
import * as path9 from "node:path";
|
|
14760
14756
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
14761
14757
|
import {
|
|
14762
14758
|
getDefaultDevRegistryPath,
|
|
@@ -14778,7 +14774,7 @@ function getPersistenceRoot(root, persistState) {
|
|
|
14778
14774
|
return;
|
|
14779
14775
|
}
|
|
14780
14776
|
const defaultPersistPath = ".wrangler/state";
|
|
14781
|
-
const persistPath =
|
|
14777
|
+
const persistPath = path9.resolve(
|
|
14782
14778
|
root,
|
|
14783
14779
|
typeof persistState === "object" ? persistState.path : defaultPersistPath,
|
|
14784
14780
|
"v3"
|
|
@@ -14913,7 +14909,7 @@ async function getDevMiniflareOptions(config) {
|
|
|
14913
14909
|
modules: [
|
|
14914
14910
|
{
|
|
14915
14911
|
type: "ESModule",
|
|
14916
|
-
path:
|
|
14912
|
+
path: path9.join(miniflareModulesRoot, ROUTER_WORKER_PATH),
|
|
14917
14913
|
contents: fs5.readFileSync(
|
|
14918
14914
|
fileURLToPath2(new URL(ROUTER_WORKER_PATH, import.meta.url))
|
|
14919
14915
|
)
|
|
@@ -14936,7 +14932,7 @@ async function getDevMiniflareOptions(config) {
|
|
|
14936
14932
|
modules: [
|
|
14937
14933
|
{
|
|
14938
14934
|
type: "ESModule",
|
|
14939
|
-
path:
|
|
14935
|
+
path: path9.join(miniflareModulesRoot, ASSET_WORKER_PATH),
|
|
14940
14936
|
contents: fs5.readFileSync(
|
|
14941
14937
|
fileURLToPath2(new URL(ASSET_WORKER_PATH, import.meta.url))
|
|
14942
14938
|
)
|
|
@@ -14957,8 +14953,8 @@ async function getDevMiniflareOptions(config) {
|
|
|
14957
14953
|
if (publicDirInRoot && pathname.startsWith(publicPath)) {
|
|
14958
14954
|
return MiniflareResponse2.json(null);
|
|
14959
14955
|
}
|
|
14960
|
-
const publicDirFilePath =
|
|
14961
|
-
const rootDirFilePath =
|
|
14956
|
+
const publicDirFilePath = path9.join(publicDir, pathname);
|
|
14957
|
+
const rootDirFilePath = path9.join(root, pathname);
|
|
14962
14958
|
for (const resolvedPath of [publicDirFilePath, rootDirFilePath]) {
|
|
14963
14959
|
try {
|
|
14964
14960
|
const stats = await fsp.stat(resolvedPath);
|
|
@@ -14977,7 +14973,7 @@ async function getDevMiniflareOptions(config) {
|
|
|
14977
14973
|
const { pathname } = new URL(request2.url);
|
|
14978
14974
|
const { root, publicDir } = resolvedViteConfig;
|
|
14979
14975
|
const isInPublicDir = pathname.startsWith(PUBLIC_DIR_PREFIX);
|
|
14980
|
-
const resolvedPath = isInPublicDir ?
|
|
14976
|
+
const resolvedPath = isInPublicDir ? path9.join(publicDir, pathname.slice(PUBLIC_DIR_PREFIX.length)) : path9.join(root, pathname);
|
|
14981
14977
|
try {
|
|
14982
14978
|
let html = await fsp.readFile(resolvedPath, "utf-8");
|
|
14983
14979
|
if (!isInPublicDir) {
|
|
@@ -15151,12 +15147,12 @@ async function getDevMiniflareOptions(config) {
|
|
|
15151
15147
|
modules: [
|
|
15152
15148
|
{
|
|
15153
15149
|
type: "ESModule",
|
|
15154
|
-
path:
|
|
15150
|
+
path: path9.join(miniflareModulesRoot, WRAPPER_PATH),
|
|
15155
15151
|
contents: wrappers.join("\n")
|
|
15156
15152
|
},
|
|
15157
15153
|
{
|
|
15158
15154
|
type: "ESModule",
|
|
15159
|
-
path:
|
|
15155
|
+
path: path9.join(miniflareModulesRoot, RUNNER_PATH),
|
|
15160
15156
|
contents: fs5.readFileSync(
|
|
15161
15157
|
fileURLToPath2(new URL(RUNNER_PATH, import.meta.url))
|
|
15162
15158
|
)
|
|
@@ -15211,8 +15207,8 @@ async function getDevMiniflareOptions(config) {
|
|
|
15211
15207
|
}
|
|
15212
15208
|
function getPreviewModules(main, modulesRules) {
|
|
15213
15209
|
assert7(modulesRules, `Unexpected error: 'modulesRules' is undefined`);
|
|
15214
|
-
const rootPath =
|
|
15215
|
-
const entryPath =
|
|
15210
|
+
const rootPath = path9.dirname(main);
|
|
15211
|
+
const entryPath = path9.basename(main);
|
|
15216
15212
|
return {
|
|
15217
15213
|
rootPath,
|
|
15218
15214
|
modules: [
|
|
@@ -15221,9 +15217,9 @@ function getPreviewModules(main, modulesRules) {
|
|
|
15221
15217
|
path: entryPath
|
|
15222
15218
|
},
|
|
15223
15219
|
...modulesRules.flatMap(
|
|
15224
|
-
({ type, include }) => globSync(include, { cwd: rootPath, ignore: entryPath }).map((
|
|
15220
|
+
({ type, include }) => globSync(include, { cwd: rootPath, ignore: entryPath }).map((path13) => ({
|
|
15225
15221
|
type,
|
|
15226
|
-
path:
|
|
15222
|
+
path: path13
|
|
15227
15223
|
}))
|
|
15228
15224
|
)
|
|
15229
15225
|
]
|
|
@@ -15333,7 +15329,7 @@ function miniflareLogLevelFromViteLogLevel(level = "info") {
|
|
|
15333
15329
|
|
|
15334
15330
|
// src/plugin-config.ts
|
|
15335
15331
|
import assert9 from "node:assert";
|
|
15336
|
-
import * as
|
|
15332
|
+
import * as path11 from "node:path";
|
|
15337
15333
|
|
|
15338
15334
|
// ../workers-shared/utils/configuration/parseStaticRouting.ts
|
|
15339
15335
|
function parseStaticRouting(input) {
|
|
@@ -15417,7 +15413,7 @@ import * as vite5 from "vite";
|
|
|
15417
15413
|
// src/workers-configs.ts
|
|
15418
15414
|
import assert8 from "node:assert";
|
|
15419
15415
|
import * as fs6 from "node:fs";
|
|
15420
|
-
import * as
|
|
15416
|
+
import * as path10 from "node:path";
|
|
15421
15417
|
import { unstable_readConfig as unstable_readConfig2 } from "wrangler";
|
|
15422
15418
|
var nonApplicableWorkerConfigs = {
|
|
15423
15419
|
/**
|
|
@@ -15509,7 +15505,7 @@ function getWarningForWorkersConfigs(configs) {
|
|
|
15509
15505
|
const lines2 = [
|
|
15510
15506
|
`
|
|
15511
15507
|
|
|
15512
|
-
\x1B[43mWARNING\x1B[0m: your worker config${configs.entryWorker.config.configPath ? ` (at \`${
|
|
15508
|
+
\x1B[43mWARNING\x1B[0m: your worker config${configs.entryWorker.config.configPath ? ` (at \`${path10.relative("", configs.entryWorker.config.configPath)}\`)` : ""} contains the following configuration options which are ignored since they are not applicable when using Vite:`
|
|
15513
15509
|
];
|
|
15514
15510
|
nonApplicableLines.forEach((line) => lines2.push(line));
|
|
15515
15511
|
lines2.push("");
|
|
@@ -15523,7 +15519,7 @@ function getWarningForWorkersConfigs(configs) {
|
|
|
15523
15519
|
);
|
|
15524
15520
|
if (nonApplicableLines.length > 0) {
|
|
15525
15521
|
lines.push(
|
|
15526
|
-
` - (${isEntryWorker ? "entry" : "auxiliary"}) worker${workerConfig.config.name ? ` "${workerConfig.config.name}"` : ""}${workerConfig.config.configPath ? ` (config at \`${
|
|
15522
|
+
` - (${isEntryWorker ? "entry" : "auxiliary"}) worker${workerConfig.config.name ? ` "${workerConfig.config.name}"` : ""}${workerConfig.config.configPath ? ` (config at \`${path10.relative("", workerConfig.config.configPath)}\`)` : ""}`
|
|
15527
15523
|
);
|
|
15528
15524
|
nonApplicableLines.forEach((line) => lines.push(line));
|
|
15529
15525
|
}
|
|
@@ -15624,10 +15620,10 @@ function getWorkerConfig(configPath, env2, opts) {
|
|
|
15624
15620
|
}
|
|
15625
15621
|
function getValidatedWranglerConfigPath(root, requestedConfigPath, isForAuxiliaryWorker = false) {
|
|
15626
15622
|
if (requestedConfigPath) {
|
|
15627
|
-
const configPath2 =
|
|
15623
|
+
const configPath2 = path10.resolve(root, requestedConfigPath);
|
|
15628
15624
|
const forAuxiliaryWorkerErrorMessage = isForAuxiliaryWorker ? " requested for one of your auxiliary workers" : "";
|
|
15629
15625
|
const errorMessagePrefix = `The provided configPath (${configPath2})${forAuxiliaryWorkerErrorMessage}`;
|
|
15630
|
-
const fileExtension =
|
|
15626
|
+
const fileExtension = path10.extname(configPath2).slice(1);
|
|
15631
15627
|
if (!allowedWranglerConfigExtensions.includes(fileExtension)) {
|
|
15632
15628
|
const foundExtensionMessage = !fileExtension ? "no extension found" : `"${fileExtension}" found`;
|
|
15633
15629
|
throw new Error(
|
|
@@ -15661,7 +15657,7 @@ function getValidatedWranglerConfigPath(root, requestedConfigPath, isForAuxiliar
|
|
|
15661
15657
|
}
|
|
15662
15658
|
function findWranglerConfig(root) {
|
|
15663
15659
|
for (const extension of allowedWranglerConfigExtensions) {
|
|
15664
|
-
const configPath =
|
|
15660
|
+
const configPath = path10.join(root, `wrangler.${extension}`);
|
|
15665
15661
|
if (fs6.existsSync(configPath)) {
|
|
15666
15662
|
return configPath;
|
|
15667
15663
|
}
|
|
@@ -15679,7 +15675,7 @@ function resolvePluginConfig(pluginConfig, userConfig, viteEnv) {
|
|
|
15679
15675
|
inspectorPort: pluginConfig.inspectorPort,
|
|
15680
15676
|
experimental: pluginConfig.experimental ?? {}
|
|
15681
15677
|
};
|
|
15682
|
-
const root = userConfig.root ?
|
|
15678
|
+
const root = userConfig.root ? path11.resolve(userConfig.root) : process.cwd();
|
|
15683
15679
|
if (viteEnv.isPreview) {
|
|
15684
15680
|
return {
|
|
15685
15681
|
...shared,
|
|
@@ -15996,36 +15992,11 @@ if (import.meta.hot) {
|
|
|
15996
15992
|
);
|
|
15997
15993
|
workerConfig.assets = {
|
|
15998
15994
|
...workerConfig.assets,
|
|
15999
|
-
directory:
|
|
16000
|
-
|
|
16001
|
-
|
|
15995
|
+
directory: path12.relative(
|
|
15996
|
+
path12.resolve(resolvedViteConfig.root, workerOutputDirectory),
|
|
15997
|
+
path12.resolve(resolvedViteConfig.root, clientOutputDirectory)
|
|
16002
15998
|
)
|
|
16003
15999
|
};
|
|
16004
|
-
if (workerConfig.containers?.length) {
|
|
16005
|
-
workerConfig.containers = workerConfig.containers.map(
|
|
16006
|
-
(container) => {
|
|
16007
|
-
const baseDir = workerConfig.configPath ? path13.dirname(workerConfig.configPath) : resolvedViteConfig.root;
|
|
16008
|
-
const image = container.configuration?.image ?? container.image;
|
|
16009
|
-
if (isDockerfile(image, workerConfig.configPath)) {
|
|
16010
|
-
const output = {
|
|
16011
|
-
...container,
|
|
16012
|
-
image: path13.resolve(baseDir, image),
|
|
16013
|
-
...container.image_build_context ? {
|
|
16014
|
-
image_build_context: path13.resolve(
|
|
16015
|
-
baseDir,
|
|
16016
|
-
container.image_build_context
|
|
16017
|
-
)
|
|
16018
|
-
} : {}
|
|
16019
|
-
};
|
|
16020
|
-
delete output.configuration?.image;
|
|
16021
|
-
if (output.configuration && Object.keys(output.configuration).length === 0) {
|
|
16022
|
-
delete output.configuration;
|
|
16023
|
-
}
|
|
16024
|
-
return output;
|
|
16025
|
-
} else return container;
|
|
16026
|
-
}
|
|
16027
|
-
);
|
|
16028
|
-
}
|
|
16029
16000
|
} else {
|
|
16030
16001
|
workerConfig.assets = void 0;
|
|
16031
16002
|
}
|
|
@@ -16078,7 +16049,7 @@ if (import.meta.hot) {
|
|
|
16078
16049
|
},
|
|
16079
16050
|
hotUpdate(options) {
|
|
16080
16051
|
assertIsNotPreview(resolvedPluginConfig);
|
|
16081
|
-
const changedFilePath =
|
|
16052
|
+
const changedFilePath = path12.resolve(options.file);
|
|
16082
16053
|
if (resolvedPluginConfig.configPaths.has(changedFilePath) || hasDotDevDotVarsFileChanged(resolvedPluginConfig, changedFilePath) || hasAssetsConfigChanged(
|
|
16083
16054
|
resolvedPluginConfig,
|
|
16084
16055
|
resolvedViteConfig,
|
|
@@ -16159,18 +16130,17 @@ if (import.meta.hot) {
|
|
|
16159
16130
|
containerBuildId,
|
|
16160
16131
|
"Build ID should be set if containers are enabled and defined"
|
|
16161
16132
|
);
|
|
16162
|
-
const containerOptions =
|
|
16133
|
+
const containerOptions = getContainerOptions(
|
|
16163
16134
|
entryWorkerConfig,
|
|
16164
16135
|
containerBuildId
|
|
16165
16136
|
);
|
|
16166
16137
|
const dockerPath = getDockerPath();
|
|
16167
16138
|
if (containerOptions) {
|
|
16168
16139
|
for (const container of containerOptions) {
|
|
16169
|
-
containerImageTagsSeen.add(container.
|
|
16140
|
+
containerImageTagsSeen.add(container.image_tag);
|
|
16170
16141
|
}
|
|
16171
16142
|
await prepareContainerImagesForDev({
|
|
16172
16143
|
dockerPath,
|
|
16173
|
-
configPath: entryWorkerConfig.configPath,
|
|
16174
16144
|
containerOptions,
|
|
16175
16145
|
onContainerImagePreparationStart: () => {
|
|
16176
16146
|
},
|
|
@@ -16347,13 +16317,13 @@ if (import.meta.hot) {
|
|
|
16347
16317
|
}
|
|
16348
16318
|
const referenceId = this.emitFile({
|
|
16349
16319
|
type: "asset",
|
|
16350
|
-
name:
|
|
16320
|
+
name: path12.basename(modulePath),
|
|
16351
16321
|
originalFileName: modulePath,
|
|
16352
16322
|
source
|
|
16353
16323
|
});
|
|
16354
16324
|
const emittedFileName = this.getFileName(referenceId);
|
|
16355
16325
|
const relativePath = vite6.normalizePath(
|
|
16356
|
-
|
|
16326
|
+
path12.relative(path12.dirname(chunk.fileName), emittedFileName)
|
|
16357
16327
|
);
|
|
16358
16328
|
const importPath = relativePath.startsWith(".") ? relativePath : `./${relativePath}`;
|
|
16359
16329
|
magicString.update(
|
|
@@ -16560,13 +16530,13 @@ if (import.meta.hot) {
|
|
|
16560
16530
|
setup(build) {
|
|
16561
16531
|
build.onResolve(
|
|
16562
16532
|
{ filter: NODEJS_MODULES_RE },
|
|
16563
|
-
({ path:
|
|
16564
|
-
if (isNodeAls(workerConfig) && isNodeAlsModule(
|
|
16533
|
+
({ path: path13, importer }) => {
|
|
16534
|
+
if (isNodeAls(workerConfig) && isNodeAlsModule(path13)) {
|
|
16565
16535
|
return;
|
|
16566
16536
|
}
|
|
16567
16537
|
const nodeJsCompatWarnings = nodeJsCompatWarningsMap.get(workerConfig);
|
|
16568
|
-
nodeJsCompatWarnings?.registerImport(
|
|
16569
|
-
return { path:
|
|
16538
|
+
nodeJsCompatWarnings?.registerImport(path13, importer);
|
|
16539
|
+
return { path: path13, external: true };
|
|
16570
16540
|
}
|
|
16571
16541
|
);
|
|
16572
16542
|
}
|
|
@@ -16611,21 +16581,32 @@ if (import.meta.hot) {
|
|
|
16611
16581
|
function getWorkerConfig2(environmentName) {
|
|
16612
16582
|
return resolvedPluginConfig.type === "workers" ? resolvedPluginConfig.workers[environmentName] : void 0;
|
|
16613
16583
|
}
|
|
16614
|
-
|
|
16584
|
+
function getContainerOptions(config, containerBuildId) {
|
|
16615
16585
|
if (!config.containers?.length || config.dev.enable_containers === false) {
|
|
16616
16586
|
return void 0;
|
|
16617
16587
|
}
|
|
16618
16588
|
return config.containers.map((container) => {
|
|
16619
|
-
|
|
16620
|
-
|
|
16621
|
-
|
|
16622
|
-
container.
|
|
16623
|
-
|
|
16624
|
-
|
|
16625
|
-
|
|
16626
|
-
|
|
16627
|
-
|
|
16628
|
-
|
|
16589
|
+
if (isDockerfile(container.image, config.configPath)) {
|
|
16590
|
+
return {
|
|
16591
|
+
dockerfile: container.image,
|
|
16592
|
+
image_build_context: container.image_build_context ?? path12.dirname(container.image),
|
|
16593
|
+
image_vars: container.image_vars,
|
|
16594
|
+
class_name: container.class_name,
|
|
16595
|
+
image_tag: getDevContainerImageName(
|
|
16596
|
+
container.class_name,
|
|
16597
|
+
containerBuildId
|
|
16598
|
+
)
|
|
16599
|
+
};
|
|
16600
|
+
} else {
|
|
16601
|
+
return {
|
|
16602
|
+
image_uri: container.image,
|
|
16603
|
+
class_name: container.class_name,
|
|
16604
|
+
image_tag: getDevContainerImageName(
|
|
16605
|
+
container.class_name,
|
|
16606
|
+
containerBuildId
|
|
16607
|
+
)
|
|
16608
|
+
};
|
|
16609
|
+
}
|
|
16629
16610
|
});
|
|
16630
16611
|
}
|
|
16631
16612
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudflare/vite-plugin",
|
|
3
|
-
"version": "1.10.
|
|
3
|
+
"version": "1.10.1",
|
|
4
4
|
"description": "Cloudflare plugin for Vite",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -33,7 +33,6 @@
|
|
|
33
33
|
"dist"
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@cloudflare/unenv-preset": "2.3.3",
|
|
37
36
|
"@mjackson/node-fetch-server": "^0.6.1",
|
|
38
37
|
"@rollup/plugin-replace": "^6.0.1",
|
|
39
38
|
"get-port": "^7.1.0",
|
|
@@ -41,8 +40,9 @@
|
|
|
41
40
|
"tinyglobby": "^0.2.12",
|
|
42
41
|
"unenv": "2.0.0-rc.17",
|
|
43
42
|
"ws": "8.18.0",
|
|
44
|
-
"
|
|
45
|
-
"
|
|
43
|
+
"@cloudflare/unenv-preset": "2.4.1",
|
|
44
|
+
"miniflare": "4.20250712.2",
|
|
45
|
+
"wrangler": "4.26.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@cloudflare/workers-types": "^4.20250712.0",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
63
63
|
"vite": "^6.1.0 || ^7.0.0",
|
|
64
|
-
"wrangler": "^4.
|
|
64
|
+
"wrangler": "^4.26.0"
|
|
65
65
|
},
|
|
66
66
|
"publishConfig": {
|
|
67
67
|
"access": "public"
|