next 15.3.0-canary.3 → 15.3.0-canary.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.
- package/dist/bin/next +1 -1
- package/dist/build/index.js +9 -10
- package/dist/build/index.js.map +1 -1
- package/dist/build/swc/index.js +1 -1
- package/dist/build/webpack-config.js +2 -2
- package/dist/client/app-bootstrap.js +1 -1
- package/dist/client/index.js +1 -1
- package/dist/esm/build/index.js +9 -10
- package/dist/esm/build/index.js.map +1 -1
- package/dist/esm/build/swc/index.js +1 -1
- package/dist/esm/build/webpack-config.js +2 -2
- package/dist/esm/client/app-bootstrap.js +1 -1
- package/dist/esm/client/index.js +1 -1
- package/dist/esm/lib/inline-static-env.js +13 -18
- package/dist/esm/lib/inline-static-env.js.map +1 -1
- package/dist/esm/server/dev/hot-reloader-turbopack.js +1 -1
- package/dist/esm/server/dev/hot-reloader-webpack.js +1 -1
- package/dist/esm/server/lib/app-info-log.js +1 -1
- package/dist/esm/server/lib/router-utils/block-cross-site.js +3 -2
- package/dist/esm/server/lib/router-utils/block-cross-site.js.map +1 -1
- package/dist/esm/server/lib/start-server.js +1 -1
- package/dist/esm/shared/lib/canary-only.js +1 -1
- package/dist/lib/inline-static-env.d.ts +1 -2
- package/dist/lib/inline-static-env.js +13 -18
- package/dist/lib/inline-static-env.js.map +1 -1
- package/dist/server/dev/hot-reloader-turbopack.js +1 -1
- package/dist/server/dev/hot-reloader-webpack.js +1 -1
- package/dist/server/lib/app-info-log.js +1 -1
- package/dist/server/lib/router-utils/block-cross-site.js +3 -2
- package/dist/server/lib/router-utils/block-cross-site.js.map +1 -1
- package/dist/server/lib/start-server.js +1 -1
- package/dist/shared/lib/canary-only.js +1 -1
- package/dist/telemetry/anonymous-meta.js +1 -1
- package/dist/telemetry/events/session-stopped.js +2 -2
- package/dist/telemetry/events/version.js +2 -2
- package/package.json +15 -15
@@ -11,7 +11,7 @@ import { isDeepStrictEqual } from 'util';
|
|
11
11
|
import { getDefineEnv } from '../webpack/plugins/define-env-plugin';
|
12
12
|
import { getReactCompilerLoader } from '../get-babel-loader-config';
|
13
13
|
import { TurbopackInternalError } from '../../shared/lib/turbopack/utils';
|
14
|
-
const nextVersion = "15.3.0-canary.
|
14
|
+
const nextVersion = "15.3.0-canary.5";
|
15
15
|
const ArchName = arch();
|
16
16
|
const PlatformName = platform();
|
17
17
|
function infoLog(...args) {
|
@@ -1527,7 +1527,7 @@ export default async function getBaseWebpackConfig(dir, { buildId, encryptionKey
|
|
1527
1527
|
isClient && new CopyFilePlugin({
|
1528
1528
|
// file path to build output of `@next/polyfill-nomodule`
|
1529
1529
|
filePath: require.resolve('./polyfills/polyfill-nomodule'),
|
1530
|
-
cacheKey: "15.3.0-canary.
|
1530
|
+
cacheKey: "15.3.0-canary.5",
|
1531
1531
|
name: `static/chunks/polyfills${dev ? '' : '-[hash]'}.js`,
|
1532
1532
|
minimize: false,
|
1533
1533
|
info: {
|
@@ -1704,7 +1704,7 @@ export default async function getBaseWebpackConfig(dir, { buildId, encryptionKey
|
|
1704
1704
|
// - Next.js location on disk (some loaders use absolute paths and some resolve options depend on absolute paths)
|
1705
1705
|
// - Next.js version
|
1706
1706
|
// - next.config.js keys that affect compilation
|
1707
|
-
version: `${__dirname}|${"15.3.0-canary.
|
1707
|
+
version: `${__dirname}|${"15.3.0-canary.5"}|${configVars}`,
|
1708
1708
|
cacheDirectory: path.join(distDir, 'cache', 'webpack'),
|
1709
1709
|
// For production builds, it's more efficient to compress all cache files together instead of compression each one individually.
|
1710
1710
|
// So we disable compression here and allow the build runner to take care of compressing the cache as a whole.
|
package/dist/esm/client/index.js
CHANGED
@@ -26,7 +26,7 @@ import { SearchParamsContext, PathParamsContext } from '../shared/lib/hooks-clie
|
|
26
26
|
import { onRecoverableError } from './react-client-callbacks/on-recoverable-error';
|
27
27
|
import tracer from './tracing/tracer';
|
28
28
|
import { isNextRouterError } from './components/is-next-router-error';
|
29
|
-
export const version = "15.3.0-canary.
|
29
|
+
export const version = "15.3.0-canary.5";
|
30
30
|
export let router;
|
31
31
|
export const emitter = mitt();
|
32
32
|
const looseToArray = (input)=>[].slice.call(input);
|
@@ -4,32 +4,27 @@ import crypto from 'crypto';
|
|
4
4
|
import { promisify } from 'util';
|
5
5
|
import globOriginal from 'next/dist/compiled/glob';
|
6
6
|
import { Sema } from 'next/dist/compiled/async-sema';
|
7
|
-
import { BUILD_MANIFEST } from '../shared/lib/constants';
|
8
7
|
import { getNextConfigEnv, getStaticEnv } from './static-env';
|
9
8
|
const glob = promisify(globOriginal);
|
10
|
-
export async function inlineStaticEnv({ distDir, config
|
9
|
+
export async function inlineStaticEnv({ distDir, config }) {
|
11
10
|
const nextConfigEnv = getNextConfigEnv(config);
|
12
11
|
const staticEnv = getStaticEnv(config);
|
13
12
|
const serverDir = path.join(distDir, 'server');
|
14
|
-
const serverChunks = await glob('**/*.js', {
|
13
|
+
const serverChunks = await glob('**/*.{js,json,js.map}', {
|
15
14
|
cwd: serverDir
|
16
15
|
});
|
17
16
|
const clientDir = path.join(distDir, 'static');
|
18
|
-
const clientChunks = await glob('**/*.js', {
|
17
|
+
const clientChunks = await glob('**/*.{js,json,js.map}', {
|
19
18
|
cwd: clientDir
|
20
19
|
});
|
21
|
-
const
|
22
|
-
|
23
|
-
|
24
|
-
value: "E662",
|
25
|
-
enumerable: false,
|
26
|
-
configurable: true
|
27
|
-
});
|
28
|
-
}
|
20
|
+
const manifestChunks = await glob('*.{js,json,js.map}', {
|
21
|
+
cwd: distDir
|
22
|
+
});
|
29
23
|
const inlineSema = new Sema(8);
|
30
24
|
const nextConfigEnvKeys = Object.keys(nextConfigEnv).map((item)=>item.split('process.env.').pop());
|
31
25
|
const builtRegEx = new RegExp(`[\\w]{1,}(\\.env)?\\.(?:NEXT_PUBLIC_[\\w]{1,}${nextConfigEnvKeys.length ? '|' + nextConfigEnvKeys.join('|') : ''})`, 'g');
|
32
26
|
const changedClientFiles = [];
|
27
|
+
const filesToCheck = new Set(manifestChunks.map((f)=>path.join(distDir, f)));
|
33
28
|
for (const [parentDir, files] of [
|
34
29
|
[
|
35
30
|
serverDir,
|
@@ -58,6 +53,7 @@ export async function inlineStaticEnv({ distDir, config, buildId }) {
|
|
58
53
|
content: newContent
|
59
54
|
});
|
60
55
|
}
|
56
|
+
filesToCheck.add(filepath);
|
61
57
|
inlineSema.release();
|
62
58
|
}));
|
63
59
|
}
|
@@ -80,14 +76,13 @@ export async function inlineStaticEnv({ distDir, config, buildId }) {
|
|
80
76
|
newHash
|
81
77
|
});
|
82
78
|
const filepath = path.join(clientDir, file);
|
83
|
-
|
79
|
+
const newFilepath = filepath.replace(originalHash, newHash);
|
80
|
+
filesToCheck.delete(filepath);
|
81
|
+
filesToCheck.add(newFilepath);
|
82
|
+
await fs.promises.rename(filepath, newFilepath);
|
84
83
|
}
|
85
84
|
// update build-manifest and webpack-runtime with new hashes
|
86
|
-
for (
|
87
|
-
path.join(distDir, BUILD_MANIFEST),
|
88
|
-
path.join(distDir, 'static', webpackRuntimeFile),
|
89
|
-
path.join(distDir, 'static', buildId, '_buildManifest.js')
|
90
|
-
]){
|
85
|
+
for (let file of filesToCheck){
|
91
86
|
const content = await fs.promises.readFile(file, 'utf-8');
|
92
87
|
let newContent = content;
|
93
88
|
for (const { originalHash, newHash } of hashChanges){
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/lib/inline-static-env.ts"],"sourcesContent":["import fs from 'fs'\nimport path from 'path'\nimport crypto from 'crypto'\nimport { promisify } from 'util'\nimport globOriginal from 'next/dist/compiled/glob'\nimport { Sema } from 'next/dist/compiled/async-sema'\nimport type { NextConfigComplete } from '../server/config-shared'\nimport {
|
1
|
+
{"version":3,"sources":["../../src/lib/inline-static-env.ts"],"sourcesContent":["import fs from 'fs'\nimport path from 'path'\nimport crypto from 'crypto'\nimport { promisify } from 'util'\nimport globOriginal from 'next/dist/compiled/glob'\nimport { Sema } from 'next/dist/compiled/async-sema'\nimport type { NextConfigComplete } from '../server/config-shared'\nimport { getNextConfigEnv, getStaticEnv } from './static-env'\n\nconst glob = promisify(globOriginal)\n\nexport async function inlineStaticEnv({\n distDir,\n config,\n}: {\n distDir: string\n config: NextConfigComplete\n}) {\n const nextConfigEnv = getNextConfigEnv(config)\n const staticEnv = getStaticEnv(config)\n\n const serverDir = path.join(distDir, 'server')\n const serverChunks = await glob('**/*.{js,json,js.map}', {\n cwd: serverDir,\n })\n const clientDir = path.join(distDir, 'static')\n const clientChunks = await glob('**/*.{js,json,js.map}', {\n cwd: clientDir,\n })\n const manifestChunks = await glob('*.{js,json,js.map}', {\n cwd: distDir,\n })\n\n const inlineSema = new Sema(8)\n const nextConfigEnvKeys = Object.keys(nextConfigEnv).map((item) =>\n item.split('process.env.').pop()\n )\n\n const builtRegEx = new RegExp(\n `[\\\\w]{1,}(\\\\.env)?\\\\.(?:NEXT_PUBLIC_[\\\\w]{1,}${nextConfigEnvKeys.length ? '|' + nextConfigEnvKeys.join('|') : ''})`,\n 'g'\n )\n const changedClientFiles: Array<{ file: string; content: string }> = []\n const filesToCheck = new Set<string>(\n manifestChunks.map((f) => path.join(distDir, f))\n )\n\n for (const [parentDir, files] of [\n [serverDir, serverChunks],\n [clientDir, clientChunks],\n ] as const) {\n await Promise.all(\n files.map(async (file) => {\n await inlineSema.acquire()\n const filepath = path.join(parentDir, file)\n const content = await fs.promises.readFile(filepath, 'utf8')\n const newContent = content.replace(builtRegEx, (match) => {\n let normalizedMatch = `process.env.${match.split('.').pop()}`\n\n if (staticEnv[normalizedMatch]) {\n return JSON.stringify(staticEnv[normalizedMatch])\n }\n return match\n })\n\n await fs.promises.writeFile(filepath, newContent)\n\n if (content !== newContent && parentDir === clientDir) {\n changedClientFiles.push({ file, content: newContent })\n }\n filesToCheck.add(filepath)\n inlineSema.release()\n })\n )\n }\n const hashChanges: Array<{\n originalHash: string\n newHash: string\n }> = []\n\n // hashes need updating for any changed client files\n for (const { file, content } of changedClientFiles) {\n // hash is 16 chars currently for all client chunks\n const originalHash = file.match(/([a-z0-9]{16})\\./)?.[1] || ''\n\n if (!originalHash) {\n throw new Error(\n `Invariant: client chunk changed but failed to detect hash ${file}`\n )\n }\n const newHash = crypto\n .createHash('sha256')\n .update(content)\n .digest('hex')\n .substring(0, 16)\n\n hashChanges.push({ originalHash, newHash })\n\n const filepath = path.join(clientDir, file)\n const newFilepath = filepath.replace(originalHash, newHash)\n\n filesToCheck.delete(filepath)\n filesToCheck.add(newFilepath)\n\n await fs.promises.rename(filepath, newFilepath)\n }\n\n // update build-manifest and webpack-runtime with new hashes\n for (let file of filesToCheck) {\n const content = await fs.promises.readFile(file, 'utf-8')\n let newContent = content\n\n for (const { originalHash, newHash } of hashChanges) {\n newContent = newContent.replaceAll(originalHash, newHash)\n }\n if (content !== newContent) {\n await fs.promises.writeFile(file, newContent)\n }\n }\n}\n"],"names":["fs","path","crypto","promisify","globOriginal","Sema","getNextConfigEnv","getStaticEnv","glob","inlineStaticEnv","distDir","config","nextConfigEnv","staticEnv","serverDir","join","serverChunks","cwd","clientDir","clientChunks","manifestChunks","inlineSema","nextConfigEnvKeys","Object","keys","map","item","split","pop","builtRegEx","RegExp","length","changedClientFiles","filesToCheck","Set","f","parentDir","files","Promise","all","file","acquire","filepath","content","promises","readFile","newContent","replace","match","normalizedMatch","JSON","stringify","writeFile","push","add","release","hashChanges","originalHash","Error","newHash","createHash","update","digest","substring","newFilepath","delete","rename","replaceAll"],"mappings":"AAAA,OAAOA,QAAQ,KAAI;AACnB,OAAOC,UAAU,OAAM;AACvB,OAAOC,YAAY,SAAQ;AAC3B,SAASC,SAAS,QAAQ,OAAM;AAChC,OAAOC,kBAAkB,0BAAyB;AAClD,SAASC,IAAI,QAAQ,gCAA+B;AAEpD,SAASC,gBAAgB,EAAEC,YAAY,QAAQ,eAAc;AAE7D,MAAMC,OAAOL,UAAUC;AAEvB,OAAO,eAAeK,gBAAgB,EACpCC,OAAO,EACPC,MAAM,EAIP;IACC,MAAMC,gBAAgBN,iBAAiB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A,WAAWqB,UAAU,CAACV,cAAcE;QACnD;QACA,IAAIhB,YAAYG,YAAY;YAC1B,MAAM9C,GAAG4C,QAAQ,CAACQ,SAAS,CAACZ,MAAMM;QACpC;IACF;AACF"}
|
@@ -83,7 +83,7 @@ export async function createHotReloaderTurbopack(opts, serverFields, distDir, re
|
|
83
83
|
}
|
84
84
|
const hasRewrites = opts.fsChecker.rewrites.afterFiles.length > 0 || opts.fsChecker.rewrites.beforeFiles.length > 0 || opts.fsChecker.rewrites.fallback.length > 0;
|
85
85
|
const hotReloaderSpan = trace('hot-reloader', undefined, {
|
86
|
-
version: "15.3.0-canary.
|
86
|
+
version: "15.3.0-canary.5"
|
87
87
|
});
|
88
88
|
// Ensure the hotReloaderSpan is flushed immediately as it's the parentSpan for all processing
|
89
89
|
// of the current `next dev` invocation.
|
@@ -180,7 +180,7 @@ export default class HotReloaderWebpack {
|
|
180
180
|
this.previewProps = previewProps;
|
181
181
|
this.rewrites = rewrites;
|
182
182
|
this.hotReloaderSpan = trace('hot-reloader', undefined, {
|
183
|
-
version: "15.3.0-canary.
|
183
|
+
version: "15.3.0-canary.5"
|
184
184
|
});
|
185
185
|
// Ensure the hotReloaderSpan is flushed immediately as it's the parentSpan for all processing
|
186
186
|
// of the current `next dev` invocation.
|
@@ -4,7 +4,7 @@ import { bold, purple } from '../../lib/picocolors';
|
|
4
4
|
import { PHASE_DEVELOPMENT_SERVER, PHASE_PRODUCTION_BUILD } from '../../shared/lib/constants';
|
5
5
|
import loadConfig, { getConfiguredExperimentalFeatures } from '../config';
|
6
6
|
export function logStartInfo({ networkUrl, appUrl, envInfo, experimentalFeatures, maxExperimentalFeatures = Infinity }) {
|
7
|
-
Log.bootstrap(`${bold(purple(`${Log.prefixes.ready} Next.js ${"15.3.0-canary.
|
7
|
+
Log.bootstrap(`${bold(purple(`${Log.prefixes.ready} Next.js ${"15.3.0-canary.5"}`))}${process.env.TURBOPACK ? ' (Turbopack)' : ''}`);
|
8
8
|
if (appUrl) {
|
9
9
|
Log.bootstrap(`- Local: ${appUrl}`);
|
10
10
|
}
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import { parseUrl } from '../../../lib/url';
|
2
2
|
import net from 'net';
|
3
3
|
import { warnOnce } from '../../../build/output/log';
|
4
|
+
import { isCsrfOriginAllowed } from '../../app-render/csrf-protection';
|
4
5
|
export const blockCrossSite = (req, res, allowedOrigins, activePort)=>{
|
5
6
|
var _req_url;
|
6
7
|
// only process _next URLs
|
@@ -14,7 +15,7 @@ export const blockCrossSite = (req, res, allowedOrigins, activePort)=>{
|
|
14
15
|
res.statusCode = 403;
|
15
16
|
}
|
16
17
|
res.end('Unauthorized');
|
17
|
-
warnOnce(`Blocked cross-origin request to /_next/*.
|
18
|
+
warnOnce(`Blocked cross-origin request to /_next/*. Cross-site requests are blocked in "no-cors" mode.`);
|
18
19
|
return true;
|
19
20
|
}
|
20
21
|
// ensure websocket requests from allowed origin
|
@@ -27,7 +28,7 @@ export const blockCrossSite = (req, res, allowedOrigins, activePort)=>{
|
|
27
28
|
const isIpRequest = net.isIPv4(originLowerCase) || net.isIPv6(originLowerCase);
|
28
29
|
if (// allow requests if direct IP and matching port and
|
29
30
|
// allow if any of the allowed origins match
|
30
|
-
!(isIpRequest && isMatchingPort) && !
|
31
|
+
!(isIpRequest && isMatchingPort) && !isCsrfOriginAllowed(originLowerCase, allowedOrigins)) {
|
31
32
|
if ('statusCode' in res) {
|
32
33
|
res.statusCode = 403;
|
33
34
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../src/server/lib/router-utils/block-cross-site.ts"],"sourcesContent":["import type { Duplex } from 'stream'\nimport type { IncomingMessage, ServerResponse } from 'webpack-dev-server'\nimport { parseUrl } from '../../../lib/url'\nimport net from 'net'\nimport { warnOnce } from '../../../build/output/log'\n\nexport const blockCrossSite = (\n req: IncomingMessage,\n res: ServerResponse | Duplex,\n allowedOrigins: string[],\n activePort: string\n): boolean => {\n // only process _next URLs\n if (!req.url?.includes('/_next')) {\n return false\n }\n // block non-cors request from cross-site e.g. script tag on\n // different host\n if (\n req.headers['sec-fetch-mode'] === 'no-cors' &&\n req.headers['sec-fetch-site'] === 'cross-site'\n ) {\n if ('statusCode' in res) {\n res.statusCode = 403\n }\n res.end('Unauthorized')\n warnOnce(\n `Blocked cross-origin request to /_next/*.
|
1
|
+
{"version":3,"sources":["../../../../src/server/lib/router-utils/block-cross-site.ts"],"sourcesContent":["import type { Duplex } from 'stream'\nimport type { IncomingMessage, ServerResponse } from 'webpack-dev-server'\nimport { parseUrl } from '../../../lib/url'\nimport net from 'net'\nimport { warnOnce } from '../../../build/output/log'\nimport { isCsrfOriginAllowed } from '../../app-render/csrf-protection'\n\nexport const blockCrossSite = (\n req: IncomingMessage,\n res: ServerResponse | Duplex,\n allowedOrigins: string[],\n activePort: string\n): boolean => {\n // only process _next URLs\n if (!req.url?.includes('/_next')) {\n return false\n }\n // block non-cors request from cross-site e.g. script tag on\n // different host\n if (\n req.headers['sec-fetch-mode'] === 'no-cors' &&\n req.headers['sec-fetch-site'] === 'cross-site'\n ) {\n if ('statusCode' in res) {\n res.statusCode = 403\n }\n res.end('Unauthorized')\n warnOnce(\n `Blocked cross-origin request to /_next/*. Cross-site requests are blocked in \"no-cors\" mode.`\n )\n return true\n }\n\n // ensure websocket requests from allowed origin\n const rawOrigin = req.headers['origin']\n\n if (rawOrigin) {\n const parsedOrigin = parseUrl(rawOrigin)\n\n if (parsedOrigin) {\n const originLowerCase = parsedOrigin.hostname.toLowerCase()\n const isMatchingPort = parsedOrigin.port === activePort\n const isIpRequest =\n net.isIPv4(originLowerCase) || net.isIPv6(originLowerCase)\n\n if (\n // allow requests if direct IP and matching port and\n // allow if any of the allowed origins match\n !(isIpRequest && isMatchingPort) &&\n !isCsrfOriginAllowed(originLowerCase, allowedOrigins)\n ) {\n if ('statusCode' in res) {\n res.statusCode = 403\n }\n res.end('Unauthorized')\n warnOnce(\n `Blocked cross-origin request from ${originLowerCase}. To allow this, configure \"allowedDevOrigins\" in next.config\\nRead more: https://nextjs.org/docs/app/api-reference/config/next-config-js/allowedDevOrigins`\n )\n return true\n }\n }\n }\n\n return false\n}\n"],"names":["parseUrl","net","warnOnce","isCsrfOriginAllowed","blockCrossSite","req","res","allowedOrigins","activePort","url","includes","headers","statusCode","end","rawOrigin","parsedOrigin","originLowerCase","hostname","toLowerCase","isMatchingPort","port","isIpRequest","isIPv4","isIPv6"],"mappings":"AAEA,SAASA,QAAQ,QAAQ,mBAAkB;AAC3C,OAAOC,SAAS,MAAK;AACrB,SAASC,QAAQ,QAAQ,4BAA2B;AACpD,SAASC,mBAAmB,QAAQ,mCAAkC;AAEtE,OAAO,MAAMC,iBAAiB,CAC5BC,KACAC,KACAC,gBACAC;QAGKH;IADL,0BAA0B;IAC1B,IAAI,GAACA,WAAAA,IAAII,GAAG,qBAAPJ,SAASK,QAAQ,CAAC,YAAW;QAChC,OAAO;IACT;IACA,4DAA4D;IAC5D,iBAAiB;IACjB,IACEL,IAAIM,OAAO,CAAC,iBAAiB,KAAK,aAClCN,IAAIM,OAAO,CAAC,iBAAiB,KAAK,cAClC;QACA,IAAI,gBAAgBL,KAAK;YACvBA,IAAIM,UAAU,GAAG;QACnB;QACAN,IAAIO,GAAG,CAAC;QACRX,SACE,CAAC,4FAA4F,CAAC;QAEhG,OAAO;IACT;IAEA,gDAAgD;IAChD,MAAMY,YAAYT,IAAIM,OAAO,CAAC,SAAS;IAEvC,IAAIG,WAAW;QACb,MAAMC,eAAef,SAASc;QAE9B,IAAIC,cAAc;YAChB,MAAMC,kBAAkBD,aAAaE,QAAQ,CAACC,WAAW;YACzD,MAAMC,iBAAiBJ,aAAaK,IAAI,KAAKZ;YAC7C,MAAMa,cACJpB,IAAIqB,MAAM,CAACN,oBAAoBf,IAAIsB,MAAM,CAACP;YAE5C,IACE,oDAAoD;YACpD,4CAA4C;YAC5C,CAAEK,CAAAA,eAAeF,cAAa,KAC9B,CAAChB,oBAAoBa,iBAAiBT,iBACtC;gBACA,IAAI,gBAAgBD,KAAK;oBACvBA,IAAIM,UAAU,GAAG;gBACnB;gBACAN,IAAIO,GAAG,CAAC;gBACRX,SACE,CAAC,kCAAkC,EAAEc,gBAAgB,2JAA2J,CAAC;gBAEnN,OAAO;YACT;QACF;IACF;IAEA,OAAO;AACT,EAAC"}
|
@@ -43,7 +43,7 @@ export async function getRequestHandlers({ dir, port, isDev, onDevServerCleanup,
|
|
43
43
|
export async function startServer(serverOptions) {
|
44
44
|
const { dir, isDev, hostname, minimalMode, allowRetry, keepAliveTimeout, selfSignedCertificate } = serverOptions;
|
45
45
|
let { port } = serverOptions;
|
46
|
-
process.title = `next-server (v${"15.3.0-canary.
|
46
|
+
process.title = `next-server (v${"15.3.0-canary.5"})`;
|
47
47
|
let handlersReady = ()=>{};
|
48
48
|
let handlersError = ()=>{};
|
49
49
|
let handlersPromise = new Promise((resolve, reject)=>{
|
@@ -1,6 +1,6 @@
|
|
1
1
|
export function isStableBuild() {
|
2
2
|
var _process_env___NEXT_VERSION;
|
3
|
-
return !((_process_env___NEXT_VERSION = "15.3.0-canary.
|
3
|
+
return !((_process_env___NEXT_VERSION = "15.3.0-canary.5") == null ? void 0 : _process_env___NEXT_VERSION.includes('canary')) && !process.env.__NEXT_TEST_MODE && !process.env.NEXT_PRIVATE_LOCAL_DEV;
|
4
4
|
}
|
5
5
|
export class CanaryOnlyError extends Error {
|
6
6
|
constructor(arg){
|
@@ -1,6 +1,5 @@
|
|
1
1
|
import type { NextConfigComplete } from '../server/config-shared';
|
2
|
-
export declare function inlineStaticEnv({ distDir, config,
|
2
|
+
export declare function inlineStaticEnv({ distDir, config, }: {
|
3
3
|
distDir: string;
|
4
|
-
buildId: string;
|
5
4
|
config: NextConfigComplete;
|
6
5
|
}): Promise<void>;
|
@@ -14,7 +14,6 @@ const _crypto = /*#__PURE__*/ _interop_require_default(require("crypto"));
|
|
14
14
|
const _util = require("util");
|
15
15
|
const _glob = /*#__PURE__*/ _interop_require_default(require("next/dist/compiled/glob"));
|
16
16
|
const _asyncsema = require("next/dist/compiled/async-sema");
|
17
|
-
const _constants = require("../shared/lib/constants");
|
18
17
|
const _staticenv = require("./static-env");
|
19
18
|
function _interop_require_default(obj) {
|
20
19
|
return obj && obj.__esModule ? obj : {
|
@@ -22,29 +21,25 @@ function _interop_require_default(obj) {
|
|
22
21
|
};
|
23
22
|
}
|
24
23
|
const glob = (0, _util.promisify)(_glob.default);
|
25
|
-
async function inlineStaticEnv({ distDir, config
|
24
|
+
async function inlineStaticEnv({ distDir, config }) {
|
26
25
|
const nextConfigEnv = (0, _staticenv.getNextConfigEnv)(config);
|
27
26
|
const staticEnv = (0, _staticenv.getStaticEnv)(config);
|
28
27
|
const serverDir = _path.default.join(distDir, 'server');
|
29
|
-
const serverChunks = await glob('**/*.js', {
|
28
|
+
const serverChunks = await glob('**/*.{js,json,js.map}', {
|
30
29
|
cwd: serverDir
|
31
30
|
});
|
32
31
|
const clientDir = _path.default.join(distDir, 'static');
|
33
|
-
const clientChunks = await glob('**/*.js', {
|
32
|
+
const clientChunks = await glob('**/*.{js,json,js.map}', {
|
34
33
|
cwd: clientDir
|
35
34
|
});
|
36
|
-
const
|
37
|
-
|
38
|
-
|
39
|
-
value: "E662",
|
40
|
-
enumerable: false,
|
41
|
-
configurable: true
|
42
|
-
});
|
43
|
-
}
|
35
|
+
const manifestChunks = await glob('*.{js,json,js.map}', {
|
36
|
+
cwd: distDir
|
37
|
+
});
|
44
38
|
const inlineSema = new _asyncsema.Sema(8);
|
45
39
|
const nextConfigEnvKeys = Object.keys(nextConfigEnv).map((item)=>item.split('process.env.').pop());
|
46
40
|
const builtRegEx = new RegExp(`[\\w]{1,}(\\.env)?\\.(?:NEXT_PUBLIC_[\\w]{1,}${nextConfigEnvKeys.length ? '|' + nextConfigEnvKeys.join('|') : ''})`, 'g');
|
47
41
|
const changedClientFiles = [];
|
42
|
+
const filesToCheck = new Set(manifestChunks.map((f)=>_path.default.join(distDir, f)));
|
48
43
|
for (const [parentDir, files] of [
|
49
44
|
[
|
50
45
|
serverDir,
|
@@ -73,6 +68,7 @@ async function inlineStaticEnv({ distDir, config, buildId }) {
|
|
73
68
|
content: newContent
|
74
69
|
});
|
75
70
|
}
|
71
|
+
filesToCheck.add(filepath);
|
76
72
|
inlineSema.release();
|
77
73
|
}));
|
78
74
|
}
|
@@ -95,14 +91,13 @@ async function inlineStaticEnv({ distDir, config, buildId }) {
|
|
95
91
|
newHash
|
96
92
|
});
|
97
93
|
const filepath = _path.default.join(clientDir, file);
|
98
|
-
|
94
|
+
const newFilepath = filepath.replace(originalHash, newHash);
|
95
|
+
filesToCheck.delete(filepath);
|
96
|
+
filesToCheck.add(newFilepath);
|
97
|
+
await _fs.default.promises.rename(filepath, newFilepath);
|
99
98
|
}
|
100
99
|
// update build-manifest and webpack-runtime with new hashes
|
101
|
-
for (
|
102
|
-
_path.default.join(distDir, _constants.BUILD_MANIFEST),
|
103
|
-
_path.default.join(distDir, 'static', webpackRuntimeFile),
|
104
|
-
_path.default.join(distDir, 'static', buildId, '_buildManifest.js')
|
105
|
-
]){
|
100
|
+
for (let file of filesToCheck){
|
106
101
|
const content = await _fs.default.promises.readFile(file, 'utf-8');
|
107
102
|
let newContent = content;
|
108
103
|
for (const { originalHash, newHash } of hashChanges){
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/lib/inline-static-env.ts"],"sourcesContent":["import fs from 'fs'\nimport path from 'path'\nimport crypto from 'crypto'\nimport { promisify } from 'util'\nimport globOriginal from 'next/dist/compiled/glob'\nimport { Sema } from 'next/dist/compiled/async-sema'\nimport type { NextConfigComplete } from '../server/config-shared'\nimport {
|
1
|
+
{"version":3,"sources":["../../src/lib/inline-static-env.ts"],"sourcesContent":["import fs from 'fs'\nimport path from 'path'\nimport crypto from 'crypto'\nimport { promisify } from 'util'\nimport globOriginal from 'next/dist/compiled/glob'\nimport { Sema } from 'next/dist/compiled/async-sema'\nimport type { NextConfigComplete } from '../server/config-shared'\nimport { getNextConfigEnv, getStaticEnv } from './static-env'\n\nconst glob = promisify(globOriginal)\n\nexport async function inlineStaticEnv({\n distDir,\n config,\n}: {\n distDir: string\n config: NextConfigComplete\n}) {\n const nextConfigEnv = getNextConfigEnv(config)\n const staticEnv = getStaticEnv(config)\n\n const serverDir = path.join(distDir, 'server')\n const serverChunks = await glob('**/*.{js,json,js.map}', {\n cwd: serverDir,\n })\n const clientDir = path.join(distDir, 'static')\n const clientChunks = await glob('**/*.{js,json,js.map}', {\n cwd: clientDir,\n })\n const manifestChunks = await glob('*.{js,json,js.map}', {\n cwd: distDir,\n })\n\n const inlineSema = new Sema(8)\n const nextConfigEnvKeys = Object.keys(nextConfigEnv).map((item) =>\n item.split('process.env.').pop()\n )\n\n const builtRegEx = new RegExp(\n `[\\\\w]{1,}(\\\\.env)?\\\\.(?:NEXT_PUBLIC_[\\\\w]{1,}${nextConfigEnvKeys.length ? '|' + nextConfigEnvKeys.join('|') : ''})`,\n 'g'\n )\n const changedClientFiles: Array<{ file: string; content: string }> = []\n const filesToCheck = new Set<string>(\n manifestChunks.map((f) => path.join(distDir, f))\n )\n\n for (const [parentDir, files] of [\n [serverDir, serverChunks],\n [clientDir, clientChunks],\n ] as const) {\n await Promise.all(\n files.map(async (file) => {\n await inlineSema.acquire()\n const filepath = path.join(parentDir, file)\n const content = await fs.promises.readFile(filepath, 'utf8')\n const newContent = content.replace(builtRegEx, (match) => {\n let normalizedMatch = `process.env.${match.split('.').pop()}`\n\n if (staticEnv[normalizedMatch]) {\n return JSON.stringify(staticEnv[normalizedMatch])\n }\n return match\n })\n\n await fs.promises.writeFile(filepath, newContent)\n\n if (content !== newContent && parentDir === clientDir) {\n changedClientFiles.push({ file, content: newContent })\n }\n filesToCheck.add(filepath)\n inlineSema.release()\n })\n )\n }\n const hashChanges: Array<{\n originalHash: string\n newHash: string\n }> = []\n\n // hashes need updating for any changed client files\n for (const { file, content } of changedClientFiles) {\n // hash is 16 chars currently for all client chunks\n const originalHash = file.match(/([a-z0-9]{16})\\./)?.[1] || ''\n\n if (!originalHash) {\n throw new Error(\n `Invariant: client chunk changed but failed to detect hash ${file}`\n )\n }\n const newHash = crypto\n .createHash('sha256')\n .update(content)\n .digest('hex')\n .substring(0, 16)\n\n hashChanges.push({ originalHash, newHash })\n\n const filepath = path.join(clientDir, file)\n const newFilepath = filepath.replace(originalHash, newHash)\n\n filesToCheck.delete(filepath)\n filesToCheck.add(newFilepath)\n\n await fs.promises.rename(filepath, newFilepath)\n }\n\n // update build-manifest and webpack-runtime with new hashes\n for (let file of filesToCheck) {\n const content = await fs.promises.readFile(file, 'utf-8')\n let newContent = content\n\n for (const { originalHash, newHash } of hashChanges) {\n newContent = newContent.replaceAll(originalHash, newHash)\n }\n if (content !== newContent) {\n await fs.promises.writeFile(file, newContent)\n }\n }\n}\n"],"names":["inlineStaticEnv","glob","promisify","globOriginal","distDir","config","nextConfigEnv","getNextConfigEnv","staticEnv","getStaticEnv","serverDir","path","join","serverChunks","cwd","clientDir","clientChunks","manifestChunks","inlineSema","Sema","nextConfigEnvKeys","Object","keys","map","item","split","pop","builtRegEx","RegExp","length","changedClientFiles","filesToCheck","Set","f","parentDir","files","Promise","all","file","acquire","filepath","content","fs","promises","readFile","newContent","replace","match","normalizedMatch","JSON","stringify","writeFile","push","add","release","hashChanges","originalHash","Error","newHash","crypto","createHash","update","digest","substring","newFilepath","delete","rename","replaceAll"],"mappings":";;;;+BAWsBA;;;eAAAA;;;2DAXP;6DACE;+DACE;sBACO;6DACD;2BACJ;2BAE0B;;;;;;AAE/C,MAAMC,OAAOC,IAAAA,eAAS,EAACC,aAAY;AAE5B,eAAeH,gBAAgB,EACpCI,OAAO,EACPC,MAAM,EAIP;IACC,MAAMC,gBAAgBC,IAAAA,2BAAgB,EAACF;IACvC,MAAMG,YAAYC,IAAAA,uBAAY,EAACJ;IAE/B,MAAMK,YAAYC,aAAI,CAACC,IAAI,CAACR,SAAS;IACrC,MAAMS,eAAe,MAAMZ,KAAK,yBAAyB;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1B,MAAMH,WAAE,CAACC,QAAQ,CAACQ,SAAS,CAACb,MAAMO;QACpC;IACF;AACF"}
|
@@ -139,7 +139,7 @@ async function createHotReloaderTurbopack(opts, serverFields, distDir, resetFetc
|
|
139
139
|
}
|
140
140
|
const hasRewrites = opts.fsChecker.rewrites.afterFiles.length > 0 || opts.fsChecker.rewrites.beforeFiles.length > 0 || opts.fsChecker.rewrites.fallback.length > 0;
|
141
141
|
const hotReloaderSpan = (0, _trace.trace)('hot-reloader', undefined, {
|
142
|
-
version: "15.3.0-canary.
|
142
|
+
version: "15.3.0-canary.5"
|
143
143
|
});
|
144
144
|
// Ensure the hotReloaderSpan is flushed immediately as it's the parentSpan for all processing
|
145
145
|
// of the current `next dev` invocation.
|
@@ -256,7 +256,7 @@ class HotReloaderWebpack {
|
|
256
256
|
this.previewProps = previewProps;
|
257
257
|
this.rewrites = rewrites;
|
258
258
|
this.hotReloaderSpan = (0, _trace.trace)('hot-reloader', undefined, {
|
259
|
-
version: "15.3.0-canary.
|
259
|
+
version: "15.3.0-canary.5"
|
260
260
|
});
|
261
261
|
// Ensure the hotReloaderSpan is flushed immediately as it's the parentSpan for all processing
|
262
262
|
// of the current `next dev` invocation.
|
@@ -67,7 +67,7 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
67
67
|
return newObj;
|
68
68
|
}
|
69
69
|
function logStartInfo({ networkUrl, appUrl, envInfo, experimentalFeatures, maxExperimentalFeatures = Infinity }) {
|
70
|
-
_log.bootstrap(`${(0, _picocolors.bold)((0, _picocolors.purple)(`${_log.prefixes.ready} Next.js ${"15.3.0-canary.
|
70
|
+
_log.bootstrap(`${(0, _picocolors.bold)((0, _picocolors.purple)(`${_log.prefixes.ready} Next.js ${"15.3.0-canary.5"}`))}${process.env.TURBOPACK ? ' (Turbopack)' : ''}`);
|
71
71
|
if (appUrl) {
|
72
72
|
_log.bootstrap(`- Local: ${appUrl}`);
|
73
73
|
}
|
@@ -11,6 +11,7 @@ Object.defineProperty(exports, "blockCrossSite", {
|
|
11
11
|
const _url = require("../../../lib/url");
|
12
12
|
const _net = /*#__PURE__*/ _interop_require_default(require("net"));
|
13
13
|
const _log = require("../../../build/output/log");
|
14
|
+
const _csrfprotection = require("../../app-render/csrf-protection");
|
14
15
|
function _interop_require_default(obj) {
|
15
16
|
return obj && obj.__esModule ? obj : {
|
16
17
|
default: obj
|
@@ -29,7 +30,7 @@ const blockCrossSite = (req, res, allowedOrigins, activePort)=>{
|
|
29
30
|
res.statusCode = 403;
|
30
31
|
}
|
31
32
|
res.end('Unauthorized');
|
32
|
-
(0, _log.warnOnce)(`Blocked cross-origin request to /_next/*.
|
33
|
+
(0, _log.warnOnce)(`Blocked cross-origin request to /_next/*. Cross-site requests are blocked in "no-cors" mode.`);
|
33
34
|
return true;
|
34
35
|
}
|
35
36
|
// ensure websocket requests from allowed origin
|
@@ -42,7 +43,7 @@ const blockCrossSite = (req, res, allowedOrigins, activePort)=>{
|
|
42
43
|
const isIpRequest = _net.default.isIPv4(originLowerCase) || _net.default.isIPv6(originLowerCase);
|
43
44
|
if (// allow requests if direct IP and matching port and
|
44
45
|
// allow if any of the allowed origins match
|
45
|
-
!(isIpRequest && isMatchingPort) && !
|
46
|
+
!(isIpRequest && isMatchingPort) && !(0, _csrfprotection.isCsrfOriginAllowed)(originLowerCase, allowedOrigins)) {
|
46
47
|
if ('statusCode' in res) {
|
47
48
|
res.statusCode = 403;
|
48
49
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../src/server/lib/router-utils/block-cross-site.ts"],"sourcesContent":["import type { Duplex } from 'stream'\nimport type { IncomingMessage, ServerResponse } from 'webpack-dev-server'\nimport { parseUrl } from '../../../lib/url'\nimport net from 'net'\nimport { warnOnce } from '../../../build/output/log'\n\nexport const blockCrossSite = (\n req: IncomingMessage,\n res: ServerResponse | Duplex,\n allowedOrigins: string[],\n activePort: string\n): boolean => {\n // only process _next URLs\n if (!req.url?.includes('/_next')) {\n return false\n }\n // block non-cors request from cross-site e.g. script tag on\n // different host\n if (\n req.headers['sec-fetch-mode'] === 'no-cors' &&\n req.headers['sec-fetch-site'] === 'cross-site'\n ) {\n if ('statusCode' in res) {\n res.statusCode = 403\n }\n res.end('Unauthorized')\n warnOnce(\n `Blocked cross-origin request to /_next/*.
|
1
|
+
{"version":3,"sources":["../../../../src/server/lib/router-utils/block-cross-site.ts"],"sourcesContent":["import type { Duplex } from 'stream'\nimport type { IncomingMessage, ServerResponse } from 'webpack-dev-server'\nimport { parseUrl } from '../../../lib/url'\nimport net from 'net'\nimport { warnOnce } from '../../../build/output/log'\nimport { isCsrfOriginAllowed } from '../../app-render/csrf-protection'\n\nexport const blockCrossSite = (\n req: IncomingMessage,\n res: ServerResponse | Duplex,\n allowedOrigins: string[],\n activePort: string\n): boolean => {\n // only process _next URLs\n if (!req.url?.includes('/_next')) {\n return false\n }\n // block non-cors request from cross-site e.g. script tag on\n // different host\n if (\n req.headers['sec-fetch-mode'] === 'no-cors' &&\n req.headers['sec-fetch-site'] === 'cross-site'\n ) {\n if ('statusCode' in res) {\n res.statusCode = 403\n }\n res.end('Unauthorized')\n warnOnce(\n `Blocked cross-origin request to /_next/*. Cross-site requests are blocked in \"no-cors\" mode.`\n )\n return true\n }\n\n // ensure websocket requests from allowed origin\n const rawOrigin = req.headers['origin']\n\n if (rawOrigin) {\n const parsedOrigin = parseUrl(rawOrigin)\n\n if (parsedOrigin) {\n const originLowerCase = parsedOrigin.hostname.toLowerCase()\n const isMatchingPort = parsedOrigin.port === activePort\n const isIpRequest =\n net.isIPv4(originLowerCase) || net.isIPv6(originLowerCase)\n\n if (\n // allow requests if direct IP and matching port and\n // allow if any of the allowed origins match\n !(isIpRequest && isMatchingPort) &&\n !isCsrfOriginAllowed(originLowerCase, allowedOrigins)\n ) {\n if ('statusCode' in res) {\n res.statusCode = 403\n }\n res.end('Unauthorized')\n warnOnce(\n `Blocked cross-origin request from ${originLowerCase}. To allow this, configure \"allowedDevOrigins\" in next.config\\nRead more: https://nextjs.org/docs/app/api-reference/config/next-config-js/allowedDevOrigins`\n )\n return true\n }\n }\n }\n\n return false\n}\n"],"names":["blockCrossSite","req","res","allowedOrigins","activePort","url","includes","headers","statusCode","end","warnOnce","rawOrigin","parsedOrigin","parseUrl","originLowerCase","hostname","toLowerCase","isMatchingPort","port","isIpRequest","net","isIPv4","isIPv6","isCsrfOriginAllowed"],"mappings":";;;;+BAOaA;;;eAAAA;;;qBALY;4DACT;qBACS;gCACW;;;;;;AAE7B,MAAMA,iBAAiB,CAC5BC,KACAC,KACAC,gBACAC;QAGKH;IADL,0BAA0B;IAC1B,IAAI,GAACA,WAAAA,IAAII,GAAG,qBAAPJ,SAASK,QAAQ,CAAC,YAAW;QAChC,OAAO;IACT;IACA,4DAA4D;IAC5D,iBAAiB;IACjB,IACEL,IAAIM,OAAO,CAAC,iBAAiB,KAAK,aAClCN,IAAIM,OAAO,CAAC,iBAAiB,KAAK,cAClC;QACA,IAAI,gBAAgBL,KAAK;YACvBA,IAAIM,UAAU,GAAG;QACnB;QACAN,IAAIO,GAAG,CAAC;QACRC,IAAAA,aAAQ,EACN,CAAC,4FAA4F,CAAC;QAEhG,OAAO;IACT;IAEA,gDAAgD;IAChD,MAAMC,YAAYV,IAAIM,OAAO,CAAC,SAAS;IAEvC,IAAII,WAAW;QACb,MAAMC,eAAeC,IAAAA,aAAQ,EAACF;QAE9B,IAAIC,cAAc;YAChB,MAAME,kBAAkBF,aAAaG,QAAQ,CAACC,WAAW;YACzD,MAAMC,iBAAiBL,aAAaM,IAAI,KAAKd;YAC7C,MAAMe,cACJC,YAAG,CAACC,MAAM,CAACP,oBAAoBM,YAAG,CAACE,MAAM,CAACR;YAE5C,IACE,oDAAoD;YACpD,4CAA4C;YAC5C,CAAEK,CAAAA,eAAeF,cAAa,KAC9B,CAACM,IAAAA,mCAAmB,EAACT,iBAAiBX,iBACtC;gBACA,IAAI,gBAAgBD,KAAK;oBACvBA,IAAIM,UAAU,GAAG;gBACnB;gBACAN,IAAIO,GAAG,CAAC;gBACRC,IAAAA,aAAQ,EACN,CAAC,kCAAkC,EAAEI,gBAAgB,2JAA2J,CAAC;gBAEnN,OAAO;YACT;QACF;IACF;IAEA,OAAO;AACT"}
|
@@ -111,7 +111,7 @@ async function getRequestHandlers({ dir, port, isDev, onDevServerCleanup, server
|
|
111
111
|
async function startServer(serverOptions) {
|
112
112
|
const { dir, isDev, hostname, minimalMode, allowRetry, keepAliveTimeout, selfSignedCertificate } = serverOptions;
|
113
113
|
let { port } = serverOptions;
|
114
|
-
process.title = `next-server (v${"15.3.0-canary.
|
114
|
+
process.title = `next-server (v${"15.3.0-canary.5"})`;
|
115
115
|
let handlersReady = ()=>{};
|
116
116
|
let handlersError = ()=>{};
|
117
117
|
let handlersPromise = new Promise((resolve, reject)=>{
|
@@ -22,7 +22,7 @@ _export(exports, {
|
|
22
22
|
});
|
23
23
|
function isStableBuild() {
|
24
24
|
var _process_env___NEXT_VERSION;
|
25
|
-
return !((_process_env___NEXT_VERSION = "15.3.0-canary.
|
25
|
+
return !((_process_env___NEXT_VERSION = "15.3.0-canary.5") == null ? void 0 : _process_env___NEXT_VERSION.includes('canary')) && !process.env.__NEXT_TEST_MODE && !process.env.NEXT_PRIVATE_LOCAL_DEV;
|
26
26
|
}
|
27
27
|
class CanaryOnlyError extends Error {
|
28
28
|
constructor(arg){
|
@@ -11,11 +11,11 @@ Object.defineProperty(exports, "eventCliSessionStopped", {
|
|
11
11
|
const EVENT_VERSION = 'NEXT_CLI_SESSION_STOPPED';
|
12
12
|
function eventCliSessionStopped(event) {
|
13
13
|
// This should be an invariant, if it fails our build tooling is broken.
|
14
|
-
if (typeof "15.3.0-canary.
|
14
|
+
if (typeof "15.3.0-canary.5" !== 'string') {
|
15
15
|
return [];
|
16
16
|
}
|
17
17
|
const payload = {
|
18
|
-
nextVersion: "15.3.0-canary.
|
18
|
+
nextVersion: "15.3.0-canary.5",
|
19
19
|
nodeVersion: process.version,
|
20
20
|
cliCommand: event.cliCommand,
|
21
21
|
durationMilliseconds: event.durationMilliseconds,
|
@@ -36,12 +36,12 @@ function hasBabelConfig(dir) {
|
|
36
36
|
function eventCliSession(dir, nextConfig, event) {
|
37
37
|
var _nextConfig_experimental_staleTimes, _nextConfig_experimental_staleTimes1, _nextConfig_experimental_reactCompiler, _nextConfig_experimental_reactCompiler1;
|
38
38
|
// This should be an invariant, if it fails our build tooling is broken.
|
39
|
-
if (typeof "15.3.0-canary.
|
39
|
+
if (typeof "15.3.0-canary.5" !== 'string') {
|
40
40
|
return [];
|
41
41
|
}
|
42
42
|
const { images, i18n } = nextConfig || {};
|
43
43
|
const payload = {
|
44
|
-
nextVersion: "15.3.0-canary.
|
44
|
+
nextVersion: "15.3.0-canary.5",
|
45
45
|
nodeVersion: process.version,
|
46
46
|
cliCommand: event.cliCommand,
|
47
47
|
isSrcDir: event.isSrcDir,
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "next",
|
3
|
-
"version": "15.3.0-canary.
|
3
|
+
"version": "15.3.0-canary.5",
|
4
4
|
"description": "The React Framework",
|
5
5
|
"main": "./dist/server/next.js",
|
6
6
|
"license": "MIT",
|
@@ -100,7 +100,7 @@
|
|
100
100
|
]
|
101
101
|
},
|
102
102
|
"dependencies": {
|
103
|
-
"@next/env": "15.3.0-canary.
|
103
|
+
"@next/env": "15.3.0-canary.5",
|
104
104
|
"@swc/counter": "0.1.3",
|
105
105
|
"@swc/helpers": "0.5.15",
|
106
106
|
"busboy": "1.6.0",
|
@@ -132,14 +132,14 @@
|
|
132
132
|
},
|
133
133
|
"optionalDependencies": {
|
134
134
|
"sharp": "^0.33.5",
|
135
|
-
"@next/swc-darwin-arm64": "15.3.0-canary.
|
136
|
-
"@next/swc-darwin-x64": "15.3.0-canary.
|
137
|
-
"@next/swc-linux-arm64-gnu": "15.3.0-canary.
|
138
|
-
"@next/swc-linux-arm64-musl": "15.3.0-canary.
|
139
|
-
"@next/swc-linux-x64-gnu": "15.3.0-canary.
|
140
|
-
"@next/swc-linux-x64-musl": "15.3.0-canary.
|
141
|
-
"@next/swc-win32-arm64-msvc": "15.3.0-canary.
|
142
|
-
"@next/swc-win32-x64-msvc": "15.3.0-canary.
|
135
|
+
"@next/swc-darwin-arm64": "15.3.0-canary.5",
|
136
|
+
"@next/swc-darwin-x64": "15.3.0-canary.5",
|
137
|
+
"@next/swc-linux-arm64-gnu": "15.3.0-canary.5",
|
138
|
+
"@next/swc-linux-arm64-musl": "15.3.0-canary.5",
|
139
|
+
"@next/swc-linux-x64-gnu": "15.3.0-canary.5",
|
140
|
+
"@next/swc-linux-x64-musl": "15.3.0-canary.5",
|
141
|
+
"@next/swc-win32-arm64-msvc": "15.3.0-canary.5",
|
142
|
+
"@next/swc-win32-x64-msvc": "15.3.0-canary.5"
|
143
143
|
},
|
144
144
|
"devDependencies": {
|
145
145
|
"@ampproject/toolbox-optimizer": "2.8.3",
|
@@ -172,11 +172,11 @@
|
|
172
172
|
"@jest/types": "29.5.0",
|
173
173
|
"@mswjs/interceptors": "0.23.0",
|
174
174
|
"@napi-rs/triples": "1.2.0",
|
175
|
-
"@next/font": "15.3.0-canary.
|
176
|
-
"@next/polyfill-module": "15.3.0-canary.
|
177
|
-
"@next/polyfill-nomodule": "15.3.0-canary.
|
178
|
-
"@next/react-refresh-utils": "15.3.0-canary.
|
179
|
-
"@next/swc": "15.3.0-canary.
|
175
|
+
"@next/font": "15.3.0-canary.5",
|
176
|
+
"@next/polyfill-module": "15.3.0-canary.5",
|
177
|
+
"@next/polyfill-nomodule": "15.3.0-canary.5",
|
178
|
+
"@next/react-refresh-utils": "15.3.0-canary.5",
|
179
|
+
"@next/swc": "15.3.0-canary.5",
|
180
180
|
"@opentelemetry/api": "1.6.0",
|
181
181
|
"@playwright/test": "1.41.2",
|
182
182
|
"@storybook/addon-a11y": "8.6.0",
|