@starko-one/sdk 0.0.0-stage → 0.1.0-beta.1
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/CHANGELOG.md +248 -0
- package/LICENSE +17 -0
- package/NOTICE +58 -0
- package/README.md +81 -2
- package/dist/api-BAFm4Lxj.d.ts +558 -0
- package/dist/api-DNrctwJu.d.cts +558 -0
- package/dist/browser/index.cjs +168 -0
- package/dist/browser/index.d.cts +131 -0
- package/dist/browser/index.d.ts +131 -0
- package/dist/browser/index.js +7 -0
- package/dist/build/rollup.cjs +22 -0
- package/dist/build/rollup.d.cts +34 -0
- package/dist/build/rollup.d.ts +34 -0
- package/dist/build/rollup.js +3 -0
- package/dist/build/vite.cjs +51 -0
- package/dist/build/vite.d.cts +23 -0
- package/dist/build/vite.d.ts +23 -0
- package/dist/build/vite.js +46 -0
- package/dist/build/webpack.cjs +18 -0
- package/dist/build/webpack.d.cts +39 -0
- package/dist/build/webpack.d.ts +39 -0
- package/dist/build/webpack.js +3 -0
- package/dist/chunk-2PM4FRM5.cjs +431 -0
- package/dist/chunk-335HNCOJ.js +249 -0
- package/dist/chunk-3AW5B2WW.js +115 -0
- package/dist/chunk-3R5TQAWD.js +216 -0
- package/dist/chunk-6H5MOPTQ.cjs +1230 -0
- package/dist/chunk-7TKNT3QJ.cjs +2487 -0
- package/dist/chunk-A4WLNFMU.cjs +220 -0
- package/dist/chunk-ALYFFOPR.cjs +134 -0
- package/dist/chunk-BVVFVRMO.js +1113 -0
- package/dist/chunk-CIHNKN62.cjs +15 -0
- package/dist/chunk-CMGCH6HD.js +1212 -0
- package/dist/chunk-D6QAPQ7L.cjs +56 -0
- package/dist/chunk-DUO5V6WZ.js +213 -0
- package/dist/chunk-EC2WZ6PG.js +90 -0
- package/dist/chunk-EFURLFJT.cjs +187 -0
- package/dist/chunk-EROUORMY.js +53 -0
- package/dist/chunk-LXBXFOAP.cjs +96 -0
- package/dist/chunk-MF6SA6DB.js +563 -0
- package/dist/chunk-N5R6ORIB.js +413 -0
- package/dist/chunk-N6R6BWHK.cjs +142 -0
- package/dist/chunk-QAGGN2T7.cjs +225 -0
- package/dist/chunk-QV4HRIDD.cjs +659 -0
- package/dist/chunk-TKNDYQB3.cjs +583 -0
- package/dist/chunk-UI5YC4TH.js +131 -0
- package/dist/chunk-VEHZYLK6.cjs +1151 -0
- package/dist/chunk-VNCWOGTI.js +12 -0
- package/dist/chunk-VWNIOGE6.js +180 -0
- package/dist/chunk-WDKRKGYF.js +608 -0
- package/dist/chunk-XOZIXBUK.js +2462 -0
- package/dist/chunk-ZS3K3SDR.cjs +258 -0
- package/dist/cli/index.cjs +2780 -0
- package/dist/common-DLFAqL2d.d.cts +36 -0
- package/dist/common-DbSXkaw6.d.ts +36 -0
- package/dist/dedupe-Bh5riD8Z.d.cts +13 -0
- package/dist/dedupe-DoYiSx-9.d.ts +13 -0
- package/dist/handler-BcnsnvhF.d.cts +82 -0
- package/dist/handler-qHzilC9T.d.ts +82 -0
- package/dist/index.cjs +309 -0
- package/dist/index.d.cts +187 -0
- package/dist/index.d.ts +187 -0
- package/dist/index.js +4 -0
- package/dist/next/client.cjs +113 -0
- package/dist/next/client.d.cts +26 -0
- package/dist/next/client.d.ts +26 -0
- package/dist/next/client.js +41 -0
- package/dist/next/config.cjs +277 -0
- package/dist/next/config.d.cts +193 -0
- package/dist/next/config.d.ts +193 -0
- package/dist/next/config.js +263 -0
- package/dist/next/index.cjs +148 -0
- package/dist/next/index.d.cts +32 -0
- package/dist/next/index.d.ts +32 -0
- package/dist/next/index.js +59 -0
- package/dist/node/index.cjs +257 -0
- package/dist/node/index.d.cts +145 -0
- package/dist/node/index.d.ts +145 -0
- package/dist/node/index.js +83 -0
- package/dist/options-BUhWuWJX.d.cts +79 -0
- package/dist/options-BUhWuWJX.d.ts +79 -0
- package/dist/react/index.cjs +107 -0
- package/dist/react/index.d.cts +84 -0
- package/dist/react/index.d.ts +84 -0
- package/dist/react/index.js +103 -0
- package/dist/scope-D1ouJm2h.d.cts +628 -0
- package/dist/scope-D1ouJm2h.d.ts +628 -0
- package/dist/server-edge-7624N3WF.cjs +51 -0
- package/dist/server-edge-BEEXWL7T.js +48 -0
- package/dist/server-node-ET4LIPEC.cjs +27 -0
- package/dist/server-node-TQUVMZUC.js +24 -0
- package/dist/session-C_WzbEN2.d.cts +4 -0
- package/dist/session-C_WzbEN2.d.ts +4 -0
- package/dist/session-propagation-Pr0Zb9Zn.d.cts +30 -0
- package/dist/session-propagation-RM5py1bp.d.ts +30 -0
- package/dist/starko.min.js +6 -0
- package/docs/browser.md +386 -0
- package/docs/configuration.md +310 -0
- package/docs/nextjs.md +488 -0
- package/docs/node.md +427 -0
- package/docs/other-backends.md +232 -0
- package/docs/privacy.md +112 -0
- package/docs/react.md +187 -0
- package/docs/source-maps.md +482 -0
- package/docs/troubleshooting.md +263 -0
- package/docs/widget.md +84 -0
- package/docs/wire-format.md +547 -0
- package/package.json +191 -4
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var chunkEFURLFJT_cjs = require('../chunk-EFURLFJT.cjs');
|
|
6
|
+
var chunk7TKNT3QJ_cjs = require('../chunk-7TKNT3QJ.cjs');
|
|
7
|
+
var chunkN6R6BWHK_cjs = require('../chunk-N6R6BWHK.cjs');
|
|
8
|
+
var fs = require('fs');
|
|
9
|
+
var module$1 = require('module');
|
|
10
|
+
var path = require('path');
|
|
11
|
+
|
|
12
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
+
|
|
14
|
+
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
15
|
+
|
|
16
|
+
// src/next/release-env.ts
|
|
17
|
+
var BUILD_RELEASE_ENV = "STARKO_BUILD_RELEASE";
|
|
18
|
+
|
|
19
|
+
// src/next/config.ts
|
|
20
|
+
var PHASE_PRODUCTION_BUILD = "phase-production-build";
|
|
21
|
+
var PHASE_DEVELOPMENT_SERVER = "phase-development-server";
|
|
22
|
+
var PHASE_PRODUCTION_SERVER = "phase-production-server";
|
|
23
|
+
function detectNextVersion() {
|
|
24
|
+
try {
|
|
25
|
+
const require2 = module$1.createRequire(path__default.default.join(process.cwd(), "package.json"));
|
|
26
|
+
return require2("next/package.json").version;
|
|
27
|
+
} catch {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function inferPhase(env = process.env, argv = process.argv) {
|
|
32
|
+
if (env.NEXT_PHASE) return env.NEXT_PHASE;
|
|
33
|
+
const command = argv.slice(2).find((a) => !a.startsWith("-"));
|
|
34
|
+
if (command === "dev") return PHASE_DEVELOPMENT_SERVER;
|
|
35
|
+
if (command === "start") return PHASE_PRODUCTION_SERVER;
|
|
36
|
+
if (command === "build") return PHASE_PRODUCTION_BUILD;
|
|
37
|
+
return env.NODE_ENV === "development" ? PHASE_DEVELOPMENT_SERVER : PHASE_PRODUCTION_BUILD;
|
|
38
|
+
}
|
|
39
|
+
function versionAtLeast(version, min) {
|
|
40
|
+
const parse = (v) => v.split(/[-+]/)[0].split(".").map((n) => Number.parseInt(n, 10) || 0);
|
|
41
|
+
const a = parse(version);
|
|
42
|
+
const b = parse(min);
|
|
43
|
+
for (let i = 0; i < 3; i++) {
|
|
44
|
+
const x = a[i] ?? 0;
|
|
45
|
+
const y = b[i] ?? 0;
|
|
46
|
+
if (x !== y) return x > y;
|
|
47
|
+
}
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
var warnedNoKey = false;
|
|
51
|
+
function warnNoKeyOnce(logger) {
|
|
52
|
+
if (warnedNoKey) return;
|
|
53
|
+
warnedNoKey = true;
|
|
54
|
+
logger.warn(chunk7TKNT3QJ_cjs.NO_API_KEY_MESSAGE);
|
|
55
|
+
}
|
|
56
|
+
var SRI_MANIFEST = path__default.default.join("server", "subresource-integrity-manifest.json");
|
|
57
|
+
function keepsClientBytes(integrity) {
|
|
58
|
+
return (_relativePath, code) => {
|
|
59
|
+
if (integrity) return true;
|
|
60
|
+
const id = chunk7TKNT3QJ_cjs.findDebugId(code);
|
|
61
|
+
return !!id && chunk7TKNT3QJ_cjs.hasNativeRegistration(code, id);
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function keepsServerMaps(distDir, standalone) {
|
|
65
|
+
return !!standalone && fs.existsSync(path__default.default.join(distDir, "server", "webpack-runtime.js"));
|
|
66
|
+
}
|
|
67
|
+
var warnedNoRelease = false;
|
|
68
|
+
function warnNoReleaseOnce(logger) {
|
|
69
|
+
if (warnedNoRelease) return;
|
|
70
|
+
warnedNoRelease = true;
|
|
71
|
+
logger.warn(
|
|
72
|
+
"no release for this build: its events and source maps carry none. Set `release` in the withStarko options or STARKO_RELEASE in the build's environment (or build from a git checkout, or in a CI that sets the commit)."
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
function _resetNextConfigWarnings() {
|
|
76
|
+
warnedNoRelease = false;
|
|
77
|
+
}
|
|
78
|
+
function resolveNextRelease(userConfig, options, phase, resolve = chunk7TKNT3QJ_cjs.resolveReleaseInfo, env = process.env) {
|
|
79
|
+
const userEnv = userConfig.env;
|
|
80
|
+
const own = userEnv && typeof userEnv === "object" && userEnv[BUILD_RELEASE_ENV] != null ? String(userEnv[BUILD_RELEASE_ENV]).trim() : void 0;
|
|
81
|
+
if (own) return { release: resolve(own), stamp: false };
|
|
82
|
+
const stamp = own === void 0;
|
|
83
|
+
if (phase === PHASE_DEVELOPMENT_SERVER) {
|
|
84
|
+
const explicit = (options.release ?? "").trim() || (env.STARKO_RELEASE ?? "").trim();
|
|
85
|
+
return { release: explicit ? { version: explicit.slice(0, chunkN6R6BWHK_cjs.LIMITS.MAX_RELEASE) } : void 0, stamp };
|
|
86
|
+
}
|
|
87
|
+
return { release: resolve(options.release), stamp };
|
|
88
|
+
}
|
|
89
|
+
async function processNextBuild(distDir, options, owners = { browser: "starko", server: "user" }, context = {}) {
|
|
90
|
+
const integrity = !!context.integrity || fs.existsSync(path__default.default.join(distDir, SRI_MANIFEST));
|
|
91
|
+
const releaseKnown = context.release !== void 0;
|
|
92
|
+
let logger = chunk7TKNT3QJ_cjs.createLogger({ silent: options.silent });
|
|
93
|
+
let failure;
|
|
94
|
+
try {
|
|
95
|
+
const connection = chunk7TKNT3QJ_cjs.resolveConnection(options);
|
|
96
|
+
logger = chunk7TKNT3QJ_cjs.createLogger({ silent: options.silent, secrets: [connection.apiKey] });
|
|
97
|
+
if (!connection.apiKey) {
|
|
98
|
+
warnNoKeyOnce(logger);
|
|
99
|
+
} else {
|
|
100
|
+
const filter = chunk7TKNT3QJ_cjs.createFileFilter(options);
|
|
101
|
+
const release = releaseKnown ? context.release ?? void 0 : chunk7TKNT3QJ_cjs.resolveReleaseInfo(options.release);
|
|
102
|
+
const entries = [];
|
|
103
|
+
for (const sub of ["static", "server"]) {
|
|
104
|
+
const dir = path__default.default.join(distDir, sub);
|
|
105
|
+
if (!fs.existsSync(dir)) continue;
|
|
106
|
+
try {
|
|
107
|
+
const subFilter = (relativePath) => filter(`${sub}/${relativePath}`);
|
|
108
|
+
const readOnly = sub === "static" && integrity;
|
|
109
|
+
const injected = await chunk7TKNT3QJ_cjs.injectDirectory(dir, { filter: subFilter, release: release?.version, dryRun: readOnly, keepNativelyRegistered: true });
|
|
110
|
+
for (const s of injected.skipped) logger.warn(`not injected: ${sub}/${s.file}: ${s.reason}`);
|
|
111
|
+
if (readOnly && injected.injected.length) {
|
|
112
|
+
logger.warn(
|
|
113
|
+
`not injected: ${injected.injected.length} client chunk(s) in ${path__default.default.basename(distDir)}/static without a debug id of their own (e.g. ${injected.injected[0].file}): experimental.sri is on, and a chunk changed after Next computed its integrity hash would not run. Errors in them are not resolved with source maps. Next 16's Turbopack gives every chunk a native debug id (turbopack.debugIds, set by withStarko).`
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
const collected = await chunk7TKNT3QJ_cjs.collectUploads(dir, subFilter);
|
|
117
|
+
for (const u of collected.unreadable) logger.warn(`could not read ${sub}/${u.file}: ${u.reason}`);
|
|
118
|
+
for (const e of collected.entries) entries.push({ ...e, fileName: `${sub}/${e.fileName}` });
|
|
119
|
+
} catch (error) {
|
|
120
|
+
failure = `could not process ${sub}: ${chunk7TKNT3QJ_cjs.errorMessage(error)}`;
|
|
121
|
+
logger.warn(failure);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
const outcome = await chunk7TKNT3QJ_cjs.runUpload(entries, {
|
|
125
|
+
apiKey: connection.apiKey,
|
|
126
|
+
host: connection.host,
|
|
127
|
+
release,
|
|
128
|
+
dryRun: options.dryRun,
|
|
129
|
+
uploadTimeoutMs: options.uploadTimeoutMs,
|
|
130
|
+
uploadConcurrency: options.uploadConcurrency,
|
|
131
|
+
uploadProtocol: options.uploadProtocol,
|
|
132
|
+
logger
|
|
133
|
+
});
|
|
134
|
+
if (!outcome.ok) failure = outcome.error ?? "source map upload failed";
|
|
135
|
+
}
|
|
136
|
+
} catch (error) {
|
|
137
|
+
failure = chunk7TKNT3QJ_cjs.errorMessage(error);
|
|
138
|
+
try {
|
|
139
|
+
logger.error(`source maps: ${failure}`);
|
|
140
|
+
} catch {
|
|
141
|
+
}
|
|
142
|
+
} finally {
|
|
143
|
+
await cleanUpNextBuild(distDir, options, owners, logger, integrity, keepsServerMaps(distDir, context.standalone));
|
|
144
|
+
}
|
|
145
|
+
if (failure && options.failOnError) throw new Error(`[starko] ${failure}`);
|
|
146
|
+
}
|
|
147
|
+
async function cleanUpNextBuild(distDir, options, owners, logger, integrity, keepServerMaps = false) {
|
|
148
|
+
for (const [sub, owner] of [["static", owners.browser], ["server", owners.server]]) {
|
|
149
|
+
if (!chunk7TKNT3QJ_cjs.shouldDeleteSourcemaps(owner, options)) continue;
|
|
150
|
+
if (sub === "server" && keepServerMaps) {
|
|
151
|
+
logger.info(`kept the server source maps in ${path__default.default.basename(distDir)}/server: output "standalone" copies them after this step (they are not served to browsers)`);
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
try {
|
|
155
|
+
let kept = 0;
|
|
156
|
+
const deleted = await chunk7TKNT3QJ_cjs.deleteAllSourcemaps(
|
|
157
|
+
path__default.default.join(distDir, sub),
|
|
158
|
+
logger,
|
|
159
|
+
sub === "static" ? { keepComment: keepsClientBytes(integrity), onKept: () => kept++ } : {}
|
|
160
|
+
);
|
|
161
|
+
if (kept > 0) {
|
|
162
|
+
logger.warn(
|
|
163
|
+
`left ${kept} sourceMappingURL comment(s) in ${path__default.default.basename(distDir)}/static pointing at the deleted source maps: client chunks are not rewritten after Next hashed them (${integrity ? "experimental.sri integrity hashes, " : ""}content-hashed file names). Browsers only request a map when developer tools are open, and then get a 404.`
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
if (deleted > 0) logger.info(`deleted ${deleted} ${sub === "static" ? "browser" : "server"} source map(s) from ${path__default.default.basename(distDir)}/${sub}`);
|
|
167
|
+
} catch (error) {
|
|
168
|
+
try {
|
|
169
|
+
logger.error(`could not delete the source maps under ${sub}: ${chunk7TKNT3QJ_cjs.errorMessage(error)}`);
|
|
170
|
+
} catch {
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
function withStarko(nextConfig = {}, options = {}, internals = {}) {
|
|
176
|
+
if (typeof nextConfig === "function") {
|
|
177
|
+
const fn = nextConfig;
|
|
178
|
+
return (phase, context = {}) => {
|
|
179
|
+
const resolved = fn(phase, { defaultConfig: context.defaultConfig ?? {} });
|
|
180
|
+
if (resolved && typeof resolved.then === "function") {
|
|
181
|
+
return Promise.resolve(resolved).then((config) => applyStarko(config, phase, options, internals));
|
|
182
|
+
}
|
|
183
|
+
return applyStarko(resolved, phase, options, internals);
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
return applyStarko(nextConfig, internals.phase ?? inferPhase(), options, internals);
|
|
187
|
+
}
|
|
188
|
+
function applyStarko(resolved, phase, options, internals) {
|
|
189
|
+
const enabled = options.enabled ?? phase === PHASE_PRODUCTION_BUILD;
|
|
190
|
+
if (!enabled || !resolved || typeof resolved !== "object") return resolved;
|
|
191
|
+
const connection = chunk7TKNT3QJ_cjs.resolveConnection(options);
|
|
192
|
+
if (!connection.apiKey) {
|
|
193
|
+
try {
|
|
194
|
+
warnNoKeyOnce(chunk7TKNT3QJ_cjs.createLogger({ silent: options.silent }));
|
|
195
|
+
} catch {
|
|
196
|
+
}
|
|
197
|
+
return resolved;
|
|
198
|
+
}
|
|
199
|
+
try {
|
|
200
|
+
return transformConfig(resolved, phase, { ...options, apiKey: connection.apiKey }, internals);
|
|
201
|
+
} catch (error) {
|
|
202
|
+
try {
|
|
203
|
+
chunk7TKNT3QJ_cjs.createLogger({ silent: options.silent, secrets: [connection.apiKey] }).error(`withStarko: config left unchanged: ${chunk7TKNT3QJ_cjs.errorMessage(error)}`);
|
|
204
|
+
} catch {
|
|
205
|
+
}
|
|
206
|
+
return resolved;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
function transformConfig(resolved, phase, starkoOptions, internals) {
|
|
210
|
+
const userConfig = resolved;
|
|
211
|
+
const { release, stamp } = resolveNextRelease(userConfig, starkoOptions, phase, internals.resolveRelease);
|
|
212
|
+
if (!release && phase !== PHASE_DEVELOPMENT_SERVER) warnNoReleaseOnce(chunk7TKNT3QJ_cjs.createLogger({ silent: starkoOptions.silent, secrets: [starkoOptions.apiKey] }));
|
|
213
|
+
const options = { ...starkoOptions, release: release?.version };
|
|
214
|
+
const version = internals.nextVersion !== void 0 ? internals.nextVersion : detectNextVersion();
|
|
215
|
+
const hasCompileHook = version === null || versionAtLeast(version, "15.4.1");
|
|
216
|
+
const hasNativeDebugIds = version === null || versionAtLeast(version, "16.0.0");
|
|
217
|
+
const owners = {
|
|
218
|
+
browser: userConfig.productionBrowserSourceMaps === true ? "user" : "starko",
|
|
219
|
+
server: userConfig.experimental?.serverSourceMaps === true ? "user" : "starko"
|
|
220
|
+
};
|
|
221
|
+
const deleteBrowserMaps = chunk7TKNT3QJ_cjs.shouldDeleteSourcemaps(owners.browser, options);
|
|
222
|
+
const config = { ...userConfig };
|
|
223
|
+
if (release && stamp) config.env = { ...userConfig.env, [BUILD_RELEASE_ENV]: release.version };
|
|
224
|
+
if (hasCompileHook) {
|
|
225
|
+
config.productionBrowserSourceMaps = true;
|
|
226
|
+
config.experimental = { ...userConfig.experimental, serverSourceMaps: true };
|
|
227
|
+
}
|
|
228
|
+
if (hasNativeDebugIds) config.turbopack = { ...userConfig.turbopack, debugIds: true };
|
|
229
|
+
const userWebpack = userConfig.webpack;
|
|
230
|
+
config.webpack = (webpackConfig, webpackContext) => {
|
|
231
|
+
const out = (userWebpack ? userWebpack(webpackConfig, webpackContext) : webpackConfig) ?? webpackConfig;
|
|
232
|
+
if (webpackContext.dev) return out;
|
|
233
|
+
try {
|
|
234
|
+
const browser = !webpackContext.isServer;
|
|
235
|
+
if (browser && deleteBrowserMaps && out.devtool) out.devtool = "hidden-source-map";
|
|
236
|
+
const owner = browser ? owners.browser : owners.server;
|
|
237
|
+
out.plugins = [
|
|
238
|
+
...out.plugins ?? [],
|
|
239
|
+
new chunkEFURLFJT_cjs.StarkoWebpackPlugin(
|
|
240
|
+
{ ...options, enabled: true, upload: !hasCompileHook },
|
|
241
|
+
// On older Next the flags are untouched: a devtool there is the user's (or Next's) own.
|
|
242
|
+
{ sourcemapOwner: hasCompileHook ? owner : "user" }
|
|
243
|
+
)
|
|
244
|
+
];
|
|
245
|
+
} catch (error) {
|
|
246
|
+
chunk7TKNT3QJ_cjs.createLogger({ silent: options.silent, secrets: [options.apiKey] }).error(`withStarko: webpack config left unchanged: ${chunk7TKNT3QJ_cjs.errorMessage(error)}`);
|
|
247
|
+
}
|
|
248
|
+
return out;
|
|
249
|
+
};
|
|
250
|
+
if (hasCompileHook) {
|
|
251
|
+
const userHook = userConfig.compiler?.runAfterProductionCompile;
|
|
252
|
+
config.compiler = {
|
|
253
|
+
...userConfig.compiler,
|
|
254
|
+
runAfterProductionCompile: async (metadata) => {
|
|
255
|
+
try {
|
|
256
|
+
if (userHook) await userHook(metadata);
|
|
257
|
+
} finally {
|
|
258
|
+
try {
|
|
259
|
+
await processNextBuild(metadata.distDir, options, owners, { integrity: !!userConfig.experimental?.sri?.algorithm, release: release ?? null, standalone: userConfig.output === "standalone" });
|
|
260
|
+
} catch (error) {
|
|
261
|
+
if (options.failOnError) throw error;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
return config;
|
|
268
|
+
}
|
|
269
|
+
var config_default = withStarko;
|
|
270
|
+
|
|
271
|
+
exports._resetNextConfigWarnings = _resetNextConfigWarnings;
|
|
272
|
+
exports.default = config_default;
|
|
273
|
+
exports.inferPhase = inferPhase;
|
|
274
|
+
exports.processNextBuild = processNextBuild;
|
|
275
|
+
exports.resolveNextRelease = resolveNextRelease;
|
|
276
|
+
exports.versionAtLeast = versionAtLeast;
|
|
277
|
+
exports.withStarko = withStarko;
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { S as SourcemapOwner, a as StarkoBuildOptions } from '../options-BUhWuWJX.cjs';
|
|
2
|
+
|
|
3
|
+
interface ReleaseInfo {
|
|
4
|
+
version: string;
|
|
5
|
+
commit?: string;
|
|
6
|
+
branch?: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/** Second argument of Next's `webpack(config, context)` function. */
|
|
10
|
+
interface NextWebpackContext {
|
|
11
|
+
dev: boolean;
|
|
12
|
+
isServer: boolean;
|
|
13
|
+
nextRuntime?: "nodejs" | "edge";
|
|
14
|
+
buildId?: string;
|
|
15
|
+
[key: string]: unknown;
|
|
16
|
+
}
|
|
17
|
+
/** The parts of a webpack configuration withStarko touches. */
|
|
18
|
+
interface NextWebpackConfig {
|
|
19
|
+
devtool?: string | false;
|
|
20
|
+
plugins?: unknown[];
|
|
21
|
+
[key: string]: unknown;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The fields of a Next config withStarko reads or writes. No index signature,
|
|
25
|
+
* so Next's own `NextConfig` interface is assignable to it; the user's other
|
|
26
|
+
* fields pass through untouched.
|
|
27
|
+
*/
|
|
28
|
+
interface NextConfigLike {
|
|
29
|
+
distDir?: string;
|
|
30
|
+
output?: string;
|
|
31
|
+
env?: Record<string, string | undefined>;
|
|
32
|
+
productionBrowserSourceMaps?: boolean;
|
|
33
|
+
webpack?: ((config: any, context: any) => any) | null;
|
|
34
|
+
compiler?: {
|
|
35
|
+
runAfterProductionCompile?: (metadata: {
|
|
36
|
+
distDir: string;
|
|
37
|
+
projectDir: string;
|
|
38
|
+
}) => Promise<void>;
|
|
39
|
+
};
|
|
40
|
+
turbopack?: {
|
|
41
|
+
debugIds?: boolean;
|
|
42
|
+
};
|
|
43
|
+
experimental?: {
|
|
44
|
+
serverSourceMaps?: boolean;
|
|
45
|
+
sri?: {
|
|
46
|
+
algorithm?: string;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/** A config function as Next calls it: `(phase, { defaultConfig })`. */
|
|
51
|
+
type NextConfigFunction<C> = (phase: string, context: {
|
|
52
|
+
defaultConfig: any;
|
|
53
|
+
}) => C | Promise<C>;
|
|
54
|
+
interface WithStarkoOptions extends StarkoBuildOptions {
|
|
55
|
+
/**
|
|
56
|
+
* What happens to the source maps in `.next` after the upload attempt.
|
|
57
|
+
* - not set (default): maps withStarko switched on are deleted whatever the
|
|
58
|
+
* upload's outcome (browser maps unless your config has
|
|
59
|
+
* `productionBrowserSourceMaps: true`; server maps unless it has
|
|
60
|
+
* `experimental.serverSourceMaps: true`); maps your config asked for are kept.
|
|
61
|
+
* - `true`: every browser and server source map is deleted (not in a dry run).
|
|
62
|
+
* - `false`: maps your config asked for are kept; maps withStarko switched on
|
|
63
|
+
* are STILL deleted. An explicit `productionBrowserSourceMaps: false` (or
|
|
64
|
+
* `serverSourceMaps: false`) therefore never leaves maps in `.next`.
|
|
65
|
+
*/
|
|
66
|
+
deleteSourcemapsAfterUpload?: boolean;
|
|
67
|
+
}
|
|
68
|
+
/** @internal Overrides for tests and unusual setups. */
|
|
69
|
+
interface WithStarkoInternals {
|
|
70
|
+
/** The Next version; `null` when unknown. Default: read from the app's `next/package.json`. */
|
|
71
|
+
nextVersion?: string | null;
|
|
72
|
+
/** The phase, for a config given as an object (Next passes it to config functions). Default: inferred, see `inferPhase`. */
|
|
73
|
+
phase?: string;
|
|
74
|
+
/** Resolves the release of a production build. Default: `resolveReleaseInfo` (src/build/shared/release.ts). */
|
|
75
|
+
resolveRelease?: (explicit?: string) => ReleaseInfo | undefined;
|
|
76
|
+
}
|
|
77
|
+
/** Who asked for the maps in each part of `.next`. */
|
|
78
|
+
interface NextSourcemapOwners {
|
|
79
|
+
browser: SourcemapOwner;
|
|
80
|
+
server: SourcemapOwner;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* The phase a config OBJECT is evaluated in. Next calls config functions with
|
|
84
|
+
* the phase, but evaluates an object without one, and `NEXT_PHASE` is only set
|
|
85
|
+
* late in `next build`. Used to decide `enabled` and whether to warn: every
|
|
86
|
+
* change withStarko makes only takes effect in a production build anyway
|
|
87
|
+
* (`productionBrowserSourceMaps`, the post-compile hook, the webpack function
|
|
88
|
+
* skips dev compilations), so a wrong guess outside a build is harmless.
|
|
89
|
+
*/
|
|
90
|
+
declare function inferPhase(env?: Record<string, string | undefined>, argv?: string[]): string;
|
|
91
|
+
/** `version >= min`, comparing major.minor.patch (pre-release tags ignored). */
|
|
92
|
+
declare function versionAtLeast(version: string, min: string): boolean;
|
|
93
|
+
/** What `processNextBuild` knows about the build besides its output. */
|
|
94
|
+
interface NextBuildContext {
|
|
95
|
+
/** `experimental.sri` is set (also detected from the manifest on disk). */
|
|
96
|
+
integrity?: boolean;
|
|
97
|
+
/**
|
|
98
|
+
* The release `withStarko` resolved when the config was built (and gave
|
|
99
|
+
* the bundles as `env.STARKO_BUILD_RELEASE`); `null` when it resolved none.
|
|
100
|
+
* Not set: resolved here from `options.release`.
|
|
101
|
+
*/
|
|
102
|
+
release?: ReleaseInfo | null;
|
|
103
|
+
/** `output: "standalone"` is set: see `keepsServerMaps`. */
|
|
104
|
+
standalone?: boolean;
|
|
105
|
+
}
|
|
106
|
+
/** @internal Test seam: say the missing release again. */
|
|
107
|
+
declare function _resetNextConfigWarnings(): void;
|
|
108
|
+
/**
|
|
109
|
+
* The release of the build `withStarko` is configuring, resolved ONCE: the
|
|
110
|
+
* same value goes into the bundles (`env.STARKO_BUILD_RELEASE`), into the
|
|
111
|
+
* webpack plugin's injection and into the upload, so a `git` call that
|
|
112
|
+
* answers differently later cannot split them.
|
|
113
|
+
* - `env.STARKO_BUILD_RELEASE` already in the user's config: theirs, left
|
|
114
|
+
* as it is, and the upload uses it too (an empty one only keeps the value
|
|
115
|
+
* out of the bundles: the upload and the injection still use the release
|
|
116
|
+
* resolved below, so no event names a release without source maps);
|
|
117
|
+
* - `next dev` (phase-development-server): only a release set explicitly
|
|
118
|
+
* (the `release` option or `STARKO_RELEASE`), never the commit: errors of
|
|
119
|
+
* a development build must not count against a release;
|
|
120
|
+
* - otherwise: the `release` option, `STARKO_RELEASE`, the CI commit,
|
|
121
|
+
* `git rev-parse HEAD` (`resolveReleaseInfo`).
|
|
122
|
+
* `stamp` is false when the user's own key stays.
|
|
123
|
+
* @internal Exported for tests.
|
|
124
|
+
*/
|
|
125
|
+
declare function resolveNextRelease(userConfig: NextConfigLike, options: WithStarkoOptions, phase: string, resolve?: (explicit?: string) => ReleaseInfo | undefined, env?: Record<string, string | undefined>): {
|
|
126
|
+
release: ReleaseInfo | undefined;
|
|
127
|
+
stamp: boolean;
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* Injects and uploads a Next build output after compilation: every bundle
|
|
131
|
+
* with a source map under `<distDir>/static` (browser) and `<distDir>/server`.
|
|
132
|
+
* Bundles that already carry a debug id (injected by the webpack plugin, or
|
|
133
|
+
* natively by Turbopack) keep it, and client chunks are never rewritten once
|
|
134
|
+
* Next has hashed them (see `keepsClientBytes`). Then, WHATEVER happened
|
|
135
|
+
* (upload failed or timed out, an error was thrown, dry run), the maps of
|
|
136
|
+
* each part are deleted when withStarko switched them on (`owners`) or when
|
|
137
|
+
* `deleteSourcemapsAfterUpload` is true. Without an API key nothing is
|
|
138
|
+
* injected or uploaded. Never throws unless `failOnError` is set.
|
|
139
|
+
* `owners` defaults to browser maps switched on by withStarko, server maps the user's.
|
|
140
|
+
* @internal Exported for tests.
|
|
141
|
+
*/
|
|
142
|
+
declare function processNextBuild(distDir: string, options: WithStarkoOptions, owners?: NextSourcemapOwners, context?: NextBuildContext): Promise<void>;
|
|
143
|
+
/**
|
|
144
|
+
* Wraps a Next.js config so production builds give every bundle a debug id
|
|
145
|
+
* and upload the source maps to Starko. Returns the same kind of thing it is
|
|
146
|
+
* given: an object for an object (so wrappers that spread their input, like
|
|
147
|
+
* `withBundleAnalyzer(withStarko(config))`, keep your config), a function for
|
|
148
|
+
* a function, an async function for an async function.
|
|
149
|
+
*
|
|
150
|
+
* Without an API key (`apiKey` or `STARKO_API_KEY`) it returns your config
|
|
151
|
+
* unchanged and warns once.
|
|
152
|
+
*
|
|
153
|
+
* - Source maps: `productionBrowserSourceMaps` and
|
|
154
|
+
* `experimental.serverSourceMaps` are switched on for the upload. Maps
|
|
155
|
+
* switched on this way (including when your config says `false`) are
|
|
156
|
+
* deleted from `.next` after the upload attempt whatever its outcome, with
|
|
157
|
+
* the comments pointing at them; maps your config asked for (`true`) are
|
|
158
|
+
* kept unless `deleteSourcemapsAfterUpload: true`.
|
|
159
|
+
* - Next 16+: `turbopack.debugIds`, so Turbopack writes native debug ids;
|
|
160
|
+
* the snippet registering them for Starko is added after compilation.
|
|
161
|
+
* - webpack builds: the Starko webpack plugin injects each client, server and
|
|
162
|
+
* edge bundle in memory; client maps are hidden (no `sourceMappingURL`)
|
|
163
|
+
* when they will be deleted.
|
|
164
|
+
* - Release: resolved once (the `release` option, `STARKO_RELEASE`, the CI
|
|
165
|
+
* commit, `git rev-parse HEAD`; see `resolveNextRelease`) and given to
|
|
166
|
+
* the build as `env.STARKO_BUILD_RELEASE`, which Next inlines into the
|
|
167
|
+
* browser, server and edge bundles before hashing them; the SDK's Next
|
|
168
|
+
* entries use it when `init` / `register` has no `release`, and the
|
|
169
|
+
* upload carries the same value. Your own `env.STARKO_BUILD_RELEASE`
|
|
170
|
+
* wins. In `next dev` (with `enabled: true`) only an explicit release.
|
|
171
|
+
* - Next 15.4.1+ (both bundlers): `compiler.runAfterProductionCompile` injects
|
|
172
|
+
* whatever is not injected yet, uploads everything once and deletes. On
|
|
173
|
+
* older Next only webpack builds are handled: the webpack plugin adds hidden
|
|
174
|
+
* maps itself, uploads, and deletes them before they are written; the
|
|
175
|
+
* config's source map flags are not touched.
|
|
176
|
+
*
|
|
177
|
+
* `enabled` defaults to `next build` (the production-build phase).
|
|
178
|
+
*/
|
|
179
|
+
declare function withStarko<C extends object = NextConfigLike>(nextConfig: (phase: string, context: {
|
|
180
|
+
defaultConfig: any;
|
|
181
|
+
}) => Promise<C>, // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
182
|
+
options?: WithStarkoOptions, internals?: WithStarkoInternals): (phase: string, context: {
|
|
183
|
+
defaultConfig: any;
|
|
184
|
+
}) => Promise<C & NextConfigLike>;
|
|
185
|
+
declare function withStarko<C extends object = NextConfigLike>(nextConfig: (phase: string, context: {
|
|
186
|
+
defaultConfig: any;
|
|
187
|
+
}) => C, // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
188
|
+
options?: WithStarkoOptions, internals?: WithStarkoInternals): (phase: string, context: {
|
|
189
|
+
defaultConfig: any;
|
|
190
|
+
}) => C & NextConfigLike;
|
|
191
|
+
declare function withStarko<C extends object = NextConfigLike>(nextConfig?: C, options?: WithStarkoOptions, internals?: WithStarkoInternals): C & NextConfigLike;
|
|
192
|
+
|
|
193
|
+
export { type NextBuildContext, type NextConfigFunction, type NextConfigLike, type NextSourcemapOwners, type NextWebpackConfig, type NextWebpackContext, type WithStarkoInternals, type WithStarkoOptions, _resetNextConfigWarnings, withStarko as default, inferPhase, processNextBuild, resolveNextRelease, versionAtLeast, withStarko };
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { S as SourcemapOwner, a as StarkoBuildOptions } from '../options-BUhWuWJX.js';
|
|
2
|
+
|
|
3
|
+
interface ReleaseInfo {
|
|
4
|
+
version: string;
|
|
5
|
+
commit?: string;
|
|
6
|
+
branch?: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/** Second argument of Next's `webpack(config, context)` function. */
|
|
10
|
+
interface NextWebpackContext {
|
|
11
|
+
dev: boolean;
|
|
12
|
+
isServer: boolean;
|
|
13
|
+
nextRuntime?: "nodejs" | "edge";
|
|
14
|
+
buildId?: string;
|
|
15
|
+
[key: string]: unknown;
|
|
16
|
+
}
|
|
17
|
+
/** The parts of a webpack configuration withStarko touches. */
|
|
18
|
+
interface NextWebpackConfig {
|
|
19
|
+
devtool?: string | false;
|
|
20
|
+
plugins?: unknown[];
|
|
21
|
+
[key: string]: unknown;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The fields of a Next config withStarko reads or writes. No index signature,
|
|
25
|
+
* so Next's own `NextConfig` interface is assignable to it; the user's other
|
|
26
|
+
* fields pass through untouched.
|
|
27
|
+
*/
|
|
28
|
+
interface NextConfigLike {
|
|
29
|
+
distDir?: string;
|
|
30
|
+
output?: string;
|
|
31
|
+
env?: Record<string, string | undefined>;
|
|
32
|
+
productionBrowserSourceMaps?: boolean;
|
|
33
|
+
webpack?: ((config: any, context: any) => any) | null;
|
|
34
|
+
compiler?: {
|
|
35
|
+
runAfterProductionCompile?: (metadata: {
|
|
36
|
+
distDir: string;
|
|
37
|
+
projectDir: string;
|
|
38
|
+
}) => Promise<void>;
|
|
39
|
+
};
|
|
40
|
+
turbopack?: {
|
|
41
|
+
debugIds?: boolean;
|
|
42
|
+
};
|
|
43
|
+
experimental?: {
|
|
44
|
+
serverSourceMaps?: boolean;
|
|
45
|
+
sri?: {
|
|
46
|
+
algorithm?: string;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/** A config function as Next calls it: `(phase, { defaultConfig })`. */
|
|
51
|
+
type NextConfigFunction<C> = (phase: string, context: {
|
|
52
|
+
defaultConfig: any;
|
|
53
|
+
}) => C | Promise<C>;
|
|
54
|
+
interface WithStarkoOptions extends StarkoBuildOptions {
|
|
55
|
+
/**
|
|
56
|
+
* What happens to the source maps in `.next` after the upload attempt.
|
|
57
|
+
* - not set (default): maps withStarko switched on are deleted whatever the
|
|
58
|
+
* upload's outcome (browser maps unless your config has
|
|
59
|
+
* `productionBrowserSourceMaps: true`; server maps unless it has
|
|
60
|
+
* `experimental.serverSourceMaps: true`); maps your config asked for are kept.
|
|
61
|
+
* - `true`: every browser and server source map is deleted (not in a dry run).
|
|
62
|
+
* - `false`: maps your config asked for are kept; maps withStarko switched on
|
|
63
|
+
* are STILL deleted. An explicit `productionBrowserSourceMaps: false` (or
|
|
64
|
+
* `serverSourceMaps: false`) therefore never leaves maps in `.next`.
|
|
65
|
+
*/
|
|
66
|
+
deleteSourcemapsAfterUpload?: boolean;
|
|
67
|
+
}
|
|
68
|
+
/** @internal Overrides for tests and unusual setups. */
|
|
69
|
+
interface WithStarkoInternals {
|
|
70
|
+
/** The Next version; `null` when unknown. Default: read from the app's `next/package.json`. */
|
|
71
|
+
nextVersion?: string | null;
|
|
72
|
+
/** The phase, for a config given as an object (Next passes it to config functions). Default: inferred, see `inferPhase`. */
|
|
73
|
+
phase?: string;
|
|
74
|
+
/** Resolves the release of a production build. Default: `resolveReleaseInfo` (src/build/shared/release.ts). */
|
|
75
|
+
resolveRelease?: (explicit?: string) => ReleaseInfo | undefined;
|
|
76
|
+
}
|
|
77
|
+
/** Who asked for the maps in each part of `.next`. */
|
|
78
|
+
interface NextSourcemapOwners {
|
|
79
|
+
browser: SourcemapOwner;
|
|
80
|
+
server: SourcemapOwner;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* The phase a config OBJECT is evaluated in. Next calls config functions with
|
|
84
|
+
* the phase, but evaluates an object without one, and `NEXT_PHASE` is only set
|
|
85
|
+
* late in `next build`. Used to decide `enabled` and whether to warn: every
|
|
86
|
+
* change withStarko makes only takes effect in a production build anyway
|
|
87
|
+
* (`productionBrowserSourceMaps`, the post-compile hook, the webpack function
|
|
88
|
+
* skips dev compilations), so a wrong guess outside a build is harmless.
|
|
89
|
+
*/
|
|
90
|
+
declare function inferPhase(env?: Record<string, string | undefined>, argv?: string[]): string;
|
|
91
|
+
/** `version >= min`, comparing major.minor.patch (pre-release tags ignored). */
|
|
92
|
+
declare function versionAtLeast(version: string, min: string): boolean;
|
|
93
|
+
/** What `processNextBuild` knows about the build besides its output. */
|
|
94
|
+
interface NextBuildContext {
|
|
95
|
+
/** `experimental.sri` is set (also detected from the manifest on disk). */
|
|
96
|
+
integrity?: boolean;
|
|
97
|
+
/**
|
|
98
|
+
* The release `withStarko` resolved when the config was built (and gave
|
|
99
|
+
* the bundles as `env.STARKO_BUILD_RELEASE`); `null` when it resolved none.
|
|
100
|
+
* Not set: resolved here from `options.release`.
|
|
101
|
+
*/
|
|
102
|
+
release?: ReleaseInfo | null;
|
|
103
|
+
/** `output: "standalone"` is set: see `keepsServerMaps`. */
|
|
104
|
+
standalone?: boolean;
|
|
105
|
+
}
|
|
106
|
+
/** @internal Test seam: say the missing release again. */
|
|
107
|
+
declare function _resetNextConfigWarnings(): void;
|
|
108
|
+
/**
|
|
109
|
+
* The release of the build `withStarko` is configuring, resolved ONCE: the
|
|
110
|
+
* same value goes into the bundles (`env.STARKO_BUILD_RELEASE`), into the
|
|
111
|
+
* webpack plugin's injection and into the upload, so a `git` call that
|
|
112
|
+
* answers differently later cannot split them.
|
|
113
|
+
* - `env.STARKO_BUILD_RELEASE` already in the user's config: theirs, left
|
|
114
|
+
* as it is, and the upload uses it too (an empty one only keeps the value
|
|
115
|
+
* out of the bundles: the upload and the injection still use the release
|
|
116
|
+
* resolved below, so no event names a release without source maps);
|
|
117
|
+
* - `next dev` (phase-development-server): only a release set explicitly
|
|
118
|
+
* (the `release` option or `STARKO_RELEASE`), never the commit: errors of
|
|
119
|
+
* a development build must not count against a release;
|
|
120
|
+
* - otherwise: the `release` option, `STARKO_RELEASE`, the CI commit,
|
|
121
|
+
* `git rev-parse HEAD` (`resolveReleaseInfo`).
|
|
122
|
+
* `stamp` is false when the user's own key stays.
|
|
123
|
+
* @internal Exported for tests.
|
|
124
|
+
*/
|
|
125
|
+
declare function resolveNextRelease(userConfig: NextConfigLike, options: WithStarkoOptions, phase: string, resolve?: (explicit?: string) => ReleaseInfo | undefined, env?: Record<string, string | undefined>): {
|
|
126
|
+
release: ReleaseInfo | undefined;
|
|
127
|
+
stamp: boolean;
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* Injects and uploads a Next build output after compilation: every bundle
|
|
131
|
+
* with a source map under `<distDir>/static` (browser) and `<distDir>/server`.
|
|
132
|
+
* Bundles that already carry a debug id (injected by the webpack plugin, or
|
|
133
|
+
* natively by Turbopack) keep it, and client chunks are never rewritten once
|
|
134
|
+
* Next has hashed them (see `keepsClientBytes`). Then, WHATEVER happened
|
|
135
|
+
* (upload failed or timed out, an error was thrown, dry run), the maps of
|
|
136
|
+
* each part are deleted when withStarko switched them on (`owners`) or when
|
|
137
|
+
* `deleteSourcemapsAfterUpload` is true. Without an API key nothing is
|
|
138
|
+
* injected or uploaded. Never throws unless `failOnError` is set.
|
|
139
|
+
* `owners` defaults to browser maps switched on by withStarko, server maps the user's.
|
|
140
|
+
* @internal Exported for tests.
|
|
141
|
+
*/
|
|
142
|
+
declare function processNextBuild(distDir: string, options: WithStarkoOptions, owners?: NextSourcemapOwners, context?: NextBuildContext): Promise<void>;
|
|
143
|
+
/**
|
|
144
|
+
* Wraps a Next.js config so production builds give every bundle a debug id
|
|
145
|
+
* and upload the source maps to Starko. Returns the same kind of thing it is
|
|
146
|
+
* given: an object for an object (so wrappers that spread their input, like
|
|
147
|
+
* `withBundleAnalyzer(withStarko(config))`, keep your config), a function for
|
|
148
|
+
* a function, an async function for an async function.
|
|
149
|
+
*
|
|
150
|
+
* Without an API key (`apiKey` or `STARKO_API_KEY`) it returns your config
|
|
151
|
+
* unchanged and warns once.
|
|
152
|
+
*
|
|
153
|
+
* - Source maps: `productionBrowserSourceMaps` and
|
|
154
|
+
* `experimental.serverSourceMaps` are switched on for the upload. Maps
|
|
155
|
+
* switched on this way (including when your config says `false`) are
|
|
156
|
+
* deleted from `.next` after the upload attempt whatever its outcome, with
|
|
157
|
+
* the comments pointing at them; maps your config asked for (`true`) are
|
|
158
|
+
* kept unless `deleteSourcemapsAfterUpload: true`.
|
|
159
|
+
* - Next 16+: `turbopack.debugIds`, so Turbopack writes native debug ids;
|
|
160
|
+
* the snippet registering them for Starko is added after compilation.
|
|
161
|
+
* - webpack builds: the Starko webpack plugin injects each client, server and
|
|
162
|
+
* edge bundle in memory; client maps are hidden (no `sourceMappingURL`)
|
|
163
|
+
* when they will be deleted.
|
|
164
|
+
* - Release: resolved once (the `release` option, `STARKO_RELEASE`, the CI
|
|
165
|
+
* commit, `git rev-parse HEAD`; see `resolveNextRelease`) and given to
|
|
166
|
+
* the build as `env.STARKO_BUILD_RELEASE`, which Next inlines into the
|
|
167
|
+
* browser, server and edge bundles before hashing them; the SDK's Next
|
|
168
|
+
* entries use it when `init` / `register` has no `release`, and the
|
|
169
|
+
* upload carries the same value. Your own `env.STARKO_BUILD_RELEASE`
|
|
170
|
+
* wins. In `next dev` (with `enabled: true`) only an explicit release.
|
|
171
|
+
* - Next 15.4.1+ (both bundlers): `compiler.runAfterProductionCompile` injects
|
|
172
|
+
* whatever is not injected yet, uploads everything once and deletes. On
|
|
173
|
+
* older Next only webpack builds are handled: the webpack plugin adds hidden
|
|
174
|
+
* maps itself, uploads, and deletes them before they are written; the
|
|
175
|
+
* config's source map flags are not touched.
|
|
176
|
+
*
|
|
177
|
+
* `enabled` defaults to `next build` (the production-build phase).
|
|
178
|
+
*/
|
|
179
|
+
declare function withStarko<C extends object = NextConfigLike>(nextConfig: (phase: string, context: {
|
|
180
|
+
defaultConfig: any;
|
|
181
|
+
}) => Promise<C>, // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
182
|
+
options?: WithStarkoOptions, internals?: WithStarkoInternals): (phase: string, context: {
|
|
183
|
+
defaultConfig: any;
|
|
184
|
+
}) => Promise<C & NextConfigLike>;
|
|
185
|
+
declare function withStarko<C extends object = NextConfigLike>(nextConfig: (phase: string, context: {
|
|
186
|
+
defaultConfig: any;
|
|
187
|
+
}) => C, // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
188
|
+
options?: WithStarkoOptions, internals?: WithStarkoInternals): (phase: string, context: {
|
|
189
|
+
defaultConfig: any;
|
|
190
|
+
}) => C & NextConfigLike;
|
|
191
|
+
declare function withStarko<C extends object = NextConfigLike>(nextConfig?: C, options?: WithStarkoOptions, internals?: WithStarkoInternals): C & NextConfigLike;
|
|
192
|
+
|
|
193
|
+
export { type NextBuildContext, type NextConfigFunction, type NextConfigLike, type NextSourcemapOwners, type NextWebpackConfig, type NextWebpackContext, type WithStarkoInternals, type WithStarkoOptions, _resetNextConfigWarnings, withStarko as default, inferPhase, processNextBuild, resolveNextRelease, versionAtLeast, withStarko };
|