Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing Source Map Files in @kubernetes/client-node@1.0.0 Cause ~100 Vite Warnings #2249

Closed
MichaelJCole opened this issue Feb 22, 2025 · 5 comments · Fixed by #2260
Closed

Comments

@MichaelJCole
Copy link

MichaelJCole commented Feb 22, 2025

Missing Source Map Files in @kubernetes/client-node@1.0.0 Cause Vite Warnings

Description

The @kubernetes/client-node package (v1.0.0) includes source map comments (e.g., //# sourceMappingURL=StorageV1alpha1Api.js.map) in its generated JS files under dist/gen/apis/, but the .map files are not included in the npm package. This causes repeated "Failed to load source map" warnings in Vite (used by Nuxt 3) during development, cluttering logs and confusing developers. The warnings are cosmetic but degrade the dev experience due to a packaging issue.

Steps to Reproduce

  1. Create a Nuxt 3 project:
    npx nuxi init k8s-test
    cd k8s-test
    npm install
    npm install @kubernetes/client-node@1.0.0
    
  2. Add to server/utils/ingress.ts:
    import * as k8s from '@kubernetes/client-node';
    export async function testK8s() {
      const kc = new k8s.KubeConfig();
      kc.loadFromCluster();
      const k8sApi = kc.makeApiClient(k8s.NetworkingV1Api);
      console.log('K8s API initialized');
    }
  3. Add to plugins/test.server.ts:
    import { defineNuxtPlugin } from '#app';
    import { testK8s } from '~/server/utils/ingress';
    export default defineNuxtPlugin(() => { testK8s(); });
  4. Run npm run dev and check logs.

Expected Behavior

No source map warnings, either by including .map files or removing the comments.

Actual Behavior

~100 Warnings like:

[7:46:46 PM]  WARN  Failed to load source map for /node_modules/@kubernetes/client-node/dist/gen/apis/StorageV1alpha1Api.js.
Error: ENOENT: no such file or directory, open '/node_modules/@kubernetes/client-node/dist/gen/apis/StorageV1alpha1Api.js.map'

Examples

  • Affected files: StorageV1alpha1Api.js, CoreV1Api.js, util.js, etc.
  • Warning: See above log snippet.

Why It’s a Problem

Clutters dev logs, confuses developers, adds minor overhead.

Suggested Fix

  • Include .map files in the package, or
  • Remove //# sourceMappingURL=... comments during build (e.g., --sourceMap false).

Workaround

Patch locally with patch-package:

npm install --save-dev patch-package
find node_modules/@kubernetes/client-node/dist/gen -name '*.js' -exec sed -i 's://# sourceMappingURL=.*$::g' {} +
npx patch-package @kubernetes/client-node

Context

  • Version: @kubernetes/client-node@1.0.0
  • Environment: Nuxt 3 (Vite), Node.js 22.11.0
@MichaelJCole MichaelJCole changed the title Missing Source Map Files in @kubernetes/client-node@1.0.0 Cause Vite Warnings Missing Source Map Files in @kubernetes/client-node@1.0.0 Cause ~100 Vite Warnings Feb 22, 2025
@cjihrig
Copy link
Contributor

cjihrig commented Feb 22, 2025

I'm leaning toward removing the source maps. All of the transpiled files that I checked appear to be very readable and don't really benefit from having source maps. What do other folks think?

@brendandburns
Copy link
Contributor

We should definitely remove them for generated code. That's not meant to be read anyway.

Is there a way that we can exclude for generated code, but retain for hand-written code?

@cjihrig
Copy link
Contributor

cjihrig commented Feb 23, 2025

I'm not sure that we can do it without two separate build steps, but I'm also not 100% sure. I don't think it makes sense to disable them only for certain files though. Even though the generated code isn't meant to be read, you'd be stuck if you were trying to debug code that entered the generated code and that code happened to be unreadable.

@MichaelJCole I realize you mostly just want the Vite warnings to go away, but as a user, do you think having or not having the source maps would make any difference to you?

@MichaelJCole
Copy link
Author

MichaelJCole commented Feb 23, 2025 via email

cjihrig added a commit to cjihrig/javascript that referenced this issue Feb 23, 2025
This commit includes the generated source maps in the artifact
published to npm. This commit also simplifies the patterns used
to match files. Some files, such as README are always included,
so it has been removed here.

Refs: https://docs.npmjs.com/cli/v11/configuring-npm/package-json#files
Fixes: kubernetes-client#2249
@cjihrig
Copy link
Contributor

cjihrig commented Feb 23, 2025

Opened #2260 to include the source maps. You can test it by running npm pack.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants