@impakers/debug 1.3.4 → 1.3.5

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.
@@ -0,0 +1,25 @@
1
+ /** Next.js config type (인라인 정의 — next를 devDependency로 안 끌어옴) */
2
+ interface NextConfig {
3
+ productionBrowserSourceMaps?: boolean;
4
+ webpack?: (config: any, context: any) => any;
5
+ [key: string]: any;
6
+ }
7
+ interface ImpakersDebugOptions {
8
+ /**
9
+ * sourcesContent를 strip할지 여부 (기본: true)
10
+ * false로 설정하면 소스코드가 .map에 그대로 노출됨
11
+ */
12
+ stripSourceContent?: boolean;
13
+ }
14
+ /**
15
+ * Next.js config wrapper — 소스맵 설정 자동 구성
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * import { withImpakersDebug } from '@impakers/debug/next'
20
+ * export default withImpakersDebug(nextConfig)
21
+ * ```
22
+ */
23
+ declare function withImpakersDebug(nextConfig: NextConfig, options?: ImpakersDebugOptions): NextConfig;
24
+
25
+ export { withImpakersDebug };
package/dist/next.d.ts ADDED
@@ -0,0 +1,25 @@
1
+ /** Next.js config type (인라인 정의 — next를 devDependency로 안 끌어옴) */
2
+ interface NextConfig {
3
+ productionBrowserSourceMaps?: boolean;
4
+ webpack?: (config: any, context: any) => any;
5
+ [key: string]: any;
6
+ }
7
+ interface ImpakersDebugOptions {
8
+ /**
9
+ * sourcesContent를 strip할지 여부 (기본: true)
10
+ * false로 설정하면 소스코드가 .map에 그대로 노출됨
11
+ */
12
+ stripSourceContent?: boolean;
13
+ }
14
+ /**
15
+ * Next.js config wrapper — 소스맵 설정 자동 구성
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * import { withImpakersDebug } from '@impakers/debug/next'
20
+ * export default withImpakersDebug(nextConfig)
21
+ * ```
22
+ */
23
+ declare function withImpakersDebug(nextConfig: NextConfig, options?: ImpakersDebugOptions): NextConfig;
24
+
25
+ export { withImpakersDebug };
package/dist/next.js ADDED
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/next.ts
21
+ var next_exports = {};
22
+ __export(next_exports, {
23
+ withImpakersDebug: () => withImpakersDebug
24
+ });
25
+ module.exports = __toCommonJS(next_exports);
26
+ var StripSourceContentPlugin = class {
27
+ apply(compiler) {
28
+ compiler.hooks.afterEmit.tapAsync(
29
+ "ImpakersDebugStripSourceContent",
30
+ (compilation, callback) => {
31
+ const fs = require("fs");
32
+ const path = require("path");
33
+ const outputPath = compilation.outputOptions?.path;
34
+ if (!outputPath) {
35
+ callback();
36
+ return;
37
+ }
38
+ const staticDir = path.resolve(outputPath, "../static");
39
+ if (!fs.existsSync(staticDir)) {
40
+ callback();
41
+ return;
42
+ }
43
+ const findMaps = (dir) => {
44
+ const results = [];
45
+ try {
46
+ for (const entry of fs.readdirSync(dir, {
47
+ withFileTypes: true
48
+ })) {
49
+ const full = path.join(dir, entry.name);
50
+ if (entry.isDirectory()) results.push(...findMaps(full));
51
+ else if (entry.name.endsWith(".js.map")) results.push(full);
52
+ }
53
+ } catch {
54
+ }
55
+ return results;
56
+ };
57
+ let stripped = 0;
58
+ for (const file of findMaps(staticDir)) {
59
+ try {
60
+ const raw = fs.readFileSync(file, "utf-8");
61
+ const map = JSON.parse(raw);
62
+ let changed = false;
63
+ if (map.sourcesContent) {
64
+ delete map.sourcesContent;
65
+ changed = true;
66
+ }
67
+ if (map.sections) {
68
+ for (const section of map.sections) {
69
+ if (section.map?.sourcesContent) {
70
+ delete section.map.sourcesContent;
71
+ changed = true;
72
+ }
73
+ }
74
+ }
75
+ if (changed) {
76
+ fs.writeFileSync(file, JSON.stringify(map));
77
+ stripped++;
78
+ }
79
+ } catch {
80
+ }
81
+ }
82
+ if (stripped > 0) {
83
+ console.log(
84
+ `[@impakers/debug] Stripped sourcesContent from ${stripped} sourcemap files`
85
+ );
86
+ }
87
+ callback();
88
+ }
89
+ );
90
+ }
91
+ };
92
+ function withImpakersDebug(nextConfig, options = {}) {
93
+ const { stripSourceContent = true } = options;
94
+ return {
95
+ ...nextConfig,
96
+ // 소스맵 생성 활성화
97
+ productionBrowserSourceMaps: true,
98
+ webpack(config, context) {
99
+ if (typeof nextConfig.webpack === "function") {
100
+ config = nextConfig.webpack(config, context);
101
+ }
102
+ if (!context.isServer && stripSourceContent) {
103
+ config.plugins = config.plugins || [];
104
+ config.plugins.push(new StripSourceContentPlugin());
105
+ }
106
+ return config;
107
+ }
108
+ };
109
+ }
110
+ // Annotate the CommonJS export names for ESM import in node:
111
+ 0 && (module.exports = {
112
+ withImpakersDebug
113
+ });
package/dist/next.mjs ADDED
@@ -0,0 +1,95 @@
1
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
+ }) : x)(function(x) {
4
+ if (typeof require !== "undefined") return require.apply(this, arguments);
5
+ throw Error('Dynamic require of "' + x + '" is not supported');
6
+ });
7
+
8
+ // src/next.ts
9
+ var StripSourceContentPlugin = class {
10
+ apply(compiler) {
11
+ compiler.hooks.afterEmit.tapAsync(
12
+ "ImpakersDebugStripSourceContent",
13
+ (compilation, callback) => {
14
+ const fs = __require("fs");
15
+ const path = __require("path");
16
+ const outputPath = compilation.outputOptions?.path;
17
+ if (!outputPath) {
18
+ callback();
19
+ return;
20
+ }
21
+ const staticDir = path.resolve(outputPath, "../static");
22
+ if (!fs.existsSync(staticDir)) {
23
+ callback();
24
+ return;
25
+ }
26
+ const findMaps = (dir) => {
27
+ const results = [];
28
+ try {
29
+ for (const entry of fs.readdirSync(dir, {
30
+ withFileTypes: true
31
+ })) {
32
+ const full = path.join(dir, entry.name);
33
+ if (entry.isDirectory()) results.push(...findMaps(full));
34
+ else if (entry.name.endsWith(".js.map")) results.push(full);
35
+ }
36
+ } catch {
37
+ }
38
+ return results;
39
+ };
40
+ let stripped = 0;
41
+ for (const file of findMaps(staticDir)) {
42
+ try {
43
+ const raw = fs.readFileSync(file, "utf-8");
44
+ const map = JSON.parse(raw);
45
+ let changed = false;
46
+ if (map.sourcesContent) {
47
+ delete map.sourcesContent;
48
+ changed = true;
49
+ }
50
+ if (map.sections) {
51
+ for (const section of map.sections) {
52
+ if (section.map?.sourcesContent) {
53
+ delete section.map.sourcesContent;
54
+ changed = true;
55
+ }
56
+ }
57
+ }
58
+ if (changed) {
59
+ fs.writeFileSync(file, JSON.stringify(map));
60
+ stripped++;
61
+ }
62
+ } catch {
63
+ }
64
+ }
65
+ if (stripped > 0) {
66
+ console.log(
67
+ `[@impakers/debug] Stripped sourcesContent from ${stripped} sourcemap files`
68
+ );
69
+ }
70
+ callback();
71
+ }
72
+ );
73
+ }
74
+ };
75
+ function withImpakersDebug(nextConfig, options = {}) {
76
+ const { stripSourceContent = true } = options;
77
+ return {
78
+ ...nextConfig,
79
+ // 소스맵 생성 활성화
80
+ productionBrowserSourceMaps: true,
81
+ webpack(config, context) {
82
+ if (typeof nextConfig.webpack === "function") {
83
+ config = nextConfig.webpack(config, context);
84
+ }
85
+ if (!context.isServer && stripSourceContent) {
86
+ config.plugins = config.plugins || [];
87
+ config.plugins.push(new StripSourceContentPlugin());
88
+ }
89
+ return config;
90
+ }
91
+ };
92
+ }
93
+ export {
94
+ withImpakersDebug
95
+ };
package/dist/react.js CHANGED
@@ -2081,7 +2081,7 @@ async function loadSourceMap(bundleUrl) {
2081
2081
  return null;
2082
2082
  }
2083
2083
  const rawMap = await res.json();
2084
- const traceMap = new import_trace_mapping.TraceMap(rawMap);
2084
+ const traceMap = new import_trace_mapping.AnyMap(rawMap);
2085
2085
  cache2.set(bundleUrl, traceMap);
2086
2086
  return traceMap;
2087
2087
  } catch {