@cloudflare/vite-plugin 1.20.0 → 1.20.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.mjs
CHANGED
|
@@ -12,7 +12,7 @@ import { version } from "vite";
|
|
|
12
12
|
import * as fs$1 from "node:fs";
|
|
13
13
|
import fs, { existsSync, readFileSync, realpathSync, statSync } from "node:fs";
|
|
14
14
|
import { URL as URL$1, fileURLToPath, pathToFileURL } from "node:url";
|
|
15
|
-
import
|
|
15
|
+
import process2 from "node:process";
|
|
16
16
|
import os from "node:os";
|
|
17
17
|
import { defu } from "defu";
|
|
18
18
|
import { getCloudflarePreset } from "@cloudflare/unenv-preset";
|
|
@@ -4428,7 +4428,7 @@ function checkType(type) {
|
|
|
4428
4428
|
__name(checkType, "checkType");
|
|
4429
4429
|
var matchType = /* @__PURE__ */ __name((type, stat) => type === void 0 || stat[typeMappings[type]](), "matchType");
|
|
4430
4430
|
var toPath = /* @__PURE__ */ __name((urlOrPath) => urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath, "toPath");
|
|
4431
|
-
function locatePathSync(paths, { cwd =
|
|
4431
|
+
function locatePathSync(paths, { cwd = process2.cwd(), type = "file", allowSymlinks = true } = {}) {
|
|
4432
4432
|
checkType(type);
|
|
4433
4433
|
cwd = toPath(cwd);
|
|
4434
4434
|
const statFunction = allowSymlinks ? fs.statSync : fs.lstatSync;
|
|
@@ -13282,10 +13282,10 @@ const doubleSlashRegEx = /[/\\]{2}/;
|
|
|
13282
13282
|
* @param {boolean} isTarget
|
|
13283
13283
|
*/
|
|
13284
13284
|
function emitInvalidSegmentDeprecation(target$1, request$1, match, packageJsonUrl, internal, base, isTarget) {
|
|
13285
|
-
if (
|
|
13285
|
+
if (process2.noDeprecation) return;
|
|
13286
13286
|
const pjsonPath = fileURLToPath(packageJsonUrl);
|
|
13287
13287
|
const double = doubleSlashRegEx.exec(isTarget ? target$1 : request$1) !== null;
|
|
13288
|
-
|
|
13288
|
+
process2.emitWarning(`Use of deprecated ${double ? "double slash" : "leading or trailing slash matching"} resolving "${target$1}" for module request "${request$1}" ${request$1 === match ? "" : `matched to "${match}" `}in the "${internal ? "imports" : "exports"}" field module resolution of the package at ${pjsonPath}${base ? ` imported from ${fileURLToPath(base)}` : ""}.`, "DeprecationWarning", "DEP0166");
|
|
13289
13289
|
}
|
|
13290
13290
|
/**
|
|
13291
13291
|
* @param {URL} url
|
|
@@ -13295,13 +13295,13 @@ function emitInvalidSegmentDeprecation(target$1, request$1, match, packageJsonUr
|
|
|
13295
13295
|
* @returns {void}
|
|
13296
13296
|
*/
|
|
13297
13297
|
function emitLegacyIndexDeprecation(url, packageJsonUrl, base, main) {
|
|
13298
|
-
if (
|
|
13298
|
+
if (process2.noDeprecation) return;
|
|
13299
13299
|
if (defaultGetFormatWithoutErrors(url, { parentURL: base.href }) !== "module") return;
|
|
13300
13300
|
const urlPath = fileURLToPath(url.href);
|
|
13301
13301
|
const packagePath = fileURLToPath(new URL$1(".", packageJsonUrl));
|
|
13302
13302
|
const basePath = fileURLToPath(base);
|
|
13303
|
-
if (!main)
|
|
13304
|
-
else if (path4.resolve(packagePath, main) !== urlPath)
|
|
13303
|
+
if (!main) process2.emitWarning(`No "main" or "exports" field defined in the package.json for ${packagePath} resolving the main entry point "${urlPath.slice(packagePath.length)}", imported from ${basePath}.\nDefault "index" lookups for the main are deprecated for ES modules.`, "DeprecationWarning", "DEP0151");
|
|
13304
|
+
else if (path4.resolve(packagePath, main) !== urlPath) process2.emitWarning(`Package ${packagePath} has a "main" field set to "${main}", excluding the full filename and extension to the resolved file at "${urlPath.slice(packagePath.length)}", imported from ${basePath}.\n Automatic extension resolution of the "main" field is deprecated for ES modules.`, "DeprecationWarning", "DEP0151");
|
|
13305
13305
|
}
|
|
13306
13306
|
/**
|
|
13307
13307
|
* @param {string} path
|
|
@@ -13601,11 +13601,11 @@ function isConditionalExportsMainSugar(exports$1, packageJsonUrl, base) {
|
|
|
13601
13601
|
* @param {URL} base
|
|
13602
13602
|
*/
|
|
13603
13603
|
function emitTrailingSlashPatternDeprecation(match, pjsonUrl, base) {
|
|
13604
|
-
if (
|
|
13604
|
+
if (process2.noDeprecation) return;
|
|
13605
13605
|
const pjsonPath = fileURLToPath(pjsonUrl);
|
|
13606
13606
|
if (emittedPackageWarnings.has(pjsonPath + "|" + match)) return;
|
|
13607
13607
|
emittedPackageWarnings.add(pjsonPath + "|" + match);
|
|
13608
|
-
|
|
13608
|
+
process2.emitWarning(`Use of deprecated trailing slash pattern mapping "${match}" in the "exports" field module resolution of the package at ${pjsonPath}${base ? ` imported from ${fileURLToPath(base)}` : ""}. Mapping specifiers ending in "/" is no longer supported.`, "DeprecationWarning", "DEP0155");
|
|
13609
13609
|
}
|
|
13610
13610
|
/**
|
|
13611
13611
|
* @param {URL} packageJsonUrl
|
|
@@ -21421,7 +21421,12 @@ const defaultConditions = [
|
|
|
21421
21421
|
];
|
|
21422
21422
|
const target = "es2024";
|
|
21423
21423
|
function createCloudflareEnvironmentOptions({ workerConfig, userConfig, mode, environmentName, isEntryWorker, hasNodeJsCompat: hasNodeJsCompat$1 }) {
|
|
21424
|
+
const isRolldown = "rolldownVersion" in vite;
|
|
21424
21425
|
const define$1 = getProcessEnvReplacements(hasNodeJsCompat$1, mode);
|
|
21426
|
+
const rollupOptions = {
|
|
21427
|
+
input: { [MAIN_ENTRY_NAME]: VIRTUAL_WORKER_ENTRY },
|
|
21428
|
+
preserveEntrySignatures: "strict"
|
|
21429
|
+
};
|
|
21425
21430
|
return {
|
|
21426
21431
|
resolve: {
|
|
21427
21432
|
noExternal: true,
|
|
@@ -21442,18 +21447,38 @@ function createCloudflareEnvironmentOptions({ workerConfig, userConfig, mode, en
|
|
|
21442
21447
|
outDir: getOutputDirectory(userConfig, environmentName),
|
|
21443
21448
|
copyPublicDir: false,
|
|
21444
21449
|
ssr: true,
|
|
21445
|
-
|
|
21446
|
-
|
|
21447
|
-
|
|
21448
|
-
|
|
21449
|
-
}
|
|
21450
|
+
...isRolldown ? { rolldownOptions: {
|
|
21451
|
+
...rollupOptions,
|
|
21452
|
+
platform: "neutral"
|
|
21453
|
+
} } : { rollupOptions }
|
|
21450
21454
|
},
|
|
21451
21455
|
optimizeDeps: {
|
|
21452
21456
|
noDiscovery: false,
|
|
21453
21457
|
ignoreOutdatedRequests: true,
|
|
21454
21458
|
entries: vite.normalizePath(workerConfig.main),
|
|
21455
21459
|
exclude: [...cloudflareBuiltInModules],
|
|
21456
|
-
|
|
21460
|
+
...isRolldown ? { rolldownOptions: {
|
|
21461
|
+
platform: "neutral",
|
|
21462
|
+
resolve: {
|
|
21463
|
+
conditionNames: [...defaultConditions, "development"],
|
|
21464
|
+
extensions: [
|
|
21465
|
+
".mjs",
|
|
21466
|
+
".js",
|
|
21467
|
+
".mts",
|
|
21468
|
+
".ts",
|
|
21469
|
+
".jsx",
|
|
21470
|
+
".tsx",
|
|
21471
|
+
".json",
|
|
21472
|
+
".cjs",
|
|
21473
|
+
".cts",
|
|
21474
|
+
".ctx"
|
|
21475
|
+
]
|
|
21476
|
+
},
|
|
21477
|
+
transform: {
|
|
21478
|
+
target,
|
|
21479
|
+
define: define$1
|
|
21480
|
+
}
|
|
21481
|
+
} } : { esbuildOptions: {
|
|
21457
21482
|
platform: "neutral",
|
|
21458
21483
|
target,
|
|
21459
21484
|
conditions: [...defaultConditions, "development"],
|
|
@@ -21470,7 +21495,7 @@ function createCloudflareEnvironmentOptions({ workerConfig, userConfig, mode, en
|
|
|
21470
21495
|
".ctx"
|
|
21471
21496
|
],
|
|
21472
21497
|
define: define$1
|
|
21473
|
-
}
|
|
21498
|
+
} }
|
|
21474
21499
|
},
|
|
21475
21500
|
keepProcessEnv: true
|
|
21476
21501
|
};
|
|
@@ -22099,17 +22124,17 @@ const getQueryString = (params) => {
|
|
|
22099
22124
|
const append = (key, value) => {
|
|
22100
22125
|
qs.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`);
|
|
22101
22126
|
};
|
|
22102
|
-
const process$
|
|
22127
|
+
const process$1 = (key, value) => {
|
|
22103
22128
|
if (isDefined(value)) if (Array.isArray(value)) value.forEach((v) => {
|
|
22104
|
-
process$
|
|
22129
|
+
process$1(key, v);
|
|
22105
22130
|
});
|
|
22106
22131
|
else if (typeof value === "object") Object.entries(value).forEach(([k, v]) => {
|
|
22107
|
-
process$
|
|
22132
|
+
process$1(`${key}[${k}]`, v);
|
|
22108
22133
|
});
|
|
22109
22134
|
else append(key, value);
|
|
22110
22135
|
};
|
|
22111
22136
|
Object.entries(params).forEach(([key, value]) => {
|
|
22112
|
-
process$
|
|
22137
|
+
process$1(key, value);
|
|
22113
22138
|
});
|
|
22114
22139
|
if (qs.length > 0) return `?${qs.join("&")}`;
|
|
22115
22140
|
return "";
|
|
@@ -22127,13 +22152,13 @@ const getUrl = (config, options) => {
|
|
|
22127
22152
|
const getFormData = (options) => {
|
|
22128
22153
|
if (options.formData) {
|
|
22129
22154
|
const formData = new FormData();
|
|
22130
|
-
const process$
|
|
22155
|
+
const process$1 = async (key, value) => {
|
|
22131
22156
|
if (isString(value)) formData.append(key, value);
|
|
22132
22157
|
else formData.append(key, JSON.stringify(value));
|
|
22133
22158
|
};
|
|
22134
22159
|
Object.entries(options.formData).filter(([_, value]) => isDefined(value)).forEach(([key, value]) => {
|
|
22135
|
-
if (Array.isArray(value)) value.forEach((v) => process$
|
|
22136
|
-
else process$
|
|
22160
|
+
if (Array.isArray(value)) value.forEach((v) => process$1(key, v));
|
|
22161
|
+
else process$1(key, value);
|
|
22137
22162
|
});
|
|
22138
22163
|
return formData;
|
|
22139
22164
|
}
|
|
@@ -23509,12 +23534,32 @@ const nodeJsCompatWarningsPlugin = createPlugin("nodejs-compat-warnings", (ctx)
|
|
|
23509
23534
|
exitCallback$1 = () => {
|
|
23510
23535
|
for (const nodeJsCompatWarnings of nodeJsCompatWarningsMap.values()) nodeJsCompatWarnings.renderWarnings();
|
|
23511
23536
|
};
|
|
23537
|
+
function resolveId(environmentName, source, importer) {
|
|
23538
|
+
const workerConfig = ctx.getWorkerConfig(environmentName);
|
|
23539
|
+
const nodeJsCompat = ctx.getNodeJsCompat(environmentName);
|
|
23540
|
+
if (workerConfig && !nodeJsCompat) {
|
|
23541
|
+
if (hasNodeJsAls(workerConfig) && isNodeAlsModule(source)) return;
|
|
23542
|
+
const nodeJsCompatWarnings = nodeJsCompatWarningsMap.get(workerConfig);
|
|
23543
|
+
if (nodeJsBuiltins.has(source)) {
|
|
23544
|
+
nodeJsCompatWarnings?.registerImport(source, importer);
|
|
23545
|
+
return {
|
|
23546
|
+
id: source,
|
|
23547
|
+
external: true
|
|
23548
|
+
};
|
|
23549
|
+
}
|
|
23550
|
+
}
|
|
23551
|
+
}
|
|
23512
23552
|
return {
|
|
23513
23553
|
enforce: "pre",
|
|
23514
23554
|
configEnvironment(environmentName) {
|
|
23515
23555
|
const workerConfig = ctx.getWorkerConfig(environmentName);
|
|
23516
23556
|
const nodeJsCompat = ctx.getNodeJsCompat(environmentName);
|
|
23517
|
-
if (workerConfig && !nodeJsCompat) return { optimizeDeps: {
|
|
23557
|
+
if (workerConfig && !nodeJsCompat) return { optimizeDeps: { ..."rolldownVersion" in vite ? { rolldownOptions: { plugins: [{
|
|
23558
|
+
name: "vite-plugin-cloudflare:nodejs-compat-warnings-resolver",
|
|
23559
|
+
resolveId(source, importer) {
|
|
23560
|
+
return resolveId(environmentName, source, importer);
|
|
23561
|
+
}
|
|
23562
|
+
}] } } : { esbuildOptions: { plugins: [{
|
|
23518
23563
|
name: "vite-plugin-cloudflare:nodejs-compat-warnings-resolver",
|
|
23519
23564
|
setup(build) {
|
|
23520
23565
|
build.onResolve({ filter: NODEJS_MODULES_RE }, ({ path, importer }) => {
|
|
@@ -23526,7 +23571,7 @@ const nodeJsCompatWarningsPlugin = createPlugin("nodejs-compat-warnings", (ctx)
|
|
|
23526
23571
|
};
|
|
23527
23572
|
});
|
|
23528
23573
|
}
|
|
23529
|
-
}] } } };
|
|
23574
|
+
}] } } } };
|
|
23530
23575
|
},
|
|
23531
23576
|
configResolved(resolvedViteConfig) {
|
|
23532
23577
|
for (const environmentName of Object.keys(resolvedViteConfig.environments)) {
|
|
@@ -23536,19 +23581,7 @@ const nodeJsCompatWarningsPlugin = createPlugin("nodejs-compat-warnings", (ctx)
|
|
|
23536
23581
|
}
|
|
23537
23582
|
},
|
|
23538
23583
|
async resolveId(source, importer) {
|
|
23539
|
-
|
|
23540
|
-
const nodeJsCompat = ctx.getNodeJsCompat(this.environment.name);
|
|
23541
|
-
if (workerConfig && !nodeJsCompat) {
|
|
23542
|
-
if (hasNodeJsAls(workerConfig) && isNodeAlsModule(source)) return;
|
|
23543
|
-
const nodeJsCompatWarnings = nodeJsCompatWarningsMap.get(workerConfig);
|
|
23544
|
-
if (nodeJsBuiltins.has(source)) {
|
|
23545
|
-
nodeJsCompatWarnings?.registerImport(source, importer);
|
|
23546
|
-
return {
|
|
23547
|
-
id: source,
|
|
23548
|
-
external: true
|
|
23549
|
-
};
|
|
23550
|
-
}
|
|
23551
|
-
}
|
|
23584
|
+
return resolveId(this.environment.name, source, importer);
|
|
23552
23585
|
}
|
|
23553
23586
|
};
|
|
23554
23587
|
});
|