Skip to content

Commit 0f2f75d

Browse files
authored
drop unused WRANGLER_UNENV_RESOLVE_PATHS env var (#9594)
1 parent c3c8a69 commit 0f2f75d

File tree

6 files changed

+20
-37
lines changed

6 files changed

+20
-37
lines changed

.changeset/sharp-phones-hope.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"wrangler": patch
3+
---
4+
5+
drop unused `WRANGLER_UNENV_RESOLVE_PATHS` env var

packages/wrangler/src/deployment-bundle/bundle.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import * as esbuild from "esbuild";
55
import {
66
getBuildConditionsFromEnv,
77
getBuildPlatformFromEnv,
8-
getUnenvResolvePathsFromEnv,
98
} from "../environment-variables/misc-variables";
109
import { UserError } from "../errors";
1110
import { getFlag } from "../experimental-flags";
@@ -417,8 +416,6 @@ export async function bundleWorker(
417416
},
418417
};
419418

420-
const unenvResolvePaths = getUnenvResolvePathsFromEnv()?.split(",");
421-
422419
const buildOptions = {
423420
// Don't use entryFile here as the file may have been changed when applying the middleware
424421
entryPoints: [entry.file],
@@ -464,10 +461,9 @@ export async function bundleWorker(
464461
plugins: [
465462
aliasPlugin,
466463
moduleCollector.plugin,
467-
...(await getNodeJSCompatPlugins({
464+
...getNodeJSCompatPlugins({
468465
mode: nodejsCompatMode ?? null,
469-
unenvResolvePaths,
470-
})),
466+
}),
471467
cloudflareInternalPlugin,
472468
buildResultPlugin,
473469
...(plugins || []),

packages/wrangler/src/deployment-bundle/esbuild-plugins/hybrid-nodejs-compat.ts

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,20 @@ const REQUIRED_UNENV_ALIAS_NAMESPACE = "required-unenv-alias";
1111
/**
1212
* ESBuild plugin to apply the unenv preset.
1313
*
14-
* @param _unenvResolvePaths Root paths used to resolve absolute paths.
1514
* @returns ESBuild plugin
1615
*/
17-
export async function nodejsHybridPlugin(
18-
_unenvResolvePaths?: string[]
19-
): Promise<Plugin> {
20-
// `unenv` and `@cloudflare/unenv-preset` only publish esm
21-
const { defineEnv } = await import("unenv");
22-
const { cloudflare } = await import("@cloudflare/unenv-preset");
23-
const { alias, inject, external, polyfill } = defineEnv({
24-
presets: [cloudflare],
25-
npmShims: true,
26-
}).env;
27-
16+
export function nodejsHybridPlugin(): Plugin {
2817
return {
2918
name: "hybrid-nodejs_compat",
30-
setup(build) {
19+
async setup(build) {
20+
// `unenv` and `@cloudflare/unenv-preset` only publish esm
21+
const { defineEnv } = await import("unenv");
22+
const { cloudflare } = await import("@cloudflare/unenv-preset");
23+
const { alias, inject, external, polyfill } = defineEnv({
24+
presets: [cloudflare],
25+
npmShims: true,
26+
}).env;
27+
3128
errorOnServiceWorkerFormat(build);
3229
handleRequireCallsToNodeJSBuiltins(build);
3330
handleUnenvAliasedPackages(build, alias, external);

packages/wrangler/src/deployment-bundle/esbuild-plugins/nodejs-plugins.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,12 @@ import type { NodeJSCompatMode } from "miniflare";
1010
/**
1111
* Returns the list of ESBuild plugins to use for a given compat mode.
1212
*/
13-
export async function getNodeJSCompatPlugins({
13+
export function getNodeJSCompatPlugins({
1414
mode,
15-
unenvResolvePaths,
1615
}: {
1716
mode: NodeJSCompatMode;
1817
unenvResolvePaths?: string[];
19-
}): Promise<Plugin[]> {
18+
}): Plugin[] {
2019
switch (mode) {
2120
case "als":
2221
return [asyncLocalStoragePlugin, nodejsCompatPlugin(mode)];
@@ -30,7 +29,7 @@ export async function getNodeJSCompatPlugins({
3029
case "v1":
3130
return [nodejsCompatPlugin(mode)];
3231
case "v2":
33-
return [await nodejsHybridPlugin(unenvResolvePaths)];
32+
return [nodejsHybridPlugin()];
3433
case null:
3534
return [nodejsCompatPlugin(mode)];
3635
}

packages/wrangler/src/environment-variables/factory.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ type VariableNames =
2626
| "WRANGLER_CI_OVERRIDE_NAME"
2727
| "WRANGLER_BUILD_CONDITIONS"
2828
| "WRANGLER_BUILD_PLATFORM"
29-
| "WRANGLER_UNENV_RESOLVE_PATHS"
3029
| "WRANGLER_REGISTRY_PATH";
3130

3231
type DeprecatedNames =

packages/wrangler/src/environment-variables/misc-variables.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -135,19 +135,6 @@ export const getBuildPlatformFromEnv = getEnvironmentVariableFactory({
135135
variableName: "WRANGLER_BUILD_PLATFORM",
136136
});
137137

138-
/**
139-
* `WRANGLER_UNENV_RESOLVE_PATHS` lists the paths used to resolve unenv.
140-
*
141-
* Note: multiple comma separated paths can be specified.
142-
*
143-
* By default wrangler uses the unenv preset version installed from the package.json.
144-
*
145-
* Setting root paths allow to use a different version of the preset.
146-
*/
147-
export const getUnenvResolvePathsFromEnv = getEnvironmentVariableFactory({
148-
variableName: "WRANGLER_UNENV_RESOLVE_PATHS",
149-
});
150-
151138
/**
152139
* `WRANGLER_REGISTRY_PATH` specifies the file based dev registry folder
153140
*/

0 commit comments

Comments
 (0)