Skip to content

@cloudflare/vite-plugin: AWS SDK v3 (≥ @aws-sdk/core 3.974) crashes in dev — subpath-barrel re-exports resolve to undefined #14600

Description

@feliperohdee

Which Cloudflare product(s)?

@cloudflare/vite-plugin

Summary

On a fresh install, any Worker that constructs an AWS SDK v3 client (e.g. new DynamoDBClient({})) throws at runtime in vite dev:

[vite] Internal server error: (0 , __vite_ssr_import_5__.emitWarningIfUnsupportedVersion) is not a function
    at getRuntimeConfig (node_modules/@aws-sdk/client-dynamodb/dist-es/runtimeConfig.js:18:5)
    at new DynamoDBClient (node_modules/@aws-sdk/client-dynamodb/dist-es/DynamoDBClient.js:20:27)
    at Object.fetch (worker/index.ts)

The Worker's Vite environment runs @aws-sdk/* / @smithy/* through the SSR module runner, and it cannot resolve named re-exports that pass through the subpath-barrel entrypoints (@aws-sdk/core/client, @smithy/core/client) introduced in the current AWS SDK generation — the binding comes back undefined.

Reproduction

Worker entry:

import { DynamoDBClient } from '@aws-sdk/client-dynamodb';

export default {
  async fetch() {
    new DynamoDBClient({ region: 'us-east-1' }); // throws during construction
    return new Response('ok');
  },
};

package.json (fresh install today resolves the broken generation):

"@aws-sdk/client-dynamodb": "^3.983.0"   // → resolves 3.1081.0
// transitively: @aws-sdk/core 3.974.29, @smithy/smithy-client 4.14.6, @smithy/core 3.29.1

wrangler.jsonc: "compatibility_flags": ["nodejs_compat"], "compatibility_date": "2026-03-10".

Hit the Worker once → 500 with the error above.

Environment

  • @cloudflare/vite-plugin: 1.43.2 (also repro on 1.41.0)
  • vite: 6.4.3
  • wrangler: 4.108.0
  • node: v22.17.0
  • OS: macOS (darwin 25.5.0)

Root cause

AWS reorganized the SDK internals so that top-level entrypoints re-export through subpath barrels. Example — installed @aws-sdk/core@3.974.29:

// @aws-sdk/core/dist-es/index.js
export { emitWarningIfUnsupportedVersion, ... } from "@aws-sdk/core/client";

@smithy/smithy-client@4.14.6 does the same via @smithy/core/client. The Worker environment's SSR runner resolves emitWarningIfUnsupportedVersion off that re-export chain as undefined, so calling it throws.

This is the downstream effect of an intentional AWS change — aws/aws-sdk-js-v3#7686 (v3.974.0, "Changes to AWS SDK internal package dependency version pinning"), which AWS closed as working-as-intended ("No changes are needed by AWS SDK users"). Because AWS declares every internal dep with ^caret ranges, a fresh install always floats the entire @aws-sdk/* + @smithy/* tree into this generation.

The previous generation resolves fine (@aws-sdk/core@3.973.27, @smithy/smithy-client@4.12.9), because those define the exports locally / via relative paths rather than through the subpath barrel.

What I tried (workarounds that do NOT work)

  1. environments.<worker>.optimizeDeps.include: ['@aws-sdk/client-dynamodb', '@aws-sdk/lib-dynamodb']
    → pre-bundles a standalone @aws-sdk_client-dynamodb.js (esbuild does resolve the barrel there), but the actual importer keeps its own copy and still throws.
  2. Nested syntax include: ['use-dynamodb > @aws-sdk/client-dynamodb']
    → no effect (looks like ssr.optimizeDeps.include with dep1 > dep2 syntax not working vitejs/vite#16405dep1 > dep2 not honored in the SSR/Worker environment).
  3. optimizeDeps.exclude / resolve.external → rejected as incompatible with @cloudflare/vite-plugin (@cloudflare/vite-plugin doesn't allow optimizeDeps.exclude for framework packages to avoid being optimized #9538).

Current workaround

Pin the whole @aws-sdk/* + @smithy/* tree back to the last pre-3.974 generation via resolutions (yarn) / overrides (npm/pnpm). Pinning a single package skews (the newer middleware re-export from the newer @aws-sdk/core/client), so the entire generation must be pinned together.

Expected

The Worker environment's dep optimizer / SSR runner should resolve named re-exports through AWS SDK v3's subpath-barrel entrypoints, so the current (default-installed) AWS SDK works in vite dev without version pinning.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    Untriaged

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions