Skip to content

Commit cf33417

Browse files
authored
drop unused WRANGLER_UNENV_RESOLVE_PATHS env var (#9593)
1 parent 748d586 commit cf33417

File tree

7 files changed

+20
-45
lines changed

7 files changed

+20
-45
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/unenv-preset/tests/index.test.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,11 @@ describe(`@cloudflare/unenv-preset ${platform} ${workerdPath}`, () => {
2525
// rather than the one bundled with wrangler.
2626
const MINIFLARE_WORKERD_PATH = workerdPath;
2727

28-
// Use the preset from the local `@cloudflare/unenv-preset` and `unjs/unenv`
29-
// rather than the one bundled with wrangler.
30-
const WRANGLER_UNENV_RESOLVE_PATHS = [
31-
localPresetResolveBaseDir,
32-
localUnenvResolveBaseDir,
33-
].join(",");
34-
3528
wrangler = await runWranglerDev(
3629
path.join(__dirname, "worker"),
3730
["--port=0", "--inspector-port=0"],
3831
{
3932
MINIFLARE_WORKERD_PATH,
40-
WRANGLER_UNENV_RESOLVE_PATHS,
4133
}
4234
);
4335
});

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";
@@ -375,8 +374,6 @@ export async function bundleWorker(
375374
},
376375
};
377376

378-
const unenvResolvePaths = getUnenvResolvePathsFromEnv()?.split(",");
379-
380377
const buildOptions = {
381378
// Don't use entryFile here as the file may have been changed when applying the middleware
382379
entryPoints: [entry.file],
@@ -423,10 +420,9 @@ export async function bundleWorker(
423420
plugins: [
424421
aliasPlugin,
425422
moduleCollector.plugin,
426-
...(await getNodeJSCompatPlugins({
423+
...getNodeJSCompatPlugins({
427424
mode: nodejsCompatMode ?? null,
428-
unenvResolvePaths,
429-
})),
425+
}),
430426
cloudflareInternalPlugin,
431427
buildResultPlugin,
432428
...(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
@@ -7,20 +7,19 @@ import type { NodeJSCompatMode } from "miniflare";
77
/**
88
* Returns the list of ESBuild plugins to use for a given compat mode.
99
*/
10-
export async function getNodeJSCompatPlugins({
10+
export function getNodeJSCompatPlugins({
1111
mode,
12-
unenvResolvePaths,
1312
}: {
1413
mode: NodeJSCompatMode;
1514
unenvResolvePaths?: string[];
16-
}): Promise<Plugin[]> {
15+
}): Plugin[] {
1716
switch (mode) {
1817
case "als":
1918
return [asyncLocalStoragePlugin, nodejsCompatPlugin(mode)];
2019
case "v1":
2120
return [nodejsCompatPlugin(mode)];
2221
case "v2":
23-
return [await nodejsHybridPlugin(unenvResolvePaths)];
22+
return [nodejsHybridPlugin()];
2423
case null:
2524
return [nodejsCompatPlugin(mode)];
2625
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ type VariableNames =
3131
| "WRANGLER_CI_GENERATE_PREVIEW_ALIAS"
3232
| "WRANGLER_BUILD_CONDITIONS"
3333
| "WRANGLER_BUILD_PLATFORM"
34-
| "WRANGLER_UNENV_RESOLVE_PATHS"
3534
| "WRANGLER_REGISTRY_PATH"
3635
| "WRANGLER_CONTAINERS_DOCKER_PATH";
3736

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

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

233-
/**
234-
* `WRANGLER_UNENV_RESOLVE_PATHS` lists the paths used to resolve unenv.
235-
*
236-
* Note: multiple comma separated paths can be specified.
237-
*
238-
* By default wrangler uses the unenv preset version installed from the package.json.
239-
*
240-
* Setting root paths allow to use a different version of the preset.
241-
*/
242-
export const getUnenvResolvePathsFromEnv = getEnvironmentVariableFactory({
243-
variableName: "WRANGLER_UNENV_RESOLVE_PATHS",
244-
});
245-
246233
/**
247234
* `WRANGLER_REGISTRY_PATH` specifies the file based dev registry folder
248235
*/

0 commit comments

Comments
 (0)