@cloudflare/vite-plugin 1.13.11 → 1.13.13
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 +22 -51
- package/dist/index.js.map +1 -1
- package/dist/workers/asset-worker.js +20 -43
- package/dist/workers/router-worker.js +19 -41
- package/dist/workers/runner-worker.js +9 -13
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -1606,8 +1606,7 @@ var require_ignore = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/igno
|
|
|
1606
1606
|
}],
|
|
1607
1607
|
[/\\\/\\\*\\\*(?=\\\/|$)/g, (_, index, str) => index + 6 < str.length ? "(?:\\/[^\\/]+)*" : "\\/.+"],
|
|
1608
1608
|
[/(^|[^\\]+)(\\\*)+(?=.+)/g, (_, p1, p2) => {
|
|
1609
|
-
|
|
1610
|
-
return p1 + unescaped;
|
|
1609
|
+
return p1 + p2.replace(/\\\*/g, "[^\\/]*");
|
|
1611
1610
|
}],
|
|
1612
1611
|
[/\\\\\\(?=[$.|*+(){^])/g, () => ESCAPE],
|
|
1613
1612
|
[/\\\\/g, () => ESCAPE],
|
|
@@ -3659,12 +3658,11 @@ var ZodType = class {
|
|
|
3659
3658
|
data: data$1,
|
|
3660
3659
|
parsedType: getParsedType(data$1)
|
|
3661
3660
|
};
|
|
3662
|
-
|
|
3661
|
+
return handleResult(ctx, this._parseSync({
|
|
3663
3662
|
data: data$1,
|
|
3664
3663
|
path: ctx.path,
|
|
3665
3664
|
parent: ctx
|
|
3666
|
-
});
|
|
3667
|
-
return handleResult(ctx, result);
|
|
3665
|
+
}));
|
|
3668
3666
|
}
|
|
3669
3667
|
async parseAsync(data$1, params) {
|
|
3670
3668
|
const result = await this.safeParseAsync(data$1, params);
|
|
@@ -3689,8 +3687,7 @@ var ZodType = class {
|
|
|
3689
3687
|
path: ctx.path,
|
|
3690
3688
|
parent: ctx
|
|
3691
3689
|
});
|
|
3692
|
-
|
|
3693
|
-
return handleResult(ctx, result);
|
|
3690
|
+
return handleResult(ctx, await (isAsync(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult)));
|
|
3694
3691
|
}
|
|
3695
3692
|
refine(check, message) {
|
|
3696
3693
|
const getIssueProperties = (val) => {
|
|
@@ -4241,9 +4238,7 @@ function floatSafeRemainder(val, step) {
|
|
|
4241
4238
|
const valDecCount = (val.toString().split(".")[1] || "").length;
|
|
4242
4239
|
const stepDecCount = (step.toString().split(".")[1] || "").length;
|
|
4243
4240
|
const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
|
|
4244
|
-
|
|
4245
|
-
const stepInt = parseInt(step.toFixed(decCount).replace(".", ""));
|
|
4246
|
-
return valInt % stepInt / Math.pow(10, decCount);
|
|
4241
|
+
return parseInt(val.toFixed(decCount).replace(".", "")) % parseInt(step.toFixed(decCount).replace(".", "")) / Math.pow(10, decCount);
|
|
4247
4242
|
}
|
|
4248
4243
|
var ZodNumber = class ZodNumber extends ZodType {
|
|
4249
4244
|
constructor() {
|
|
@@ -4642,8 +4637,7 @@ var ZodDate = class ZodDate extends ZodType {
|
|
|
4642
4637
|
return INVALID;
|
|
4643
4638
|
}
|
|
4644
4639
|
if (isNaN(input.data.getTime())) {
|
|
4645
|
-
|
|
4646
|
-
addIssueToContext(ctx$1, { code: ZodIssueCode.invalid_date });
|
|
4640
|
+
addIssueToContext(this._getOrReturnCtx(input), { code: ZodIssueCode.invalid_date });
|
|
4647
4641
|
return INVALID;
|
|
4648
4642
|
}
|
|
4649
4643
|
const status = new ParseStatus();
|
|
@@ -4995,10 +4989,9 @@ var ZodObject = class ZodObject extends ZodType {
|
|
|
4995
4989
|
_getCached() {
|
|
4996
4990
|
if (this._cached !== null) return this._cached;
|
|
4997
4991
|
const shape = this._def.shape();
|
|
4998
|
-
const keys = util$1.objectKeys(shape);
|
|
4999
4992
|
return this._cached = {
|
|
5000
4993
|
shape,
|
|
5001
|
-
keys
|
|
4994
|
+
keys: util$1.objectKeys(shape)
|
|
5002
4995
|
};
|
|
5003
4996
|
}
|
|
5004
4997
|
_parse(input) {
|
|
@@ -5996,8 +5989,7 @@ var ZodPromise = class extends ZodType {
|
|
|
5996
5989
|
});
|
|
5997
5990
|
return INVALID;
|
|
5998
5991
|
}
|
|
5999
|
-
|
|
6000
|
-
return OK(promisified.then((data$1) => {
|
|
5992
|
+
return OK((ctx.parsedType === ZodParsedType.promise ? ctx.data : Promise.resolve(ctx.data)).then((data$1) => {
|
|
6001
5993
|
return this._def.type.parseAsync(data$1, {
|
|
6002
5994
|
path: ctx.path,
|
|
6003
5995
|
errorMap: ctx.common.contextualErrorMap
|
|
@@ -6819,8 +6811,7 @@ function createBuildApp(resolvedPluginConfig) {
|
|
|
6819
6811
|
const entryWorkerEnvironment = builder.environments[entryWorkerEnvironmentName];
|
|
6820
6812
|
assert(entryWorkerEnvironment, `No "${entryWorkerEnvironmentName}" environment`);
|
|
6821
6813
|
const entryWorkerBuildDirectory = path$2.resolve(builder.config.root, entryWorkerEnvironment.config.build.outDir);
|
|
6822
|
-
const
|
|
6823
|
-
const importedAssetPaths = getImportedAssetPaths(entryWorkerManifest);
|
|
6814
|
+
const importedAssetPaths = getImportedAssetPaths(loadViteManifest(entryWorkerBuildDirectory));
|
|
6824
6815
|
if (hasClientEntry) await builder.build(clientEnvironment);
|
|
6825
6816
|
else if (importedAssetPaths.size || getHasPublicAssets(builder.config)) await fallbackBuild(builder, clientEnvironment);
|
|
6826
6817
|
else {
|
|
@@ -6897,8 +6888,7 @@ function createRequestHandler(handler) {
|
|
|
6897
6888
|
return async (req, res, next) => {
|
|
6898
6889
|
try {
|
|
6899
6890
|
if (req.originalUrl) req.url = req.originalUrl;
|
|
6900
|
-
|
|
6901
|
-
let response = await handler(toMiniflareRequest(request$1), req);
|
|
6891
|
+
let response = await handler(toMiniflareRequest(createRequest(req, res)), req);
|
|
6902
6892
|
if (req.httpVersionMajor === 2) {
|
|
6903
6893
|
response = new Response$1(response.body, response);
|
|
6904
6894
|
response.headers.delete("transfer-encoding");
|
|
@@ -7522,10 +7512,9 @@ function getLocator(source) {
|
|
|
7522
7512
|
else i$1 = m + 1;
|
|
7523
7513
|
}
|
|
7524
7514
|
const line = i$1 - 1;
|
|
7525
|
-
const column = index - lineOffsets[line];
|
|
7526
7515
|
return {
|
|
7527
7516
|
line,
|
|
7528
|
-
column
|
|
7517
|
+
column: index - lineOffsets[line]
|
|
7529
7518
|
};
|
|
7530
7519
|
};
|
|
7531
7520
|
}
|
|
@@ -8796,8 +8785,7 @@ function getWorkerConfigs(root) {
|
|
|
8796
8785
|
const deployConfigPath = getDeployConfigPath(root);
|
|
8797
8786
|
const deployConfig = JSON.parse(fs$1.readFileSync(deployConfigPath, "utf-8"));
|
|
8798
8787
|
return [{ configPath: deployConfig.configPath }, ...deployConfig.auxiliaryWorkers].map(({ configPath }) => {
|
|
8799
|
-
|
|
8800
|
-
return unstable_readConfig({ config: resolvedConfigPath });
|
|
8788
|
+
return unstable_readConfig({ config: path$2.resolve(path$2.dirname(deployConfigPath), configPath) });
|
|
8801
8789
|
});
|
|
8802
8790
|
}
|
|
8803
8791
|
function getRelativePathToWorkerConfig(deployConfigDirectory, root, outputDirectory) {
|
|
@@ -14356,8 +14344,7 @@ function getFileProtocolModuleFormat(url, _context, ignoreErrors) {
|
|
|
14356
14344
|
const format$1 = extensionFormatMap[value];
|
|
14357
14345
|
if (format$1) return format$1;
|
|
14358
14346
|
if (ignoreErrors) return;
|
|
14359
|
-
|
|
14360
|
-
throw new ERR_UNKNOWN_FILE_EXTENSION(value, filepath);
|
|
14347
|
+
throw new ERR_UNKNOWN_FILE_EXTENSION(value, fileURLToPath(url));
|
|
14361
14348
|
}
|
|
14362
14349
|
function getHttpProtocolModuleFormat() {}
|
|
14363
14350
|
/**
|
|
@@ -14551,8 +14538,7 @@ function exportsNotFound(subpath, packageJsonUrl, base) {
|
|
|
14551
14538
|
* @returns {never}
|
|
14552
14539
|
*/
|
|
14553
14540
|
function throwInvalidSubpath(request$1, match, packageJsonUrl, internal, base) {
|
|
14554
|
-
|
|
14555
|
-
throw new ERR_INVALID_MODULE_SPECIFIER(request$1, reason, base && fileURLToPath(base));
|
|
14541
|
+
throw new ERR_INVALID_MODULE_SPECIFIER(request$1, `request is not a valid match in pattern "${match}" for the "${internal ? "imports" : "exports"}" resolution of ${fileURLToPath(packageJsonUrl)}`, base && fileURLToPath(base));
|
|
14556
14542
|
}
|
|
14557
14543
|
/**
|
|
14558
14544
|
* @param {string} subpath
|
|
@@ -14587,18 +14573,14 @@ function resolvePackageTargetString(target$1, subpath, match, packageJsonUrl, ba
|
|
|
14587
14573
|
new URL$1(target$1);
|
|
14588
14574
|
isURL = true;
|
|
14589
14575
|
} catch {}
|
|
14590
|
-
if (!isURL)
|
|
14591
|
-
const exportTarget = pattern ? RegExpPrototypeSymbolReplace.call(patternRegEx, target$1, () => subpath) : target$1 + subpath;
|
|
14592
|
-
return packageResolve(exportTarget, packageJsonUrl, conditions);
|
|
14593
|
-
}
|
|
14576
|
+
if (!isURL) return packageResolve(pattern ? RegExpPrototypeSymbolReplace.call(patternRegEx, target$1, () => subpath) : target$1 + subpath, packageJsonUrl, conditions);
|
|
14594
14577
|
}
|
|
14595
14578
|
throw invalidPackageTarget(match, target$1, packageJsonUrl, internal, base);
|
|
14596
14579
|
}
|
|
14597
14580
|
if (invalidSegmentRegEx.exec(target$1.slice(2)) !== null) if (deprecatedInvalidSegmentRegEx.exec(target$1.slice(2)) === null) {
|
|
14598
14581
|
if (!isPathMap) {
|
|
14599
14582
|
const request$1 = pattern ? match.replace("*", () => subpath) : match + subpath;
|
|
14600
|
-
|
|
14601
|
-
emitInvalidSegmentDeprecation(resolvedTarget, request$1, match, packageJsonUrl, internal, base, true);
|
|
14583
|
+
emitInvalidSegmentDeprecation(pattern ? RegExpPrototypeSymbolReplace.call(patternRegEx, target$1, () => subpath) : target$1, request$1, match, packageJsonUrl, internal, base, true);
|
|
14602
14584
|
}
|
|
14603
14585
|
} else throw invalidPackageTarget(match, target$1, packageJsonUrl, internal, base);
|
|
14604
14586
|
const resolved = new URL$1(target$1, packageJsonUrl);
|
|
@@ -14609,10 +14591,7 @@ function resolvePackageTargetString(target$1, subpath, match, packageJsonUrl, ba
|
|
|
14609
14591
|
if (invalidSegmentRegEx.exec(subpath) !== null) {
|
|
14610
14592
|
const request$1 = pattern ? match.replace("*", () => subpath) : match + subpath;
|
|
14611
14593
|
if (deprecatedInvalidSegmentRegEx.exec(subpath) === null) {
|
|
14612
|
-
if (!isPathMap)
|
|
14613
|
-
const resolvedTarget = pattern ? RegExpPrototypeSymbolReplace.call(patternRegEx, target$1, () => subpath) : target$1;
|
|
14614
|
-
emitInvalidSegmentDeprecation(resolvedTarget, request$1, match, packageJsonUrl, internal, base, false);
|
|
14615
|
-
}
|
|
14594
|
+
if (!isPathMap) emitInvalidSegmentDeprecation(pattern ? RegExpPrototypeSymbolReplace.call(patternRegEx, target$1, () => subpath) : target$1, request$1, match, packageJsonUrl, internal, base, false);
|
|
14616
14595
|
} else throwInvalidSubpath(request$1, match, packageJsonUrl, internal, base);
|
|
14617
14596
|
}
|
|
14618
14597
|
if (pattern) return new URL$1(RegExpPrototypeSymbolReplace.call(patternRegEx, resolved.href, () => subpath));
|
|
@@ -14841,10 +14820,9 @@ function parsePackageName(specifier, base) {
|
|
|
14841
14820
|
const packageName = separatorIndex === -1 ? specifier : specifier.slice(0, separatorIndex);
|
|
14842
14821
|
if (invalidPackageNameRegEx.exec(packageName) !== null) validPackageName = false;
|
|
14843
14822
|
if (!validPackageName) throw new ERR_INVALID_MODULE_SPECIFIER(specifier, "is not a valid package name", fileURLToPath(base));
|
|
14844
|
-
const packageSubpath = "." + (separatorIndex === -1 ? "" : specifier.slice(separatorIndex));
|
|
14845
14823
|
return {
|
|
14846
14824
|
packageName,
|
|
14847
|
-
packageSubpath,
|
|
14825
|
+
packageSubpath: "." + (separatorIndex === -1 ? "" : specifier.slice(separatorIndex)),
|
|
14848
14826
|
isScoped
|
|
14849
14827
|
};
|
|
14850
14828
|
}
|
|
@@ -15225,9 +15203,7 @@ var NodeJsCompat = class {
|
|
|
15225
15203
|
* Gets the necessary global polyfills to inject into the entry-point of the user's code.
|
|
15226
15204
|
*/
|
|
15227
15205
|
injectGlobalCode() {
|
|
15228
|
-
|
|
15229
|
-
const polyfillCode = this.#env.polyfill.map((polyfillPath) => `import "${polyfillPath}";`).join("\n");
|
|
15230
|
-
return `${injectedCode}${polyfillCode}`;
|
|
15206
|
+
return `${Array.from(this.#virtualModulePathToSpecifier.keys()).map((moduleId) => `import "${moduleId}";`).join("\n")}${this.#env.polyfill.map((polyfillPath) => `import "${polyfillPath}";`).join("\n")}`;
|
|
15231
15207
|
}
|
|
15232
15208
|
/**
|
|
15233
15209
|
* Resolves the `source` to a Node.js compat alias if possible.
|
|
@@ -15536,8 +15512,7 @@ function resolvePluginConfig(pluginConfig, userConfig, viteEnv) {
|
|
|
15536
15512
|
};
|
|
15537
15513
|
const configPaths = /* @__PURE__ */ new Set();
|
|
15538
15514
|
const cloudflareEnv = prefixedEnv.CLOUDFLARE_ENV;
|
|
15539
|
-
const
|
|
15540
|
-
const entryWorkerResolvedConfig = getWorkerConfig(entryWorkerConfigPath, cloudflareEnv, {
|
|
15515
|
+
const entryWorkerResolvedConfig = getWorkerConfig(getValidatedWranglerConfigPath(root, pluginConfig.configPath), cloudflareEnv, {
|
|
15541
15516
|
visitedConfigPaths: configPaths,
|
|
15542
15517
|
isEntryWorker: true
|
|
15543
15518
|
});
|
|
@@ -15556,8 +15531,7 @@ function resolvePluginConfig(pluginConfig, userConfig, viteEnv) {
|
|
|
15556
15531
|
const workers = { [entryWorkerEnvironmentName]: entryWorkerConfig };
|
|
15557
15532
|
const auxiliaryWorkersResolvedConfigs = [];
|
|
15558
15533
|
for (const auxiliaryWorker of pluginConfig.auxiliaryWorkers ?? []) {
|
|
15559
|
-
const
|
|
15560
|
-
const workerResolvedConfig = getWorkerConfig(workerConfigPath, cloudflareEnv, { visitedConfigPaths: configPaths });
|
|
15534
|
+
const workerResolvedConfig = getWorkerConfig(getValidatedWranglerConfigPath(root, auxiliaryWorker.configPath, true), cloudflareEnv, { visitedConfigPaths: configPaths });
|
|
15561
15535
|
auxiliaryWorkersResolvedConfigs.push(workerResolvedConfig);
|
|
15562
15536
|
assert(workerResolvedConfig.type === "worker", "Unexpected error: received AssetsOnlyResult with auxiliary workers.");
|
|
15563
15537
|
const workerConfig = workerResolvedConfig.config;
|
|
@@ -15934,10 +15908,7 @@ function cloudflare(pluginConfig = {}) {
|
|
|
15934
15908
|
}));
|
|
15935
15909
|
},
|
|
15936
15910
|
async buildEnd() {
|
|
15937
|
-
if (ctx.resolvedViteConfig.command === "serve" && containerImageTagsSeen?.size)
|
|
15938
|
-
const dockerPath = getDockerPath();
|
|
15939
|
-
cleanupContainers(dockerPath, containerImageTagsSeen);
|
|
15940
|
-
}
|
|
15911
|
+
if (ctx.resolvedViteConfig.command === "serve" && containerImageTagsSeen?.size) cleanupContainers(getDockerPath(), containerImageTagsSeen);
|
|
15941
15912
|
debuglog("buildEnd:", restartingServer ? "restarted" : "disposing");
|
|
15942
15913
|
if (!restartingServer) {
|
|
15943
15914
|
debuglog("buildEnd: disposing Miniflare instance");
|