@cloudflare/vite-plugin 1.13.12 → 1.13.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +33 -18
- package/dist/index.js.map +1 -1
- package/dist/workers/runner-worker.js +1 -1
- package/package.json +9 -9
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/plugin-config.ts","../src/index.ts"],"sourcesContent":[],"mappings":";;;;;AA0BU,KANE,YAAA,GAMgB,OAAQ,GAAA;EAI1B,IAAA,EAAA,MAAA;AAA8C,CAAA;AAWxD,UAnBU,gBAAA,CAmBoB;EAAA,eAAA,CAAA,EAAA;IACV,IAAA,CAAA,EAAA,MAAA;;;UAhBV,iBAAA,SAA0B,gBAeE,CAAA;EAAiB,UAAA,CAAA,EAAA,MAAA;;UAX7C,qBAAA,SAA8B;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/plugin-config.ts","../src/index.ts"],"sourcesContent":[],"mappings":";;;;;AA0BU,KANE,YAAA,GAMgB,OAAQ,GAAA;EAI1B,IAAA,EAAA,MAAA;AAA8C,CAAA;AAWxD,UAnBU,gBAAA,CAmBoB;EAAA,eAAA,CAAA,EAAA;IACV,IAAA,CAAA,EAAA,MAAA;;;UAhBV,iBAAA,SAA0B,gBAeE,CAAA;EAAiB,UAAA,CAAA,EAAA,MAAA;;UAX7C,qBAAA,SAA8B;;AC+CxC;UD3CU,YAAA,CC2CgB;;mCAAwC,CAAA,EAAA,OAAA;EAAM;;;UDpCvD,YAAA,SAAqB;qBAClB;iBACJ;;iBAEA;;;;;AAzBhB;AAAsD;AAE5B;AAI0B;AAII;AAWxD;AAA8B,iBCoCd,UAAA,CDpCc,YAAA,CAAA,ECoCW,YDpCX,CAAA,ECoC+B,IAAA,CAAK,MDpCpC,EAAA"}
|
package/dist/index.js
CHANGED
|
@@ -754,6 +754,7 @@ async function constructBuildCommand(options, logger) {
|
|
|
754
754
|
const platform = options.platform ?? "linux/amd64";
|
|
755
755
|
const buildCmd = [
|
|
756
756
|
"build",
|
|
757
|
+
"--load",
|
|
757
758
|
"-t",
|
|
758
759
|
options.tag,
|
|
759
760
|
"--platform",
|
|
@@ -957,8 +958,8 @@ const runDockerCmdWithOutput = (dockerPath, args) => {
|
|
|
957
958
|
throw new UserError(`Failed running docker command: ${error.message}. Command: ${dockerPath} ${args.join(" ")}`);
|
|
958
959
|
}
|
|
959
960
|
};
|
|
960
|
-
/**
|
|
961
|
-
const
|
|
961
|
+
/** Checks whether docker is running on the system */
|
|
962
|
+
const isDockerRunning = async (dockerPath) => {
|
|
962
963
|
try {
|
|
963
964
|
await runDockerCmd(dockerPath, ["info"], [
|
|
964
965
|
"inherit",
|
|
@@ -966,9 +967,14 @@ const verifyDockerInstalled = async (dockerPath, isDev = true) => {
|
|
|
966
967
|
"pipe"
|
|
967
968
|
]);
|
|
968
969
|
} catch {
|
|
969
|
-
|
|
970
|
-
Other container tooling that is compatible with the Docker CLI and engine may work, but is not yet guaranteed to do so. You can specify an executable with the environment variable WRANGLER_DOCKER_BIN and a socket with DOCKER_HOST.${isDev ? "\nTo suppress this error if you do not intend on triggering any container instances, set dev.enable_containers to false in your Wrangler config or passing in --enable-containers=false." : ""}`);
|
|
970
|
+
return false;
|
|
971
971
|
}
|
|
972
|
+
return true;
|
|
973
|
+
};
|
|
974
|
+
/** throws when docker is not installed */
|
|
975
|
+
const verifyDockerInstalled = async (dockerPath, isDev = true) => {
|
|
976
|
+
if (!await isDockerRunning(dockerPath)) throw new UserError(`The Docker CLI could not be launched. Please ensure that the Docker CLI is installed and the daemon is running.
|
|
977
|
+
Other container tooling that is compatible with the Docker CLI and engine may work, but is not yet guaranteed to do so. You can specify an executable with the environment variable WRANGLER_DOCKER_BIN and a socket with DOCKER_HOST.${isDev ? "\nTo suppress this error if you do not intend on triggering any container instances, set dev.enable_containers to false in your Wrangler config or passing in --enable-containers=false." : ""}`);
|
|
972
978
|
};
|
|
973
979
|
function isDir(inputPath) {
|
|
974
980
|
return statSync(inputPath).isDirectory();
|
|
@@ -6886,15 +6892,18 @@ function withTrailingSlash$1(path$3) {
|
|
|
6886
6892
|
}
|
|
6887
6893
|
function createRequestHandler(handler) {
|
|
6888
6894
|
return async (req, res, next) => {
|
|
6895
|
+
let request$1;
|
|
6889
6896
|
try {
|
|
6890
6897
|
if (req.originalUrl) req.url = req.originalUrl;
|
|
6891
|
-
|
|
6898
|
+
request$1 = createRequest(req, res);
|
|
6899
|
+
let response = await handler(toMiniflareRequest(request$1), req);
|
|
6892
6900
|
if (req.httpVersionMajor === 2) {
|
|
6893
6901
|
response = new Response$1(response.body, response);
|
|
6894
6902
|
response.headers.delete("transfer-encoding");
|
|
6895
6903
|
}
|
|
6896
6904
|
await sendResponse(res, response);
|
|
6897
6905
|
} catch (error) {
|
|
6906
|
+
if (request$1?.signal.aborted) return;
|
|
6898
6907
|
next(error);
|
|
6899
6908
|
}
|
|
6900
6909
|
};
|
|
@@ -6909,7 +6918,8 @@ function toMiniflareRequest(request$1) {
|
|
|
6909
6918
|
method: request$1.method,
|
|
6910
6919
|
headers: [["accept-encoding", "identity"], ...request$1.headers],
|
|
6911
6920
|
body: request$1.body,
|
|
6912
|
-
duplex: "half"
|
|
6921
|
+
duplex: "half",
|
|
6922
|
+
signal: request$1.signal
|
|
6913
6923
|
});
|
|
6914
6924
|
}
|
|
6915
6925
|
|
|
@@ -8547,11 +8557,7 @@ async function getDevMiniflareOptions(config) {
|
|
|
8547
8557
|
inspectorPort: inspectorPort === false ? void 0 : inspectorPort,
|
|
8548
8558
|
unsafeDevRegistryPath: getDefaultDevRegistryPath(),
|
|
8549
8559
|
unsafeTriggerHandlers: true,
|
|
8550
|
-
|
|
8551
|
-
const decoder = new TextDecoder();
|
|
8552
|
-
stdout.forEach((data$1) => logger.info(decoder.decode(data$1)));
|
|
8553
|
-
stderr.forEach((error) => logger.logWithLevel(LogLevel.ERROR, decoder.decode(error)));
|
|
8554
|
-
},
|
|
8560
|
+
handleStructuredLogs: getStructuredLogsLogger(logger),
|
|
8555
8561
|
defaultPersistRoot: getPersistenceRoot(resolvedViteConfig.root, resolvedPluginConfig.persistState),
|
|
8556
8562
|
workers: [
|
|
8557
8563
|
...assetWorkers,
|
|
@@ -8691,11 +8697,7 @@ async function getPreviewMiniflareOptions(config) {
|
|
|
8691
8697
|
inspectorPort: inspectorPort === false ? void 0 : inspectorPort,
|
|
8692
8698
|
unsafeDevRegistryPath: getDefaultDevRegistryPath(),
|
|
8693
8699
|
unsafeTriggerHandlers: true,
|
|
8694
|
-
|
|
8695
|
-
const decoder = new TextDecoder();
|
|
8696
|
-
stdout.forEach((data$1) => logger.info(decoder.decode(data$1)));
|
|
8697
|
-
stderr.forEach((error) => logger.logWithLevel(LogLevel.ERROR, decoder.decode(error)));
|
|
8698
|
-
},
|
|
8700
|
+
handleStructuredLogs: getStructuredLogsLogger(logger),
|
|
8699
8701
|
defaultPersistRoot: getPersistenceRoot(resolvedViteConfig.root, resolvedPluginConfig.persistState),
|
|
8700
8702
|
workers
|
|
8701
8703
|
},
|
|
@@ -8728,6 +8730,19 @@ function miniflareLogLevelFromViteLogLevel(level = "info") {
|
|
|
8728
8730
|
case "silent": return LogLevel.NONE;
|
|
8729
8731
|
}
|
|
8730
8732
|
}
|
|
8733
|
+
/**
|
|
8734
|
+
* Generates a log handler to be passed as the `handleStructuredLogs` option to miniflare
|
|
8735
|
+
*
|
|
8736
|
+
* @param logger the vite logger to use
|
|
8737
|
+
* @returns the log handler to pass to miniflare
|
|
8738
|
+
*/
|
|
8739
|
+
function getStructuredLogsLogger(logger) {
|
|
8740
|
+
return ({ level, message }) => {
|
|
8741
|
+
if (level === "warn") return logger.warn(message);
|
|
8742
|
+
if (level === "error") return logger.logWithLevel(LogLevel.ERROR, message);
|
|
8743
|
+
return logger.info(message);
|
|
8744
|
+
};
|
|
8745
|
+
}
|
|
8731
8746
|
|
|
8732
8747
|
//#endregion
|
|
8733
8748
|
//#region ../workers-shared/utils/configuration/parseStaticRouting.ts
|
|
@@ -15710,6 +15725,8 @@ function handleWebSocket(httpServer, getFetcher) {
|
|
|
15710
15725
|
//#region src/index.ts
|
|
15711
15726
|
const debuglog = util.debuglog("@cloudflare:vite-plugin");
|
|
15712
15727
|
let workersConfigsWarningShown = false;
|
|
15728
|
+
/** Used to track whether hooks are being called because of a server restart or a server close event. */
|
|
15729
|
+
let restartingServer = false;
|
|
15713
15730
|
let miniflare;
|
|
15714
15731
|
/**
|
|
15715
15732
|
* Vite plugin that enables a full-featured integration between Vite and the Cloudflare Workers runtime.
|
|
@@ -15721,8 +15738,6 @@ let miniflare;
|
|
|
15721
15738
|
function cloudflare(pluginConfig = {}) {
|
|
15722
15739
|
const ctx = new PluginContext();
|
|
15723
15740
|
let containerImageTagsSeen = /* @__PURE__ */ new Set();
|
|
15724
|
-
/** Used to track whether hooks are being called because of a server restart or a server close event. */
|
|
15725
|
-
let restartingServer = false;
|
|
15726
15741
|
return [
|
|
15727
15742
|
{
|
|
15728
15743
|
name: "vite-plugin-cloudflare",
|