@autter/runtime-cli 1.0.0 → 1.1.0

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/next.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { A as AutterSourceMapsOptions } from './build-BXFh_jbP.cjs';
1
+ import { A as AutterSourceMapsOptions } from './build-CPXR9Xd3.cjs';
2
2
 
3
3
  type NextConfigObject = Record<string, any>;
4
4
  type NextConfigFunction = (phase: string, context: {
@@ -9,7 +9,8 @@ declare function installedNextVersion(cwd?: string): string | null;
9
9
  /**
10
10
  * Next.js config wrapper: hidden source maps for client production builds,
11
11
  * debug ids injected into every client chunk, maps uploaded after the build
12
- * when AUTTER_RUNTIME_KEY (or `key`) is set. Works with webpack builds, and
12
+ * when AUTTER_RUNTIME_KEY (or `key`) is set, then deleted whatever the
13
+ * upload's outcome (without a key, no maps are turned on at all). Works with webpack builds, and
13
14
  * with Turbopack builds on Next.js 15.4.1+ (`compiler.runAfterProductionCompile`).
14
15
  *
15
16
  * ```js
package/dist/next.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { A as AutterSourceMapsOptions } from './build-BXFh_jbP.js';
1
+ import { A as AutterSourceMapsOptions } from './build-CPXR9Xd3.js';
2
2
 
3
3
  type NextConfigObject = Record<string, any>;
4
4
  type NextConfigFunction = (phase: string, context: {
@@ -9,7 +9,8 @@ declare function installedNextVersion(cwd?: string): string | null;
9
9
  /**
10
10
  * Next.js config wrapper: hidden source maps for client production builds,
11
11
  * debug ids injected into every client chunk, maps uploaded after the build
12
- * when AUTTER_RUNTIME_KEY (or `key`) is set. Works with webpack builds, and
12
+ * when AUTTER_RUNTIME_KEY (or `key`) is set, then deleted whatever the
13
+ * upload's outcome (without a key, no maps are turned on at all). Works with webpack builds, and
13
14
  * with Turbopack builds on Next.js 15.4.1+ (`compiler.runAfterProductionCompile`).
14
15
  *
15
16
  * ```js
package/dist/next.js CHANGED
@@ -1,9 +1,12 @@
1
1
  import {
2
2
  AutterSourceMapsWebpackPlugin
3
- } from "./chunk-GGHHEUPQ.js";
3
+ } from "./chunk-I2743JCN.js";
4
4
  import {
5
- processBuildOutput
6
- } from "./chunk-SIRFO2QU.js";
5
+ findMapFiles,
6
+ logMapsNotGenerated,
7
+ processBuildOutput,
8
+ shouldGenerateMaps
9
+ } from "./chunk-DQLLM2NT.js";
7
10
 
8
11
  // src/next.ts
9
12
  import { createRequire } from "module";
@@ -28,7 +31,15 @@ function hasAfterCompileHook(version) {
28
31
  }
29
32
  function wrapConfig(config, options) {
30
33
  const publicMaps = config.productionBrowserSourceMaps === true;
34
+ const ownMaps = !publicMaps && shouldGenerateMaps(options);
31
35
  const deleteAfterUpload = options.deleteAfterUpload ?? !publicMaps;
36
+ let notified = false;
37
+ const notifyNoMaps = () => {
38
+ if (!publicMaps && !ownMaps && !notified) {
39
+ notified = true;
40
+ logMapsNotGenerated(options);
41
+ }
42
+ };
32
43
  const base = String(config.assetPrefix || config.basePath || "").replace(/\/+$/, "");
33
44
  const nextPrefix = `${base}/_next/`;
34
45
  const useHook = hasAfterCompileHook(installedNextVersion());
@@ -38,11 +49,14 @@ function wrapConfig(config, options) {
38
49
  webpack(webpackConfig, context) {
39
50
  const result = typeof userWebpack === "function" ? userWebpack(webpackConfig, context) : webpackConfig;
40
51
  if (!context.isServer && !context.dev) {
41
- if (!publicMaps) result.devtool = "hidden-source-map";
52
+ if (ownMaps) result.devtool = "hidden-source-map";
42
53
  if (!useHook) {
43
54
  result.plugins = [
44
55
  ...result.plugins ?? [],
45
- new AutterSourceMapsWebpackPlugin({ ...options, urlPrefix: options.urlPrefix ?? nextPrefix, deleteAfterUpload })
56
+ new AutterSourceMapsWebpackPlugin(
57
+ { ...options, urlPrefix: options.urlPrefix ?? nextPrefix, deleteAfterUpload },
58
+ { ownMaps }
59
+ )
46
60
  ];
47
61
  }
48
62
  }
@@ -50,19 +64,24 @@ function wrapConfig(config, options) {
50
64
  }
51
65
  };
52
66
  if (useHook) {
53
- wrapped.productionBrowserSourceMaps = true;
67
+ if (ownMaps) wrapped.productionBrowserSourceMaps = true;
54
68
  const userHook = config.compiler?.runAfterProductionCompile;
55
69
  wrapped.compiler = {
56
70
  ...config.compiler,
57
71
  async runAfterProductionCompile(ctx = {}) {
58
72
  if (typeof userHook === "function") await userHook(ctx);
59
73
  const distDir = ctx.distDir ?? resolve(ctx.projectDir ?? process.cwd(), String(config.distDir ?? ".next"));
74
+ const staticDir = join(distDir, "static");
75
+ notifyNoMaps();
60
76
  await processBuildOutput({
61
- dir: join(distDir, "static"),
77
+ dir: staticDir,
62
78
  urlPrefix: options.urlPrefix ?? `${nextPrefix}static/`,
63
79
  options: { ...options, deleteAfterUpload },
64
80
  deleteAfterUpload,
65
- stripSourceMappingUrl: !publicMaps
81
+ stripSourceMappingUrl: !publicMaps,
82
+ ownMaps,
83
+ // Every client map (JS and CSS): .next/static is deployed as is.
84
+ maps: ownMaps ? await findMapFiles(staticDir) : void 0
66
85
  });
67
86
  }
68
87
  };