@glasstrace/sdk 0.14.0 → 0.14.2

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.cts CHANGED
@@ -488,7 +488,25 @@ declare function registerGlasstrace(options?: GlasstraceOptions): void;
488
488
  */
489
489
  declare function getDiscoveryHandler(): ((request: Request) => Promise<Response | null>) | null;
490
490
 
491
- type NextConfig = Record<string, unknown>;
491
+ /**
492
+ * Structural view of Next.js's `NextConfig`. The SDK does not import Next's
493
+ * type directly because Next is not a peer dependency — this wrapper must
494
+ * type-check regardless of which Next.js version the consumer has installed.
495
+ *
496
+ * The constraint is `object` rather than `Record<string, unknown>` because
497
+ * Next's actual `NextConfig` is an interface *without* a string index
498
+ * signature. Requiring `[key: string]: unknown` would fail the assignability
499
+ * check that caused DISC-1256, reported by Next 16 consumers as:
500
+ * > Argument of type 'NextConfig' is not assignable to parameter of type
501
+ * > 'NextConfig'. Index signature for type 'string' is missing in type
502
+ * > 'NextConfig'.
503
+ *
504
+ * `object` accepts every non-primitive value, which is what the wrapper
505
+ * actually handles at runtime (it shallow-copies the input and reads a few
506
+ * known properties defensively). Combined with the generic signature on
507
+ * `withGlasstraceConfig`, callers preserve their exact config subtype.
508
+ */
509
+ type NextConfig = object;
492
510
  /**
493
511
  * Wraps the developer's Next.js config to enable source map generation
494
512
  * and upload .map files to the ingestion API at build time.
@@ -496,10 +514,26 @@ type NextConfig = Record<string, unknown>;
496
514
  * The build NEVER fails because of Glasstrace — all errors are caught
497
515
  * and logged as warnings.
498
516
  *
517
+ * ## Turbopack
518
+ *
519
+ * Next.js 16 made Turbopack the default bundler for `next build`, and Next
520
+ * rejects configs that set `webpack` without also setting `turbopack`. This
521
+ * wrapper therefore seeds an empty `turbopack: {}` when the user has not set
522
+ * one themselves, preserving existing behaviour for explicit Turbopack configs.
523
+ *
524
+ * **Source-map upload is currently webpack-only.** Under Turbopack the build
525
+ * succeeds, but the afterEmit hook that collects and uploads `.map` files does
526
+ * not fire. Run `next build --webpack` to get source-map uploads, or wait for
527
+ * a follow-up release that ports the plugin to Turbopack.
528
+ *
499
529
  * @param nextConfig - The developer's existing Next.js configuration object.
500
530
  * @returns A new config object with source map generation and upload enabled.
531
+ * The return type mirrors the input type so that caller-side config
532
+ * properties are preserved. The `object` constraint (rather than
533
+ * `Record<string, unknown>`) is what makes the wrapper accept Next's
534
+ * real `NextConfig` interface (DISC-1256).
501
535
  */
502
- declare function withGlasstraceConfig(nextConfig: NextConfig): NextConfig;
536
+ declare function withGlasstraceConfig<T extends NextConfig>(nextConfig: T): T;
503
537
 
504
538
  /**
505
539
  * Returns true when the SDK is in ACTIVE or ACTIVE_DEGRADED state.
package/dist/index.d.ts CHANGED
@@ -488,7 +488,25 @@ declare function registerGlasstrace(options?: GlasstraceOptions): void;
488
488
  */
489
489
  declare function getDiscoveryHandler(): ((request: Request) => Promise<Response | null>) | null;
490
490
 
491
- type NextConfig = Record<string, unknown>;
491
+ /**
492
+ * Structural view of Next.js's `NextConfig`. The SDK does not import Next's
493
+ * type directly because Next is not a peer dependency — this wrapper must
494
+ * type-check regardless of which Next.js version the consumer has installed.
495
+ *
496
+ * The constraint is `object` rather than `Record<string, unknown>` because
497
+ * Next's actual `NextConfig` is an interface *without* a string index
498
+ * signature. Requiring `[key: string]: unknown` would fail the assignability
499
+ * check that caused DISC-1256, reported by Next 16 consumers as:
500
+ * > Argument of type 'NextConfig' is not assignable to parameter of type
501
+ * > 'NextConfig'. Index signature for type 'string' is missing in type
502
+ * > 'NextConfig'.
503
+ *
504
+ * `object` accepts every non-primitive value, which is what the wrapper
505
+ * actually handles at runtime (it shallow-copies the input and reads a few
506
+ * known properties defensively). Combined with the generic signature on
507
+ * `withGlasstraceConfig`, callers preserve their exact config subtype.
508
+ */
509
+ type NextConfig = object;
492
510
  /**
493
511
  * Wraps the developer's Next.js config to enable source map generation
494
512
  * and upload .map files to the ingestion API at build time.
@@ -496,10 +514,26 @@ type NextConfig = Record<string, unknown>;
496
514
  * The build NEVER fails because of Glasstrace — all errors are caught
497
515
  * and logged as warnings.
498
516
  *
517
+ * ## Turbopack
518
+ *
519
+ * Next.js 16 made Turbopack the default bundler for `next build`, and Next
520
+ * rejects configs that set `webpack` without also setting `turbopack`. This
521
+ * wrapper therefore seeds an empty `turbopack: {}` when the user has not set
522
+ * one themselves, preserving existing behaviour for explicit Turbopack configs.
523
+ *
524
+ * **Source-map upload is currently webpack-only.** Under Turbopack the build
525
+ * succeeds, but the afterEmit hook that collects and uploads `.map` files does
526
+ * not fire. Run `next build --webpack` to get source-map uploads, or wait for
527
+ * a follow-up release that ports the plugin to Turbopack.
528
+ *
499
529
  * @param nextConfig - The developer's existing Next.js configuration object.
500
530
  * @returns A new config object with source map generation and upload enabled.
531
+ * The return type mirrors the input type so that caller-side config
532
+ * properties are preserved. The `object` constraint (rather than
533
+ * `Record<string, unknown>`) is what makes the wrapper accept Next's
534
+ * real `NextConfig` interface (DISC-1256).
501
535
  */
502
- declare function withGlasstraceConfig(nextConfig: NextConfig): NextConfig;
536
+ declare function withGlasstraceConfig<T extends NextConfig>(nextConfig: T): T;
503
537
 
504
538
  /**
505
539
  * Returns true when the SDK is in ACTIVE or ACTIVE_DEGRADED state.
package/dist/index.js CHANGED
@@ -13,7 +13,7 @@ import {
13
13
  uploadSourceMaps,
14
14
  uploadSourceMapsAuto,
15
15
  uploadSourceMapsPresigned
16
- } from "./chunk-ERGEG4ZQ.js";
16
+ } from "./chunk-2LDBR3F3.js";
17
17
  import {
18
18
  buildImportGraph,
19
19
  discoverTestFiles,
@@ -4681,7 +4681,7 @@ function registerGlasstrace(options) {
4681
4681
  setCoreState(CoreState.REGISTERING);
4682
4682
  startRuntimeStateWriter({
4683
4683
  projectRoot: process.cwd(),
4684
- sdkVersion: "0.14.0"
4684
+ sdkVersion: "0.14.2"
4685
4685
  });
4686
4686
  const config = resolveConfig(options);
4687
4687
  if (config.verbose) {
@@ -4843,8 +4843,8 @@ async function backgroundInit(config, anonKeyForInit, generation) {
4843
4843
  if (config.verbose) {
4844
4844
  console.info("[glasstrace] Background init firing.");
4845
4845
  }
4846
- const healthReport = collectHealthReport("0.14.0");
4847
- const initResult = await performInit(config, anonKeyForInit, "0.14.0", healthReport);
4846
+ const healthReport = collectHealthReport("0.14.2");
4847
+ const initResult = await performInit(config, anonKeyForInit, "0.14.2", healthReport);
4848
4848
  if (generation !== registrationGeneration) return;
4849
4849
  const currentState = getCoreState();
4850
4850
  if (currentState === CoreState.SHUTTING_DOWN || currentState === CoreState.SHUTDOWN) {
@@ -4867,7 +4867,7 @@ async function backgroundInit(config, anonKeyForInit, generation) {
4867
4867
  }
4868
4868
  maybeInstallConsoleCapture();
4869
4869
  if (didLastInitSucceed()) {
4870
- startHeartbeat(config, anonKeyForInit, "0.14.0", generation, (newApiKey, accountId) => {
4870
+ startHeartbeat(config, anonKeyForInit, "0.14.2", generation, (newApiKey, accountId) => {
4871
4871
  setAuthState(AuthState.CLAIMING);
4872
4872
  emitLifecycleEvent("auth:claim_started", { accountId });
4873
4873
  setResolvedApiKey(newApiKey);
@@ -4898,16 +4898,34 @@ function isDiscoveryEnabled(config) {
4898
4898
 
4899
4899
  // src/config-wrapper.ts
4900
4900
  init_esm_shims();
4901
+ function isTurbopackBuild() {
4902
+ if (typeof process === "undefined") return false;
4903
+ const argv = Array.isArray(process.argv) ? process.argv : [];
4904
+ if (argv.includes("--webpack")) return false;
4905
+ if (argv.includes("--turbopack")) return true;
4906
+ if (process.env?.TURBOPACK === "1") return true;
4907
+ return false;
4908
+ }
4901
4909
  function withGlasstraceConfig(nextConfig) {
4902
4910
  if (typeof process === "undefined" || typeof process.versions?.node !== "string") {
4903
4911
  return nextConfig != null ? { ...nextConfig } : {};
4904
4912
  }
4905
4913
  const config = nextConfig != null ? { ...nextConfig } : {};
4906
- const existingExperimental = config.experimental ?? {};
4907
- config.experimental = { ...existingExperimental, serverSourceMaps: true };
4908
- const distDir = typeof config.distDir === "string" ? config.distDir : ".next";
4909
- const existingWebpack = config.webpack;
4910
- config.webpack = (webpackConfig, context2) => {
4914
+ const bag = config;
4915
+ const existingExperimental = bag.experimental ?? {};
4916
+ bag.experimental = {
4917
+ ...existingExperimental,
4918
+ serverSourceMaps: true
4919
+ };
4920
+ if (bag.turbopack == null) {
4921
+ bag.turbopack = {};
4922
+ }
4923
+ if (isTurbopackBuild()) {
4924
+ warnTurbopackLimitationOnce();
4925
+ }
4926
+ const distDir = typeof bag.distDir === "string" ? bag.distDir : ".next";
4927
+ const existingWebpack = bag.webpack;
4928
+ bag.webpack = (webpackConfig, context2) => {
4911
4929
  let result = webpackConfig;
4912
4930
  if (typeof existingWebpack === "function") {
4913
4931
  result = existingWebpack(webpackConfig, context2);
@@ -4934,6 +4952,14 @@ function withGlasstraceConfig(nextConfig) {
4934
4952
  };
4935
4953
  return config;
4936
4954
  }
4955
+ var _turbopackWarningEmitted = false;
4956
+ function warnTurbopackLimitationOnce() {
4957
+ if (_turbopackWarningEmitted) return;
4958
+ _turbopackWarningEmitted = true;
4959
+ console.warn(
4960
+ "[glasstrace] Turbopack detected. Source-map upload currently runs only under webpack \u2014 run `next build --webpack` to upload source maps, or wait for the Turbopack port in a future SDK release."
4961
+ );
4962
+ }
4937
4963
  async function handleSourceMapUpload(distDir) {
4938
4964
  try {
4939
4965
  const apiKey = process.env.GLASSTRACE_API_KEY;
@@ -4944,7 +4970,7 @@ async function handleSourceMapUpload(distDir) {
4944
4970
  );
4945
4971
  return;
4946
4972
  }
4947
- const { discoverSourceMapFiles: discoverSourceMapFiles2, computeBuildHash: computeBuildHash2, uploadSourceMaps: uploadSourceMaps2 } = await import("./source-map-uploader-W6VPGY26.js");
4973
+ const { discoverSourceMapFiles: discoverSourceMapFiles2, computeBuildHash: computeBuildHash2, uploadSourceMaps: uploadSourceMaps2 } = await import("./source-map-uploader-3GWUQDTS.js");
4948
4974
  const files = await discoverSourceMapFiles2(distDir);
4949
4975
  if (files.length === 0) {
4950
4976
  console.info("[glasstrace] No source map files found. Skipping upload.");