fixed version control heatmap and activity
This commit is contained in:
66
.next/standalone/node_modules/next/dist/build/webpack/plugins/app-build-manifest-plugin.js
generated
vendored
Normal file
66
.next/standalone/node_modules/next/dist/build/webpack/plugins/app-build-manifest-plugin.js
generated
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "AppBuildManifestPlugin", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return AppBuildManifestPlugin;
|
||||
}
|
||||
});
|
||||
const _webpack = require("next/dist/compiled/webpack/webpack");
|
||||
const _constants = require("../../../shared/lib/constants");
|
||||
const _buildmanifestplugin = require("./build-manifest-plugin");
|
||||
const _getapproutefromentrypoint = /*#__PURE__*/ _interop_require_default(require("../../../server/get-app-route-from-entrypoint"));
|
||||
function _interop_require_default(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
const PLUGIN_NAME = "AppBuildManifestPlugin";
|
||||
class AppBuildManifestPlugin {
|
||||
constructor(options){
|
||||
this.dev = options.dev;
|
||||
}
|
||||
apply(compiler) {
|
||||
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation, { normalModuleFactory })=>{
|
||||
compilation.dependencyFactories.set(_webpack.webpack.dependencies.ModuleDependency, normalModuleFactory);
|
||||
compilation.dependencyTemplates.set(_webpack.webpack.dependencies.ModuleDependency, new _webpack.webpack.dependencies.NullDependency.Template());
|
||||
});
|
||||
compiler.hooks.make.tap(PLUGIN_NAME, (compilation)=>{
|
||||
compilation.hooks.processAssets.tap({
|
||||
name: PLUGIN_NAME,
|
||||
stage: _webpack.webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS
|
||||
}, (assets)=>this.createAsset(assets, compilation));
|
||||
});
|
||||
}
|
||||
createAsset(assets, compilation) {
|
||||
const manifest = {
|
||||
pages: {}
|
||||
};
|
||||
const mainFiles = new Set((0, _buildmanifestplugin.getEntrypointFiles)(compilation.entrypoints.get(_constants.CLIENT_STATIC_FILES_RUNTIME_MAIN_APP)));
|
||||
for (const entrypoint of compilation.entrypoints.values()){
|
||||
if (!entrypoint.name) {
|
||||
continue;
|
||||
}
|
||||
if (_constants.SYSTEM_ENTRYPOINTS.has(entrypoint.name)) {
|
||||
continue;
|
||||
}
|
||||
const pagePath = (0, _getapproutefromentrypoint.default)(entrypoint.name);
|
||||
if (!pagePath) {
|
||||
continue;
|
||||
}
|
||||
const filesForPage = (0, _buildmanifestplugin.getEntrypointFiles)(entrypoint);
|
||||
manifest.pages[pagePath] = [
|
||||
...new Set([
|
||||
...mainFiles,
|
||||
...filesForPage
|
||||
])
|
||||
];
|
||||
}
|
||||
const json = JSON.stringify(manifest, null, 2);
|
||||
assets[_constants.APP_BUILD_MANIFEST] = new _webpack.sources.RawSource(json);
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=app-build-manifest-plugin.js.map
|
||||
216
.next/standalone/node_modules/next/dist/build/webpack/plugins/build-manifest-plugin.js
generated
vendored
Normal file
216
.next/standalone/node_modules/next/dist/build/webpack/plugins/build-manifest-plugin.js
generated
vendored
Normal file
@@ -0,0 +1,216 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
0 && (module.exports = {
|
||||
default: null,
|
||||
getEntrypointFiles: null,
|
||||
normalizeRewritesForBuildManifest: null,
|
||||
srcEmptySsgManifest: null
|
||||
});
|
||||
function _export(target, all) {
|
||||
for(var name in all)Object.defineProperty(target, name, {
|
||||
enumerable: true,
|
||||
get: all[name]
|
||||
});
|
||||
}
|
||||
_export(exports, {
|
||||
// This plugin creates a build-manifest.json for all assets that are being output
|
||||
// It has a mapping of "entry" filename to real filename. Because the real filename can be hashed in production
|
||||
default: function() {
|
||||
return BuildManifestPlugin;
|
||||
},
|
||||
getEntrypointFiles: function() {
|
||||
return getEntrypointFiles;
|
||||
},
|
||||
normalizeRewritesForBuildManifest: function() {
|
||||
return normalizeRewritesForBuildManifest;
|
||||
},
|
||||
srcEmptySsgManifest: function() {
|
||||
return srcEmptySsgManifest;
|
||||
}
|
||||
});
|
||||
const _devalue = /*#__PURE__*/ _interop_require_default(require("next/dist/compiled/devalue"));
|
||||
const _webpack = require("next/dist/compiled/webpack/webpack");
|
||||
const _constants = require("../../../shared/lib/constants");
|
||||
const _getroutefromentrypoint = /*#__PURE__*/ _interop_require_default(require("../../../server/get-route-from-entrypoint"));
|
||||
const _nextdropclientpageplugin = require("./next-drop-client-page-plugin");
|
||||
const _utils = require("../../../shared/lib/router/utils");
|
||||
const _profilingplugin = require("./profiling-plugin");
|
||||
function _interop_require_default(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
const srcEmptySsgManifest = `self.__SSG_MANIFEST=new Set;self.__SSG_MANIFEST_CB&&self.__SSG_MANIFEST_CB()`;
|
||||
function normalizeRewrite(item) {
|
||||
return {
|
||||
has: item.has,
|
||||
source: item.source,
|
||||
destination: item.destination
|
||||
};
|
||||
}
|
||||
function normalizeRewritesForBuildManifest(rewrites) {
|
||||
var _rewrites_afterFiles, _rewrites_beforeFiles, _rewrites_fallback;
|
||||
return {
|
||||
afterFiles: (_rewrites_afterFiles = rewrites.afterFiles) == null ? void 0 : _rewrites_afterFiles.map((item)=>normalizeRewrite(item)),
|
||||
beforeFiles: (_rewrites_beforeFiles = rewrites.beforeFiles) == null ? void 0 : _rewrites_beforeFiles.map((item)=>normalizeRewrite(item)),
|
||||
fallback: (_rewrites_fallback = rewrites.fallback) == null ? void 0 : _rewrites_fallback.map((item)=>normalizeRewrite(item))
|
||||
};
|
||||
}
|
||||
// This function takes the asset map generated in BuildManifestPlugin and creates a
|
||||
// reduced version to send to the client.
|
||||
function generateClientManifest(compiler, compilation, assetMap, rewrites) {
|
||||
const compilationSpan = _profilingplugin.spans.get(compilation) || _profilingplugin.spans.get(compiler);
|
||||
const genClientManifestSpan = compilationSpan == null ? void 0 : compilationSpan.traceChild("NextJsBuildManifest-generateClientManifest");
|
||||
return genClientManifestSpan == null ? void 0 : genClientManifestSpan.traceFn(()=>{
|
||||
const clientManifest = {
|
||||
__rewrites: normalizeRewritesForBuildManifest(rewrites)
|
||||
};
|
||||
const appDependencies = new Set(assetMap.pages["/_app"]);
|
||||
const sortedPageKeys = (0, _utils.getSortedRoutes)(Object.keys(assetMap.pages));
|
||||
sortedPageKeys.forEach((page)=>{
|
||||
const dependencies = assetMap.pages[page];
|
||||
if (page === "/_app") return;
|
||||
// Filter out dependencies in the _app entry, because those will have already
|
||||
// been loaded by the client prior to a navigation event
|
||||
const filteredDeps = dependencies.filter((dep)=>!appDependencies.has(dep));
|
||||
// The manifest can omit the page if it has no requirements
|
||||
if (filteredDeps.length) {
|
||||
clientManifest[page] = filteredDeps;
|
||||
}
|
||||
});
|
||||
// provide the sorted pages as an array so we don't rely on the object's keys
|
||||
// being in order and we don't slow down look-up time for page assets
|
||||
clientManifest.sortedPages = sortedPageKeys;
|
||||
return (0, _devalue.default)(clientManifest);
|
||||
});
|
||||
}
|
||||
function getEntrypointFiles(entrypoint) {
|
||||
return (entrypoint == null ? void 0 : entrypoint.getFiles().filter((file)=>{
|
||||
// We don't want to include `.hot-update.js` files into the initial page
|
||||
return /(?<!\.hot-update)\.(js|css)($|\?)/.test(file);
|
||||
}).map((file)=>file.replace(/\\/g, "/"))) ?? [];
|
||||
}
|
||||
const processRoute = (r)=>{
|
||||
const rewrite = {
|
||||
...r
|
||||
};
|
||||
// omit external rewrite destinations since these aren't
|
||||
// handled client-side
|
||||
if (!rewrite.destination.startsWith("/")) {
|
||||
delete rewrite.destination;
|
||||
}
|
||||
return rewrite;
|
||||
};
|
||||
class BuildManifestPlugin {
|
||||
constructor(options){
|
||||
this.buildId = options.buildId;
|
||||
this.isDevFallback = !!options.isDevFallback;
|
||||
this.rewrites = {
|
||||
beforeFiles: [],
|
||||
afterFiles: [],
|
||||
fallback: []
|
||||
};
|
||||
this.appDirEnabled = options.appDirEnabled;
|
||||
this.rewrites.beforeFiles = options.rewrites.beforeFiles.map(processRoute);
|
||||
this.rewrites.afterFiles = options.rewrites.afterFiles.map(processRoute);
|
||||
this.rewrites.fallback = options.rewrites.fallback.map(processRoute);
|
||||
this.exportRuntime = !!options.exportRuntime;
|
||||
}
|
||||
createAssets(compiler, compilation, assets) {
|
||||
const compilationSpan = _profilingplugin.spans.get(compilation) || _profilingplugin.spans.get(compiler);
|
||||
const createAssetsSpan = compilationSpan == null ? void 0 : compilationSpan.traceChild("NextJsBuildManifest-createassets");
|
||||
return createAssetsSpan == null ? void 0 : createAssetsSpan.traceFn(()=>{
|
||||
const entrypoints = compilation.entrypoints;
|
||||
const assetMap = {
|
||||
polyfillFiles: [],
|
||||
devFiles: [],
|
||||
ampDevFiles: [],
|
||||
lowPriorityFiles: [],
|
||||
rootMainFiles: [],
|
||||
pages: {
|
||||
"/_app": []
|
||||
},
|
||||
ampFirstPages: []
|
||||
};
|
||||
const ampFirstEntryNames = _nextdropclientpageplugin.ampFirstEntryNamesMap.get(compilation);
|
||||
if (ampFirstEntryNames) {
|
||||
for (const entryName of ampFirstEntryNames){
|
||||
const pagePath = (0, _getroutefromentrypoint.default)(entryName);
|
||||
if (!pagePath) {
|
||||
continue;
|
||||
}
|
||||
assetMap.ampFirstPages.push(pagePath);
|
||||
}
|
||||
}
|
||||
const mainFiles = new Set(getEntrypointFiles(entrypoints.get(_constants.CLIENT_STATIC_FILES_RUNTIME_MAIN)));
|
||||
if (this.appDirEnabled) {
|
||||
assetMap.rootMainFiles = [
|
||||
...new Set(getEntrypointFiles(entrypoints.get(_constants.CLIENT_STATIC_FILES_RUNTIME_MAIN_APP)))
|
||||
];
|
||||
}
|
||||
const compilationAssets = compilation.getAssets();
|
||||
assetMap.polyfillFiles = compilationAssets.filter((p)=>{
|
||||
// Ensure only .js files are passed through
|
||||
if (!p.name.endsWith(".js")) {
|
||||
return false;
|
||||
}
|
||||
return p.info && _constants.CLIENT_STATIC_FILES_RUNTIME_POLYFILLS_SYMBOL in p.info;
|
||||
}).map((v)=>v.name);
|
||||
assetMap.devFiles = getEntrypointFiles(entrypoints.get(_constants.CLIENT_STATIC_FILES_RUNTIME_REACT_REFRESH)).filter((file)=>!mainFiles.has(file));
|
||||
assetMap.ampDevFiles = getEntrypointFiles(entrypoints.get(_constants.CLIENT_STATIC_FILES_RUNTIME_AMP));
|
||||
for (const entrypoint of compilation.entrypoints.values()){
|
||||
if (_constants.SYSTEM_ENTRYPOINTS.has(entrypoint.name)) continue;
|
||||
const pagePath = (0, _getroutefromentrypoint.default)(entrypoint.name);
|
||||
if (!pagePath) {
|
||||
continue;
|
||||
}
|
||||
const filesForPage = getEntrypointFiles(entrypoint);
|
||||
assetMap.pages[pagePath] = [
|
||||
...new Set([
|
||||
...mainFiles,
|
||||
...filesForPage
|
||||
])
|
||||
];
|
||||
}
|
||||
if (!this.isDevFallback) {
|
||||
// Add the runtime build manifest file (generated later in this file)
|
||||
// as a dependency for the app. If the flag is false, the file won't be
|
||||
// downloaded by the client.
|
||||
assetMap.lowPriorityFiles.push(`${_constants.CLIENT_STATIC_FILES_PATH}/${this.buildId}/_buildManifest.js`);
|
||||
const ssgManifestPath = `${_constants.CLIENT_STATIC_FILES_PATH}/${this.buildId}/_ssgManifest.js`;
|
||||
assetMap.lowPriorityFiles.push(ssgManifestPath);
|
||||
assets[ssgManifestPath] = new _webpack.sources.RawSource(srcEmptySsgManifest);
|
||||
}
|
||||
assetMap.pages = Object.keys(assetMap.pages).sort()// eslint-disable-next-line
|
||||
.reduce((a, c)=>(a[c] = assetMap.pages[c], a), {});
|
||||
let buildManifestName = _constants.BUILD_MANIFEST;
|
||||
if (this.isDevFallback) {
|
||||
buildManifestName = `fallback-${_constants.BUILD_MANIFEST}`;
|
||||
}
|
||||
assets[buildManifestName] = new _webpack.sources.RawSource(JSON.stringify(assetMap, null, 2));
|
||||
if (this.exportRuntime) {
|
||||
assets[`server/${_constants.MIDDLEWARE_BUILD_MANIFEST}.js`] = new _webpack.sources.RawSource(`self.__BUILD_MANIFEST=${JSON.stringify(assetMap)}`);
|
||||
}
|
||||
if (!this.isDevFallback) {
|
||||
const clientManifestPath = `${_constants.CLIENT_STATIC_FILES_PATH}/${this.buildId}/_buildManifest.js`;
|
||||
assets[clientManifestPath] = new _webpack.sources.RawSource(`self.__BUILD_MANIFEST = ${generateClientManifest(compiler, compilation, assetMap, this.rewrites)};self.__BUILD_MANIFEST_CB && self.__BUILD_MANIFEST_CB()`);
|
||||
}
|
||||
return assets;
|
||||
});
|
||||
}
|
||||
apply(compiler) {
|
||||
compiler.hooks.make.tap("NextJsBuildManifest", (compilation)=>{
|
||||
compilation.hooks.processAssets.tap({
|
||||
name: "NextJsBuildManifest",
|
||||
stage: _webpack.webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS
|
||||
}, (assets)=>{
|
||||
this.createAssets(compiler, compilation, assets);
|
||||
});
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=build-manifest-plugin.js.map
|
||||
67
.next/standalone/node_modules/next/dist/build/webpack/plugins/copy-file-plugin.js
generated
vendored
Normal file
67
.next/standalone/node_modules/next/dist/build/webpack/plugins/copy-file-plugin.js
generated
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "CopyFilePlugin", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return CopyFilePlugin;
|
||||
}
|
||||
});
|
||||
const _fs = require("fs");
|
||||
const _loaderutils3 = /*#__PURE__*/ _interop_require_default(require("next/dist/compiled/loader-utils3"));
|
||||
const _webpack = require("next/dist/compiled/webpack/webpack");
|
||||
function _interop_require_default(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
const PLUGIN_NAME = "CopyFilePlugin";
|
||||
class CopyFilePlugin {
|
||||
constructor({ filePath, cacheKey, name, info }){
|
||||
this.filePath = filePath;
|
||||
this.cacheKey = cacheKey;
|
||||
this.name = name;
|
||||
this.info = info;
|
||||
}
|
||||
apply(compiler) {
|
||||
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation)=>{
|
||||
const cache = compilation.getCache("CopyFilePlugin");
|
||||
const hook = compilation.hooks.processAssets;
|
||||
hook.tapPromise({
|
||||
name: PLUGIN_NAME,
|
||||
stage: _webpack.webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS
|
||||
}, async ()=>{
|
||||
if (cache) {
|
||||
const cachedResult = await cache.getPromise(this.filePath, this.cacheKey);
|
||||
if (cachedResult) {
|
||||
const { file, source } = cachedResult;
|
||||
compilation.emitAsset(file, source, {
|
||||
...this.info
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
const content = await _fs.promises.readFile(this.filePath, "utf8");
|
||||
const file = _loaderutils3.default.interpolateName({
|
||||
resourcePath: this.filePath
|
||||
}, this.name, {
|
||||
content,
|
||||
context: compiler.context
|
||||
});
|
||||
const source = new _webpack.sources.RawSource(content);
|
||||
if (cache) {
|
||||
await cache.storePromise(this.filePath, this.cacheKey, {
|
||||
file,
|
||||
source
|
||||
});
|
||||
}
|
||||
compilation.emitAsset(file, source, {
|
||||
...this.info
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=copy-file-plugin.js.map
|
||||
277
.next/standalone/node_modules/next/dist/build/webpack/plugins/css-chunking-plugin.js
generated
vendored
Normal file
277
.next/standalone/node_modules/next/dist/build/webpack/plugins/css-chunking-plugin.js
generated
vendored
Normal file
@@ -0,0 +1,277 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "CssChunkingPlugin", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return CssChunkingPlugin;
|
||||
}
|
||||
});
|
||||
const PLUGIN_NAME = "CssChunkingPlugin";
|
||||
/**
|
||||
* Merge chunks until they are bigger than the target size.
|
||||
*/ const MIN_CSS_CHUNK_SIZE = 30 * 1024;
|
||||
/**
|
||||
* Avoid merging chunks when they would be bigger than this size.
|
||||
*/ const MAX_CSS_CHUNK_SIZE = 100 * 1024;
|
||||
function isGlobalCss(module) {
|
||||
return !/\.module\.(css|scss|sass)$/.test(module.nameForCondition() || "");
|
||||
}
|
||||
class CssChunkingPlugin {
|
||||
constructor(strict){
|
||||
this.strict = strict;
|
||||
}
|
||||
apply(compiler) {
|
||||
const strict = this.strict;
|
||||
const summary = !!process.env.CSS_CHUNKING_SUMMARY;
|
||||
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation)=>{
|
||||
let once = false;
|
||||
compilation.hooks.optimizeChunks.tap({
|
||||
name: PLUGIN_NAME,
|
||||
stage: 5
|
||||
}, ()=>{
|
||||
if (once) {
|
||||
return;
|
||||
}
|
||||
once = true;
|
||||
const chunkGraph = compilation.chunkGraph;
|
||||
let changed = undefined;
|
||||
const chunkStates = new Map();
|
||||
const chunkStatesByModule = new Map();
|
||||
// Collect all css modules in chunks and the execpted order of them
|
||||
for (const chunk of compilation.chunks){
|
||||
var _chunk_name;
|
||||
if ((_chunk_name = chunk.name) == null ? void 0 : _chunk_name.startsWith("pages/")) continue;
|
||||
const modules = [];
|
||||
for (const module of chunkGraph.getChunkModulesIterable(chunk)){
|
||||
var _module_type;
|
||||
if (!((_module_type = module.type) == null ? void 0 : _module_type.startsWith("css"))) continue;
|
||||
modules.push(module);
|
||||
}
|
||||
if (!modules.length) continue;
|
||||
const chunkState = {
|
||||
chunk,
|
||||
modules,
|
||||
order: 0,
|
||||
requests: modules.length
|
||||
};
|
||||
chunkStates.set(chunk, chunkState);
|
||||
for(let i = 0; i < modules.length; i++){
|
||||
const module = modules[i];
|
||||
let moduleChunkStates = chunkStatesByModule.get(module);
|
||||
if (!moduleChunkStates) {
|
||||
moduleChunkStates = new Map();
|
||||
chunkStatesByModule.set(module, moduleChunkStates);
|
||||
}
|
||||
moduleChunkStates.set(chunkState, i);
|
||||
chunkStatesByModule.set(module, moduleChunkStates);
|
||||
}
|
||||
}
|
||||
// Sort modules by their index sum
|
||||
const orderedModules = [];
|
||||
for (const [module, moduleChunkStates] of chunkStatesByModule){
|
||||
let sum = 0;
|
||||
for (const i of moduleChunkStates.values()){
|
||||
sum += i;
|
||||
}
|
||||
orderedModules.push({
|
||||
module,
|
||||
sum
|
||||
});
|
||||
}
|
||||
orderedModules.sort((a, b)=>a.sum - b.sum);
|
||||
// A queue of modules that still need to be processed
|
||||
const remainingModules = new Set(orderedModules.map(({ module })=>module));
|
||||
// In loose mode we guess the dependents of modules from the order
|
||||
// assuming that when a module is a dependency of another module
|
||||
// it will always appear before it in every chunk.
|
||||
const allDependents = new Map();
|
||||
if (!this.strict) {
|
||||
for (const b of remainingModules){
|
||||
const dependent = new Set();
|
||||
loop: for (const a of remainingModules){
|
||||
if (a === b) continue;
|
||||
// check if a depends on b
|
||||
for (const [chunkState, ia] of chunkStatesByModule.get(a)){
|
||||
const bChunkStates = chunkStatesByModule.get(b);
|
||||
const ib = bChunkStates.get(chunkState);
|
||||
if (ib === undefined) {
|
||||
continue loop;
|
||||
}
|
||||
if (ib > ia) {
|
||||
continue loop;
|
||||
}
|
||||
}
|
||||
dependent.add(a);
|
||||
}
|
||||
if (dependent.size > 0) allDependents.set(b, dependent);
|
||||
}
|
||||
}
|
||||
// Stores the new chunk for every module
|
||||
const newChunksByModule = new Map();
|
||||
// Process through all modules
|
||||
for (const startModule of remainingModules){
|
||||
let globalCssMode = isGlobalCss(startModule);
|
||||
// The current position of processing in all selected chunks
|
||||
let allChunkStates = new Map(chunkStatesByModule.get(startModule));
|
||||
// The list of modules that goes into the new chunk
|
||||
const newChunkModules = new Set([
|
||||
startModule
|
||||
]);
|
||||
// The current size of the new chunk
|
||||
let currentSize = startModule.size();
|
||||
// A pool of potential modules where the next module is selected from.
|
||||
// It's filled from the next module of the selected modules in every chunk.
|
||||
// It also keeps some metadata to improve performance [size, chunkStates].
|
||||
const potentialNextModules = new Map();
|
||||
for (const [chunkState, i] of allChunkStates){
|
||||
const nextModule = chunkState.modules[i + 1];
|
||||
if (nextModule && remainingModules.has(nextModule)) {
|
||||
potentialNextModules.set(nextModule, [
|
||||
nextModule.size(),
|
||||
chunkStatesByModule.get(nextModule)
|
||||
]);
|
||||
}
|
||||
}
|
||||
// Try to add modules to the chunk until a break condition is met
|
||||
let cont;
|
||||
do {
|
||||
cont = false;
|
||||
// We try to select a module that reduces request count and
|
||||
// has the highest number of requests
|
||||
const orderedPotentialNextModules = [];
|
||||
for (const [nextModule, [size, nextChunkStates]] of potentialNextModules){
|
||||
let maxRequests = 0;
|
||||
for (const chunkState of nextChunkStates.keys()){
|
||||
// There is always some overlap
|
||||
if (allChunkStates.has(chunkState)) {
|
||||
maxRequests = Math.max(maxRequests, chunkState.requests);
|
||||
}
|
||||
}
|
||||
orderedPotentialNextModules.push([
|
||||
nextModule,
|
||||
size,
|
||||
nextChunkStates,
|
||||
maxRequests
|
||||
]);
|
||||
}
|
||||
orderedPotentialNextModules.sort((a, b)=>b[3] - a[3] || (a[0].identifier() < b[0].identifier() ? -1 : 1));
|
||||
// Try every potential module
|
||||
loop: for (const [nextModule, size, nextChunkStates] of orderedPotentialNextModules){
|
||||
if (currentSize + size > MAX_CSS_CHUNK_SIZE) {
|
||||
continue;
|
||||
}
|
||||
if (!strict) {
|
||||
// In loose mode we only check if the dependencies are not violated
|
||||
const dependent = allDependents.get(nextModule);
|
||||
if (dependent) {
|
||||
for (const dep of dependent){
|
||||
if (newChunkModules.has(dep)) {
|
||||
continue loop;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// In strict mode we check that none of the order in any chunk is changed by adding the module
|
||||
for (const [chunkState, i] of nextChunkStates){
|
||||
const prevState = allChunkStates.get(chunkState);
|
||||
if (prevState === undefined) {
|
||||
// New chunk group, can add it, but should we?
|
||||
// We only add that if below min size
|
||||
if (currentSize < MIN_CSS_CHUNK_SIZE) {
|
||||
continue;
|
||||
} else {
|
||||
continue loop;
|
||||
}
|
||||
} else if (prevState + 1 === i) {
|
||||
continue;
|
||||
} else {
|
||||
continue loop;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Global CSS must not leak into unrelated chunks
|
||||
const nextIsGlobalCss = isGlobalCss(nextModule);
|
||||
if (nextIsGlobalCss && globalCssMode) {
|
||||
if (allChunkStates.size !== nextChunkStates.size) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (globalCssMode) {
|
||||
for (const chunkState of nextChunkStates.keys()){
|
||||
if (!allChunkStates.has(chunkState)) {
|
||||
continue loop;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (nextIsGlobalCss) {
|
||||
for (const chunkState of allChunkStates.keys()){
|
||||
if (!nextChunkStates.has(chunkState)) {
|
||||
continue loop;
|
||||
}
|
||||
}
|
||||
}
|
||||
potentialNextModules.delete(nextModule);
|
||||
currentSize += size;
|
||||
if (nextIsGlobalCss) {
|
||||
globalCssMode = true;
|
||||
}
|
||||
for (const [chunkState, i] of nextChunkStates){
|
||||
if (allChunkStates.has(chunkState)) {
|
||||
// This reduces the request count of the chunk group
|
||||
chunkState.requests--;
|
||||
}
|
||||
allChunkStates.set(chunkState, i);
|
||||
const newNextModule = chunkState.modules[i + 1];
|
||||
if (newNextModule && remainingModules.has(newNextModule) && !newChunkModules.has(newNextModule)) {
|
||||
potentialNextModules.set(newNextModule, [
|
||||
newNextModule.size(),
|
||||
chunkStatesByModule.get(newNextModule)
|
||||
]);
|
||||
}
|
||||
}
|
||||
newChunkModules.add(nextModule);
|
||||
cont = true;
|
||||
break;
|
||||
}
|
||||
}while (cont);
|
||||
const newChunk = compilation.addChunk();
|
||||
newChunk.preventIntegration = true;
|
||||
newChunk.idNameHints.add("css");
|
||||
for (const module of newChunkModules){
|
||||
remainingModules.delete(module);
|
||||
chunkGraph.connectChunkAndModule(newChunk, module);
|
||||
newChunksByModule.set(module, newChunk);
|
||||
}
|
||||
changed = true;
|
||||
}
|
||||
for (const { chunk, modules } of chunkStates.values()){
|
||||
const chunks = new Set();
|
||||
for (const module of modules){
|
||||
const newChunk = newChunksByModule.get(module);
|
||||
if (newChunk) {
|
||||
chunkGraph.disconnectChunkAndModule(chunk, module);
|
||||
if (chunks.has(newChunk)) continue;
|
||||
chunks.add(newChunk);
|
||||
chunk.split(newChunk);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (summary) {
|
||||
console.log("Top 20 chunks by request count:");
|
||||
const orderedChunkStates = [
|
||||
...chunkStates.values()
|
||||
];
|
||||
orderedChunkStates.sort((a, b)=>b.requests - a.requests);
|
||||
for (const { chunk, modules, requests } of orderedChunkStates.slice(0, 20)){
|
||||
console.log(`- ${requests} requests for ${chunk.name} (has ${modules.length} modules)`);
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=css-chunking-plugin.js.map
|
||||
90
.next/standalone/node_modules/next/dist/build/webpack/plugins/css-minimizer-plugin.js
generated
vendored
Normal file
90
.next/standalone/node_modules/next/dist/build/webpack/plugins/css-minimizer-plugin.js
generated
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "CssMinimizerPlugin", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return CssMinimizerPlugin;
|
||||
}
|
||||
});
|
||||
const _cssnanosimple = /*#__PURE__*/ _interop_require_default(require("next/dist/compiled/cssnano-simple"));
|
||||
const _postcssscss = /*#__PURE__*/ _interop_require_default(require("next/dist/compiled/postcss-scss"));
|
||||
const _postcss = /*#__PURE__*/ _interop_require_default(require("postcss"));
|
||||
const _webpack = require("next/dist/compiled/webpack/webpack");
|
||||
const _profilingplugin = require("./profiling-plugin");
|
||||
function _interop_require_default(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
// https://github.com/NMFR/optimize-css-assets-webpack-plugin/blob/0a410a9bf28c7b0e81a3470a13748e68ca2f50aa/src/index.js#L20
|
||||
const CSS_REGEX = /\.css(\?.*)?$/i;
|
||||
class CssMinimizerPlugin {
|
||||
constructor(options){
|
||||
this.__next_css_remove = true;
|
||||
this.options = options;
|
||||
}
|
||||
optimizeAsset(file, asset) {
|
||||
const postcssOptions = {
|
||||
...this.options.postcssOptions,
|
||||
to: file,
|
||||
from: file,
|
||||
// We don't actually add this parser to support Sass. It can also be used
|
||||
// for inline comment support. See the README:
|
||||
// https://github.com/postcss/postcss-scss/blob/master/README.md#2-inline-comments-for-postcss
|
||||
parser: _postcssscss.default
|
||||
};
|
||||
let input;
|
||||
if (postcssOptions.map && asset.sourceAndMap) {
|
||||
const { source, map } = asset.sourceAndMap();
|
||||
input = source;
|
||||
postcssOptions.map.prev = map ? map : false;
|
||||
} else {
|
||||
input = asset.source();
|
||||
}
|
||||
return (0, _postcss.default)([
|
||||
(0, _cssnanosimple.default)({}, _postcss.default)
|
||||
]).process(input, postcssOptions).then((res)=>{
|
||||
if (res.map) {
|
||||
return new _webpack.sources.SourceMapSource(res.css, file, res.map.toJSON());
|
||||
} else {
|
||||
return new _webpack.sources.RawSource(res.css);
|
||||
}
|
||||
});
|
||||
}
|
||||
apply(compiler) {
|
||||
compiler.hooks.compilation.tap("CssMinimizerPlugin", (compilation)=>{
|
||||
const cache = compilation.getCache("CssMinimizerPlugin");
|
||||
compilation.hooks.processAssets.tapPromise({
|
||||
name: "CssMinimizerPlugin",
|
||||
stage: _webpack.webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE
|
||||
}, async (assets)=>{
|
||||
const compilationSpan = _profilingplugin.spans.get(compilation) || _profilingplugin.spans.get(compiler);
|
||||
const cssMinimizerSpan = compilationSpan.traceChild("css-minimizer-plugin");
|
||||
return cssMinimizerSpan.traceAsyncFn(async ()=>{
|
||||
const files = Object.keys(assets);
|
||||
await Promise.all(files.filter((file)=>CSS_REGEX.test(file)).map(async (file)=>{
|
||||
const assetSpan = cssMinimizerSpan.traceChild("minify-css");
|
||||
assetSpan.setAttribute("file", file);
|
||||
return assetSpan.traceAsyncFn(async ()=>{
|
||||
const asset = assets[file];
|
||||
const etag = cache.getLazyHashedEtag(asset);
|
||||
const cachedResult = await cache.getPromise(file, etag);
|
||||
assetSpan.setAttribute("cache", cachedResult ? "HIT" : "MISS");
|
||||
if (cachedResult) {
|
||||
assets[file] = cachedResult;
|
||||
return;
|
||||
}
|
||||
const result = await this.optimizeAsset(file, asset);
|
||||
await cache.storePromise(file, etag, result);
|
||||
assets[file] = result;
|
||||
});
|
||||
}));
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=css-minimizer-plugin.js.map
|
||||
172
.next/standalone/node_modules/next/dist/build/webpack/plugins/define-env-plugin.js
generated
vendored
Normal file
172
.next/standalone/node_modules/next/dist/build/webpack/plugins/define-env-plugin.js
generated
vendored
Normal file
@@ -0,0 +1,172 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
0 && (module.exports = {
|
||||
getDefineEnv: null,
|
||||
getDefineEnvPlugin: null
|
||||
});
|
||||
function _export(target, all) {
|
||||
for(var name in all)Object.defineProperty(target, name, {
|
||||
enumerable: true,
|
||||
get: all[name]
|
||||
});
|
||||
}
|
||||
_export(exports, {
|
||||
getDefineEnv: function() {
|
||||
return getDefineEnv;
|
||||
},
|
||||
getDefineEnvPlugin: function() {
|
||||
return getDefineEnvPlugin;
|
||||
}
|
||||
});
|
||||
const _webpack = require("next/dist/compiled/webpack/webpack");
|
||||
const _needsexperimentalreact = require("../../../lib/needs-experimental-react");
|
||||
function errorIfEnvConflicted(config, key) {
|
||||
const isPrivateKey = /^(?:NODE_.+)|^(?:__.+)$/i.test(key);
|
||||
const hasNextRuntimeKey = key === "NEXT_RUNTIME";
|
||||
if (isPrivateKey || hasNextRuntimeKey) {
|
||||
throw new Error(`The key "${key}" under "env" in ${config.configFileName} is not allowed. https://nextjs.org/docs/messages/env-key-not-allowed`);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Collects all environment variables that are using the `NEXT_PUBLIC_` prefix.
|
||||
*/ function getNextPublicEnvironmentVariables() {
|
||||
const defineEnv = {};
|
||||
for(const key in process.env){
|
||||
if (key.startsWith("NEXT_PUBLIC_")) {
|
||||
const value = process.env[key];
|
||||
if (value) {
|
||||
defineEnv[`process.env.${key}`] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return defineEnv;
|
||||
}
|
||||
/**
|
||||
* Collects the `env` config value from the Next.js config.
|
||||
*/ function getNextConfigEnv(config) {
|
||||
// Refactored code below to use for-of
|
||||
const defineEnv = {};
|
||||
const env = config.env;
|
||||
for(const key in env){
|
||||
const value = env[key];
|
||||
if (value) {
|
||||
errorIfEnvConflicted(config, key);
|
||||
defineEnv[`process.env.${key}`] = value;
|
||||
}
|
||||
}
|
||||
return defineEnv;
|
||||
}
|
||||
/**
|
||||
* Serializes the DefineEnv config so that it can be inserted into the code by Webpack/Turbopack, JSON stringifies each value.
|
||||
*/ function serializeDefineEnv(defineEnv) {
|
||||
const defineEnvStringified = {};
|
||||
for(const key in defineEnv){
|
||||
const value = defineEnv[key];
|
||||
defineEnvStringified[key] = JSON.stringify(value);
|
||||
}
|
||||
return defineEnvStringified;
|
||||
}
|
||||
function getImageConfig(config, dev) {
|
||||
var _config_images, _config_images1;
|
||||
return {
|
||||
"process.env.__NEXT_IMAGE_OPTS": {
|
||||
deviceSizes: config.images.deviceSizes,
|
||||
imageSizes: config.images.imageSizes,
|
||||
path: config.images.path,
|
||||
loader: config.images.loader,
|
||||
dangerouslyAllowSVG: config.images.dangerouslyAllowSVG,
|
||||
unoptimized: config == null ? void 0 : (_config_images = config.images) == null ? void 0 : _config_images.unoptimized,
|
||||
...dev ? {
|
||||
// pass domains in development to allow validating on the client
|
||||
domains: config.images.domains,
|
||||
remotePatterns: (_config_images1 = config.images) == null ? void 0 : _config_images1.remotePatterns,
|
||||
output: config.output
|
||||
} : {}
|
||||
}
|
||||
};
|
||||
}
|
||||
function getDefineEnv({ isTurbopack, clientRouterFilters, config, dev, distDir, fetchCacheKeyPrefix, hasRewrites, isClient, isEdgeServer, isNodeOrEdgeCompilation, isNodeServer, middlewareMatchers }) {
|
||||
var _config_experimental_staleTimes, _config_experimental_staleTimes1, _config_experimental_staleTimes2, _config_experimental_staleTimes3, _config_i18n;
|
||||
const defineEnv = {
|
||||
// internal field to identify the plugin config
|
||||
__NEXT_DEFINE_ENV: true,
|
||||
...getNextPublicEnvironmentVariables(),
|
||||
...getNextConfigEnv(config),
|
||||
...!isEdgeServer ? {} : {
|
||||
EdgeRuntime: /**
|
||||
* Cloud providers can set this environment variable to allow users
|
||||
* and library authors to have different implementations based on
|
||||
* the runtime they are running with, if it's not using `edge-runtime`
|
||||
*/ process.env.NEXT_EDGE_RUNTIME_PROVIDER ?? "edge-runtime"
|
||||
},
|
||||
"process.turbopack": isTurbopack,
|
||||
"process.env.TURBOPACK": isTurbopack,
|
||||
// TODO: enforce `NODE_ENV` on `process.env`, and add a test:
|
||||
"process.env.NODE_ENV": dev ? "development" : "production",
|
||||
"process.env.NEXT_RUNTIME": isEdgeServer ? "edge" : isNodeServer ? "nodejs" : "",
|
||||
"process.env.NEXT_MINIMAL": "",
|
||||
"process.env.__NEXT_PPR": config.experimental.ppr === true,
|
||||
"process.env.NEXT_DEPLOYMENT_ID": config.deploymentId || false,
|
||||
"process.env.__NEXT_FETCH_CACHE_KEY_PREFIX": fetchCacheKeyPrefix ?? "",
|
||||
"process.env.__NEXT_MIDDLEWARE_MATCHERS": middlewareMatchers ?? [],
|
||||
"process.env.__NEXT_MANUAL_CLIENT_BASE_PATH": config.experimental.manualClientBasePath ?? false,
|
||||
"process.env.__NEXT_CLIENT_ROUTER_DYNAMIC_STALETIME": JSON.stringify(isNaN(Number((_config_experimental_staleTimes = config.experimental.staleTimes) == null ? void 0 : _config_experimental_staleTimes.dynamic)) ? 30 // 30 seconds
|
||||
: (_config_experimental_staleTimes1 = config.experimental.staleTimes) == null ? void 0 : _config_experimental_staleTimes1.dynamic),
|
||||
"process.env.__NEXT_CLIENT_ROUTER_STATIC_STALETIME": JSON.stringify(isNaN(Number((_config_experimental_staleTimes2 = config.experimental.staleTimes) == null ? void 0 : _config_experimental_staleTimes2.static)) ? 5 * 60 // 5 minutes
|
||||
: (_config_experimental_staleTimes3 = config.experimental.staleTimes) == null ? void 0 : _config_experimental_staleTimes3.static),
|
||||
"process.env.__NEXT_CLIENT_ROUTER_FILTER_ENABLED": config.experimental.clientRouterFilter ?? true,
|
||||
"process.env.__NEXT_CLIENT_ROUTER_S_FILTER": (clientRouterFilters == null ? void 0 : clientRouterFilters.staticFilter) ?? false,
|
||||
"process.env.__NEXT_CLIENT_ROUTER_D_FILTER": (clientRouterFilters == null ? void 0 : clientRouterFilters.dynamicFilter) ?? false,
|
||||
"process.env.__NEXT_OPTIMISTIC_CLIENT_CACHE": config.experimental.optimisticClientCache ?? true,
|
||||
"process.env.__NEXT_MIDDLEWARE_PREFETCH": config.experimental.middlewarePrefetch ?? "flexible",
|
||||
"process.env.__NEXT_CROSS_ORIGIN": config.crossOrigin,
|
||||
"process.browser": isClient,
|
||||
"process.env.__NEXT_TEST_MODE": process.env.__NEXT_TEST_MODE ?? false,
|
||||
// This is used in client/dev-error-overlay/hot-dev-client.js to replace the dist directory
|
||||
...dev && (isClient ?? isEdgeServer) ? {
|
||||
"process.env.__NEXT_DIST_DIR": distDir
|
||||
} : {},
|
||||
"process.env.__NEXT_TRAILING_SLASH": config.trailingSlash,
|
||||
"process.env.__NEXT_BUILD_INDICATOR": config.devIndicators.buildActivity ?? true,
|
||||
"process.env.__NEXT_BUILD_INDICATOR_POSITION": config.devIndicators.buildActivityPosition ?? "bottom-right",
|
||||
"process.env.__NEXT_STRICT_MODE": config.reactStrictMode === null ? false : config.reactStrictMode,
|
||||
"process.env.__NEXT_STRICT_MODE_APP": // When next.config.js does not have reactStrictMode it's enabled by default.
|
||||
config.reactStrictMode === null ? true : config.reactStrictMode,
|
||||
"process.env.__NEXT_OPTIMIZE_FONTS": !dev && config.optimizeFonts,
|
||||
"process.env.__NEXT_OPTIMIZE_CSS": (config.experimental.optimizeCss && !dev) ?? false,
|
||||
"process.env.__NEXT_SCRIPT_WORKERS": (config.experimental.nextScriptWorkers && !dev) ?? false,
|
||||
"process.env.__NEXT_SCROLL_RESTORATION": config.experimental.scrollRestoration ?? false,
|
||||
...getImageConfig(config, dev),
|
||||
"process.env.__NEXT_ROUTER_BASEPATH": config.basePath,
|
||||
"process.env.__NEXT_STRICT_NEXT_HEAD": config.experimental.strictNextHead ?? false,
|
||||
"process.env.__NEXT_HAS_REWRITES": hasRewrites,
|
||||
"process.env.__NEXT_CONFIG_OUTPUT": config.output,
|
||||
"process.env.__NEXT_I18N_SUPPORT": !!config.i18n,
|
||||
"process.env.__NEXT_I18N_DOMAINS": ((_config_i18n = config.i18n) == null ? void 0 : _config_i18n.domains) ?? false,
|
||||
"process.env.__NEXT_ANALYTICS_ID": config.analyticsId,
|
||||
"process.env.__NEXT_NO_MIDDLEWARE_URL_NORMALIZE": config.skipMiddlewareUrlNormalize,
|
||||
"process.env.__NEXT_EXTERNAL_MIDDLEWARE_REWRITE_RESOLVE": config.experimental.externalMiddlewareRewritesResolve ?? false,
|
||||
"process.env.__NEXT_MANUAL_TRAILING_SLASH": config.skipTrailingSlashRedirect,
|
||||
"process.env.__NEXT_HAS_WEB_VITALS_ATTRIBUTION": (config.experimental.webVitalsAttribution && config.experimental.webVitalsAttribution.length > 0) ?? false,
|
||||
"process.env.__NEXT_WEB_VITALS_ATTRIBUTION": config.experimental.webVitalsAttribution ?? false,
|
||||
"process.env.__NEXT_LINK_NO_TOUCH_START": config.experimental.linkNoTouchStart ?? false,
|
||||
"process.env.__NEXT_ASSET_PREFIX": config.assetPrefix,
|
||||
...isNodeOrEdgeCompilation ? {
|
||||
// Fix bad-actors in the npm ecosystem (e.g. `node-formidable`)
|
||||
// This is typically found in unmaintained modules from the
|
||||
// pre-webpack era (common in server-side code)
|
||||
"global.GENTLY": false
|
||||
} : undefined,
|
||||
...isNodeOrEdgeCompilation ? {
|
||||
"process.env.__NEXT_EXPERIMENTAL_REACT": (0, _needsexperimentalreact.needsExperimentalReact)(config)
|
||||
} : undefined
|
||||
};
|
||||
return serializeDefineEnv(defineEnv);
|
||||
}
|
||||
function getDefineEnvPlugin(options) {
|
||||
return new _webpack.webpack.DefinePlugin(getDefineEnv(options));
|
||||
}
|
||||
|
||||
//# sourceMappingURL=define-env-plugin.js.map
|
||||
699
.next/standalone/node_modules/next/dist/build/webpack/plugins/flight-client-entry-plugin.js
generated
vendored
Normal file
699
.next/standalone/node_modules/next/dist/build/webpack/plugins/flight-client-entry-plugin.js
generated
vendored
Normal file
@@ -0,0 +1,699 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "FlightClientEntryPlugin", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return FlightClientEntryPlugin;
|
||||
}
|
||||
});
|
||||
const _webpack = require("next/dist/compiled/webpack/webpack");
|
||||
const _querystring = require("querystring");
|
||||
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
||||
const _ondemandentryhandler = require("../../../server/dev/on-demand-entry-handler");
|
||||
const _constants = require("../../../lib/constants");
|
||||
const _constants1 = require("../../../shared/lib/constants");
|
||||
const _utils = require("../loaders/utils");
|
||||
const _utils1 = require("../utils");
|
||||
const _normalizepathsep = require("../../../shared/lib/page-path/normalize-path-sep");
|
||||
const _buildcontext = require("../../build-context");
|
||||
const _pagetypes = require("../../../lib/page-types");
|
||||
const _utils2 = require("../../utils");
|
||||
const _getmodulebuildinfo = require("../loaders/get-module-build-info");
|
||||
const _nextflightloader = require("../loaders/next-flight-loader");
|
||||
function _interop_require_default(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
const PLUGIN_NAME = "FlightClientEntryPlugin";
|
||||
const pluginState = (0, _buildcontext.getProxiedPluginState)({
|
||||
// A map to track "action" -> "list of bundles".
|
||||
serverActions: {},
|
||||
edgeServerActions: {},
|
||||
actionModServerId: {},
|
||||
actionModEdgeServerId: {},
|
||||
// Mapping of resource path to module id for server/edge server.
|
||||
serverModuleIds: {},
|
||||
edgeServerModuleIds: {},
|
||||
// Collect modules from server/edge compiler in client layer,
|
||||
// and detect if it's been used, and mark it as `async: true` for react.
|
||||
// So that react could unwrap the async module from promise and render module itself.
|
||||
// Use an object to simulate Set lookup
|
||||
ASYNC_CLIENT_MODULES: {},
|
||||
injectedClientEntries: {}
|
||||
});
|
||||
function deduplicateCSSImportsForEntry(mergedCSSimports) {
|
||||
// If multiple entry module connections are having the same CSS import,
|
||||
// we only need to have one module to keep track of that CSS import.
|
||||
// It is based on the fact that if a page or a layout is rendered in the
|
||||
// given entry, all its parent layouts are always rendered too.
|
||||
// This can avoid duplicate CSS imports in the generated CSS manifest,
|
||||
// for example, if a page and its parent layout are both using the same
|
||||
// CSS import, we only need to have the layout to keep track of that CSS
|
||||
// import.
|
||||
// To achieve this, we need to first collect all the CSS imports from
|
||||
// every connection, and deduplicate them in the order of layers from
|
||||
// top to bottom. The implementation can be generally described as:
|
||||
// - Sort by number of `/` in the request path (the more `/`, the deeper)
|
||||
// - When in the same depth, sort by the filename (template < layout < page and others)
|
||||
// Sort the connections as described above.
|
||||
const sortedCSSImports = Object.entries(mergedCSSimports).sort((a, b)=>{
|
||||
const [aPath] = a;
|
||||
const [bPath] = b;
|
||||
const aDepth = aPath.split("/").length;
|
||||
const bDepth = bPath.split("/").length;
|
||||
if (aDepth !== bDepth) {
|
||||
return aDepth - bDepth;
|
||||
}
|
||||
const aName = _path.default.parse(aPath).name;
|
||||
const bName = _path.default.parse(bPath).name;
|
||||
const indexA = [
|
||||
"template",
|
||||
"layout"
|
||||
].indexOf(aName);
|
||||
const indexB = [
|
||||
"template",
|
||||
"layout"
|
||||
].indexOf(bName);
|
||||
if (indexA === -1) return 1;
|
||||
if (indexB === -1) return -1;
|
||||
return indexA - indexB;
|
||||
});
|
||||
const dedupedCSSImports = {};
|
||||
const trackedCSSImports = new Set();
|
||||
for (const [entryName, cssImports] of sortedCSSImports){
|
||||
for (const cssImport of cssImports){
|
||||
if (trackedCSSImports.has(cssImport)) continue;
|
||||
// Only track CSS imports that are in files that can inherit CSS.
|
||||
const filename = _path.default.parse(entryName).name;
|
||||
if ([
|
||||
"template",
|
||||
"layout"
|
||||
].includes(filename)) {
|
||||
trackedCSSImports.add(cssImport);
|
||||
}
|
||||
if (!dedupedCSSImports[entryName]) {
|
||||
dedupedCSSImports[entryName] = [];
|
||||
}
|
||||
dedupedCSSImports[entryName].push(cssImport);
|
||||
}
|
||||
}
|
||||
return dedupedCSSImports;
|
||||
}
|
||||
class FlightClientEntryPlugin {
|
||||
constructor(options){
|
||||
this.dev = options.dev;
|
||||
this.appDir = options.appDir;
|
||||
this.isEdgeServer = options.isEdgeServer;
|
||||
this.assetPrefix = !this.dev && !this.isEdgeServer ? "../" : "";
|
||||
this.encryptionKey = options.encryptionKey;
|
||||
}
|
||||
apply(compiler) {
|
||||
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation, { normalModuleFactory })=>{
|
||||
compilation.dependencyFactories.set(_webpack.webpack.dependencies.ModuleDependency, normalModuleFactory);
|
||||
compilation.dependencyTemplates.set(_webpack.webpack.dependencies.ModuleDependency, new _webpack.webpack.dependencies.NullDependency.Template());
|
||||
});
|
||||
compiler.hooks.finishMake.tapPromise(PLUGIN_NAME, (compilation)=>this.createClientEntries(compiler, compilation));
|
||||
compiler.hooks.afterCompile.tap(PLUGIN_NAME, (compilation)=>{
|
||||
const recordModule = (modId, mod)=>{
|
||||
var _mod_resourceResolveData, _mod_resourceResolveData1;
|
||||
// Match Resource is undefined unless an import is using the inline match resource syntax
|
||||
// https://webpack.js.org/api/loaders/#inline-matchresource
|
||||
const modPath = mod.matchResource || ((_mod_resourceResolveData = mod.resourceResolveData) == null ? void 0 : _mod_resourceResolveData.path);
|
||||
const modQuery = ((_mod_resourceResolveData1 = mod.resourceResolveData) == null ? void 0 : _mod_resourceResolveData1.query) || "";
|
||||
// query is already part of mod.resource
|
||||
// so it's only necessary to add it for matchResource or mod.resourceResolveData
|
||||
const modResource = modPath ? modPath.startsWith(_constants1.BARREL_OPTIMIZATION_PREFIX) ? (0, _utils1.formatBarrelOptimizedResource)(mod.resource, modPath) : modPath + modQuery : mod.resource;
|
||||
if (mod.layer !== _constants.WEBPACK_LAYERS.serverSideRendering) {
|
||||
return;
|
||||
}
|
||||
// Check mod resource to exclude the empty resource module like virtual module created by next-flight-client-entry-loader
|
||||
if (typeof modId !== "undefined" && modResource) {
|
||||
// Note that this isn't that reliable as webpack is still possible to assign
|
||||
// additional queries to make sure there's no conflict even using the `named`
|
||||
// module ID strategy.
|
||||
let ssrNamedModuleId = _path.default.relative(compiler.context, modResource);
|
||||
if (!ssrNamedModuleId.startsWith(".")) {
|
||||
// TODO use getModuleId instead
|
||||
ssrNamedModuleId = `./${(0, _normalizepathsep.normalizePathSep)(ssrNamedModuleId)}`;
|
||||
}
|
||||
if (this.isEdgeServer) {
|
||||
pluginState.edgeServerModuleIds[ssrNamedModuleId.replace(/\/next\/dist\/esm\//, "/next/dist/")] = modId;
|
||||
} else {
|
||||
pluginState.serverModuleIds[ssrNamedModuleId] = modId;
|
||||
}
|
||||
}
|
||||
};
|
||||
(0, _utils1.traverseModules)(compilation, (mod, _chunk, _chunkGroup, modId)=>{
|
||||
if (mod && mod.resource && !(0, _utils2.isWebpackServerOnlyLayer)(mod.layer)) {
|
||||
if (compilation.moduleGraph.isAsync(mod)) {
|
||||
// The module must has resolved resource path so it's not a new entry created with loader.
|
||||
// Checking the module layer to make sure it's from client layers (SSR or browser, not RSC).
|
||||
pluginState.ASYNC_CLIENT_MODULES[mod.resource] = true;
|
||||
}
|
||||
}
|
||||
if (modId) recordModule(modId, mod);
|
||||
});
|
||||
});
|
||||
compiler.hooks.make.tap(PLUGIN_NAME, (compilation)=>{
|
||||
compilation.hooks.processAssets.tapPromise({
|
||||
name: PLUGIN_NAME,
|
||||
stage: _webpack.webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_HASH
|
||||
}, (assets)=>this.createActionAssets(compilation, assets));
|
||||
});
|
||||
}
|
||||
async createClientEntries(compiler, compilation) {
|
||||
const addClientEntryAndSSRModulesList = [];
|
||||
const createdSSRDependenciesForEntry = {};
|
||||
const addActionEntryList = [];
|
||||
const actionMapsPerEntry = {};
|
||||
const createdActions = new Set();
|
||||
// For each SC server compilation entry, we need to create its corresponding
|
||||
// client component entry.
|
||||
(0, _utils1.forEachEntryModule)(compilation, ({ name, entryModule })=>{
|
||||
const internalClientComponentEntryImports = {};
|
||||
const actionEntryImports = new Map();
|
||||
const clientEntriesToInject = [];
|
||||
const mergedCSSimports = {};
|
||||
for (const connection of (0, _utils1.getModuleReferencesInOrder)(entryModule, compilation.moduleGraph)){
|
||||
// Entry can be any user defined entry files such as layout, page, error, loading, etc.
|
||||
const entryRequest = connection.dependency.request;
|
||||
const { clientComponentImports, actionImports, cssImports } = this.collectComponentInfoFromServerEntryDependency({
|
||||
entryRequest,
|
||||
compilation,
|
||||
resolvedModule: connection.resolvedModule
|
||||
});
|
||||
actionImports.forEach(([dep, names])=>actionEntryImports.set(dep, names));
|
||||
const isAbsoluteRequest = _path.default.isAbsolute(entryRequest);
|
||||
// Next.js internals are put into a separate entry.
|
||||
if (!isAbsoluteRequest) {
|
||||
Object.keys(clientComponentImports).forEach((value)=>internalClientComponentEntryImports[value] = new Set());
|
||||
continue;
|
||||
}
|
||||
// TODO-APP: Enable these lines. This ensures no entrypoint is created for layout/page when there are no client components.
|
||||
// Currently disabled because it causes test failures in CI.
|
||||
// if (clientImports.length === 0 && actionImports.length === 0) {
|
||||
// continue
|
||||
// }
|
||||
const relativeRequest = isAbsoluteRequest ? _path.default.relative(compilation.options.context, entryRequest) : entryRequest;
|
||||
// Replace file suffix as `.js` will be added.
|
||||
const bundlePath = (0, _normalizepathsep.normalizePathSep)(relativeRequest.replace(/\.[^.\\/]+$/, "").replace(/^src[\\/]/, ""));
|
||||
Object.assign(mergedCSSimports, cssImports);
|
||||
clientEntriesToInject.push({
|
||||
compiler,
|
||||
compilation,
|
||||
entryName: name,
|
||||
clientComponentImports,
|
||||
bundlePath,
|
||||
absolutePagePath: entryRequest
|
||||
});
|
||||
// The webpack implementation of writing the client reference manifest relies on all entrypoints writing a page.js even when there is no client components in the page.
|
||||
// It needs the file in order to write the reference manifest for the path in the `.next/server` folder.
|
||||
// TODO-APP: This could be better handled, however Turbopack does not have the same problem as we resolve client components in a single graph.
|
||||
if (name === `app${_constants1.UNDERSCORE_NOT_FOUND_ROUTE_ENTRY}` && bundlePath === "app/not-found") {
|
||||
clientEntriesToInject.push({
|
||||
compiler,
|
||||
compilation,
|
||||
entryName: name,
|
||||
clientComponentImports: {},
|
||||
bundlePath: `app${_constants1.UNDERSCORE_NOT_FOUND_ROUTE_ENTRY}`,
|
||||
absolutePagePath: entryRequest
|
||||
});
|
||||
}
|
||||
}
|
||||
// Make sure CSS imports are deduplicated before injecting the client entry
|
||||
// and SSR modules.
|
||||
const dedupedCSSImports = deduplicateCSSImportsForEntry(mergedCSSimports);
|
||||
for (const clientEntryToInject of clientEntriesToInject){
|
||||
const injected = this.injectClientEntryAndSSRModules({
|
||||
...clientEntryToInject,
|
||||
clientImports: {
|
||||
...clientEntryToInject.clientComponentImports,
|
||||
...(dedupedCSSImports[clientEntryToInject.absolutePagePath] || []).reduce((res, curr)=>{
|
||||
res[curr] = new Set();
|
||||
return res;
|
||||
}, {})
|
||||
}
|
||||
});
|
||||
// Track all created SSR dependencies for each entry from the server layer.
|
||||
if (!createdSSRDependenciesForEntry[clientEntryToInject.entryName]) {
|
||||
createdSSRDependenciesForEntry[clientEntryToInject.entryName] = [];
|
||||
}
|
||||
createdSSRDependenciesForEntry[clientEntryToInject.entryName].push(injected[2]);
|
||||
addClientEntryAndSSRModulesList.push(injected);
|
||||
}
|
||||
// Create internal app
|
||||
addClientEntryAndSSRModulesList.push(this.injectClientEntryAndSSRModules({
|
||||
compiler,
|
||||
compilation,
|
||||
entryName: name,
|
||||
clientImports: {
|
||||
...internalClientComponentEntryImports
|
||||
},
|
||||
bundlePath: _constants1.APP_CLIENT_INTERNALS
|
||||
}));
|
||||
if (actionEntryImports.size > 0) {
|
||||
if (!actionMapsPerEntry[name]) {
|
||||
actionMapsPerEntry[name] = new Map();
|
||||
}
|
||||
actionMapsPerEntry[name] = new Map([
|
||||
...actionMapsPerEntry[name],
|
||||
...actionEntryImports
|
||||
]);
|
||||
}
|
||||
});
|
||||
for (const [name, actionEntryImports] of Object.entries(actionMapsPerEntry)){
|
||||
for (const [dep, actionNames] of actionEntryImports){
|
||||
for (const actionName of actionNames){
|
||||
createdActions.add(name + "@" + dep + "@" + actionName);
|
||||
}
|
||||
}
|
||||
addActionEntryList.push(this.injectActionEntry({
|
||||
compiler,
|
||||
compilation,
|
||||
actions: actionEntryImports,
|
||||
entryName: name,
|
||||
bundlePath: name
|
||||
}));
|
||||
}
|
||||
compilation.hooks.finishModules.tapPromise(PLUGIN_NAME, async ()=>{
|
||||
const addedClientActionEntryList = [];
|
||||
const actionMapsPerClientEntry = {};
|
||||
// We need to create extra action entries that are created from the
|
||||
// client layer.
|
||||
// Start from each entry's created SSR dependency from our previous step.
|
||||
for (const [name, ssrEntryDependencies] of Object.entries(createdSSRDependenciesForEntry)){
|
||||
// Collect from all entries, e.g. layout.js, page.js, loading.js, ...
|
||||
// add aggregate them.
|
||||
const actionEntryImports = this.collectClientActionsFromDependencies({
|
||||
compilation,
|
||||
dependencies: ssrEntryDependencies
|
||||
});
|
||||
if (actionEntryImports.size > 0) {
|
||||
if (!actionMapsPerClientEntry[name]) {
|
||||
actionMapsPerClientEntry[name] = new Map();
|
||||
}
|
||||
actionMapsPerClientEntry[name] = new Map([
|
||||
...actionMapsPerClientEntry[name],
|
||||
...actionEntryImports
|
||||
]);
|
||||
}
|
||||
}
|
||||
for (const [name, actionEntryImports] of Object.entries(actionMapsPerClientEntry)){
|
||||
// If an action method is already created in the server layer, we don't
|
||||
// need to create it again in the action layer.
|
||||
// This is to avoid duplicate action instances and make sure the module
|
||||
// state is shared.
|
||||
let remainingClientImportedActions = false;
|
||||
const remainingActionEntryImports = new Map();
|
||||
for (const [dep, actionNames] of actionEntryImports){
|
||||
const remainingActionNames = [];
|
||||
for (const actionName of actionNames){
|
||||
const id = name + "@" + dep + "@" + actionName;
|
||||
if (!createdActions.has(id)) {
|
||||
remainingActionNames.push(actionName);
|
||||
}
|
||||
}
|
||||
if (remainingActionNames.length > 0) {
|
||||
remainingActionEntryImports.set(dep, remainingActionNames);
|
||||
remainingClientImportedActions = true;
|
||||
}
|
||||
}
|
||||
if (remainingClientImportedActions) {
|
||||
addedClientActionEntryList.push(this.injectActionEntry({
|
||||
compiler,
|
||||
compilation,
|
||||
actions: remainingActionEntryImports,
|
||||
entryName: name,
|
||||
bundlePath: name,
|
||||
fromClient: true
|
||||
}));
|
||||
}
|
||||
}
|
||||
await Promise.all(addedClientActionEntryList);
|
||||
return;
|
||||
});
|
||||
// Invalidate in development to trigger recompilation
|
||||
const invalidator = (0, _ondemandentryhandler.getInvalidator)(compiler.outputPath);
|
||||
// Check if any of the entry injections need an invalidation
|
||||
if (invalidator && addClientEntryAndSSRModulesList.some(([shouldInvalidate])=>shouldInvalidate === true)) {
|
||||
invalidator.invalidate([
|
||||
_constants1.COMPILER_NAMES.client
|
||||
]);
|
||||
}
|
||||
// Client compiler is invalidated before awaiting the compilation of the SSR client component entries
|
||||
// so that the client compiler is running in parallel to the server compiler.
|
||||
await Promise.all(addClientEntryAndSSRModulesList.map((addClientEntryAndSSRModules)=>addClientEntryAndSSRModules[1]));
|
||||
// Wait for action entries to be added.
|
||||
await Promise.all(addActionEntryList);
|
||||
}
|
||||
collectClientActionsFromDependencies({ compilation, dependencies }) {
|
||||
// action file path -> action names
|
||||
const collectedActions = new Map();
|
||||
// Keep track of checked modules to avoid infinite loops with recursive imports.
|
||||
const visitedModule = new Set();
|
||||
const visitedEntry = new Set();
|
||||
const collectActions = ({ entryRequest, resolvedModule })=>{
|
||||
const collectActionsInDep = (mod)=>{
|
||||
var _mod_resourceResolveData, _mod_resourceResolveData1, _mod_matchResource;
|
||||
if (!mod) return;
|
||||
const modPath = ((_mod_resourceResolveData = mod.resourceResolveData) == null ? void 0 : _mod_resourceResolveData.path) || "";
|
||||
// We have to always use the resolved request here to make sure the
|
||||
// server and client are using the same module path (required by RSC), as
|
||||
// the server compiler and client compiler have different resolve configs.
|
||||
let modRequest = modPath + (((_mod_resourceResolveData1 = mod.resourceResolveData) == null ? void 0 : _mod_resourceResolveData1.query) || "");
|
||||
// For the barrel optimization, we need to use the match resource instead
|
||||
// because there will be 2 modules for the same file (same resource path)
|
||||
// but they're different modules and can't be deduped via `visitedModule`.
|
||||
// The first module is a virtual re-export module created by the loader.
|
||||
if ((_mod_matchResource = mod.matchResource) == null ? void 0 : _mod_matchResource.startsWith(_constants1.BARREL_OPTIMIZATION_PREFIX)) {
|
||||
modRequest = mod.matchResource + ":" + modRequest;
|
||||
}
|
||||
if (!modRequest || visitedModule.has(modRequest)) return;
|
||||
visitedModule.add(modRequest);
|
||||
const actions = (0, _utils.getActions)(mod);
|
||||
if (actions) {
|
||||
collectedActions.set(modRequest, actions);
|
||||
}
|
||||
(0, _utils1.getModuleReferencesInOrder)(mod, compilation.moduleGraph).forEach((connection)=>{
|
||||
collectActionsInDep(connection.resolvedModule);
|
||||
});
|
||||
};
|
||||
// Don't traverse the module graph anymore once hitting the action layer.
|
||||
if (entryRequest && !entryRequest.includes("next-flight-action-entry-loader")) {
|
||||
// Traverse the module graph to find all client components.
|
||||
collectActionsInDep(resolvedModule);
|
||||
}
|
||||
};
|
||||
for (const entryDependency of dependencies){
|
||||
const ssrEntryModule = compilation.moduleGraph.getResolvedModule(entryDependency);
|
||||
for (const connection of (0, _utils1.getModuleReferencesInOrder)(ssrEntryModule, compilation.moduleGraph)){
|
||||
const dependency = connection.dependency;
|
||||
const request = dependency.request;
|
||||
// It is possible that the same entry is added multiple times in the
|
||||
// connection graph. We can just skip these to speed up the process.
|
||||
if (visitedEntry.has(request)) continue;
|
||||
visitedEntry.add(request);
|
||||
collectActions({
|
||||
entryRequest: request,
|
||||
resolvedModule: connection.resolvedModule
|
||||
});
|
||||
}
|
||||
}
|
||||
return collectedActions;
|
||||
}
|
||||
collectComponentInfoFromServerEntryDependency({ entryRequest, compilation, resolvedModule }) {
|
||||
// Keep track of checked modules to avoid infinite loops with recursive imports.
|
||||
const visited = new Set();
|
||||
// Info to collect.
|
||||
const clientComponentImports = {};
|
||||
const actionImports = [];
|
||||
const CSSImports = new Set();
|
||||
const filterClientComponents = (mod, importedIdentifiers)=>{
|
||||
var _mod_resourceResolveData, _mod_resourceResolveData1, _mod_matchResource;
|
||||
if (!mod) return;
|
||||
const isCSS = (0, _utils.isCSSMod)(mod);
|
||||
const modPath = ((_mod_resourceResolveData = mod.resourceResolveData) == null ? void 0 : _mod_resourceResolveData.path) || "";
|
||||
// We have to always use the resolved request here to make sure the
|
||||
// server and client are using the same module path (required by RSC), as
|
||||
// the server compiler and client compiler have different resolve configs.
|
||||
let modRequest = modPath + ((_mod_resourceResolveData1 = mod.resourceResolveData) == null ? void 0 : _mod_resourceResolveData1.query);
|
||||
// Context modules don't have a resource path, we use the identifier instead.
|
||||
if (mod.constructor.name === "ContextModule") {
|
||||
modRequest = mod._identifier;
|
||||
}
|
||||
// For the barrel optimization, we need to use the match resource instead
|
||||
// because there will be 2 modules for the same file (same resource path)
|
||||
// but they're different modules and can't be deduped via `visitedModule`.
|
||||
// The first module is a virtual re-export module created by the loader.
|
||||
if ((_mod_matchResource = mod.matchResource) == null ? void 0 : _mod_matchResource.startsWith(_constants1.BARREL_OPTIMIZATION_PREFIX)) {
|
||||
modRequest = mod.matchResource + ":" + modRequest;
|
||||
}
|
||||
if (!modRequest) return;
|
||||
if (visited.has(modRequest)) {
|
||||
if (clientComponentImports[modRequest]) {
|
||||
addClientImport(mod, modRequest, clientComponentImports, importedIdentifiers, false);
|
||||
}
|
||||
return;
|
||||
}
|
||||
visited.add(modRequest);
|
||||
const actions = (0, _utils.getActions)(mod);
|
||||
if (actions) {
|
||||
actionImports.push([
|
||||
modRequest,
|
||||
actions
|
||||
]);
|
||||
}
|
||||
const webpackRuntime = this.isEdgeServer ? _constants1.EDGE_RUNTIME_WEBPACK : _constants1.DEFAULT_RUNTIME_WEBPACK;
|
||||
if (isCSS) {
|
||||
const sideEffectFree = mod.factoryMeta && mod.factoryMeta.sideEffectFree;
|
||||
if (sideEffectFree) {
|
||||
const unused = !compilation.moduleGraph.getExportsInfo(mod).isModuleUsed(webpackRuntime);
|
||||
if (unused) return;
|
||||
}
|
||||
CSSImports.add(modRequest);
|
||||
} else if ((0, _utils.isClientComponentEntryModule)(mod)) {
|
||||
if (!clientComponentImports[modRequest]) {
|
||||
clientComponentImports[modRequest] = new Set();
|
||||
}
|
||||
addClientImport(mod, modRequest, clientComponentImports, importedIdentifiers, true);
|
||||
return;
|
||||
}
|
||||
(0, _utils1.getModuleReferencesInOrder)(mod, compilation.moduleGraph).forEach((connection)=>{
|
||||
var _connection_dependency;
|
||||
let dependencyIds = [];
|
||||
const depModule = connection.resolvedModule;
|
||||
// `ids` are the identifiers that are imported from the dependency,
|
||||
// if it's present, it's an array of strings.
|
||||
if ((_connection_dependency = connection.dependency) == null ? void 0 : _connection_dependency.ids) {
|
||||
dependencyIds.push(...connection.dependency.ids);
|
||||
} else {
|
||||
dependencyIds = [
|
||||
"*"
|
||||
];
|
||||
}
|
||||
filterClientComponents(depModule, dependencyIds);
|
||||
});
|
||||
};
|
||||
// Traverse the module graph to find all client components.
|
||||
filterClientComponents(resolvedModule, []);
|
||||
return {
|
||||
clientComponentImports,
|
||||
cssImports: CSSImports.size ? {
|
||||
[entryRequest]: Array.from(CSSImports)
|
||||
} : {},
|
||||
actionImports
|
||||
};
|
||||
}
|
||||
injectClientEntryAndSSRModules({ compiler, compilation, entryName, clientImports, bundlePath, absolutePagePath }) {
|
||||
let shouldInvalidate = false;
|
||||
const loaderOptions = {
|
||||
modules: Object.keys(clientImports).sort((a, b)=>_utils.regexCSS.test(b) ? 1 : a.localeCompare(b)).map((clientImportPath)=>({
|
||||
request: clientImportPath,
|
||||
ids: [
|
||||
...clientImports[clientImportPath]
|
||||
]
|
||||
})),
|
||||
server: false
|
||||
};
|
||||
// For the client entry, we always use the CJS build of Next.js. If the
|
||||
// server is using the ESM build (when using the Edge runtime), we need to
|
||||
// replace them.
|
||||
const clientBrowserLoader = `next-flight-client-entry-loader?${(0, _querystring.stringify)({
|
||||
modules: (this.isEdgeServer ? loaderOptions.modules.map(({ request, ids })=>({
|
||||
request: request.replace(/[\\/]next[\\/]dist[\\/]esm[\\/]/, "/next/dist/".replace(/\//g, _path.default.sep)),
|
||||
ids
|
||||
})) : loaderOptions.modules).map((x)=>JSON.stringify(x)),
|
||||
server: false
|
||||
})}!`;
|
||||
const clientSSRLoader = `next-flight-client-entry-loader?${(0, _querystring.stringify)({
|
||||
modules: loaderOptions.modules.map((x)=>JSON.stringify(x)),
|
||||
server: true
|
||||
})}!`;
|
||||
// Add for the client compilation
|
||||
// Inject the entry to the client compiler.
|
||||
if (this.dev) {
|
||||
const entries = (0, _ondemandentryhandler.getEntries)(compiler.outputPath);
|
||||
const pageKey = (0, _ondemandentryhandler.getEntryKey)(_constants1.COMPILER_NAMES.client, _pagetypes.PAGE_TYPES.APP, bundlePath);
|
||||
if (!entries[pageKey]) {
|
||||
entries[pageKey] = {
|
||||
type: _ondemandentryhandler.EntryTypes.CHILD_ENTRY,
|
||||
parentEntries: new Set([
|
||||
entryName
|
||||
]),
|
||||
absoluteEntryFilePath: absolutePagePath,
|
||||
bundlePath,
|
||||
request: clientBrowserLoader,
|
||||
dispose: false,
|
||||
lastActiveTime: Date.now()
|
||||
};
|
||||
shouldInvalidate = true;
|
||||
} else {
|
||||
const entryData = entries[pageKey];
|
||||
// New version of the client loader
|
||||
if (entryData.request !== clientBrowserLoader) {
|
||||
entryData.request = clientBrowserLoader;
|
||||
shouldInvalidate = true;
|
||||
}
|
||||
if (entryData.type === _ondemandentryhandler.EntryTypes.CHILD_ENTRY) {
|
||||
entryData.parentEntries.add(entryName);
|
||||
}
|
||||
entryData.dispose = false;
|
||||
entryData.lastActiveTime = Date.now();
|
||||
}
|
||||
} else {
|
||||
pluginState.injectedClientEntries[bundlePath] = clientBrowserLoader;
|
||||
}
|
||||
// Inject the entry to the server compiler (__ssr__).
|
||||
const clientComponentEntryDep = _webpack.webpack.EntryPlugin.createDependency(clientSSRLoader, {
|
||||
name: bundlePath
|
||||
});
|
||||
return [
|
||||
shouldInvalidate,
|
||||
// Add the dependency to the server compiler.
|
||||
// This promise is awaited later using `Promise.all` in order to parallelize adding the entries.
|
||||
// It ensures we can parallelize the SSR and Client compiler entries.
|
||||
this.addEntry(compilation, // Reuse compilation context.
|
||||
compiler.context, clientComponentEntryDep, {
|
||||
// By using the same entry name
|
||||
name: entryName,
|
||||
// Layer should be client for the SSR modules
|
||||
// This ensures the client components are bundled on client layer
|
||||
layer: _constants.WEBPACK_LAYERS.serverSideRendering
|
||||
}),
|
||||
clientComponentEntryDep
|
||||
];
|
||||
}
|
||||
injectActionEntry({ compiler, compilation, actions, entryName, bundlePath, fromClient }) {
|
||||
const actionsArray = Array.from(actions.entries());
|
||||
const actionLoader = `next-flight-action-entry-loader?${(0, _querystring.stringify)({
|
||||
actions: JSON.stringify(actionsArray),
|
||||
__client_imported__: fromClient
|
||||
})}!`;
|
||||
const currentCompilerServerActions = this.isEdgeServer ? pluginState.edgeServerActions : pluginState.serverActions;
|
||||
for (const [p, names] of actionsArray){
|
||||
for (const name of names){
|
||||
const id = (0, _utils.generateActionId)(p, name);
|
||||
if (typeof currentCompilerServerActions[id] === "undefined") {
|
||||
currentCompilerServerActions[id] = {
|
||||
workers: {},
|
||||
layer: {}
|
||||
};
|
||||
}
|
||||
currentCompilerServerActions[id].workers[bundlePath] = "";
|
||||
currentCompilerServerActions[id].layer[bundlePath] = fromClient ? _constants.WEBPACK_LAYERS.actionBrowser : _constants.WEBPACK_LAYERS.reactServerComponents;
|
||||
}
|
||||
}
|
||||
// Inject the entry to the server compiler
|
||||
const actionEntryDep = _webpack.webpack.EntryPlugin.createDependency(actionLoader, {
|
||||
name: bundlePath
|
||||
});
|
||||
return this.addEntry(compilation, // Reuse compilation context.
|
||||
compiler.context, actionEntryDep, {
|
||||
name: entryName,
|
||||
layer: fromClient ? _constants.WEBPACK_LAYERS.actionBrowser : _constants.WEBPACK_LAYERS.reactServerComponents
|
||||
});
|
||||
}
|
||||
addEntry(compilation, context, dependency, options) /* Promise<module> */ {
|
||||
return new Promise((resolve, reject)=>{
|
||||
const entry = compilation.entries.get(options.name);
|
||||
entry.includeDependencies.push(dependency);
|
||||
compilation.hooks.addEntry.call(entry, options);
|
||||
compilation.addModuleTree({
|
||||
context,
|
||||
dependency,
|
||||
contextInfo: {
|
||||
issuerLayer: options.layer
|
||||
}
|
||||
}, (err, module)=>{
|
||||
if (err) {
|
||||
compilation.hooks.failedEntry.call(dependency, options, err);
|
||||
return reject(err);
|
||||
}
|
||||
compilation.hooks.succeedEntry.call(dependency, options, module);
|
||||
return resolve(module);
|
||||
});
|
||||
});
|
||||
}
|
||||
async createActionAssets(compilation, assets) {
|
||||
const serverActions = {};
|
||||
const edgeServerActions = {};
|
||||
(0, _utils1.traverseModules)(compilation, (mod, _chunk, chunkGroup, modId)=>{
|
||||
// Go through all action entries and record the module ID for each entry.
|
||||
if (chunkGroup.name && mod.request && modId && /next-flight-action-entry-loader/.test(mod.request)) {
|
||||
const fromClient = /&__client_imported__=true/.test(mod.request);
|
||||
const mapping = this.isEdgeServer ? pluginState.actionModEdgeServerId : pluginState.actionModServerId;
|
||||
if (!mapping[chunkGroup.name]) {
|
||||
mapping[chunkGroup.name] = {};
|
||||
}
|
||||
mapping[chunkGroup.name][fromClient ? "client" : "server"] = modId;
|
||||
}
|
||||
});
|
||||
for(let id in pluginState.serverActions){
|
||||
const action = pluginState.serverActions[id];
|
||||
for(let name in action.workers){
|
||||
const modId = pluginState.actionModServerId[name][action.layer[name] === _constants.WEBPACK_LAYERS.actionBrowser ? "client" : "server"];
|
||||
action.workers[name] = modId;
|
||||
}
|
||||
serverActions[id] = action;
|
||||
}
|
||||
for(let id in pluginState.edgeServerActions){
|
||||
const action = pluginState.edgeServerActions[id];
|
||||
for(let name in action.workers){
|
||||
const modId = pluginState.actionModEdgeServerId[name][action.layer[name] === _constants.WEBPACK_LAYERS.actionBrowser ? "client" : "server"];
|
||||
action.workers[name] = modId;
|
||||
}
|
||||
edgeServerActions[id] = action;
|
||||
}
|
||||
const json = JSON.stringify({
|
||||
node: serverActions,
|
||||
edge: edgeServerActions,
|
||||
encryptionKey: this.encryptionKey
|
||||
}, null, this.dev ? 2 : undefined);
|
||||
assets[`${this.assetPrefix}${_constants1.SERVER_REFERENCE_MANIFEST}.js`] = new _webpack.sources.RawSource(`self.__RSC_SERVER_MANIFEST=${JSON.stringify(json)}`);
|
||||
assets[`${this.assetPrefix}${_constants1.SERVER_REFERENCE_MANIFEST}.json`] = new _webpack.sources.RawSource(json);
|
||||
}
|
||||
}
|
||||
function addClientImport(mod, modRequest, clientComponentImports, importedIdentifiers, isFirstImport) {
|
||||
var _getModuleBuildInfo_rsc;
|
||||
const clientEntryType = (_getModuleBuildInfo_rsc = (0, _getmodulebuildinfo.getModuleBuildInfo)(mod).rsc) == null ? void 0 : _getModuleBuildInfo_rsc.clientEntryType;
|
||||
const isCjsModule = clientEntryType === "cjs";
|
||||
const assumedSourceType = (0, _nextflightloader.getAssumedSourceType)(mod, isCjsModule ? "commonjs" : "auto");
|
||||
const clientImportsSet = clientComponentImports[modRequest];
|
||||
if (importedIdentifiers[0] === "*") {
|
||||
// If there's collected import path with named import identifiers,
|
||||
// or there's nothing in collected imports are empty.
|
||||
// we should include the whole module.
|
||||
if (!isFirstImport && [
|
||||
...clientImportsSet
|
||||
][0] !== "*") {
|
||||
clientComponentImports[modRequest] = new Set([
|
||||
"*"
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
const isAutoModuleSourceType = assumedSourceType === "auto";
|
||||
if (isAutoModuleSourceType) {
|
||||
clientComponentImports[modRequest] = new Set([
|
||||
"*"
|
||||
]);
|
||||
} else {
|
||||
// If it's not analyzed as named ESM exports, e.g. if it's mixing `export *` with named exports,
|
||||
// We'll include all modules since it's not able to do tree-shaking.
|
||||
for (const name of importedIdentifiers){
|
||||
// For cjs module default import, we include the whole module since
|
||||
const isCjsDefaultImport = isCjsModule && name === "default";
|
||||
// Always include __esModule along with cjs module default export,
|
||||
// to make sure it work with client module proxy from React.
|
||||
if (isCjsDefaultImport) {
|
||||
clientComponentImports[modRequest].add("__esModule");
|
||||
}
|
||||
clientComponentImports[modRequest].add(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=flight-client-entry-plugin.js.map
|
||||
351
.next/standalone/node_modules/next/dist/build/webpack/plugins/flight-manifest-plugin.js
generated
vendored
Normal file
351
.next/standalone/node_modules/next/dist/build/webpack/plugins/flight-manifest-plugin.js
generated
vendored
Normal file
@@ -0,0 +1,351 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/ "use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "ClientReferenceManifestPlugin", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return ClientReferenceManifestPlugin;
|
||||
}
|
||||
});
|
||||
const _path = /*#__PURE__*/ _interop_require_wildcard(require("path"));
|
||||
const _webpack = require("next/dist/compiled/webpack/webpack");
|
||||
const _constants = require("../../../shared/lib/constants");
|
||||
const _buildcontext = require("../../build-context");
|
||||
const _constants1 = require("../../../lib/constants");
|
||||
const _normalizepagepath = require("../../../shared/lib/page-path/normalize-page-path");
|
||||
const _deploymentid = require("../../deployment-id");
|
||||
const _utils = require("../utils");
|
||||
function _getRequireWildcardCache(nodeInterop) {
|
||||
if (typeof WeakMap !== "function") return null;
|
||||
var cacheBabelInterop = new WeakMap();
|
||||
var cacheNodeInterop = new WeakMap();
|
||||
return (_getRequireWildcardCache = function(nodeInterop) {
|
||||
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
||||
})(nodeInterop);
|
||||
}
|
||||
function _interop_require_wildcard(obj, nodeInterop) {
|
||||
if (!nodeInterop && obj && obj.__esModule) {
|
||||
return obj;
|
||||
}
|
||||
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
||||
return {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
var cache = _getRequireWildcardCache(nodeInterop);
|
||||
if (cache && cache.has(obj)) {
|
||||
return cache.get(obj);
|
||||
}
|
||||
var newObj = {
|
||||
__proto__: null
|
||||
};
|
||||
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
||||
for(var key in obj){
|
||||
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
||||
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
||||
if (desc && (desc.get || desc.set)) {
|
||||
Object.defineProperty(newObj, key, desc);
|
||||
} else {
|
||||
newObj[key] = obj[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
newObj.default = obj;
|
||||
if (cache) {
|
||||
cache.set(obj, newObj);
|
||||
}
|
||||
return newObj;
|
||||
}
|
||||
const pluginState = (0, _buildcontext.getProxiedPluginState)({
|
||||
serverModuleIds: {},
|
||||
edgeServerModuleIds: {},
|
||||
// Use an object to simulate Set lookup
|
||||
ASYNC_CLIENT_MODULES: {}
|
||||
});
|
||||
function getAppPathRequiredChunks(chunkGroup, excludedFiles) {
|
||||
const deploymentIdChunkQuery = (0, _deploymentid.getDeploymentIdQueryOrEmptyString)();
|
||||
const chunks = [];
|
||||
chunkGroup.chunks.forEach((chunk)=>{
|
||||
if (_constants.SYSTEM_ENTRYPOINTS.has(chunk.name || "")) {
|
||||
return null;
|
||||
}
|
||||
// Get the actual chunk file names from the chunk file list.
|
||||
// It's possible that the chunk is generated via `import()`, in
|
||||
// that case the chunk file name will be '[name].[contenthash]'
|
||||
// instead of '[name]-[chunkhash]'.
|
||||
if (chunk.id != null) {
|
||||
const chunkId = "" + chunk.id;
|
||||
chunk.files.forEach((file)=>{
|
||||
// It's possible that a chunk also emits CSS files, that will
|
||||
// be handled separatedly.
|
||||
if (!file.endsWith(".js")) return null;
|
||||
if (file.endsWith(".hot-update.js")) return null;
|
||||
if (excludedFiles.has(file)) return null;
|
||||
// We encode the file as a URI because our server (and many other services such as S3)
|
||||
// expect to receive reserved characters such as `[` and `]` as encoded. This was
|
||||
// previously done for dynamic chunks by patching the webpack runtime but we want
|
||||
// these filenames to be managed by React's Flight runtime instead and so we need
|
||||
// to implement any special handling of the file name here.
|
||||
return chunks.push(chunkId, encodeURI(file + deploymentIdChunkQuery));
|
||||
});
|
||||
}
|
||||
});
|
||||
return chunks;
|
||||
}
|
||||
// Normalize the entry names to their "group names" so a page can easily track
|
||||
// all the manifest items it needs from parent groups by looking up the group
|
||||
// segments:
|
||||
// - app/foo/loading -> app/foo
|
||||
// - app/foo/page -> app/foo
|
||||
// - app/(group)/@named/foo/page -> app/foo
|
||||
// - app/(.)foo/(..)bar/loading -> app/bar
|
||||
// - app/[...catchAll]/page -> app
|
||||
// - app/foo/@slot/[...catchAll]/page -> app/foo
|
||||
function entryNameToGroupName(entryName) {
|
||||
let groupName = entryName.slice(0, entryName.lastIndexOf("/"))// Remove slots
|
||||
.replace(/\/@[^/]+/g, "")// Remove the group with lookahead to make sure it's not interception route
|
||||
.replace(/\/\([^/]+\)(?=(\/|$))/g, "")// Remove catch-all routes since they should be part of the parent group that the catch-all would apply to.
|
||||
// This is necessary to support parallel routes since multiple page components can be rendered on the same page.
|
||||
// In order to do that, we need to ensure that the manifests are merged together by putting them in the same group.
|
||||
.replace(/\/\[?\[\.\.\.[^\]]*\]\]?/g, "");
|
||||
// Interception routes
|
||||
groupName = groupName.replace(/^.+\/\(\.\.\.\)/g, "app/").replace(/\/\(\.\)/g, "/");
|
||||
// Interception routes (recursive)
|
||||
while(/\/[^/]+\/\(\.\.\)/.test(groupName)){
|
||||
groupName = groupName.replace(/\/[^/]+\/\(\.\.\)/g, "/");
|
||||
}
|
||||
return groupName;
|
||||
}
|
||||
function mergeManifest(manifest, manifestToMerge) {
|
||||
Object.assign(manifest.clientModules, manifestToMerge.clientModules);
|
||||
Object.assign(manifest.ssrModuleMapping, manifestToMerge.ssrModuleMapping);
|
||||
Object.assign(manifest.edgeSSRModuleMapping, manifestToMerge.edgeSSRModuleMapping);
|
||||
Object.assign(manifest.entryCSSFiles, manifestToMerge.entryCSSFiles);
|
||||
}
|
||||
const PLUGIN_NAME = "ClientReferenceManifestPlugin";
|
||||
class ClientReferenceManifestPlugin {
|
||||
constructor(options){
|
||||
this.dev = false;
|
||||
this.dev = options.dev;
|
||||
this.appDir = options.appDir;
|
||||
this.appDirBase = _path.default.dirname(this.appDir) + _path.default.sep;
|
||||
}
|
||||
apply(compiler) {
|
||||
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation, { normalModuleFactory })=>{
|
||||
compilation.dependencyFactories.set(_webpack.webpack.dependencies.ModuleDependency, normalModuleFactory);
|
||||
compilation.dependencyTemplates.set(_webpack.webpack.dependencies.ModuleDependency, new _webpack.webpack.dependencies.NullDependency.Template());
|
||||
compilation.hooks.processAssets.tap({
|
||||
name: PLUGIN_NAME,
|
||||
// Have to be in the optimize stage to run after updating the CSS
|
||||
// asset hash via extract mini css plugin.
|
||||
stage: _webpack.webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_HASH
|
||||
}, (assets)=>this.createAsset(assets, compilation, compiler.context));
|
||||
});
|
||||
}
|
||||
createAsset(assets, compilation, context) {
|
||||
var _compilation_entrypoints_get;
|
||||
const manifestsPerGroup = new Map();
|
||||
const manifestEntryFiles = [];
|
||||
const configuredCrossOriginLoading = compilation.outputOptions.crossOriginLoading;
|
||||
const crossOriginMode = typeof configuredCrossOriginLoading === "string" ? configuredCrossOriginLoading === "use-credentials" ? configuredCrossOriginLoading : "anonymous" : null;
|
||||
if (typeof compilation.outputOptions.publicPath !== "string") {
|
||||
throw new Error("Expected webpack publicPath to be a string when using App Router. To customize where static assets are loaded from, use the `assetPrefix` option in next.config.js. If you are customizing your webpack config please make sure you are not modifying or removing the publicPath configuration option");
|
||||
}
|
||||
const prefix = compilation.outputOptions.publicPath || "";
|
||||
// We want to omit any files that will always be loaded on any App Router page
|
||||
// because they will already be loaded by the main entrypoint.
|
||||
const rootMainFiles = new Set();
|
||||
(_compilation_entrypoints_get = compilation.entrypoints.get(_constants.CLIENT_STATIC_FILES_RUNTIME_MAIN_APP)) == null ? void 0 : _compilation_entrypoints_get.getFiles().forEach((file)=>{
|
||||
if (/(?<!\.hot-update)\.(js|css)($|\?)/.test(file)) {
|
||||
rootMainFiles.add(file.replace(/\\/g, "/"));
|
||||
}
|
||||
});
|
||||
for (let [entryName, entrypoint] of compilation.entrypoints){
|
||||
if (entryName === _constants.CLIENT_STATIC_FILES_RUNTIME_MAIN_APP || entryName === _constants.APP_CLIENT_INTERNALS) {
|
||||
entryName = "";
|
||||
} else if (!/^app[\\/]/.test(entryName)) {
|
||||
continue;
|
||||
}
|
||||
const manifest = {
|
||||
moduleLoading: {
|
||||
prefix,
|
||||
crossOrigin: crossOriginMode
|
||||
},
|
||||
ssrModuleMapping: {},
|
||||
edgeSSRModuleMapping: {},
|
||||
clientModules: {},
|
||||
entryCSSFiles: {}
|
||||
};
|
||||
// Absolute path without the extension
|
||||
const chunkEntryName = (this.appDirBase + entryName).replace(/[\\/]/g, _path.default.sep);
|
||||
manifest.entryCSSFiles[chunkEntryName] = entrypoint.getFiles().filter((f)=>!f.startsWith("static/css/pages/") && f.endsWith(".css"));
|
||||
const requiredChunks = getAppPathRequiredChunks(entrypoint, rootMainFiles);
|
||||
const recordModule = (modId, mod)=>{
|
||||
var _mod_resourceResolveData, _mod_matchResource;
|
||||
let resource = mod.type === "css/mini-extract" ? mod._identifier.slice(mod._identifier.lastIndexOf("!") + 1) : mod.resource;
|
||||
if (!resource) {
|
||||
return;
|
||||
}
|
||||
const moduleReferences = manifest.clientModules;
|
||||
const moduleIdMapping = manifest.ssrModuleMapping;
|
||||
const edgeModuleIdMapping = manifest.edgeSSRModuleMapping;
|
||||
// Note that this isn't that reliable as webpack is still possible to assign
|
||||
// additional queries to make sure there's no conflict even using the `named`
|
||||
// module ID strategy.
|
||||
let ssrNamedModuleId = (0, _path.relative)(context, ((_mod_resourceResolveData = mod.resourceResolveData) == null ? void 0 : _mod_resourceResolveData.path) || resource);
|
||||
if (!ssrNamedModuleId.startsWith(".")) ssrNamedModuleId = `./${ssrNamedModuleId.replace(/\\/g, "/")}`;
|
||||
const isAsyncModule = !!pluginState.ASYNC_CLIENT_MODULES[mod.resource];
|
||||
// The client compiler will always use the CJS Next.js build, so here we
|
||||
// also add the mapping for the ESM build (Edge runtime) to consume.
|
||||
const esmResource = /[\\/]next[\\/]dist[\\/]/.test(resource) ? resource.replace(/[\\/]next[\\/]dist[\\/]/, "/next/dist/esm/".replace(/\//g, _path.default.sep)) : null;
|
||||
// An extra query param is added to the resource key when it's optimized
|
||||
// through the Barrel Loader. That's because the same file might be created
|
||||
// as multiple modules (depending on what you import from it).
|
||||
// See also: webpack/loaders/next-flight-loader/index.ts.
|
||||
if ((_mod_matchResource = mod.matchResource) == null ? void 0 : _mod_matchResource.startsWith(_constants.BARREL_OPTIMIZATION_PREFIX)) {
|
||||
ssrNamedModuleId = (0, _utils.formatBarrelOptimizedResource)(ssrNamedModuleId, mod.matchResource);
|
||||
resource = (0, _utils.formatBarrelOptimizedResource)(resource, mod.matchResource);
|
||||
}
|
||||
function addClientReference() {
|
||||
const exportName = resource;
|
||||
manifest.clientModules[exportName] = {
|
||||
id: modId,
|
||||
name: "*",
|
||||
chunks: requiredChunks,
|
||||
async: isAsyncModule
|
||||
};
|
||||
if (esmResource) {
|
||||
const edgeExportName = esmResource;
|
||||
manifest.clientModules[edgeExportName] = manifest.clientModules[exportName];
|
||||
}
|
||||
}
|
||||
function addSSRIdMapping() {
|
||||
const exportName = resource;
|
||||
if (typeof pluginState.serverModuleIds[ssrNamedModuleId] !== "undefined") {
|
||||
moduleIdMapping[modId] = moduleIdMapping[modId] || {};
|
||||
moduleIdMapping[modId]["*"] = {
|
||||
...manifest.clientModules[exportName],
|
||||
// During SSR, we don't have external chunks to load on the server
|
||||
// side with our architecture of Webpack / Turbopack. We can keep
|
||||
// this field empty to save some bytes.
|
||||
chunks: [],
|
||||
id: pluginState.serverModuleIds[ssrNamedModuleId]
|
||||
};
|
||||
}
|
||||
if (typeof pluginState.edgeServerModuleIds[ssrNamedModuleId] !== "undefined") {
|
||||
edgeModuleIdMapping[modId] = edgeModuleIdMapping[modId] || {};
|
||||
edgeModuleIdMapping[modId]["*"] = {
|
||||
...manifest.clientModules[exportName],
|
||||
// During SSR, we don't have external chunks to load on the server
|
||||
// side with our architecture of Webpack / Turbopack. We can keep
|
||||
// this field empty to save some bytes.
|
||||
chunks: [],
|
||||
id: pluginState.edgeServerModuleIds[ssrNamedModuleId]
|
||||
};
|
||||
}
|
||||
}
|
||||
addClientReference();
|
||||
addSSRIdMapping();
|
||||
manifest.clientModules = moduleReferences;
|
||||
manifest.ssrModuleMapping = moduleIdMapping;
|
||||
manifest.edgeSSRModuleMapping = edgeModuleIdMapping;
|
||||
};
|
||||
const checkedChunkGroups = new Set();
|
||||
const checkedChunks = new Set();
|
||||
function recordChunkGroup(chunkGroup) {
|
||||
// Ensure recursion is stopped if we've already checked this chunk group.
|
||||
if (checkedChunkGroups.has(chunkGroup)) return;
|
||||
checkedChunkGroups.add(chunkGroup);
|
||||
// Only apply following logic to client module requests from client entry,
|
||||
// or if the module is marked as client module. That's because other
|
||||
// client modules don't need to be in the manifest at all as they're
|
||||
// never be referenced by the server/client boundary.
|
||||
// This saves a lot of bytes in the manifest.
|
||||
chunkGroup.chunks.forEach((chunk)=>{
|
||||
// Ensure recursion is stopped if we've already checked this chunk.
|
||||
if (checkedChunks.has(chunk)) return;
|
||||
checkedChunks.add(chunk);
|
||||
const entryMods = compilation.chunkGraph.getChunkEntryModulesIterable(chunk);
|
||||
for (const mod of entryMods){
|
||||
if (mod.layer !== _constants1.WEBPACK_LAYERS.appPagesBrowser) continue;
|
||||
const request = mod.request;
|
||||
if (!request || !request.includes("next-flight-client-entry-loader.js?")) {
|
||||
continue;
|
||||
}
|
||||
const connections = (0, _utils.getModuleReferencesInOrder)(mod, compilation.moduleGraph);
|
||||
for (const connection of connections){
|
||||
const dependency = connection.dependency;
|
||||
if (!dependency) continue;
|
||||
const clientEntryMod = compilation.moduleGraph.getResolvedModule(dependency);
|
||||
const modId = compilation.chunkGraph.getModuleId(clientEntryMod);
|
||||
if (modId !== null) {
|
||||
recordModule(modId, clientEntryMod);
|
||||
} else {
|
||||
var _connection_module;
|
||||
// If this is a concatenation, register each child to the parent ID.
|
||||
if (((_connection_module = connection.module) == null ? void 0 : _connection_module.constructor.name) === "ConcatenatedModule") {
|
||||
const concatenatedMod = connection.module;
|
||||
const concatenatedModId = compilation.chunkGraph.getModuleId(concatenatedMod);
|
||||
recordModule(concatenatedModId, clientEntryMod);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
// Walk through all children chunk groups too.
|
||||
for (const child of chunkGroup.childrenIterable){
|
||||
recordChunkGroup(child);
|
||||
}
|
||||
}
|
||||
recordChunkGroup(entrypoint);
|
||||
// A page's entry name can have extensions. For example, these are both valid:
|
||||
// - app/foo/page
|
||||
// - app/foo/page.page
|
||||
if (/\/page(\.[^/]+)?$/.test(entryName)) {
|
||||
manifestEntryFiles.push(entryName.replace(/\/page(\.[^/]+)?$/, "/page"));
|
||||
}
|
||||
const groupName = entryNameToGroupName(entryName);
|
||||
if (!manifestsPerGroup.has(groupName)) {
|
||||
manifestsPerGroup.set(groupName, []);
|
||||
}
|
||||
manifestsPerGroup.get(groupName).push(manifest);
|
||||
}
|
||||
// Generate per-page manifests.
|
||||
for (const pageName of manifestEntryFiles){
|
||||
const mergedManifest = {
|
||||
moduleLoading: {
|
||||
prefix,
|
||||
crossOrigin: crossOriginMode
|
||||
},
|
||||
ssrModuleMapping: {},
|
||||
edgeSSRModuleMapping: {},
|
||||
clientModules: {},
|
||||
entryCSSFiles: {}
|
||||
};
|
||||
const segments = [
|
||||
...entryNameToGroupName(pageName).split("/"),
|
||||
"page"
|
||||
];
|
||||
let group = "";
|
||||
for (const segment of segments){
|
||||
for (const manifest of manifestsPerGroup.get(group) || []){
|
||||
mergeManifest(mergedManifest, manifest);
|
||||
}
|
||||
group += (group ? "/" : "") + segment;
|
||||
}
|
||||
const json = JSON.stringify(mergedManifest);
|
||||
const pagePath = pageName.replace(/%5F/g, "_");
|
||||
const pageBundlePath = (0, _normalizepagepath.normalizePagePath)(pagePath.slice("app".length));
|
||||
assets["server/app" + pageBundlePath + "_" + _constants.CLIENT_REFERENCE_MANIFEST + ".js"] = new _webpack.sources.RawSource(`globalThis.__RSC_MANIFEST=(globalThis.__RSC_MANIFEST||{});globalThis.__RSC_MANIFEST[${JSON.stringify(pagePath.slice("app".length))}]=${json}`);
|
||||
}
|
||||
pluginState.ASYNC_CLIENT_MODULES = {};
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=flight-manifest-plugin.js.map
|
||||
224
.next/standalone/node_modules/next/dist/build/webpack/plugins/font-stylesheet-gathering-plugin.js
generated
vendored
Normal file
224
.next/standalone/node_modules/next/dist/build/webpack/plugins/font-stylesheet-gathering-plugin.js
generated
vendored
Normal file
@@ -0,0 +1,224 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "FontStylesheetGatheringPlugin", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return FontStylesheetGatheringPlugin;
|
||||
}
|
||||
});
|
||||
const _webpack = require("next/dist/compiled/webpack/webpack");
|
||||
const _fontutils = require("../../../server/font-utils");
|
||||
const _postcss = /*#__PURE__*/ _interop_require_default(require("postcss"));
|
||||
const _cssnanosimple = /*#__PURE__*/ _interop_require_default(require("next/dist/compiled/cssnano-simple"));
|
||||
const _constants = require("../../../shared/lib/constants");
|
||||
const _log = /*#__PURE__*/ _interop_require_wildcard(require("../../output/log"));
|
||||
function _interop_require_default(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
function _getRequireWildcardCache(nodeInterop) {
|
||||
if (typeof WeakMap !== "function") return null;
|
||||
var cacheBabelInterop = new WeakMap();
|
||||
var cacheNodeInterop = new WeakMap();
|
||||
return (_getRequireWildcardCache = function(nodeInterop) {
|
||||
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
||||
})(nodeInterop);
|
||||
}
|
||||
function _interop_require_wildcard(obj, nodeInterop) {
|
||||
if (!nodeInterop && obj && obj.__esModule) {
|
||||
return obj;
|
||||
}
|
||||
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
||||
return {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
var cache = _getRequireWildcardCache(nodeInterop);
|
||||
if (cache && cache.has(obj)) {
|
||||
return cache.get(obj);
|
||||
}
|
||||
var newObj = {
|
||||
__proto__: null
|
||||
};
|
||||
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
||||
for(var key in obj){
|
||||
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
||||
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
||||
if (desc && (desc.get || desc.set)) {
|
||||
Object.defineProperty(newObj, key, desc);
|
||||
} else {
|
||||
newObj[key] = obj[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
newObj.default = obj;
|
||||
if (cache) {
|
||||
cache.set(obj, newObj);
|
||||
}
|
||||
return newObj;
|
||||
}
|
||||
function minifyCss(css) {
|
||||
return (0, _postcss.default)([
|
||||
(0, _cssnanosimple.default)({
|
||||
excludeAll: true,
|
||||
discardComments: true,
|
||||
normalizeWhitespace: {
|
||||
exclude: false
|
||||
}
|
||||
}, _postcss.default)
|
||||
]).process(css, {
|
||||
from: undefined
|
||||
}).then((res)=>res.css);
|
||||
}
|
||||
function isNodeCreatingLinkElement(node) {
|
||||
const callee = node.callee;
|
||||
if (callee.type !== "Identifier") {
|
||||
return false;
|
||||
}
|
||||
const componentNode = node.arguments[0];
|
||||
if (componentNode.type !== "Literal") {
|
||||
return false;
|
||||
}
|
||||
// React has pragma: _jsx.
|
||||
// Next has pragma: __jsx.
|
||||
return (callee.name === "_jsx" || callee.name === "__jsx") && componentNode.value === "link";
|
||||
}
|
||||
class FontStylesheetGatheringPlugin {
|
||||
constructor({ adjustFontFallbacks, adjustFontFallbacksWithSizeAdjust }){
|
||||
this.gatheredStylesheets = [];
|
||||
this.manifestContent = [];
|
||||
this.parserHandler = (factory)=>{
|
||||
const JS_TYPES = [
|
||||
"auto",
|
||||
"esm",
|
||||
"dynamic"
|
||||
];
|
||||
// Do an extra walk per module and add interested visitors to the walk.
|
||||
for (const type of JS_TYPES){
|
||||
factory.hooks.parser.for("javascript/" + type).tap(this.constructor.name, (parser)=>{
|
||||
/**
|
||||
* Webpack fun facts:
|
||||
* `parser.hooks.call.for` cannot catch calls for user defined identifiers like `__jsx`
|
||||
* it can only detect calls for native objects like `window`, `this`, `eval` etc.
|
||||
* In order to be able to catch calls of variables like `__jsx`, first we need to catch them as
|
||||
* Identifier and then return `BasicEvaluatedExpression` whose `id` and `type` webpack matches to
|
||||
* invoke hook for call.
|
||||
* See: https://github.com/webpack/webpack/blob/webpack-4/lib/Parser.js#L1931-L1932.
|
||||
*/ parser.hooks.evaluate.for("Identifier").tap(this.constructor.name, (node)=>{
|
||||
var _parser_state_module, _parser_state;
|
||||
// We will only optimize fonts from first party code.
|
||||
if (parser == null ? void 0 : (_parser_state = parser.state) == null ? void 0 : (_parser_state_module = _parser_state.module) == null ? void 0 : _parser_state_module.resource.includes("node_modules")) {
|
||||
return;
|
||||
}
|
||||
let result;
|
||||
if (node.name === "_jsx" || node.name === "__jsx") {
|
||||
result = new _webpack.BasicEvaluatedExpression();
|
||||
// @ts-ignore
|
||||
result.setRange(node.range);
|
||||
result.setExpression(node);
|
||||
result.setIdentifier(node.name);
|
||||
// This was added in webpack 5.
|
||||
result.getMembers = ()=>[];
|
||||
}
|
||||
return result;
|
||||
});
|
||||
const jsxNodeHandler = (node)=>{
|
||||
var _parser_state_module, _parser_state;
|
||||
if (node.arguments.length !== 2) {
|
||||
// A font link tag has only two arguments rel=stylesheet and href='...'
|
||||
return;
|
||||
}
|
||||
if (!isNodeCreatingLinkElement(node)) {
|
||||
return;
|
||||
}
|
||||
// node.arguments[0] is the name of the tag and [1] are the props.
|
||||
const arg1 = node.arguments[1];
|
||||
const propsNode = arg1.type === "ObjectExpression" ? arg1 : undefined;
|
||||
const props = {};
|
||||
if (propsNode) {
|
||||
propsNode.properties.forEach((prop)=>{
|
||||
if (prop.type !== "Property") {
|
||||
return;
|
||||
}
|
||||
if (prop.key.type === "Identifier" && prop.value.type === "Literal") {
|
||||
props[prop.key.name] = prop.value.value;
|
||||
}
|
||||
});
|
||||
}
|
||||
if (!props.rel || props.rel !== "stylesheet" || !props.href || !_constants.OPTIMIZED_FONT_PROVIDERS.some(({ url })=>props.href.startsWith(url))) {
|
||||
return false;
|
||||
}
|
||||
this.gatheredStylesheets.push(props.href);
|
||||
const buildInfo = parser == null ? void 0 : (_parser_state = parser.state) == null ? void 0 : (_parser_state_module = _parser_state.module) == null ? void 0 : _parser_state_module.buildInfo;
|
||||
if (buildInfo) {
|
||||
buildInfo.valueDependencies.set(_constants.AUTOMATIC_FONT_OPTIMIZATION_MANIFEST, this.gatheredStylesheets);
|
||||
}
|
||||
};
|
||||
// React JSX transform:
|
||||
parser.hooks.call.for("_jsx").tap(this.constructor.name, jsxNodeHandler);
|
||||
// Next.js JSX transform:
|
||||
parser.hooks.call.for("__jsx").tap(this.constructor.name, jsxNodeHandler);
|
||||
// New React JSX transform:
|
||||
parser.hooks.call.for("imported var").tap(this.constructor.name, jsxNodeHandler);
|
||||
});
|
||||
}
|
||||
};
|
||||
this.adjustFontFallbacks = adjustFontFallbacks;
|
||||
this.adjustFontFallbacksWithSizeAdjust = adjustFontFallbacksWithSizeAdjust;
|
||||
}
|
||||
apply(compiler) {
|
||||
this.compiler = compiler;
|
||||
compiler.hooks.normalModuleFactory.tap(this.constructor.name, this.parserHandler);
|
||||
compiler.hooks.make.tapAsync(this.constructor.name, (compilation, cb)=>{
|
||||
compilation.hooks.finishModules.tapAsync(this.constructor.name, async (modules, modulesFinished)=>{
|
||||
let fontStylesheets = this.gatheredStylesheets;
|
||||
const fontUrls = new Set();
|
||||
modules.forEach((module)=>{
|
||||
var _module_buildInfo_valueDependencies, _module_buildInfo;
|
||||
const fontDependencies = module == null ? void 0 : (_module_buildInfo = module.buildInfo) == null ? void 0 : (_module_buildInfo_valueDependencies = _module_buildInfo.valueDependencies) == null ? void 0 : _module_buildInfo_valueDependencies.get(_constants.AUTOMATIC_FONT_OPTIMIZATION_MANIFEST);
|
||||
if (fontDependencies) {
|
||||
fontDependencies.forEach((v)=>fontUrls.add(v));
|
||||
}
|
||||
});
|
||||
fontStylesheets = Array.from(fontUrls);
|
||||
const fontDefinitionPromises = fontStylesheets.map((url)=>(0, _fontutils.getFontDefinitionFromNetwork)(url));
|
||||
this.manifestContent = [];
|
||||
for(let promiseIndex in fontDefinitionPromises){
|
||||
let css = await fontDefinitionPromises[promiseIndex];
|
||||
if (this.adjustFontFallbacks) {
|
||||
css += (0, _fontutils.getFontOverrideCss)(fontStylesheets[promiseIndex], css, this.adjustFontFallbacksWithSizeAdjust);
|
||||
}
|
||||
if (css) {
|
||||
try {
|
||||
const content = await minifyCss(css);
|
||||
this.manifestContent.push({
|
||||
url: fontStylesheets[promiseIndex],
|
||||
content
|
||||
});
|
||||
} catch (err) {
|
||||
_log.warn(`Failed to minify the stylesheet for ${fontStylesheets[promiseIndex]}. Skipped optimizing this font.`);
|
||||
console.error(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
// @ts-expect-error invalid assets type
|
||||
compilation.assets[_constants.AUTOMATIC_FONT_OPTIMIZATION_MANIFEST] = new _webpack.sources.RawSource(JSON.stringify(this.manifestContent, null, " "));
|
||||
modulesFinished();
|
||||
});
|
||||
cb();
|
||||
});
|
||||
compiler.hooks.make.tap(this.constructor.name, (compilation)=>{
|
||||
compilation.hooks.processAssets.tap({
|
||||
name: this.constructor.name,
|
||||
stage: _webpack.webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS
|
||||
}, (assets)=>{
|
||||
assets["../" + _constants.AUTOMATIC_FONT_OPTIMIZATION_MANIFEST] = new _webpack.sources.RawSource(JSON.stringify(this.manifestContent, null, " "));
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=font-stylesheet-gathering-plugin.js.map
|
||||
219
.next/standalone/node_modules/next/dist/build/webpack/plugins/jsconfig-paths-plugin.js
generated
vendored
Normal file
219
.next/standalone/node_modules/next/dist/build/webpack/plugins/jsconfig-paths-plugin.js
generated
vendored
Normal file
@@ -0,0 +1,219 @@
|
||||
/**
|
||||
* This webpack resolver is largely based on TypeScript's "paths" handling
|
||||
* The TypeScript license can be found here:
|
||||
* https://github.com/microsoft/TypeScript/blob/214df64e287804577afa1fea0184c18c40f7d1ca/LICENSE.txt
|
||||
*/ "use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
0 && (module.exports = {
|
||||
JsConfigPathsPlugin: null,
|
||||
findBestPatternMatch: null,
|
||||
hasZeroOrOneAsteriskCharacter: null,
|
||||
isString: null,
|
||||
matchPatternOrExact: null,
|
||||
matchedText: null,
|
||||
pathIsRelative: null,
|
||||
patternText: null,
|
||||
tryParsePattern: null
|
||||
});
|
||||
function _export(target, all) {
|
||||
for(var name in all)Object.defineProperty(target, name, {
|
||||
enumerable: true,
|
||||
get: all[name]
|
||||
});
|
||||
}
|
||||
_export(exports, {
|
||||
JsConfigPathsPlugin: function() {
|
||||
return JsConfigPathsPlugin;
|
||||
},
|
||||
findBestPatternMatch: function() {
|
||||
return findBestPatternMatch;
|
||||
},
|
||||
hasZeroOrOneAsteriskCharacter: function() {
|
||||
return hasZeroOrOneAsteriskCharacter;
|
||||
},
|
||||
isString: function() {
|
||||
return isString;
|
||||
},
|
||||
matchPatternOrExact: function() {
|
||||
return matchPatternOrExact;
|
||||
},
|
||||
matchedText: function() {
|
||||
return matchedText;
|
||||
},
|
||||
pathIsRelative: function() {
|
||||
return pathIsRelative;
|
||||
},
|
||||
patternText: function() {
|
||||
return patternText;
|
||||
},
|
||||
tryParsePattern: function() {
|
||||
return tryParsePattern;
|
||||
}
|
||||
});
|
||||
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
||||
const _debug = require("next/dist/compiled/debug");
|
||||
function _interop_require_default(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
const log = (0, _debug.debug)("next:jsconfig-paths-plugin");
|
||||
const asterisk = 0x2a;
|
||||
function hasZeroOrOneAsteriskCharacter(str) {
|
||||
let seenAsterisk = false;
|
||||
for(let i = 0; i < str.length; i++){
|
||||
if (str.charCodeAt(i) === asterisk) {
|
||||
if (!seenAsterisk) {
|
||||
seenAsterisk = true;
|
||||
} else {
|
||||
// have already seen asterisk
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
function pathIsRelative(testPath) {
|
||||
return /^\.\.?($|[\\/])/.test(testPath);
|
||||
}
|
||||
function tryParsePattern(pattern) {
|
||||
// This should be verified outside of here and a proper error thrown.
|
||||
const indexOfStar = pattern.indexOf("*");
|
||||
return indexOfStar === -1 ? undefined : {
|
||||
prefix: pattern.slice(0, indexOfStar),
|
||||
suffix: pattern.slice(indexOfStar + 1)
|
||||
};
|
||||
}
|
||||
function isPatternMatch({ prefix, suffix }, candidate) {
|
||||
return candidate.length >= prefix.length + suffix.length && candidate.startsWith(prefix) && candidate.endsWith(suffix);
|
||||
}
|
||||
function findBestPatternMatch(values, getPattern, candidate) {
|
||||
let matchedValue;
|
||||
// use length of prefix as betterness criteria
|
||||
let longestMatchPrefixLength = -1;
|
||||
for (const v of values){
|
||||
const pattern = getPattern(v);
|
||||
if (isPatternMatch(pattern, candidate) && pattern.prefix.length > longestMatchPrefixLength) {
|
||||
longestMatchPrefixLength = pattern.prefix.length;
|
||||
matchedValue = v;
|
||||
}
|
||||
}
|
||||
return matchedValue;
|
||||
}
|
||||
function matchPatternOrExact(patternStrings, candidate) {
|
||||
const patterns = [];
|
||||
for (const patternString of patternStrings){
|
||||
if (!hasZeroOrOneAsteriskCharacter(patternString)) continue;
|
||||
const pattern = tryParsePattern(patternString);
|
||||
if (pattern) {
|
||||
patterns.push(pattern);
|
||||
} else if (patternString === candidate) {
|
||||
// pattern was matched as is - no need to search further
|
||||
return patternString;
|
||||
}
|
||||
}
|
||||
return findBestPatternMatch(patterns, (_)=>_, candidate);
|
||||
}
|
||||
function isString(text) {
|
||||
return typeof text === "string";
|
||||
}
|
||||
function matchedText(pattern, candidate) {
|
||||
return candidate.substring(pattern.prefix.length, candidate.length - pattern.suffix.length);
|
||||
}
|
||||
function patternText({ prefix, suffix }) {
|
||||
return `${prefix}*${suffix}`;
|
||||
}
|
||||
/**
|
||||
* Calls the iterator function for each entry of the array
|
||||
* until the first result or error is reached
|
||||
*/ function forEachBail(array, iterator, callback) {
|
||||
if (array.length === 0) return callback();
|
||||
let i = 0;
|
||||
const next = ()=>{
|
||||
let loop = undefined;
|
||||
iterator(array[i++], (err, result)=>{
|
||||
if (err || result !== undefined || i >= array.length) {
|
||||
return callback(err, result);
|
||||
}
|
||||
if (loop === false) while(next());
|
||||
loop = true;
|
||||
});
|
||||
if (!loop) loop = false;
|
||||
return loop;
|
||||
};
|
||||
while(next());
|
||||
}
|
||||
const NODE_MODULES_REGEX = /node_modules/;
|
||||
class JsConfigPathsPlugin {
|
||||
constructor(paths, resolvedBaseUrl){
|
||||
this.paths = paths;
|
||||
this.resolvedBaseUrl = resolvedBaseUrl;
|
||||
this.jsConfigPlugin = true;
|
||||
log("tsconfig.json or jsconfig.json paths: %O", paths);
|
||||
log("resolved baseUrl: %s", resolvedBaseUrl);
|
||||
}
|
||||
apply(resolver) {
|
||||
const target = resolver.ensureHook("resolve");
|
||||
resolver.getHook("described-resolve").tapAsync("JsConfigPathsPlugin", (request, resolveContext, callback)=>{
|
||||
const resolvedBaseUrl = this.resolvedBaseUrl;
|
||||
if (resolvedBaseUrl === undefined) {
|
||||
return callback();
|
||||
}
|
||||
const paths = this.paths;
|
||||
const pathsKeys = Object.keys(paths);
|
||||
// If no aliases are added bail out
|
||||
if (pathsKeys.length === 0) {
|
||||
log("paths are empty, bailing out");
|
||||
return callback();
|
||||
}
|
||||
const moduleName = request.request;
|
||||
// Exclude node_modules from paths support (speeds up resolving)
|
||||
if (request.path.match(NODE_MODULES_REGEX)) {
|
||||
log("skipping request as it is inside node_modules %s", moduleName);
|
||||
return callback();
|
||||
}
|
||||
if (_path.default.posix.isAbsolute(moduleName) || process.platform === "win32" && _path.default.win32.isAbsolute(moduleName)) {
|
||||
log("skipping request as it is an absolute path %s", moduleName);
|
||||
return callback();
|
||||
}
|
||||
if (pathIsRelative(moduleName)) {
|
||||
log("skipping request as it is a relative path %s", moduleName);
|
||||
return callback();
|
||||
}
|
||||
// log('starting to resolve request %s', moduleName)
|
||||
// If the module name does not match any of the patterns in `paths` we hand off resolving to webpack
|
||||
const matchedPattern = matchPatternOrExact(pathsKeys, moduleName);
|
||||
if (!matchedPattern) {
|
||||
log("moduleName did not match any paths pattern %s", moduleName);
|
||||
return callback();
|
||||
}
|
||||
const matchedStar = isString(matchedPattern) ? undefined : matchedText(matchedPattern, moduleName);
|
||||
const matchedPatternText = isString(matchedPattern) ? matchedPattern : patternText(matchedPattern);
|
||||
let triedPaths = [];
|
||||
forEachBail(paths[matchedPatternText], (subst, pathCallback)=>{
|
||||
const curPath = matchedStar ? subst.replace("*", matchedStar) : subst;
|
||||
// Ensure .d.ts is not matched
|
||||
if (curPath.endsWith(".d.ts")) {
|
||||
// try next path candidate
|
||||
return pathCallback();
|
||||
}
|
||||
const candidate = _path.default.join(resolvedBaseUrl.baseUrl, curPath);
|
||||
const obj = Object.assign({}, request, {
|
||||
request: candidate
|
||||
});
|
||||
resolver.doResolve(target, obj, `Aliased with tsconfig.json or jsconfig.json ${matchedPatternText} to ${candidate}`, resolveContext, (resolverErr, resolverResult)=>{
|
||||
if (resolverErr || resolverResult === undefined) {
|
||||
triedPaths.push(candidate);
|
||||
// try next path candidate
|
||||
return pathCallback();
|
||||
}
|
||||
return pathCallback(resolverErr, resolverResult);
|
||||
});
|
||||
}, callback);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=jsconfig-paths-plugin.js.map
|
||||
114
.next/standalone/node_modules/next/dist/build/webpack/plugins/memory-with-gc-cache-plugin.js
generated
vendored
Normal file
114
.next/standalone/node_modules/next/dist/build/webpack/plugins/memory-with-gc-cache-plugin.js
generated
vendored
Normal file
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
This plugin is based on the internal one in webpack but heavily modified to use a different caching heuristic.
|
||||
https://github.com/webpack/webpack/blob/853bfda35a0080605c09e1bdeb0103bcb9367a10/lib/cache/MemoryWithGcCachePlugin.js#L15
|
||||
|
||||
https://github.com/webpack/webpack/blob/main/LICENSE
|
||||
Copyright JS Foundation and other contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
'Software'), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/ /*
|
||||
The change in this plugin compared to the built-in one in webpack is that this plugin always cleans up after 5 compilations.
|
||||
The built-in plugin only cleans up "total modules / max generations".
|
||||
The default for max generations is 5, so 1/5th of the modules would be marked for deletion.
|
||||
This plugin instead always checks the cache and decreases the time to live of all entries. That way memory is cleaned up earlier.
|
||||
*/ "use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "MemoryWithGcCachePlugin", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return MemoryWithGcCachePlugin;
|
||||
}
|
||||
});
|
||||
// Used to hook into the memory stage of the webpack caching
|
||||
const CACHE_STAGE_MEMORY = -10 // TODO: Somehow webpack.Cache.STAGE_MEMORY doesn't work.
|
||||
;
|
||||
const PLUGIN_NAME = "NextJsMemoryWithGcCachePlugin";
|
||||
class MemoryWithGcCachePlugin {
|
||||
constructor({ maxGenerations }){
|
||||
this.maxGenerations = maxGenerations;
|
||||
}
|
||||
apply(compiler) {
|
||||
const maxGenerations = this.maxGenerations;
|
||||
/**
|
||||
* The memory cache
|
||||
*/ const cache = new Map();
|
||||
/**
|
||||
* Cache cleanup implementation
|
||||
*/ function decreaseTTLAndEvict() {
|
||||
for (const [identifier, entry] of cache){
|
||||
// Decrease item time to live
|
||||
entry.ttl--;
|
||||
// if ttl is 0 or below, evict entry from the cache
|
||||
if (entry.ttl <= 0) {
|
||||
cache.delete(identifier);
|
||||
}
|
||||
}
|
||||
}
|
||||
compiler.hooks.afterDone.tap(PLUGIN_NAME, decreaseTTLAndEvict);
|
||||
compiler.cache.hooks.store.tap({
|
||||
name: PLUGIN_NAME,
|
||||
stage: CACHE_STAGE_MEMORY
|
||||
}, (identifier, etag, data)=>{
|
||||
cache.set(identifier, {
|
||||
etag,
|
||||
data,
|
||||
ttl: maxGenerations
|
||||
});
|
||||
});
|
||||
compiler.cache.hooks.get.tap({
|
||||
name: PLUGIN_NAME,
|
||||
stage: CACHE_STAGE_MEMORY
|
||||
}, (identifier, etag, gotHandlers)=>{
|
||||
const cacheEntry = cache.get(identifier);
|
||||
// Item found
|
||||
if (cacheEntry !== undefined) {
|
||||
// When cache entry is hit we reset the counter.
|
||||
cacheEntry.ttl = maxGenerations;
|
||||
// Handles `null` separately as it doesn't have an etag.
|
||||
if (cacheEntry.data === null) {
|
||||
return null;
|
||||
}
|
||||
return cacheEntry.etag === etag ? cacheEntry.data : null;
|
||||
}
|
||||
// Handle case where other cache does have the identifier, puts it into the memory cache
|
||||
gotHandlers.push((result, callback)=>{
|
||||
cache.set(identifier, {
|
||||
// Handles `null` separately as it doesn't have an etag.
|
||||
etag: result === null ? null : etag,
|
||||
data: result,
|
||||
ttl: maxGenerations
|
||||
});
|
||||
return callback();
|
||||
});
|
||||
// No item found
|
||||
return undefined;
|
||||
});
|
||||
compiler.cache.hooks.shutdown.tap({
|
||||
name: PLUGIN_NAME,
|
||||
stage: CACHE_STAGE_MEMORY
|
||||
}, ()=>{
|
||||
cache.clear();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=memory-with-gc-cache-plugin.js.map
|
||||
559
.next/standalone/node_modules/next/dist/build/webpack/plugins/middleware-plugin.js
generated
vendored
Normal file
559
.next/standalone/node_modules/next/dist/build/webpack/plugins/middleware-plugin.js
generated
vendored
Normal file
@@ -0,0 +1,559 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
0 && (module.exports = {
|
||||
SUPPORTED_NATIVE_MODULES: null,
|
||||
default: null,
|
||||
getEdgePolyfilledModules: null,
|
||||
handleWebpackExternalForEdgeRuntime: null
|
||||
});
|
||||
function _export(target, all) {
|
||||
for(var name in all)Object.defineProperty(target, name, {
|
||||
enumerable: true,
|
||||
get: all[name]
|
||||
});
|
||||
}
|
||||
_export(exports, {
|
||||
SUPPORTED_NATIVE_MODULES: function() {
|
||||
return SUPPORTED_NATIVE_MODULES;
|
||||
},
|
||||
default: function() {
|
||||
return MiddlewarePlugin;
|
||||
},
|
||||
getEdgePolyfilledModules: function() {
|
||||
return getEdgePolyfilledModules;
|
||||
},
|
||||
handleWebpackExternalForEdgeRuntime: function() {
|
||||
return handleWebpackExternalForEdgeRuntime;
|
||||
}
|
||||
});
|
||||
const _routeregex = require("../../../shared/lib/router/utils/route-regex");
|
||||
const _getmodulebuildinfo = require("../loaders/get-module-build-info");
|
||||
const _utils = require("../../../shared/lib/router/utils");
|
||||
const _webpack = require("next/dist/compiled/webpack/webpack");
|
||||
const _picomatch = /*#__PURE__*/ _interop_require_default(require("next/dist/compiled/picomatch"));
|
||||
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
||||
const _constants = require("../../../shared/lib/constants");
|
||||
const _shared = require("../../../trace/shared");
|
||||
const _events = require("../../../telemetry/events");
|
||||
const _apppaths = require("../../../shared/lib/router/utils/app-paths");
|
||||
const _constants1 = require("../../../lib/constants");
|
||||
const _generateinterceptionroutesrewrites = require("../../../lib/generate-interception-routes-rewrites");
|
||||
const _parsedynamiccodeevaluationerror = require("./wellknown-errors-plugin/parse-dynamic-code-evaluation-error");
|
||||
const _utils1 = require("../utils");
|
||||
function _interop_require_default(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
const KNOWN_SAFE_DYNAMIC_PACKAGES = require("../../../lib/known-edge-safe-packages.json");
|
||||
const NAME = "MiddlewarePlugin";
|
||||
const MANIFEST_VERSION = 3;
|
||||
/**
|
||||
* Checks the value of usingIndirectEval and when it is a set of modules it
|
||||
* check if any of the modules is actually being used. If the value is
|
||||
* simply truthy it will return true.
|
||||
*/ function isUsingIndirectEvalAndUsedByExports(args) {
|
||||
const { moduleGraph, runtime, module: module1, usingIndirectEval, wp } = args;
|
||||
if (typeof usingIndirectEval === "boolean") {
|
||||
return usingIndirectEval;
|
||||
}
|
||||
const exportsInfo = moduleGraph.getExportsInfo(module1);
|
||||
for (const exportName of usingIndirectEval){
|
||||
if (exportsInfo.getUsed(exportName, runtime) !== wp.UsageState.Unused) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function getEntryFiles(entryFiles, meta, hasInstrumentationHook, opts) {
|
||||
const files = [];
|
||||
if (meta.edgeSSR) {
|
||||
if (meta.edgeSSR.isServerComponent) {
|
||||
files.push(`server/${_constants.SERVER_REFERENCE_MANIFEST}.js`);
|
||||
if (opts.sriEnabled) {
|
||||
files.push(`server/${_constants.SUBRESOURCE_INTEGRITY_MANIFEST}.js`);
|
||||
}
|
||||
files.push(...entryFiles.filter((file)=>file.startsWith("app/") && !file.endsWith(".hot-update.js")).map((file)=>"server/" + file.replace(".js", "_" + _constants.CLIENT_REFERENCE_MANIFEST + ".js")));
|
||||
}
|
||||
files.push(`server/${_constants.MIDDLEWARE_BUILD_MANIFEST}.js`, `server/${_constants.MIDDLEWARE_REACT_LOADABLE_MANIFEST}.js`, `server/${_constants.NEXT_FONT_MANIFEST}.js`, `server/${_constants.INTERCEPTION_ROUTE_REWRITE_MANIFEST}.js`);
|
||||
}
|
||||
if (hasInstrumentationHook) {
|
||||
files.push(`server/edge-${_constants1.INSTRUMENTATION_HOOK_FILENAME}.js`);
|
||||
}
|
||||
if (process.env.NODE_ENV === "production") {
|
||||
files.push(_constants.PRERENDER_MANIFEST.replace("json", "js"));
|
||||
}
|
||||
files.push(...entryFiles.filter((file)=>!file.endsWith(".hot-update.js")).map((file)=>"server/" + file));
|
||||
return files;
|
||||
}
|
||||
function getCreateAssets(params) {
|
||||
const { compilation, metadataByEntry, opts } = params;
|
||||
return (assets)=>{
|
||||
const middlewareManifest = {
|
||||
version: MANIFEST_VERSION,
|
||||
middleware: {},
|
||||
functions: {},
|
||||
sortedMiddleware: []
|
||||
};
|
||||
const hasInstrumentationHook = compilation.entrypoints.has(_constants1.INSTRUMENTATION_HOOK_FILENAME);
|
||||
// we only emit this entry for the edge runtime since it doesn't have access to a routes manifest
|
||||
// and we don't need to provide the entire route manifest, just the interception routes.
|
||||
const interceptionRewrites = JSON.stringify(opts.rewrites.beforeFiles.filter(_generateinterceptionroutesrewrites.isInterceptionRouteRewrite));
|
||||
assets[`${_constants.INTERCEPTION_ROUTE_REWRITE_MANIFEST}.js`] = new _webpack.sources.RawSource(`self.__INTERCEPTION_ROUTE_REWRITE_MANIFEST=${JSON.stringify(interceptionRewrites)}`);
|
||||
for (const entrypoint of compilation.entrypoints.values()){
|
||||
var _metadata_edgeMiddleware, _metadata_edgeSSR, _metadata_edgeApiFunction, _metadata_edgeSSR1, _metadata_edgeMiddleware1;
|
||||
if (!entrypoint.name) {
|
||||
continue;
|
||||
}
|
||||
// There should always be metadata for the entrypoint.
|
||||
const metadata = metadataByEntry.get(entrypoint.name);
|
||||
const page = (metadata == null ? void 0 : (_metadata_edgeMiddleware = metadata.edgeMiddleware) == null ? void 0 : _metadata_edgeMiddleware.page) || (metadata == null ? void 0 : (_metadata_edgeSSR = metadata.edgeSSR) == null ? void 0 : _metadata_edgeSSR.page) || (metadata == null ? void 0 : (_metadata_edgeApiFunction = metadata.edgeApiFunction) == null ? void 0 : _metadata_edgeApiFunction.page);
|
||||
if (!page) {
|
||||
continue;
|
||||
}
|
||||
const matcherSource = ((_metadata_edgeSSR1 = metadata.edgeSSR) == null ? void 0 : _metadata_edgeSSR1.isAppDir) ? (0, _apppaths.normalizeAppPath)(page) : page;
|
||||
const catchAll = !metadata.edgeSSR && !metadata.edgeApiFunction;
|
||||
const { namedRegex } = (0, _routeregex.getNamedMiddlewareRegex)(matcherSource, {
|
||||
catchAll
|
||||
});
|
||||
const matchers = (metadata == null ? void 0 : (_metadata_edgeMiddleware1 = metadata.edgeMiddleware) == null ? void 0 : _metadata_edgeMiddleware1.matchers) ?? [
|
||||
{
|
||||
regexp: namedRegex,
|
||||
originalSource: page === "/" && catchAll ? "/:path*" : matcherSource
|
||||
}
|
||||
];
|
||||
const isEdgeFunction = !!(metadata.edgeApiFunction || metadata.edgeSSR);
|
||||
const edgeFunctionDefinition = {
|
||||
files: getEntryFiles(entrypoint.getFiles(), metadata, hasInstrumentationHook, opts),
|
||||
name: entrypoint.name,
|
||||
page: page,
|
||||
matchers,
|
||||
wasm: Array.from(metadata.wasmBindings, ([name, filePath])=>({
|
||||
name,
|
||||
filePath
|
||||
})),
|
||||
assets: Array.from(metadata.assetBindings, ([name, filePath])=>({
|
||||
name,
|
||||
filePath
|
||||
})),
|
||||
environments: opts.edgeEnvironments,
|
||||
...metadata.regions && {
|
||||
regions: metadata.regions
|
||||
}
|
||||
};
|
||||
if (isEdgeFunction) {
|
||||
middlewareManifest.functions[page] = edgeFunctionDefinition;
|
||||
} else {
|
||||
middlewareManifest.middleware[page] = edgeFunctionDefinition;
|
||||
}
|
||||
}
|
||||
middlewareManifest.sortedMiddleware = (0, _utils.getSortedRoutes)(Object.keys(middlewareManifest.middleware));
|
||||
assets[_constants.MIDDLEWARE_MANIFEST] = new _webpack.sources.RawSource(JSON.stringify(middlewareManifest, null, 2));
|
||||
};
|
||||
}
|
||||
function buildWebpackError({ message, loc, compilation, entryModule, parser }) {
|
||||
const error = new compilation.compiler.webpack.WebpackError(message);
|
||||
error.name = NAME;
|
||||
const module1 = entryModule ?? (parser == null ? void 0 : parser.state.current);
|
||||
if (module1) {
|
||||
error.module = module1;
|
||||
}
|
||||
error.loc = loc;
|
||||
return error;
|
||||
}
|
||||
function isInMiddlewareLayer(parser) {
|
||||
var _parser_state_module;
|
||||
return ((_parser_state_module = parser.state.module) == null ? void 0 : _parser_state_module.layer) === "middleware";
|
||||
}
|
||||
function isNodeJsModule(moduleName) {
|
||||
return require("module").builtinModules.includes(moduleName);
|
||||
}
|
||||
function isDynamicCodeEvaluationAllowed(fileName, middlewareConfig, rootDir) {
|
||||
// Some packages are known to use `eval` but are safe to use in the Edge
|
||||
// Runtime because the dynamic code will never be executed.
|
||||
if (KNOWN_SAFE_DYNAMIC_PACKAGES.some((pkg)=>fileName.includes(`/node_modules/${pkg}/`.replace(/\//g, _path.default.sep)))) {
|
||||
return true;
|
||||
}
|
||||
const name = fileName.replace(rootDir ?? "", "");
|
||||
return (0, _picomatch.default)((middlewareConfig == null ? void 0 : middlewareConfig.unstable_allowDynamicGlobs) ?? [])(name);
|
||||
}
|
||||
function buildUnsupportedApiError({ apiName, loc, ...rest }) {
|
||||
return buildWebpackError({
|
||||
message: `A Node.js API is used (${apiName} at line: ${loc.start.line}) which is not supported in the Edge Runtime.
|
||||
Learn more: https://nextjs.org/docs/api-reference/edge-runtime`,
|
||||
loc,
|
||||
...rest
|
||||
});
|
||||
}
|
||||
function registerUnsupportedApiHooks(parser, compilation) {
|
||||
for (const expression of _constants.EDGE_UNSUPPORTED_NODE_APIS){
|
||||
const warnForUnsupportedApi = (node)=>{
|
||||
if (!isInMiddlewareLayer(parser)) {
|
||||
return;
|
||||
}
|
||||
compilation.warnings.push(buildUnsupportedApiError({
|
||||
compilation,
|
||||
parser,
|
||||
apiName: expression,
|
||||
...node
|
||||
}));
|
||||
return true;
|
||||
};
|
||||
parser.hooks.call.for(expression).tap(NAME, warnForUnsupportedApi);
|
||||
parser.hooks.expression.for(expression).tap(NAME, warnForUnsupportedApi);
|
||||
parser.hooks.callMemberChain.for(expression).tap(NAME, warnForUnsupportedApi);
|
||||
parser.hooks.expressionMemberChain.for(expression).tap(NAME, warnForUnsupportedApi);
|
||||
}
|
||||
const warnForUnsupportedProcessApi = (node, [callee])=>{
|
||||
if (!isInMiddlewareLayer(parser) || callee === "env") {
|
||||
return;
|
||||
}
|
||||
compilation.warnings.push(buildUnsupportedApiError({
|
||||
compilation,
|
||||
parser,
|
||||
apiName: `process.${callee}`,
|
||||
...node
|
||||
}));
|
||||
return true;
|
||||
};
|
||||
parser.hooks.callMemberChain.for("process").tap(NAME, warnForUnsupportedProcessApi);
|
||||
parser.hooks.expressionMemberChain.for("process").tap(NAME, warnForUnsupportedProcessApi);
|
||||
}
|
||||
function getCodeAnalyzer(params) {
|
||||
return (parser)=>{
|
||||
const { dev, compiler: { webpack: wp }, compilation } = params;
|
||||
const { hooks } = parser;
|
||||
/**
|
||||
* For an expression this will check the graph to ensure it is being used
|
||||
* by exports. Then it will store in the module buildInfo a boolean to
|
||||
* express that it contains dynamic code and, if it is available, the
|
||||
* module path that is using it.
|
||||
*/ const handleExpression = ()=>{
|
||||
if (!isInMiddlewareLayer(parser)) {
|
||||
return;
|
||||
}
|
||||
wp.optimize.InnerGraph.onUsage(parser.state, (used = true)=>{
|
||||
const buildInfo = (0, _getmodulebuildinfo.getModuleBuildInfo)(parser.state.module);
|
||||
if (buildInfo.usingIndirectEval === true || used === false) {
|
||||
return;
|
||||
}
|
||||
if (!buildInfo.usingIndirectEval || used === true) {
|
||||
buildInfo.usingIndirectEval = used;
|
||||
return;
|
||||
}
|
||||
buildInfo.usingIndirectEval = new Set([
|
||||
...Array.from(buildInfo.usingIndirectEval),
|
||||
...Array.from(used)
|
||||
]);
|
||||
});
|
||||
};
|
||||
/**
|
||||
* This expression handler allows to wrap a dynamic code expression with a
|
||||
* function call where we can warn about dynamic code not being allowed
|
||||
* but actually execute the expression.
|
||||
*/ const handleWrapExpression = (expr)=>{
|
||||
if (!isInMiddlewareLayer(parser)) {
|
||||
return;
|
||||
}
|
||||
const { ConstDependency } = wp.dependencies;
|
||||
const dep1 = new ConstDependency("__next_eval__(function() { return ", expr.range[0]);
|
||||
dep1.loc = expr.loc;
|
||||
parser.state.module.addPresentationalDependency(dep1);
|
||||
const dep2 = new ConstDependency("})", expr.range[1]);
|
||||
dep2.loc = expr.loc;
|
||||
parser.state.module.addPresentationalDependency(dep2);
|
||||
handleExpression();
|
||||
return true;
|
||||
};
|
||||
/**
|
||||
* This expression handler allows to wrap a WebAssembly.compile invocation with a
|
||||
* function call where we can warn about WASM code generation not being allowed
|
||||
* but actually execute the expression.
|
||||
*/ const handleWrapWasmCompileExpression = (expr)=>{
|
||||
if (!isInMiddlewareLayer(parser)) {
|
||||
return;
|
||||
}
|
||||
const { ConstDependency } = wp.dependencies;
|
||||
const dep1 = new ConstDependency("__next_webassembly_compile__(function() { return ", expr.range[0]);
|
||||
dep1.loc = expr.loc;
|
||||
parser.state.module.addPresentationalDependency(dep1);
|
||||
const dep2 = new ConstDependency("})", expr.range[1]);
|
||||
dep2.loc = expr.loc;
|
||||
parser.state.module.addPresentationalDependency(dep2);
|
||||
handleExpression();
|
||||
};
|
||||
/**
|
||||
* This expression handler allows to wrap a WebAssembly.instatiate invocation with a
|
||||
* function call where we can warn about WASM code generation not being allowed
|
||||
* but actually execute the expression.
|
||||
*
|
||||
* Note that we don't update `usingIndirectEval`, i.e. we don't abort a production build
|
||||
* since we can't determine statically if the first parameter is a module (legit use) or
|
||||
* a buffer (dynamic code generation).
|
||||
*/ const handleWrapWasmInstantiateExpression = (expr)=>{
|
||||
if (!isInMiddlewareLayer(parser)) {
|
||||
return;
|
||||
}
|
||||
if (dev) {
|
||||
const { ConstDependency } = wp.dependencies;
|
||||
const dep1 = new ConstDependency("__next_webassembly_instantiate__(function() { return ", expr.range[0]);
|
||||
dep1.loc = expr.loc;
|
||||
parser.state.module.addPresentationalDependency(dep1);
|
||||
const dep2 = new ConstDependency("})", expr.range[1]);
|
||||
dep2.loc = expr.loc;
|
||||
parser.state.module.addPresentationalDependency(dep2);
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Handler to store original source location of static and dynamic imports into module's buildInfo.
|
||||
*/ const handleImport = (node)=>{
|
||||
var _node_source;
|
||||
if (isInMiddlewareLayer(parser) && ((_node_source = node.source) == null ? void 0 : _node_source.value) && (node == null ? void 0 : node.loc)) {
|
||||
var _node_source_value;
|
||||
const { module: module1, source } = parser.state;
|
||||
const buildInfo = (0, _getmodulebuildinfo.getModuleBuildInfo)(module1);
|
||||
if (!buildInfo.importLocByPath) {
|
||||
buildInfo.importLocByPath = new Map();
|
||||
}
|
||||
const importedModule = (_node_source_value = node.source.value) == null ? void 0 : _node_source_value.toString();
|
||||
buildInfo.importLocByPath.set(importedModule, {
|
||||
sourcePosition: {
|
||||
...node.loc.start,
|
||||
source: module1.identifier()
|
||||
},
|
||||
sourceContent: source.toString()
|
||||
});
|
||||
if (!dev && isNodeJsModule(importedModule)) {
|
||||
compilation.warnings.push(buildWebpackError({
|
||||
message: `A Node.js module is loaded ('${importedModule}' at line ${node.loc.start.line}) which is not supported in the Edge Runtime.
|
||||
Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`,
|
||||
compilation,
|
||||
parser,
|
||||
...node
|
||||
}));
|
||||
}
|
||||
}
|
||||
};
|
||||
/**
|
||||
* A noop handler to skip analyzing some cases.
|
||||
* Order matters: for it to work, it must be registered first
|
||||
*/ const skip = ()=>isInMiddlewareLayer(parser) ? true : undefined;
|
||||
for (const prefix of [
|
||||
"",
|
||||
"global."
|
||||
]){
|
||||
hooks.expression.for(`${prefix}Function.prototype`).tap(NAME, skip);
|
||||
hooks.expression.for(`${prefix}Function.bind`).tap(NAME, skip);
|
||||
hooks.call.for(`${prefix}eval`).tap(NAME, handleWrapExpression);
|
||||
hooks.call.for(`${prefix}Function`).tap(NAME, handleWrapExpression);
|
||||
hooks.new.for(`${prefix}Function`).tap(NAME, handleWrapExpression);
|
||||
hooks.call.for(`${prefix}WebAssembly.compile`).tap(NAME, handleWrapWasmCompileExpression);
|
||||
hooks.call.for(`${prefix}WebAssembly.instantiate`).tap(NAME, handleWrapWasmInstantiateExpression);
|
||||
}
|
||||
hooks.importCall.tap(NAME, handleImport);
|
||||
hooks.import.tap(NAME, handleImport);
|
||||
if (!dev) {
|
||||
// do not issue compilation warning on dev: invoking code will provide details
|
||||
registerUnsupportedApiHooks(parser, compilation);
|
||||
}
|
||||
};
|
||||
}
|
||||
function getExtractMetadata(params) {
|
||||
const { dev, compilation, metadataByEntry, compiler } = params;
|
||||
const { webpack: wp } = compiler;
|
||||
return async ()=>{
|
||||
metadataByEntry.clear();
|
||||
const telemetry = _shared.traceGlobals.get("telemetry");
|
||||
for (const [entryName, entry] of compilation.entries){
|
||||
var _entry_dependencies, _route_middlewareConfig;
|
||||
if (entry.options.runtime !== _constants.EDGE_RUNTIME_WEBPACK) {
|
||||
continue;
|
||||
}
|
||||
const entryDependency = (_entry_dependencies = entry.dependencies) == null ? void 0 : _entry_dependencies[0];
|
||||
const resolvedModule = compilation.moduleGraph.getResolvedModule(entryDependency);
|
||||
if (!resolvedModule) {
|
||||
continue;
|
||||
}
|
||||
const { rootDir, route } = (0, _getmodulebuildinfo.getModuleBuildInfo)(resolvedModule);
|
||||
const { moduleGraph } = compilation;
|
||||
const modules = new Set();
|
||||
const addEntriesFromDependency = (dependency)=>{
|
||||
const module1 = moduleGraph.getModule(dependency);
|
||||
if (module1) {
|
||||
modules.add(module1);
|
||||
}
|
||||
};
|
||||
entry.dependencies.forEach(addEntriesFromDependency);
|
||||
entry.includeDependencies.forEach(addEntriesFromDependency);
|
||||
const entryMetadata = {
|
||||
wasmBindings: new Map(),
|
||||
assetBindings: new Map()
|
||||
};
|
||||
if (route == null ? void 0 : (_route_middlewareConfig = route.middlewareConfig) == null ? void 0 : _route_middlewareConfig.regions) {
|
||||
entryMetadata.regions = route.middlewareConfig.regions;
|
||||
}
|
||||
if (route == null ? void 0 : route.preferredRegion) {
|
||||
const preferredRegion = route.preferredRegion;
|
||||
entryMetadata.regions = // Ensures preferredRegion is always an array in the manifest.
|
||||
typeof preferredRegion === "string" ? [
|
||||
preferredRegion
|
||||
] : preferredRegion;
|
||||
}
|
||||
let ogImageGenerationCount = 0;
|
||||
for (const module1 of modules){
|
||||
const buildInfo = (0, _getmodulebuildinfo.getModuleBuildInfo)(module1);
|
||||
/**
|
||||
* Check if it uses the image generation feature.
|
||||
*/ if (!dev) {
|
||||
const resource = module1.resource;
|
||||
const hasOGImageGeneration = resource && /[\\/]node_modules[\\/]@vercel[\\/]og[\\/]dist[\\/]index\.(edge|node)\.js$|[\\/]next[\\/]dist[\\/](esm[\\/])?server[\\/]og[\\/]image-response\.js$/.test(resource);
|
||||
if (hasOGImageGeneration) {
|
||||
ogImageGenerationCount++;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* When building for production checks if the module is using `eval`
|
||||
* and in such case produces a compilation error. The module has to
|
||||
* be in use.
|
||||
*/ if (!dev && buildInfo.usingIndirectEval && isUsingIndirectEvalAndUsedByExports({
|
||||
module: module1,
|
||||
moduleGraph,
|
||||
runtime: wp.util.runtime.getEntryRuntime(compilation, entryName),
|
||||
usingIndirectEval: buildInfo.usingIndirectEval,
|
||||
wp
|
||||
})) {
|
||||
var _route_middlewareConfig1;
|
||||
const id = module1.identifier();
|
||||
if (/node_modules[\\/]regenerator-runtime[\\/]runtime\.js/.test(id)) {
|
||||
continue;
|
||||
}
|
||||
if (route == null ? void 0 : (_route_middlewareConfig1 = route.middlewareConfig) == null ? void 0 : _route_middlewareConfig1.unstable_allowDynamicGlobs) {
|
||||
telemetry == null ? void 0 : telemetry.record({
|
||||
eventName: "NEXT_EDGE_ALLOW_DYNAMIC_USED",
|
||||
payload: {
|
||||
file: route == null ? void 0 : route.absolutePagePath.replace(rootDir ?? "", ""),
|
||||
config: route == null ? void 0 : route.middlewareConfig,
|
||||
fileWithDynamicCode: module1.userRequest.replace(rootDir ?? "", "")
|
||||
}
|
||||
});
|
||||
}
|
||||
if (!isDynamicCodeEvaluationAllowed(module1.userRequest, route == null ? void 0 : route.middlewareConfig, rootDir)) {
|
||||
const message = `Dynamic Code Evaluation (e. g. 'eval', 'new Function', 'WebAssembly.compile') not allowed in Edge Runtime ${typeof buildInfo.usingIndirectEval !== "boolean" ? `\nUsed by ${Array.from(buildInfo.usingIndirectEval).join(", ")}` : ""}\nLearn More: https://nextjs.org/docs/messages/edge-dynamic-code-evaluation`;
|
||||
compilation.errors.push((0, _parsedynamiccodeevaluationerror.getDynamicCodeEvaluationError)(message, module1, compilation, compiler));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* The entry module has to be either a page or a middleware and hold
|
||||
* the corresponding metadata.
|
||||
*/ if (buildInfo == null ? void 0 : buildInfo.nextEdgeSSR) {
|
||||
entryMetadata.edgeSSR = buildInfo.nextEdgeSSR;
|
||||
} else if (buildInfo == null ? void 0 : buildInfo.nextEdgeMiddleware) {
|
||||
entryMetadata.edgeMiddleware = buildInfo.nextEdgeMiddleware;
|
||||
} else if (buildInfo == null ? void 0 : buildInfo.nextEdgeApiFunction) {
|
||||
entryMetadata.edgeApiFunction = buildInfo.nextEdgeApiFunction;
|
||||
}
|
||||
/**
|
||||
* If the module is a WASM module we read the binding information and
|
||||
* append it to the entry wasm bindings.
|
||||
*/ if (buildInfo == null ? void 0 : buildInfo.nextWasmMiddlewareBinding) {
|
||||
entryMetadata.wasmBindings.set(buildInfo.nextWasmMiddlewareBinding.name, buildInfo.nextWasmMiddlewareBinding.filePath);
|
||||
}
|
||||
if (buildInfo == null ? void 0 : buildInfo.nextAssetMiddlewareBinding) {
|
||||
entryMetadata.assetBindings.set(buildInfo.nextAssetMiddlewareBinding.name, buildInfo.nextAssetMiddlewareBinding.filePath);
|
||||
}
|
||||
/**
|
||||
* Append to the list of modules to process outgoingConnections from
|
||||
* the module that is being processed.
|
||||
*/ for (const conn of (0, _utils1.getModuleReferencesInOrder)(module1, moduleGraph)){
|
||||
if (conn.module) {
|
||||
modules.add(conn.module);
|
||||
}
|
||||
}
|
||||
}
|
||||
telemetry == null ? void 0 : telemetry.record({
|
||||
eventName: _events.EVENT_BUILD_FEATURE_USAGE,
|
||||
payload: {
|
||||
featureName: "vercelImageGeneration",
|
||||
invocationCount: ogImageGenerationCount
|
||||
}
|
||||
});
|
||||
metadataByEntry.set(entryName, entryMetadata);
|
||||
}
|
||||
};
|
||||
}
|
||||
class MiddlewarePlugin {
|
||||
constructor({ dev, sriEnabled, rewrites, edgeEnvironments }){
|
||||
this.dev = dev;
|
||||
this.sriEnabled = sriEnabled;
|
||||
this.rewrites = rewrites;
|
||||
this.edgeEnvironments = edgeEnvironments;
|
||||
}
|
||||
apply(compiler) {
|
||||
compiler.hooks.compilation.tap(NAME, (compilation, params)=>{
|
||||
const { hooks } = params.normalModuleFactory;
|
||||
/**
|
||||
* This is the static code analysis phase.
|
||||
*/ const codeAnalyzer = getCodeAnalyzer({
|
||||
dev: this.dev,
|
||||
compiler,
|
||||
compilation
|
||||
});
|
||||
hooks.parser.for("javascript/auto").tap(NAME, codeAnalyzer);
|
||||
hooks.parser.for("javascript/dynamic").tap(NAME, codeAnalyzer);
|
||||
hooks.parser.for("javascript/esm").tap(NAME, codeAnalyzer);
|
||||
/**
|
||||
* Extract all metadata for the entry points in a Map object.
|
||||
*/ const metadataByEntry = new Map();
|
||||
compilation.hooks.finishModules.tapPromise(NAME, getExtractMetadata({
|
||||
compilation,
|
||||
compiler,
|
||||
dev: this.dev,
|
||||
metadataByEntry
|
||||
}));
|
||||
/**
|
||||
* Emit the middleware manifest.
|
||||
*/ compilation.hooks.processAssets.tap({
|
||||
name: "NextJsMiddlewareManifest",
|
||||
stage: _webpack.webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS
|
||||
}, getCreateAssets({
|
||||
compilation,
|
||||
metadataByEntry,
|
||||
opts: {
|
||||
sriEnabled: this.sriEnabled,
|
||||
rewrites: this.rewrites,
|
||||
edgeEnvironments: this.edgeEnvironments
|
||||
}
|
||||
}));
|
||||
});
|
||||
}
|
||||
}
|
||||
const SUPPORTED_NATIVE_MODULES = [
|
||||
"buffer",
|
||||
"events",
|
||||
"assert",
|
||||
"util",
|
||||
"async_hooks"
|
||||
];
|
||||
const supportedEdgePolyfills = new Set(SUPPORTED_NATIVE_MODULES);
|
||||
function getEdgePolyfilledModules() {
|
||||
const records = {};
|
||||
for (const mod of SUPPORTED_NATIVE_MODULES){
|
||||
records[mod] = `commonjs node:${mod}`;
|
||||
records[`node:${mod}`] = `commonjs node:${mod}`;
|
||||
}
|
||||
return records;
|
||||
}
|
||||
async function handleWebpackExternalForEdgeRuntime({ request, context, contextInfo, getResolve }) {
|
||||
if (contextInfo.issuerLayer === "middleware" && isNodeJsModule(request) && !supportedEdgePolyfills.has(request)) {
|
||||
// allows user to provide and use their polyfills, as we do with buffer.
|
||||
try {
|
||||
await getResolve()(context, request);
|
||||
} catch {
|
||||
return `root globalThis.__import_unsupported('${request}')`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=middleware-plugin.js.map
|
||||
25
.next/standalone/node_modules/next/dist/build/webpack/plugins/mini-css-extract-plugin.js
generated
vendored
Normal file
25
.next/standalone/node_modules/next/dist/build/webpack/plugins/mini-css-extract-plugin.js
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
// @ts-ignore: TODO: remove when webpack 5 is stable
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "default", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return NextMiniCssExtractPlugin;
|
||||
}
|
||||
});
|
||||
const _minicssextractplugin = /*#__PURE__*/ _interop_require_default(require("next/dist/compiled/mini-css-extract-plugin"));
|
||||
function _interop_require_default(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
class NextMiniCssExtractPlugin extends _minicssextractplugin.default {
|
||||
constructor(...args){
|
||||
super(...args);
|
||||
this.__next_css_remove = true;
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=mini-css-extract-plugin.js.map
|
||||
85
.next/standalone/node_modules/next/dist/build/webpack/plugins/next-drop-client-page-plugin.js
generated
vendored
Normal file
85
.next/standalone/node_modules/next/dist/build/webpack/plugins/next-drop-client-page-plugin.js
generated
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
0 && (module.exports = {
|
||||
DropClientPage: null,
|
||||
ampFirstEntryNamesMap: null
|
||||
});
|
||||
function _export(target, all) {
|
||||
for(var name in all)Object.defineProperty(target, name, {
|
||||
enumerable: true,
|
||||
get: all[name]
|
||||
});
|
||||
}
|
||||
_export(exports, {
|
||||
DropClientPage: function() {
|
||||
return DropClientPage;
|
||||
},
|
||||
ampFirstEntryNamesMap: function() {
|
||||
return ampFirstEntryNamesMap;
|
||||
}
|
||||
});
|
||||
const _constants = require("../../../shared/lib/constants");
|
||||
const ampFirstEntryNamesMap = new WeakMap();
|
||||
const PLUGIN_NAME = "DropAmpFirstPagesPlugin";
|
||||
class DropClientPage {
|
||||
apply(compiler) {
|
||||
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation, { normalModuleFactory })=>{
|
||||
// Recursively look up the issuer till it ends up at the root
|
||||
function findEntryModule(mod) {
|
||||
const queue = new Set([
|
||||
mod
|
||||
]);
|
||||
for (const module1 of queue){
|
||||
const incomingConnections = compilation.moduleGraph.getIncomingConnections(module1);
|
||||
for (const incomingConnection of incomingConnections){
|
||||
if (!incomingConnection.originModule) return module1;
|
||||
queue.add(incomingConnection.originModule);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
function handler(parser) {
|
||||
function markAsAmpFirst() {
|
||||
const entryModule = findEntryModule(parser.state.module);
|
||||
if (!entryModule) {
|
||||
return;
|
||||
}
|
||||
// @ts-ignore buildInfo exists on Module
|
||||
entryModule.buildInfo.NEXT_ampFirst = true;
|
||||
}
|
||||
parser.hooks.preDeclarator.tap(PLUGIN_NAME, (declarator)=>{
|
||||
var _declarator_id;
|
||||
if ((declarator == null ? void 0 : (_declarator_id = declarator.id) == null ? void 0 : _declarator_id.name) === _constants.STRING_LITERAL_DROP_BUNDLE) {
|
||||
markAsAmpFirst();
|
||||
}
|
||||
});
|
||||
}
|
||||
normalModuleFactory.hooks.parser.for("javascript/auto").tap(PLUGIN_NAME, handler);
|
||||
normalModuleFactory.hooks.parser.for("javascript/esm").tap(PLUGIN_NAME, handler);
|
||||
normalModuleFactory.hooks.parser.for("javascript/dynamic").tap(PLUGIN_NAME, handler);
|
||||
if (!ampFirstEntryNamesMap.has(compilation)) {
|
||||
ampFirstEntryNamesMap.set(compilation, []);
|
||||
}
|
||||
const ampFirstEntryNamesItem = ampFirstEntryNamesMap.get(compilation);
|
||||
compilation.hooks.seal.tap(PLUGIN_NAME, ()=>{
|
||||
for (const [name, entryData] of compilation.entries){
|
||||
for (const dependency of entryData.dependencies){
|
||||
var _module_buildInfo;
|
||||
const module1 = compilation.moduleGraph.getModule(dependency);
|
||||
if (module1 == null ? void 0 : (_module_buildInfo = module1.buildInfo) == null ? void 0 : _module_buildInfo.NEXT_ampFirst) {
|
||||
ampFirstEntryNamesItem.push(name);
|
||||
compilation.entries.delete(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
constructor(){
|
||||
this.ampPages = new Set();
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=next-drop-client-page-plugin.js.map
|
||||
120
.next/standalone/node_modules/next/dist/build/webpack/plugins/next-font-manifest-plugin.js
generated
vendored
Normal file
120
.next/standalone/node_modules/next/dist/build/webpack/plugins/next-font-manifest-plugin.js
generated
vendored
Normal file
@@ -0,0 +1,120 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "NextFontManifestPlugin", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return NextFontManifestPlugin;
|
||||
}
|
||||
});
|
||||
const _webpack = require("next/dist/compiled/webpack/webpack");
|
||||
const _getroutefromentrypoint = /*#__PURE__*/ _interop_require_default(require("../../../server/get-route-from-entrypoint"));
|
||||
const _constants = require("../../../shared/lib/constants");
|
||||
const _utils = require("../utils");
|
||||
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
||||
function _interop_require_default(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
const PLUGIN_NAME = "NextFontManifestPlugin";
|
||||
/**
|
||||
* When calling font functions with next/font, you can specify if you'd like the font to be preloaded (true by default).
|
||||
* e.g.: const inter = Inter({ subsets: ['latin'], preload: true })
|
||||
*
|
||||
* In that case, next-font-loader will emit the font file as [name].p.[ext] instead of [name].[ext]
|
||||
* This function returns those files from an array that can include both preloaded and non-preloaded files.
|
||||
*/ function getPreloadedFontFiles(fontFiles) {
|
||||
return fontFiles.filter((file)=>/\.p\.(woff|woff2|eot|ttf|otf)$/.test(file));
|
||||
}
|
||||
/**
|
||||
* Similarly to getPreloadedFontFiles, but returns true if some of the files includes -s in the name.
|
||||
* This means that a font is using size adjust in its fallback font.
|
||||
* This was added to enable adding data-size-adjust="true" to the dom, used by the Google Aurora team to collect statistics.
|
||||
*/ function getPageIsUsingSizeAdjust(fontFiles) {
|
||||
return fontFiles.some((file)=>file.includes("-s"));
|
||||
}
|
||||
class NextFontManifestPlugin {
|
||||
constructor(options){
|
||||
this.appDir = options.appDir;
|
||||
}
|
||||
apply(compiler) {
|
||||
compiler.hooks.make.tap(PLUGIN_NAME, (compilation)=>{
|
||||
// In this stage the font files are emitted and we can collect all files emitted by each chunkGroup (entry).
|
||||
compilation.hooks.processAssets.tap({
|
||||
name: PLUGIN_NAME,
|
||||
stage: _webpack.webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS
|
||||
}, (assets)=>{
|
||||
const nextFontManifest = {
|
||||
pages: {},
|
||||
app: {},
|
||||
appUsingSizeAdjust: false,
|
||||
pagesUsingSizeAdjust: false
|
||||
};
|
||||
if (this.appDir) {
|
||||
const appDirBase = _path.default.dirname(this.appDir) + _path.default.sep;
|
||||
// After all modules are created, we collect the modules that was created by next-font-loader.
|
||||
(0, _utils.traverseModules)(compilation, (mod, _chunk, chunkGroup)=>{
|
||||
var _mod_request;
|
||||
if (mod == null ? void 0 : (_mod_request = mod.request) == null ? void 0 : _mod_request.includes("/next-font-loader/index.js?")) {
|
||||
var _mod_buildInfo;
|
||||
if (!((_mod_buildInfo = mod.buildInfo) == null ? void 0 : _mod_buildInfo.assets)) return;
|
||||
const chunkEntryName = (appDirBase + chunkGroup.name).replace(/[\\/]/g, _path.default.sep);
|
||||
const modAssets = Object.keys(mod.buildInfo.assets);
|
||||
const fontFiles = modAssets.filter((file)=>/\.(woff|woff2|eot|ttf|otf)$/.test(file));
|
||||
// Look if size-adjust fallback font is being used
|
||||
if (!nextFontManifest.appUsingSizeAdjust) {
|
||||
nextFontManifest.appUsingSizeAdjust = getPageIsUsingSizeAdjust(fontFiles);
|
||||
}
|
||||
const preloadedFontFiles = getPreloadedFontFiles(fontFiles);
|
||||
// Add an entry of the module's font files in the manifest.
|
||||
// We'll add an entry even if no files should preload.
|
||||
// When an entry is present but empty, instead of preloading the font files, a preconnect tag is added.
|
||||
if (fontFiles.length > 0) {
|
||||
if (!nextFontManifest.app[chunkEntryName]) {
|
||||
nextFontManifest.app[chunkEntryName] = [];
|
||||
}
|
||||
nextFontManifest.app[chunkEntryName].push(...preloadedFontFiles);
|
||||
}
|
||||
}
|
||||
}, (chunkGroup)=>{
|
||||
var _chunkGroup_name;
|
||||
// Only loop through entrypoints that are under app/.
|
||||
return !!((_chunkGroup_name = chunkGroup.name) == null ? void 0 : _chunkGroup_name.startsWith("app/"));
|
||||
});
|
||||
}
|
||||
// Look at all the entrypoints created for pages/.
|
||||
for (const entrypoint of compilation.entrypoints.values()){
|
||||
const pagePath = (0, _getroutefromentrypoint.default)(entrypoint.name);
|
||||
if (!pagePath) {
|
||||
continue;
|
||||
}
|
||||
// Get font files from the chunks included in the entrypoint.
|
||||
const fontFiles = entrypoint.chunks.flatMap((chunk)=>[
|
||||
...chunk.auxiliaryFiles
|
||||
]).filter((file)=>/\.(woff|woff2|eot|ttf|otf)$/.test(file));
|
||||
// Look if size-adjust fallback font is being used
|
||||
if (!nextFontManifest.pagesUsingSizeAdjust) {
|
||||
nextFontManifest.pagesUsingSizeAdjust = getPageIsUsingSizeAdjust(fontFiles);
|
||||
}
|
||||
const preloadedFontFiles = getPreloadedFontFiles(fontFiles);
|
||||
// Add an entry of the route's font files in the manifest.
|
||||
// We'll add an entry even if no files should preload.
|
||||
// When an entry is present but empty, instead of preloading the font files, a preconnect tag is added.
|
||||
if (fontFiles.length > 0) {
|
||||
nextFontManifest.pages[pagePath] = preloadedFontFiles;
|
||||
}
|
||||
}
|
||||
const manifest = JSON.stringify(nextFontManifest, null);
|
||||
// Create manifest for edge
|
||||
assets[`server/${_constants.NEXT_FONT_MANIFEST}.js`] = new _webpack.sources.RawSource(`self.__NEXT_FONT_MANIFEST=${JSON.stringify(manifest)}`);
|
||||
// Create manifest for server
|
||||
assets[`server/${_constants.NEXT_FONT_MANIFEST}.json`] = new _webpack.sources.RawSource(manifest);
|
||||
});
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=next-font-manifest-plugin.js.map
|
||||
524
.next/standalone/node_modules/next/dist/build/webpack/plugins/next-trace-entrypoints-plugin.js
generated
vendored
Normal file
524
.next/standalone/node_modules/next/dist/build/webpack/plugins/next-trace-entrypoints-plugin.js
generated
vendored
Normal file
@@ -0,0 +1,524 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
0 && (module.exports = {
|
||||
TRACE_IGNORES: null,
|
||||
TraceEntryPointsPlugin: null,
|
||||
getFilesMapFromReasons: null
|
||||
});
|
||||
function _export(target, all) {
|
||||
for(var name in all)Object.defineProperty(target, name, {
|
||||
enumerable: true,
|
||||
get: all[name]
|
||||
});
|
||||
}
|
||||
_export(exports, {
|
||||
TRACE_IGNORES: function() {
|
||||
return TRACE_IGNORES;
|
||||
},
|
||||
TraceEntryPointsPlugin: function() {
|
||||
return TraceEntryPointsPlugin;
|
||||
},
|
||||
getFilesMapFromReasons: function() {
|
||||
return getFilesMapFromReasons;
|
||||
}
|
||||
});
|
||||
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
||||
const _profilingplugin = require("./profiling-plugin");
|
||||
const _iserror = /*#__PURE__*/ _interop_require_default(require("../../../lib/is-error"));
|
||||
const _nft = require("next/dist/compiled/@vercel/nft");
|
||||
const _constants = require("../../../shared/lib/constants");
|
||||
const _webpack = require("next/dist/compiled/webpack/webpack");
|
||||
const _webpackconfig = require("../../webpack-config");
|
||||
const _swc = require("../../swc");
|
||||
const _picomatch = /*#__PURE__*/ _interop_require_default(require("next/dist/compiled/picomatch"));
|
||||
const _getmodulebuildinfo = require("../loaders/get-module-build-info");
|
||||
const _entries = require("../../entries");
|
||||
const _handleexternals = require("../../handle-externals");
|
||||
function _interop_require_default(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
const PLUGIN_NAME = "TraceEntryPointsPlugin";
|
||||
const TRACE_IGNORES = [
|
||||
"**/*/next/dist/server/next.js",
|
||||
"**/*/next/dist/bin/next"
|
||||
];
|
||||
const NOT_TRACEABLE = [
|
||||
".wasm",
|
||||
".png",
|
||||
".jpg",
|
||||
".jpeg",
|
||||
".gif",
|
||||
".webp",
|
||||
".avif",
|
||||
".ico",
|
||||
".bmp",
|
||||
".svg"
|
||||
];
|
||||
function getModuleFromDependency(compilation, dep) {
|
||||
return compilation.moduleGraph.getModule(dep);
|
||||
}
|
||||
function getFilesMapFromReasons(fileList, reasons, ignoreFn) {
|
||||
// this uses the reasons tree to collect files specific to a
|
||||
// certain parent allowing us to not have to trace each parent
|
||||
// separately
|
||||
const parentFilesMap = new Map();
|
||||
function propagateToParents(parents, file, seen = new Set()) {
|
||||
for (const parent of parents || []){
|
||||
if (!seen.has(parent)) {
|
||||
seen.add(parent);
|
||||
let parentFiles = parentFilesMap.get(parent);
|
||||
if (!parentFiles) {
|
||||
parentFiles = new Set();
|
||||
parentFilesMap.set(parent, parentFiles);
|
||||
}
|
||||
if (!(ignoreFn == null ? void 0 : ignoreFn(file, parent))) {
|
||||
parentFiles.add(file);
|
||||
}
|
||||
const parentReason = reasons.get(parent);
|
||||
if (parentReason == null ? void 0 : parentReason.parents) {
|
||||
propagateToParents(parentReason.parents, file, seen);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (const file of fileList){
|
||||
const reason = reasons.get(file);
|
||||
const isInitial = (reason == null ? void 0 : reason.type.length) === 1 && reason.type.includes("initial");
|
||||
if (!reason || !reason.parents || isInitial && reason.parents.size === 0) {
|
||||
continue;
|
||||
}
|
||||
propagateToParents(reason.parents, file);
|
||||
}
|
||||
return parentFilesMap;
|
||||
}
|
||||
class TraceEntryPointsPlugin {
|
||||
constructor({ rootDir, appDir, pagesDir, optOutBundlingPackages, appDirEnabled, traceIgnores, esmExternals, outputFileTracingRoot, turbotrace }){
|
||||
this.buildTraceContext = {};
|
||||
this.rootDir = rootDir;
|
||||
this.appDir = appDir;
|
||||
this.pagesDir = pagesDir;
|
||||
this.entryTraces = new Map();
|
||||
this.esmExternals = esmExternals;
|
||||
this.appDirEnabled = appDirEnabled;
|
||||
this.traceIgnores = traceIgnores || [];
|
||||
this.tracingRoot = outputFileTracingRoot || rootDir;
|
||||
this.turbotrace = turbotrace;
|
||||
this.optOutBundlingPackages = optOutBundlingPackages;
|
||||
}
|
||||
// Here we output all traced assets and webpack chunks to a
|
||||
// ${page}.js.nft.json file
|
||||
async createTraceAssets(compilation, assets, span) {
|
||||
const outputPath = compilation.outputOptions.path;
|
||||
await span.traceChild("create-trace-assets").traceAsyncFn(async ()=>{
|
||||
var _this_turbotrace, _this_turbotrace1, _this_turbotrace2, _this_turbotrace3;
|
||||
const entryFilesMap = new Map();
|
||||
const chunksToTrace = new Set();
|
||||
const entryNameFilesMap = new Map();
|
||||
const isTraceable = (file)=>!NOT_TRACEABLE.some((suffix)=>{
|
||||
return file.endsWith(suffix);
|
||||
});
|
||||
for (const entrypoint of compilation.entrypoints.values()){
|
||||
const entryFiles = new Set();
|
||||
for (const chunk of entrypoint.getEntrypointChunk().getAllReferencedChunks()){
|
||||
for (const file of chunk.files){
|
||||
if (isTraceable(file)) {
|
||||
const filePath = _path.default.join(outputPath, file);
|
||||
chunksToTrace.add(filePath);
|
||||
entryFiles.add(filePath);
|
||||
}
|
||||
}
|
||||
for (const file of chunk.auxiliaryFiles){
|
||||
if (isTraceable(file)) {
|
||||
const filePath = _path.default.join(outputPath, file);
|
||||
chunksToTrace.add(filePath);
|
||||
entryFiles.add(filePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
entryFilesMap.set(entrypoint, entryFiles);
|
||||
entryNameFilesMap.set(entrypoint.name, [
|
||||
...entryFiles
|
||||
]);
|
||||
}
|
||||
// startTrace existed and callable
|
||||
this.buildTraceContext.chunksTrace = {
|
||||
action: {
|
||||
action: "annotate",
|
||||
input: [
|
||||
...chunksToTrace
|
||||
],
|
||||
contextDirectory: ((_this_turbotrace = this.turbotrace) == null ? void 0 : _this_turbotrace.contextDirectory) ?? this.tracingRoot,
|
||||
processCwd: ((_this_turbotrace1 = this.turbotrace) == null ? void 0 : _this_turbotrace1.processCwd) ?? this.rootDir,
|
||||
showAll: (_this_turbotrace2 = this.turbotrace) == null ? void 0 : _this_turbotrace2.logAll,
|
||||
logLevel: (_this_turbotrace3 = this.turbotrace) == null ? void 0 : _this_turbotrace3.logLevel
|
||||
},
|
||||
outputPath,
|
||||
entryNameFilesMap: Object.fromEntries(entryNameFilesMap)
|
||||
};
|
||||
for (const [entrypoint, entryFiles] of entryFilesMap){
|
||||
const traceOutputName = `../${entrypoint.name}.js.nft.json`;
|
||||
const traceOutputPath = _path.default.dirname(_path.default.join(outputPath, traceOutputName));
|
||||
// don't include the entry itself in the trace
|
||||
entryFiles.delete(_path.default.join(outputPath, `../${entrypoint.name}.js`));
|
||||
if (entrypoint.name.startsWith("app/")) {
|
||||
// include the client reference manifest
|
||||
const clientManifestsForPage = entrypoint.name.endsWith("/page") || entrypoint.name === _constants.UNDERSCORE_NOT_FOUND_ROUTE_ENTRY ? _path.default.join(outputPath, "..", entrypoint.name.replace(/%5F/g, "_") + "_" + _constants.CLIENT_REFERENCE_MANIFEST + ".js") : null;
|
||||
if (clientManifestsForPage !== null) {
|
||||
entryFiles.add(clientManifestsForPage);
|
||||
}
|
||||
}
|
||||
const finalFiles = [];
|
||||
for (const file of new Set([
|
||||
...entryFiles,
|
||||
...this.entryTraces.get(entrypoint.name) || []
|
||||
])){
|
||||
if (file) {
|
||||
finalFiles.push(_path.default.relative(traceOutputPath, file).replace(/\\/g, "/"));
|
||||
}
|
||||
}
|
||||
assets[traceOutputName] = new _webpack.sources.RawSource(JSON.stringify({
|
||||
version: _constants.TRACE_OUTPUT_VERSION,
|
||||
files: finalFiles
|
||||
}));
|
||||
}
|
||||
});
|
||||
}
|
||||
tapfinishModules(compilation, traceEntrypointsPluginSpan, doResolve, readlink, stat) {
|
||||
compilation.hooks.finishModules.tapAsync(PLUGIN_NAME, async (_stats, callback)=>{
|
||||
const finishModulesSpan = traceEntrypointsPluginSpan.traceChild("finish-modules");
|
||||
await finishModulesSpan.traceAsyncFn(async ()=>{
|
||||
var _this_turbotrace, _this_turbotrace1, _this_turbotrace2, _this_turbotrace3;
|
||||
// we create entry -> module maps so that we can
|
||||
// look them up faster instead of having to iterate
|
||||
// over the compilation modules list
|
||||
const entryNameMap = new Map();
|
||||
const entryModMap = new Map();
|
||||
const additionalEntries = new Map();
|
||||
const depModMap = new Map();
|
||||
finishModulesSpan.traceChild("get-entries").traceFn(()=>{
|
||||
compilation.entries.forEach((entry, name)=>{
|
||||
const normalizedName = name == null ? void 0 : name.replace(/\\/g, "/");
|
||||
const isPage = normalizedName.startsWith("pages/");
|
||||
const isApp = this.appDirEnabled && normalizedName.startsWith("app/");
|
||||
if (isApp || isPage) {
|
||||
for (const dep of entry.dependencies){
|
||||
if (!dep) continue;
|
||||
const entryMod = getModuleFromDependency(compilation, dep);
|
||||
// Handle case where entry is a loader coming from Next.js.
|
||||
// For example edge-loader or app-loader.
|
||||
if (entryMod && entryMod.resource === "") {
|
||||
const moduleBuildInfo = (0, _getmodulebuildinfo.getModuleBuildInfo)(entryMod);
|
||||
// All loaders that are used to create entries have a `route` property on the buildInfo.
|
||||
if (moduleBuildInfo.route) {
|
||||
const absolutePath = (0, _entries.getPageFilePath)({
|
||||
absolutePagePath: moduleBuildInfo.route.absolutePagePath,
|
||||
rootDir: this.rootDir,
|
||||
appDir: this.appDir,
|
||||
pagesDir: this.pagesDir
|
||||
});
|
||||
// Ensures we don't handle non-pages.
|
||||
if (this.pagesDir && absolutePath.startsWith(this.pagesDir) || this.appDir && absolutePath.startsWith(this.appDir)) {
|
||||
entryModMap.set(absolutePath, entryMod);
|
||||
entryNameMap.set(absolutePath, name);
|
||||
}
|
||||
}
|
||||
// If there was no `route` property, we can assume that it was something custom instead.
|
||||
// In order to trace these we add them to the additionalEntries map.
|
||||
if (entryMod.request) {
|
||||
let curMap = additionalEntries.get(name);
|
||||
if (!curMap) {
|
||||
curMap = new Map();
|
||||
additionalEntries.set(name, curMap);
|
||||
}
|
||||
depModMap.set(entryMod.request, entryMod);
|
||||
curMap.set(entryMod.resource, entryMod);
|
||||
}
|
||||
}
|
||||
if (entryMod && entryMod.resource) {
|
||||
entryNameMap.set(entryMod.resource, name);
|
||||
entryModMap.set(entryMod.resource, entryMod);
|
||||
let curMap = additionalEntries.get(name);
|
||||
if (!curMap) {
|
||||
curMap = new Map();
|
||||
additionalEntries.set(name, curMap);
|
||||
}
|
||||
depModMap.set(entryMod.resource, entryMod);
|
||||
curMap.set(entryMod.resource, entryMod);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
const readFile = async (path)=>{
|
||||
var _mod_originalSource;
|
||||
const mod = depModMap.get(path) || entryModMap.get(path);
|
||||
// map the transpiled source when available to avoid
|
||||
// parse errors in node-file-trace
|
||||
const source = mod == null ? void 0 : (_mod_originalSource = mod.originalSource) == null ? void 0 : _mod_originalSource.call(mod);
|
||||
if (source) {
|
||||
return source.buffer();
|
||||
}
|
||||
// we don't want to analyze non-transpiled
|
||||
// files here, that is done against webpack output
|
||||
return "";
|
||||
};
|
||||
const entryPaths = Array.from(entryModMap.keys());
|
||||
const collectDependencies = (mod)=>{
|
||||
if (!mod || !mod.dependencies) return;
|
||||
for (const dep of mod.dependencies){
|
||||
const depMod = getModuleFromDependency(compilation, dep);
|
||||
if ((depMod == null ? void 0 : depMod.resource) && !depModMap.get(depMod.resource)) {
|
||||
depModMap.set(depMod.resource, depMod);
|
||||
collectDependencies(depMod);
|
||||
}
|
||||
}
|
||||
};
|
||||
const entriesToTrace = [
|
||||
...entryPaths
|
||||
];
|
||||
entryPaths.forEach((entry)=>{
|
||||
collectDependencies(entryModMap.get(entry));
|
||||
const entryName = entryNameMap.get(entry);
|
||||
const curExtraEntries = additionalEntries.get(entryName);
|
||||
if (curExtraEntries) {
|
||||
entriesToTrace.push(...curExtraEntries.keys());
|
||||
}
|
||||
});
|
||||
const contextDirectory = ((_this_turbotrace = this.turbotrace) == null ? void 0 : _this_turbotrace.contextDirectory) ?? this.tracingRoot;
|
||||
const chunks = [
|
||||
...entriesToTrace
|
||||
];
|
||||
this.buildTraceContext.entriesTrace = {
|
||||
action: {
|
||||
action: "print",
|
||||
input: chunks,
|
||||
contextDirectory,
|
||||
processCwd: ((_this_turbotrace1 = this.turbotrace) == null ? void 0 : _this_turbotrace1.processCwd) ?? this.rootDir,
|
||||
logLevel: (_this_turbotrace2 = this.turbotrace) == null ? void 0 : _this_turbotrace2.logLevel,
|
||||
showAll: (_this_turbotrace3 = this.turbotrace) == null ? void 0 : _this_turbotrace3.logAll
|
||||
},
|
||||
appDir: this.rootDir,
|
||||
depModArray: Array.from(depModMap.keys()),
|
||||
entryNameMap: Object.fromEntries(entryNameMap),
|
||||
outputPath: compilation.outputOptions.path
|
||||
};
|
||||
// if we're using turbotrace we can skip tracing
|
||||
// loader contents as it should be able to capture
|
||||
// fs usage in final chunks instead
|
||||
if (this.turbotrace) {
|
||||
let binding = await (0, _swc.loadBindings)();
|
||||
if (!(binding == null ? void 0 : binding.isWasm) && typeof binding.turbo.startTrace === "function") {
|
||||
return;
|
||||
}
|
||||
}
|
||||
let fileList;
|
||||
let reasons;
|
||||
const ignores = [
|
||||
...TRACE_IGNORES,
|
||||
...this.traceIgnores,
|
||||
"**/node_modules/**"
|
||||
];
|
||||
// pre-compile the ignore matcher to avoid repeating on every ignoreFn call
|
||||
const isIgnoreMatcher = (0, _picomatch.default)(ignores, {
|
||||
contains: true,
|
||||
dot: true
|
||||
});
|
||||
const ignoreFn = (path)=>{
|
||||
return isIgnoreMatcher(path);
|
||||
};
|
||||
await finishModulesSpan.traceChild("node-file-trace-plugin", {
|
||||
traceEntryCount: entriesToTrace.length + ""
|
||||
}).traceAsyncFn(async ()=>{
|
||||
const result = await (0, _nft.nodeFileTrace)(entriesToTrace, {
|
||||
base: this.tracingRoot,
|
||||
processCwd: this.rootDir,
|
||||
readFile,
|
||||
readlink,
|
||||
stat,
|
||||
resolve: doResolve ? async (id, parent, job, isCjs)=>{
|
||||
return doResolve(id, parent, job, !isCjs);
|
||||
} : undefined,
|
||||
ignore: ignoreFn,
|
||||
mixedModules: true
|
||||
});
|
||||
// @ts-ignore
|
||||
fileList = result.fileList;
|
||||
result.esmFileList.forEach((file)=>fileList.add(file));
|
||||
reasons = result.reasons;
|
||||
});
|
||||
await finishModulesSpan.traceChild("collect-traced-files").traceAsyncFn(()=>{
|
||||
const parentFilesMap = getFilesMapFromReasons(fileList, reasons, (file)=>{
|
||||
var _reasons_get;
|
||||
// if a file was imported and a loader handled it
|
||||
// we don't include it in the trace e.g.
|
||||
// static image imports, CSS imports
|
||||
file = _path.default.join(this.tracingRoot, file);
|
||||
const depMod = depModMap.get(file);
|
||||
const isAsset = (_reasons_get = reasons.get(_path.default.relative(this.tracingRoot, file))) == null ? void 0 : _reasons_get.type.includes("asset");
|
||||
return !isAsset && Array.isArray(depMod == null ? void 0 : depMod.loaders) && depMod.loaders.length > 0;
|
||||
});
|
||||
entryPaths.forEach((entry)=>{
|
||||
var _parentFilesMap_get;
|
||||
const entryName = entryNameMap.get(entry);
|
||||
const normalizedEntry = _path.default.relative(this.tracingRoot, entry);
|
||||
const curExtraEntries = additionalEntries.get(entryName);
|
||||
const finalDeps = new Set();
|
||||
(_parentFilesMap_get = parentFilesMap.get(normalizedEntry)) == null ? void 0 : _parentFilesMap_get.forEach((dep)=>{
|
||||
finalDeps.add(_path.default.join(this.tracingRoot, dep));
|
||||
});
|
||||
if (curExtraEntries) {
|
||||
for (const extraEntry of curExtraEntries.keys()){
|
||||
var _parentFilesMap_get1;
|
||||
const normalizedExtraEntry = _path.default.relative(this.tracingRoot, extraEntry);
|
||||
finalDeps.add(extraEntry);
|
||||
(_parentFilesMap_get1 = parentFilesMap.get(normalizedExtraEntry)) == null ? void 0 : _parentFilesMap_get1.forEach((dep)=>{
|
||||
finalDeps.add(_path.default.join(this.tracingRoot, dep));
|
||||
});
|
||||
}
|
||||
}
|
||||
this.entryTraces.set(entryName, finalDeps);
|
||||
});
|
||||
});
|
||||
}).then(()=>callback(), (err)=>callback(err));
|
||||
});
|
||||
}
|
||||
apply(compiler) {
|
||||
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation)=>{
|
||||
const readlink = async (path)=>{
|
||||
try {
|
||||
return await new Promise((resolve, reject)=>{
|
||||
compilation.inputFileSystem.readlink(path, (err, link)=>{
|
||||
if (err) return reject(err);
|
||||
resolve(link);
|
||||
});
|
||||
});
|
||||
} catch (e) {
|
||||
if ((0, _iserror.default)(e) && (e.code === "EINVAL" || e.code === "ENOENT" || e.code === "UNKNOWN")) {
|
||||
return null;
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
const stat = async (path)=>{
|
||||
try {
|
||||
return await new Promise((resolve, reject)=>{
|
||||
compilation.inputFileSystem.stat(path, (err, stats)=>{
|
||||
if (err) return reject(err);
|
||||
resolve(stats);
|
||||
});
|
||||
});
|
||||
} catch (e) {
|
||||
if ((0, _iserror.default)(e) && (e.code === "ENOENT" || e.code === "ENOTDIR")) {
|
||||
return null;
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
const compilationSpan = _profilingplugin.spans.get(compilation) || _profilingplugin.spans.get(compiler);
|
||||
const traceEntrypointsPluginSpan = compilationSpan.traceChild("next-trace-entrypoint-plugin");
|
||||
traceEntrypointsPluginSpan.traceFn(()=>{
|
||||
compilation.hooks.processAssets.tapAsync({
|
||||
name: PLUGIN_NAME,
|
||||
stage: _webpack.webpack.Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE
|
||||
}, (assets, callback)=>{
|
||||
this.createTraceAssets(compilation, assets, traceEntrypointsPluginSpan).then(()=>callback()).catch((err)=>callback(err));
|
||||
});
|
||||
let resolver = compilation.resolverFactory.get("normal");
|
||||
function getPkgName(name) {
|
||||
const segments = name.split("/");
|
||||
if (name[0] === "@" && segments.length > 1) return segments.length > 1 ? segments.slice(0, 2).join("/") : null;
|
||||
return segments.length ? segments[0] : null;
|
||||
}
|
||||
const getResolve = (options)=>{
|
||||
const curResolver = resolver.withOptions(options);
|
||||
return (parent, request, job)=>new Promise((resolve, reject)=>{
|
||||
const context = _path.default.dirname(parent);
|
||||
curResolver.resolve({}, context, request, {
|
||||
fileDependencies: compilation.fileDependencies,
|
||||
missingDependencies: compilation.missingDependencies,
|
||||
contextDependencies: compilation.contextDependencies
|
||||
}, async (err, result, resContext)=>{
|
||||
if (err) return reject(err);
|
||||
if (!result) {
|
||||
return reject(new Error("module not found"));
|
||||
}
|
||||
// webpack resolver doesn't strip loader query info
|
||||
// from the result so use path instead
|
||||
if (result.includes("?") || result.includes("!")) {
|
||||
result = (resContext == null ? void 0 : resContext.path) || result;
|
||||
}
|
||||
try {
|
||||
// we need to collect all parent package.json's used
|
||||
// as webpack's resolve doesn't expose this and parent
|
||||
// package.json could be needed for resolving e.g. stylis
|
||||
// stylis/package.json -> stylis/dist/umd/package.json
|
||||
if (result.includes("node_modules")) {
|
||||
let requestPath = result.replace(/\\/g, "/").replace(/\0/g, "");
|
||||
if (!_path.default.isAbsolute(request) && request.includes("/") && (resContext == null ? void 0 : resContext.descriptionFileRoot)) {
|
||||
var _getPkgName;
|
||||
requestPath = (resContext.descriptionFileRoot + request.slice(((_getPkgName = getPkgName(request)) == null ? void 0 : _getPkgName.length) || 0) + _path.default.sep + "package.json").replace(/\\/g, "/").replace(/\0/g, "");
|
||||
}
|
||||
const rootSeparatorIndex = requestPath.indexOf("/");
|
||||
let separatorIndex;
|
||||
while((separatorIndex = requestPath.lastIndexOf("/")) > rootSeparatorIndex){
|
||||
requestPath = requestPath.slice(0, separatorIndex);
|
||||
const curPackageJsonPath = `${requestPath}/package.json`;
|
||||
if (await job.isFile(curPackageJsonPath)) {
|
||||
await job.emitFile(await job.realpath(curPackageJsonPath), "resolve", parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (_err) {
|
||||
// we failed to resolve the package.json boundary,
|
||||
// we don't block emitting the initial asset from this
|
||||
}
|
||||
resolve([
|
||||
result,
|
||||
options.dependencyType === "esm"
|
||||
]);
|
||||
});
|
||||
});
|
||||
};
|
||||
const CJS_RESOLVE_OPTIONS = {
|
||||
..._webpackconfig.NODE_RESOLVE_OPTIONS,
|
||||
fullySpecified: undefined,
|
||||
modules: undefined,
|
||||
extensions: undefined
|
||||
};
|
||||
const BASE_CJS_RESOLVE_OPTIONS = {
|
||||
...CJS_RESOLVE_OPTIONS,
|
||||
alias: false
|
||||
};
|
||||
const ESM_RESOLVE_OPTIONS = {
|
||||
..._webpackconfig.NODE_ESM_RESOLVE_OPTIONS,
|
||||
fullySpecified: undefined,
|
||||
modules: undefined,
|
||||
extensions: undefined
|
||||
};
|
||||
const BASE_ESM_RESOLVE_OPTIONS = {
|
||||
...ESM_RESOLVE_OPTIONS,
|
||||
alias: false
|
||||
};
|
||||
const doResolve = async (request, parent, job, isEsmRequested)=>{
|
||||
const context = _path.default.dirname(parent);
|
||||
// When in esm externals mode, and using import, we resolve with
|
||||
// ESM resolving options.
|
||||
const { res } = await (0, _handleexternals.resolveExternal)(this.rootDir, this.esmExternals, context, request, isEsmRequested, this.optOutBundlingPackages, (options)=>(_, resRequest)=>{
|
||||
return getResolve(options)(parent, resRequest, job);
|
||||
}, undefined, undefined, ESM_RESOLVE_OPTIONS, CJS_RESOLVE_OPTIONS, BASE_ESM_RESOLVE_OPTIONS, BASE_CJS_RESOLVE_OPTIONS);
|
||||
if (!res) {
|
||||
throw new Error(`failed to resolve ${request} from ${parent}`);
|
||||
}
|
||||
return res.replace(/\0/g, "");
|
||||
};
|
||||
this.tapfinishModules(compilation, traceEntrypointsPluginSpan, doResolve, readlink, stat);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=next-trace-entrypoints-plugin.js.map
|
||||
556
.next/standalone/node_modules/next/dist/build/webpack/plugins/next-types-plugin/index.js
generated
vendored
Normal file
556
.next/standalone/node_modules/next/dist/build/webpack/plugins/next-types-plugin/index.js
generated
vendored
Normal file
@@ -0,0 +1,556 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "NextTypesPlugin", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return NextTypesPlugin;
|
||||
}
|
||||
});
|
||||
const _promises = /*#__PURE__*/ _interop_require_default(require("fs/promises"));
|
||||
const _webpack = require("next/dist/compiled/webpack/webpack");
|
||||
const _pathtoregexp = require("next/dist/compiled/path-to-regexp");
|
||||
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
||||
const _constants = require("../../../../lib/constants");
|
||||
const _denormalizepagepath = require("../../../../shared/lib/page-path/denormalize-page-path");
|
||||
const _ensureleadingslash = require("../../../../shared/lib/page-path/ensure-leading-slash");
|
||||
const _normalizepathsep = require("../../../../shared/lib/page-path/normalize-path-sep");
|
||||
const _http = require("../../../../server/web/http");
|
||||
const _utils = require("../../../../shared/lib/router/utils");
|
||||
const _apppaths = require("../../../../shared/lib/router/utils/app-paths");
|
||||
const _entries = require("../../../entries");
|
||||
const _shared = require("./shared");
|
||||
const _buildcontext = require("../../../build-context");
|
||||
function _interop_require_default(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
const PLUGIN_NAME = "NextTypesPlugin";
|
||||
function createTypeGuardFile(fullPath, relativePath, options) {
|
||||
return `// File: ${fullPath}
|
||||
import * as entry from '${relativePath}.js'
|
||||
${options.type === "route" ? `import type { NextRequest } from 'next/server.js'` : `import type { ResolvingMetadata, ResolvingViewport } from 'next/dist/lib/metadata/types/metadata-interface.js'`}
|
||||
|
||||
type TEntry = typeof import('${relativePath}.js')
|
||||
|
||||
// Check that the entry is a valid entry
|
||||
checkFields<Diff<{
|
||||
${options.type === "route" ? _http.HTTP_METHODS.map((method)=>`${method}?: Function`).join("\n ") : "default: Function"}
|
||||
config?: {}
|
||||
generateStaticParams?: Function
|
||||
revalidate?: RevalidateRange<TEntry> | false
|
||||
dynamic?: 'auto' | 'force-dynamic' | 'error' | 'force-static'
|
||||
dynamicParams?: boolean
|
||||
fetchCache?: 'auto' | 'force-no-store' | 'only-no-store' | 'default-no-store' | 'default-cache' | 'only-cache' | 'force-cache'
|
||||
preferredRegion?: 'auto' | 'global' | 'home' | string | string[]
|
||||
runtime?: 'nodejs' | 'experimental-edge' | 'edge'
|
||||
maxDuration?: number
|
||||
${options.type === "route" ? "" : `
|
||||
metadata?: any
|
||||
generateMetadata?: Function
|
||||
viewport?: any
|
||||
generateViewport?: Function
|
||||
`}
|
||||
}, TEntry, ''>>()
|
||||
|
||||
${options.type === "route" ? _http.HTTP_METHODS.map((method)=>`// Check the prop type of the entry function
|
||||
if ('${method}' in entry) {
|
||||
checkFields<
|
||||
Diff<
|
||||
ParamCheck<Request | NextRequest>,
|
||||
{
|
||||
__tag__: '${method}'
|
||||
__param_position__: 'first'
|
||||
__param_type__: FirstArg<MaybeField<TEntry, '${method}'>>
|
||||
},
|
||||
'${method}'
|
||||
>
|
||||
>()
|
||||
checkFields<
|
||||
Diff<
|
||||
ParamCheck<PageParams>,
|
||||
{
|
||||
__tag__: '${method}'
|
||||
__param_position__: 'second'
|
||||
__param_type__: SecondArg<MaybeField<TEntry, '${method}'>>
|
||||
},
|
||||
'${method}'
|
||||
>
|
||||
>()
|
||||
${""}
|
||||
checkFields<
|
||||
Diff<
|
||||
{
|
||||
__tag__: '${method}',
|
||||
__return_type__: Response | void | never | Promise<Response | void | never>
|
||||
},
|
||||
{
|
||||
__tag__: '${method}',
|
||||
__return_type__: ReturnType<MaybeField<TEntry, '${method}'>>
|
||||
},
|
||||
'${method}'
|
||||
>
|
||||
>()
|
||||
}
|
||||
`).join("") : `// Check the prop type of the entry function
|
||||
checkFields<Diff<${options.type === "page" ? "PageProps" : "LayoutProps"}, FirstArg<TEntry['default']>, 'default'>>()
|
||||
|
||||
// Check the arguments and return type of the generateMetadata function
|
||||
if ('generateMetadata' in entry) {
|
||||
checkFields<Diff<${options.type === "page" ? "PageProps" : "LayoutProps"}, FirstArg<MaybeField<TEntry, 'generateMetadata'>>, 'generateMetadata'>>()
|
||||
checkFields<Diff<ResolvingMetadata, SecondArg<MaybeField<TEntry, 'generateMetadata'>>, 'generateMetadata'>>()
|
||||
}
|
||||
|
||||
// Check the arguments and return type of the generateViewport function
|
||||
if ('generateViewport' in entry) {
|
||||
checkFields<Diff<${options.type === "page" ? "PageProps" : "LayoutProps"}, FirstArg<MaybeField<TEntry, 'generateViewport'>>, 'generateViewport'>>()
|
||||
checkFields<Diff<ResolvingViewport, SecondArg<MaybeField<TEntry, 'generateViewport'>>, 'generateViewport'>>()
|
||||
}
|
||||
`}
|
||||
// Check the arguments and return type of the generateStaticParams function
|
||||
if ('generateStaticParams' in entry) {
|
||||
checkFields<Diff<{ params: PageParams }, FirstArg<MaybeField<TEntry, 'generateStaticParams'>>, 'generateStaticParams'>>()
|
||||
checkFields<Diff<{ __tag__: 'generateStaticParams', __return_type__: any[] | Promise<any[]> }, { __tag__: 'generateStaticParams', __return_type__: ReturnType<MaybeField<TEntry, 'generateStaticParams'>> }>>()
|
||||
}
|
||||
|
||||
type PageParams = any
|
||||
export interface PageProps {
|
||||
params?: any
|
||||
searchParams?: any
|
||||
}
|
||||
export interface LayoutProps {
|
||||
children?: React.ReactNode
|
||||
${options.slots ? options.slots.map((slot)=>` ${slot}: React.ReactNode`).join("\n") : ""}
|
||||
params?: any
|
||||
}
|
||||
|
||||
// =============
|
||||
// Utility types
|
||||
type RevalidateRange<T> = T extends { revalidate: any } ? NonNegative<T['revalidate']> : never
|
||||
|
||||
// If T is unknown or any, it will be an empty {} type. Otherwise, it will be the same as Omit<T, keyof Base>.
|
||||
type OmitWithTag<T, K extends keyof any, _M> = Omit<T, K>
|
||||
type Diff<Base, T extends Base, Message extends string = ''> = 0 extends (1 & T) ? {} : OmitWithTag<T, keyof Base, Message>
|
||||
|
||||
type FirstArg<T extends Function> = T extends (...args: [infer T, any]) => any ? unknown extends T ? any : T : never
|
||||
type SecondArg<T extends Function> = T extends (...args: [any, infer T]) => any ? unknown extends T ? any : T : never
|
||||
type MaybeField<T, K extends string> = T extends { [k in K]: infer G } ? G extends Function ? G : never : never
|
||||
|
||||
${options.type === "route" ? `type ParamCheck<T> = {
|
||||
__tag__: string
|
||||
__param_position__: string
|
||||
__param_type__: T
|
||||
}` : ""}
|
||||
|
||||
function checkFields<_ extends { [k in keyof any]: never }>() {}
|
||||
|
||||
// https://github.com/sindresorhus/type-fest
|
||||
type Numeric = number | bigint
|
||||
type Zero = 0 | 0n
|
||||
type Negative<T extends Numeric> = T extends Zero ? never : \`\${T}\` extends \`-\${string}\` ? T : never
|
||||
type NonNegative<T extends Numeric> = T extends Zero ? T : Negative<T> extends never ? T : '__invalid_negative_number__'
|
||||
`;
|
||||
}
|
||||
async function collectNamedSlots(layoutPath) {
|
||||
const layoutDir = _path.default.dirname(layoutPath);
|
||||
const items = await _promises.default.readdir(layoutDir, {
|
||||
withFileTypes: true
|
||||
});
|
||||
const slots = [];
|
||||
for (const item of items){
|
||||
if (item.isDirectory() && item.name.startsWith("@") && // `@children slots are matched to the children prop, and should not be handled separately for type-checking
|
||||
item.name !== "@children") {
|
||||
slots.push(item.name.slice(1));
|
||||
}
|
||||
}
|
||||
return slots;
|
||||
}
|
||||
// By exposing the static route types separately as string literals,
|
||||
// editors can provide autocompletion for them. However it's currently not
|
||||
// possible to provide the same experience for dynamic routes.
|
||||
const pluginState = (0, _buildcontext.getProxiedPluginState)({
|
||||
routeTypes: {
|
||||
edge: {
|
||||
static: "",
|
||||
dynamic: ""
|
||||
},
|
||||
node: {
|
||||
static: "",
|
||||
dynamic: ""
|
||||
},
|
||||
extra: {
|
||||
static: "",
|
||||
dynamic: ""
|
||||
}
|
||||
}
|
||||
});
|
||||
function formatRouteToRouteType(route) {
|
||||
const isDynamic = (0, _utils.isDynamicRoute)(route);
|
||||
if (isDynamic) {
|
||||
route = route.split("/").map((part)=>{
|
||||
if (part.startsWith("[") && part.endsWith("]")) {
|
||||
if (part.startsWith("[...")) {
|
||||
// /[...slug]
|
||||
return `\${CatchAllSlug<T>}`;
|
||||
} else if (part.startsWith("[[...") && part.endsWith("]]")) {
|
||||
// /[[...slug]]
|
||||
return `\${OptionalCatchAllSlug<T>}`;
|
||||
}
|
||||
// /[slug]
|
||||
return `\${SafeSlug<T>}`;
|
||||
}
|
||||
return part;
|
||||
}).join("/");
|
||||
}
|
||||
return {
|
||||
isDynamic,
|
||||
routeType: `\n | \`${route}\``
|
||||
};
|
||||
}
|
||||
// Whether redirects and rewrites have been converted into routeTypes or not.
|
||||
let redirectsRewritesTypesProcessed = false;
|
||||
// Convert redirects and rewrites into routeTypes.
|
||||
function addRedirectsRewritesRouteTypes(rewrites, redirects) {
|
||||
function addExtraRoute(source) {
|
||||
let tokens;
|
||||
try {
|
||||
tokens = (0, _pathtoregexp.parse)(source);
|
||||
} catch {
|
||||
// Ignore invalid routes - they will be handled by other checks.
|
||||
}
|
||||
if (Array.isArray(tokens)) {
|
||||
const possibleNormalizedRoutes = [
|
||||
""
|
||||
];
|
||||
let slugCnt = 1;
|
||||
function append(suffix) {
|
||||
for(let i = 0; i < possibleNormalizedRoutes.length; i++){
|
||||
possibleNormalizedRoutes[i] += suffix;
|
||||
}
|
||||
}
|
||||
function fork(suffix) {
|
||||
const currentLength = possibleNormalizedRoutes.length;
|
||||
for(let i = 0; i < currentLength; i++){
|
||||
possibleNormalizedRoutes.push(possibleNormalizedRoutes[i] + suffix);
|
||||
}
|
||||
}
|
||||
for (const token of tokens){
|
||||
if (typeof token === "object") {
|
||||
// Make sure the slug is always named.
|
||||
const slug = token.name || (slugCnt++ === 1 ? "slug" : `slug${slugCnt}`);
|
||||
if (token.modifier === "*") {
|
||||
append(`${token.prefix}[[...${slug}]]`);
|
||||
} else if (token.modifier === "+") {
|
||||
append(`${token.prefix}[...${slug}]`);
|
||||
} else if (token.modifier === "") {
|
||||
if (token.pattern === "[^\\/#\\?]+?") {
|
||||
// A safe slug
|
||||
append(`${token.prefix}[${slug}]`);
|
||||
} else if (token.pattern === ".*") {
|
||||
// An optional catch-all slug
|
||||
append(`${token.prefix}[[...${slug}]]`);
|
||||
} else if (token.pattern === ".+") {
|
||||
// A catch-all slug
|
||||
append(`${token.prefix}[...${slug}]`);
|
||||
} else {
|
||||
// Other regex patterns are not supported. Skip this route.
|
||||
return;
|
||||
}
|
||||
} else if (token.modifier === "?") {
|
||||
if (/^[a-zA-Z0-9_/]*$/.test(token.pattern)) {
|
||||
// An optional slug with plain text only, fork the route.
|
||||
append(token.prefix);
|
||||
fork(token.pattern);
|
||||
} else {
|
||||
// Optional modifier `?` and regex patterns are not supported.
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else if (typeof token === "string") {
|
||||
append(token);
|
||||
}
|
||||
}
|
||||
for (const normalizedRoute of possibleNormalizedRoutes){
|
||||
const { isDynamic, routeType } = formatRouteToRouteType(normalizedRoute);
|
||||
pluginState.routeTypes.extra[isDynamic ? "dynamic" : "static"] += routeType;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (rewrites) {
|
||||
for (const rewrite of rewrites.beforeFiles){
|
||||
addExtraRoute(rewrite.source);
|
||||
}
|
||||
for (const rewrite of rewrites.afterFiles){
|
||||
addExtraRoute(rewrite.source);
|
||||
}
|
||||
for (const rewrite of rewrites.fallback){
|
||||
addExtraRoute(rewrite.source);
|
||||
}
|
||||
}
|
||||
if (redirects) {
|
||||
for (const redirect of redirects){
|
||||
// Skip internal redirects
|
||||
// https://github.com/vercel/next.js/blob/8ff3d7ff57836c24088474175d595b4d50b3f857/packages/next/src/lib/load-custom-routes.ts#L704-L710
|
||||
if (!("internal" in redirect)) {
|
||||
addExtraRoute(redirect.source);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
function createRouteDefinitions() {
|
||||
let staticRouteTypes = "";
|
||||
let dynamicRouteTypes = "";
|
||||
for (const type of [
|
||||
"edge",
|
||||
"node",
|
||||
"extra"
|
||||
]){
|
||||
staticRouteTypes += pluginState.routeTypes[type].static;
|
||||
dynamicRouteTypes += pluginState.routeTypes[type].dynamic;
|
||||
}
|
||||
// If both StaticRoutes and DynamicRoutes are empty, fallback to type 'string'.
|
||||
const routeTypesFallback = !staticRouteTypes && !dynamicRouteTypes ? "string" : "";
|
||||
return `// Type definitions for Next.js routes
|
||||
|
||||
/**
|
||||
* Internal types used by the Next.js router and Link component.
|
||||
* These types are not meant to be used directly.
|
||||
* @internal
|
||||
*/
|
||||
declare namespace __next_route_internal_types__ {
|
||||
type SearchOrHash = \`?\${string}\` | \`#\${string}\`
|
||||
type WithProtocol = \`\${string}:\${string}\`
|
||||
|
||||
type Suffix = '' | SearchOrHash
|
||||
|
||||
type SafeSlug<S extends string> = S extends \`\${string}/\${string}\`
|
||||
? never
|
||||
: S extends \`\${string}\${SearchOrHash}\`
|
||||
? never
|
||||
: S extends ''
|
||||
? never
|
||||
: S
|
||||
|
||||
type CatchAllSlug<S extends string> = S extends \`\${string}\${SearchOrHash}\`
|
||||
? never
|
||||
: S extends ''
|
||||
? never
|
||||
: S
|
||||
|
||||
type OptionalCatchAllSlug<S extends string> =
|
||||
S extends \`\${string}\${SearchOrHash}\` ? never : S
|
||||
|
||||
type StaticRoutes = ${staticRouteTypes || "never"}
|
||||
type DynamicRoutes<T extends string = string> = ${dynamicRouteTypes || "never"}
|
||||
|
||||
type RouteImpl<T> = ${routeTypesFallback || `
|
||||
${// This keeps autocompletion working for static routes.
|
||||
"| StaticRoutes"}
|
||||
| SearchOrHash
|
||||
| WithProtocol
|
||||
| \`\${StaticRoutes}\${SearchOrHash}\`
|
||||
| (T extends \`\${DynamicRoutes<infer _>}\${Suffix}\` ? T : never)
|
||||
`}
|
||||
}
|
||||
|
||||
declare module 'next' {
|
||||
export { default } from 'next/types/index.js'
|
||||
export * from 'next/types/index.js'
|
||||
|
||||
export type Route<T extends string = string> =
|
||||
__next_route_internal_types__.RouteImpl<T>
|
||||
}
|
||||
|
||||
declare module 'next/link' {
|
||||
import type { LinkProps as OriginalLinkProps } from 'next/dist/client/link.js'
|
||||
import type { AnchorHTMLAttributes, DetailedHTMLProps } from 'react'
|
||||
import type { UrlObject } from 'url'
|
||||
|
||||
type LinkRestProps = Omit<
|
||||
Omit<
|
||||
DetailedHTMLProps<
|
||||
AnchorHTMLAttributes<HTMLAnchorElement>,
|
||||
HTMLAnchorElement
|
||||
>,
|
||||
keyof OriginalLinkProps
|
||||
> &
|
||||
OriginalLinkProps,
|
||||
'href'
|
||||
>
|
||||
|
||||
export type LinkProps<RouteInferType> = LinkRestProps & {
|
||||
/**
|
||||
* The path or URL to navigate to. This is the only required prop. It can also be an object.
|
||||
* @see https://nextjs.org/docs/api-reference/next/link
|
||||
*/
|
||||
href: __next_route_internal_types__.RouteImpl<RouteInferType> | UrlObject
|
||||
}
|
||||
|
||||
export default function Link<RouteType>(props: LinkProps<RouteType>): JSX.Element
|
||||
}
|
||||
|
||||
declare module 'next/navigation' {
|
||||
export * from 'next/dist/client/components/navigation.js'
|
||||
|
||||
import type { NavigateOptions, AppRouterInstance as OriginalAppRouterInstance } from 'next/dist/shared/lib/app-router-context.shared-runtime.js'
|
||||
interface AppRouterInstance extends OriginalAppRouterInstance {
|
||||
/**
|
||||
* Navigate to the provided href.
|
||||
* Pushes a new history entry.
|
||||
*/
|
||||
push<RouteType>(href: __next_route_internal_types__.RouteImpl<RouteType>, options?: NavigateOptions): void
|
||||
/**
|
||||
* Navigate to the provided href.
|
||||
* Replaces the current history entry.
|
||||
*/
|
||||
replace<RouteType>(href: __next_route_internal_types__.RouteImpl<RouteType>, options?: NavigateOptions): void
|
||||
/**
|
||||
* Prefetch the provided href.
|
||||
*/
|
||||
prefetch<RouteType>(href: __next_route_internal_types__.RouteImpl<RouteType>): void
|
||||
}
|
||||
|
||||
export declare function useRouter(): AppRouterInstance;
|
||||
}
|
||||
`;
|
||||
}
|
||||
const appTypesBasePath = _path.default.join("types", "app");
|
||||
class NextTypesPlugin {
|
||||
constructor(options){
|
||||
this.dir = options.dir;
|
||||
this.distDir = options.distDir;
|
||||
this.appDir = options.appDir;
|
||||
this.dev = options.dev;
|
||||
this.isEdgeServer = options.isEdgeServer;
|
||||
this.pageExtensions = options.pageExtensions;
|
||||
this.pagesDir = _path.default.join(this.appDir, "..", "pages");
|
||||
this.typedRoutes = options.typedRoutes;
|
||||
this.distDirAbsolutePath = _path.default.join(this.dir, this.distDir);
|
||||
if (this.typedRoutes && !redirectsRewritesTypesProcessed) {
|
||||
redirectsRewritesTypesProcessed = true;
|
||||
addRedirectsRewritesRouteTypes(options.originalRewrites, options.originalRedirects);
|
||||
}
|
||||
}
|
||||
getRelativePathFromAppTypesDir(moduleRelativePathToAppDir) {
|
||||
const moduleAbsolutePath = _path.default.join(this.appDir, moduleRelativePathToAppDir);
|
||||
const moduleInAppTypesAbsolutePath = _path.default.join(this.distDirAbsolutePath, appTypesBasePath, moduleRelativePathToAppDir);
|
||||
return _path.default.relative(moduleInAppTypesAbsolutePath + "/..", moduleAbsolutePath);
|
||||
}
|
||||
collectPage(filePath) {
|
||||
if (!this.typedRoutes) return;
|
||||
const isApp = filePath.startsWith(this.appDir + _path.default.sep);
|
||||
const isPages = !isApp && filePath.startsWith(this.pagesDir + _path.default.sep);
|
||||
if (!isApp && !isPages) {
|
||||
return;
|
||||
}
|
||||
// Filter out non-page and non-route files in app dir
|
||||
if (isApp && !/[/\\](?:page|route)\.[^.]+$/.test(filePath)) {
|
||||
return;
|
||||
}
|
||||
// Filter out non-page files in pages dir
|
||||
if (isPages && /[/\\](?:_app|_document|_error|404|500)\.[^.]+$/.test(filePath)) {
|
||||
return;
|
||||
}
|
||||
let route = (isApp ? _apppaths.normalizeAppPath : _denormalizepagepath.denormalizePagePath)((0, _ensureleadingslash.ensureLeadingSlash)((0, _entries.getPageFromPath)(_path.default.relative(isApp ? this.appDir : this.pagesDir, filePath), this.pageExtensions)));
|
||||
const { isDynamic, routeType } = formatRouteToRouteType(route);
|
||||
pluginState.routeTypes[this.isEdgeServer ? "edge" : "node"][isDynamic ? "dynamic" : "static"] += routeType;
|
||||
}
|
||||
apply(compiler) {
|
||||
// From asset root to dist root
|
||||
const assetDirRelative = this.dev ? ".." : this.isEdgeServer ? ".." : "../..";
|
||||
const handleModule = async (mod, assets)=>{
|
||||
if (!mod.resource) return;
|
||||
if (!/\.(js|jsx|ts|tsx|mjs)$/.test(mod.resource)) return;
|
||||
if (!mod.resource.startsWith(this.appDir + _path.default.sep)) {
|
||||
if (!this.dev) {
|
||||
if (mod.resource.startsWith(this.pagesDir + _path.default.sep)) {
|
||||
this.collectPage(mod.resource);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (mod.layer !== _constants.WEBPACK_LAYERS.reactServerComponents && mod.layer !== _constants.WEBPACK_LAYERS.appRouteHandler) return;
|
||||
const IS_LAYOUT = /[/\\]layout\.[^./\\]+$/.test(mod.resource);
|
||||
const IS_PAGE = !IS_LAYOUT && /[/\\]page\.[^.]+$/.test(mod.resource);
|
||||
const IS_ROUTE = !IS_PAGE && /[/\\]route\.[^.]+$/.test(mod.resource);
|
||||
const relativePathToApp = _path.default.relative(this.appDir, mod.resource);
|
||||
if (!this.dev) {
|
||||
if (IS_PAGE || IS_ROUTE) {
|
||||
this.collectPage(mod.resource);
|
||||
}
|
||||
}
|
||||
const typePath = _path.default.join(appTypesBasePath, relativePathToApp.replace(/\.(js|jsx|ts|tsx|mjs)$/, ".ts"));
|
||||
const relativeImportPath = (0, _normalizepathsep.normalizePathSep)(_path.default.join(this.getRelativePathFromAppTypesDir(relativePathToApp)).replace(/\.(js|jsx|ts|tsx|mjs)$/, ""));
|
||||
const assetPath = _path.default.join(assetDirRelative, typePath);
|
||||
if (IS_LAYOUT) {
|
||||
const slots = await collectNamedSlots(mod.resource);
|
||||
assets[assetPath] = new _webpack.sources.RawSource(createTypeGuardFile(mod.resource, relativeImportPath, {
|
||||
type: "layout",
|
||||
slots
|
||||
}));
|
||||
} else if (IS_PAGE) {
|
||||
assets[assetPath] = new _webpack.sources.RawSource(createTypeGuardFile(mod.resource, relativeImportPath, {
|
||||
type: "page"
|
||||
}));
|
||||
} else if (IS_ROUTE) {
|
||||
assets[assetPath] = new _webpack.sources.RawSource(createTypeGuardFile(mod.resource, relativeImportPath, {
|
||||
type: "route"
|
||||
}));
|
||||
}
|
||||
};
|
||||
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation)=>{
|
||||
compilation.hooks.processAssets.tapAsync({
|
||||
name: PLUGIN_NAME,
|
||||
stage: _webpack.webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_HASH
|
||||
}, async (assets, callback)=>{
|
||||
const promises = [];
|
||||
// Clear routes
|
||||
if (this.isEdgeServer) {
|
||||
pluginState.routeTypes.edge.dynamic = "";
|
||||
pluginState.routeTypes.edge.static = "";
|
||||
} else {
|
||||
pluginState.routeTypes.node.dynamic = "";
|
||||
pluginState.routeTypes.node.static = "";
|
||||
}
|
||||
compilation.chunkGroups.forEach((chunkGroup)=>{
|
||||
chunkGroup.chunks.forEach((chunk)=>{
|
||||
if (!chunk.name) return;
|
||||
// Here we only track page and route chunks.
|
||||
if (!chunk.name.startsWith("pages/") && !(chunk.name.startsWith("app/") && (chunk.name.endsWith("/page") || chunk.name.endsWith("/route")))) {
|
||||
return;
|
||||
}
|
||||
const chunkModules = compilation.chunkGraph.getChunkModulesIterable(chunk);
|
||||
for (const mod of chunkModules){
|
||||
promises.push(handleModule(mod, assets));
|
||||
// If this is a concatenation, register each child to the parent ID.
|
||||
const anyModule = mod;
|
||||
if (anyModule.modules) {
|
||||
anyModule.modules.forEach((concatenatedMod)=>{
|
||||
promises.push(handleModule(concatenatedMod, assets));
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
await Promise.all(promises);
|
||||
// Support `"moduleResolution": "Node16" | "NodeNext"` with `"type": "module"`
|
||||
const packageJsonAssetPath = _path.default.join(assetDirRelative, "types/package.json");
|
||||
assets[packageJsonAssetPath] = new _webpack.sources.RawSource('{"type": "module"}');
|
||||
if (this.typedRoutes) {
|
||||
if (this.dev && !this.isEdgeServer) {
|
||||
_shared.devPageFiles.forEach((file)=>{
|
||||
this.collectPage(file);
|
||||
});
|
||||
}
|
||||
const linkAssetPath = _path.default.join(assetDirRelative, "types/link.d.ts");
|
||||
assets[linkAssetPath] = new _webpack.sources.RawSource(createRouteDefinitions());
|
||||
}
|
||||
callback();
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=index.js.map
|
||||
14
.next/standalone/node_modules/next/dist/build/webpack/plugins/next-types-plugin/shared.js
generated
vendored
Normal file
14
.next/standalone/node_modules/next/dist/build/webpack/plugins/next-types-plugin/shared.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
// TODO: Eliminate this singleton in the future.
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "devPageFiles", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return devPageFiles;
|
||||
}
|
||||
});
|
||||
const devPageFiles = new Set();
|
||||
|
||||
//# sourceMappingURL=shared.js.map
|
||||
123
.next/standalone/node_modules/next/dist/build/webpack/plugins/nextjs-require-cache-hot-reloader.js
generated
vendored
Normal file
123
.next/standalone/node_modules/next/dist/build/webpack/plugins/nextjs-require-cache-hot-reloader.js
generated
vendored
Normal file
@@ -0,0 +1,123 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
0 && (module.exports = {
|
||||
NextJsRequireCacheHotReloader: null,
|
||||
deleteAppClientCache: null,
|
||||
deleteCache: null
|
||||
});
|
||||
function _export(target, all) {
|
||||
for(var name in all)Object.defineProperty(target, name, {
|
||||
enumerable: true,
|
||||
get: all[name]
|
||||
});
|
||||
}
|
||||
_export(exports, {
|
||||
NextJsRequireCacheHotReloader: function() {
|
||||
return NextJsRequireCacheHotReloader;
|
||||
},
|
||||
deleteAppClientCache: function() {
|
||||
return deleteAppClientCache;
|
||||
},
|
||||
deleteCache: function() {
|
||||
return deleteCache;
|
||||
}
|
||||
});
|
||||
const _sandbox = require("../../../server/web/sandbox");
|
||||
const _realpath = require("../../../lib/realpath");
|
||||
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
||||
const _iserror = /*#__PURE__*/ _interop_require_default(require("../../../lib/is-error"));
|
||||
const _loadmanifest = require("../../../server/load-manifest");
|
||||
function _interop_require_default(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
const originModules = [
|
||||
require.resolve("../../../server/require"),
|
||||
require.resolve("../../../server/load-components"),
|
||||
require.resolve("../../../server/next-server"),
|
||||
require.resolve("next/dist/compiled/next-server/app-page.runtime.dev.js"),
|
||||
require.resolve("next/dist/compiled/next-server/app-route.runtime.dev.js"),
|
||||
require.resolve("next/dist/compiled/next-server/pages.runtime.dev.js"),
|
||||
require.resolve("next/dist/compiled/next-server/pages-api.runtime.dev.js")
|
||||
];
|
||||
const RUNTIME_NAMES = [
|
||||
"webpack-runtime",
|
||||
"webpack-api-runtime"
|
||||
];
|
||||
function deleteFromRequireCache(filePath) {
|
||||
try {
|
||||
filePath = (0, _realpath.realpathSync)(filePath);
|
||||
} catch (e) {
|
||||
if ((0, _iserror.default)(e) && e.code !== "ENOENT") throw e;
|
||||
}
|
||||
const mod = require.cache[filePath];
|
||||
if (mod) {
|
||||
// remove the child reference from the originModules
|
||||
for (const originModule of originModules){
|
||||
const parent = require.cache[originModule];
|
||||
if (parent) {
|
||||
const idx = parent.children.indexOf(mod);
|
||||
if (idx >= 0) parent.children.splice(idx, 1);
|
||||
}
|
||||
}
|
||||
// remove parent references from external modules
|
||||
for (const child of mod.children){
|
||||
child.parent = null;
|
||||
}
|
||||
delete require.cache[filePath];
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function deleteAppClientCache() {
|
||||
deleteFromRequireCache(require.resolve("next/dist/compiled/next-server/app-page.runtime.dev.js"));
|
||||
deleteFromRequireCache(require.resolve("next/dist/compiled/next-server/app-page-experimental.runtime.dev.js"));
|
||||
}
|
||||
function deleteCache(filePath) {
|
||||
// try to clear it from the fs cache
|
||||
(0, _loadmanifest.clearManifestCache)(filePath);
|
||||
deleteFromRequireCache(filePath);
|
||||
}
|
||||
const PLUGIN_NAME = "NextJsRequireCacheHotReloader";
|
||||
class NextJsRequireCacheHotReloader {
|
||||
constructor(opts){
|
||||
this.prevAssets = null;
|
||||
this.serverComponents = opts.serverComponents;
|
||||
}
|
||||
apply(compiler) {
|
||||
compiler.hooks.assetEmitted.tap(PLUGIN_NAME, (_file, { targetPath })=>{
|
||||
// Clear module context in this process
|
||||
(0, _sandbox.clearModuleContext)(targetPath);
|
||||
deleteCache(targetPath);
|
||||
});
|
||||
compiler.hooks.afterEmit.tapPromise(PLUGIN_NAME, async (compilation)=>{
|
||||
for (const name of RUNTIME_NAMES){
|
||||
const runtimeChunkPath = _path.default.join(compilation.outputOptions.path, `${name}.js`);
|
||||
deleteCache(runtimeChunkPath);
|
||||
}
|
||||
// we need to make sure to clear all server entries from cache
|
||||
// since they can have a stale webpack-runtime cache
|
||||
// which needs to always be in-sync
|
||||
let hasAppEntry = false;
|
||||
const entries = [
|
||||
...compilation.entries.keys()
|
||||
].filter((entry)=>{
|
||||
const isAppPath = entry.toString().startsWith("app/");
|
||||
if (isAppPath) hasAppEntry = true;
|
||||
return entry.toString().startsWith("pages/") || isAppPath;
|
||||
});
|
||||
if (hasAppEntry) {
|
||||
deleteAppClientCache();
|
||||
}
|
||||
for (const page of entries){
|
||||
const outputPath = _path.default.join(compilation.outputOptions.path, page + ".js");
|
||||
deleteCache(outputPath);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=nextjs-require-cache-hot-reloader.js.map
|
||||
45
.next/standalone/node_modules/next/dist/build/webpack/plugins/optional-peer-dependency-resolve-plugin.js
generated
vendored
Normal file
45
.next/standalone/node_modules/next/dist/build/webpack/plugins/optional-peer-dependency-resolve-plugin.js
generated
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "OptionalPeerDependencyResolverPlugin", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return OptionalPeerDependencyResolverPlugin;
|
||||
}
|
||||
});
|
||||
const pluginSymbol = Symbol("OptionalPeerDependencyResolverPlugin");
|
||||
class OptionalPeerDependencyResolverPlugin {
|
||||
apply(resolver) {
|
||||
const target = resolver.ensureHook("raw-module");
|
||||
target.tapAsync("OptionalPeerDependencyResolverPlugin", (request, resolveContext, callback)=>{
|
||||
var // popping the stack to prevent the recursion check
|
||||
_resolveContext_stack;
|
||||
// if we've already recursed into this plugin, we want to skip it
|
||||
if (request[pluginSymbol]) {
|
||||
return callback();
|
||||
}
|
||||
(_resolveContext_stack = resolveContext.stack) == null ? void 0 : _resolveContext_stack.delete(Array.from(resolveContext.stack).pop());
|
||||
resolver.doResolve(target, // when we call doResolve again, we need to make sure we don't
|
||||
// recurse into this plugin again
|
||||
{
|
||||
...request,
|
||||
[pluginSymbol]: true
|
||||
}, null, resolveContext, (err, result)=>{
|
||||
var _request_descriptionFileData;
|
||||
if (!result && (request == null ? void 0 : (_request_descriptionFileData = request.descriptionFileData) == null ? void 0 : _request_descriptionFileData.peerDependenciesMeta) && request.request) {
|
||||
const peerDependenciesMeta = request.descriptionFileData.peerDependenciesMeta;
|
||||
const isOptional = peerDependenciesMeta && peerDependenciesMeta[request.request] && peerDependenciesMeta[request.request].optional;
|
||||
if (isOptional) {
|
||||
return callback(null, {
|
||||
path: false
|
||||
});
|
||||
}
|
||||
}
|
||||
return callback(err, result);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=optional-peer-dependency-resolve-plugin.js.map
|
||||
146
.next/standalone/node_modules/next/dist/build/webpack/plugins/pages-manifest-plugin.js
generated
vendored
Normal file
146
.next/standalone/node_modules/next/dist/build/webpack/plugins/pages-manifest-plugin.js
generated
vendored
Normal file
@@ -0,0 +1,146 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
0 && (module.exports = {
|
||||
default: null,
|
||||
edgeServerAppPaths: null,
|
||||
edgeServerPages: null,
|
||||
nodeServerAppPaths: null,
|
||||
nodeServerPages: null
|
||||
});
|
||||
function _export(target, all) {
|
||||
for(var name in all)Object.defineProperty(target, name, {
|
||||
enumerable: true,
|
||||
get: all[name]
|
||||
});
|
||||
}
|
||||
_export(exports, {
|
||||
// This plugin creates a pages-manifest.json from page entrypoints.
|
||||
// This is used for mapping paths like `/` to `.next/server/static/<buildid>/pages/index.js` when doing SSR
|
||||
// It's also used by next export to provide defaultPathMap
|
||||
default: function() {
|
||||
return PagesManifestPlugin;
|
||||
},
|
||||
edgeServerAppPaths: function() {
|
||||
return edgeServerAppPaths;
|
||||
},
|
||||
edgeServerPages: function() {
|
||||
return edgeServerPages;
|
||||
},
|
||||
nodeServerAppPaths: function() {
|
||||
return nodeServerAppPaths;
|
||||
},
|
||||
nodeServerPages: function() {
|
||||
return nodeServerPages;
|
||||
}
|
||||
});
|
||||
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
||||
const _promises = /*#__PURE__*/ _interop_require_default(require("fs/promises"));
|
||||
const _webpack = require("next/dist/compiled/webpack/webpack");
|
||||
const _constants = require("../../../shared/lib/constants");
|
||||
const _getroutefromentrypoint = /*#__PURE__*/ _interop_require_default(require("../../../server/get-route-from-entrypoint"));
|
||||
const _normalizepathsep = require("../../../shared/lib/page-path/normalize-path-sep");
|
||||
function _interop_require_default(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
let edgeServerPages = {};
|
||||
let nodeServerPages = {};
|
||||
let edgeServerAppPaths = {};
|
||||
let nodeServerAppPaths = {};
|
||||
class PagesManifestPlugin {
|
||||
constructor({ dev, distDir, isEdgeRuntime, appDirEnabled }){
|
||||
this.dev = dev;
|
||||
this.distDir = distDir;
|
||||
this.isEdgeRuntime = isEdgeRuntime;
|
||||
this.appDirEnabled = appDirEnabled;
|
||||
}
|
||||
async createAssets(compilation, assets) {
|
||||
const entrypoints = compilation.entrypoints;
|
||||
const pages = {};
|
||||
const appPaths = {};
|
||||
for (const entrypoint of entrypoints.values()){
|
||||
const pagePath = (0, _getroutefromentrypoint.default)(entrypoint.name, this.appDirEnabled);
|
||||
if (!pagePath) {
|
||||
continue;
|
||||
}
|
||||
const files = entrypoint.getFiles().filter((file)=>!file.includes("webpack-runtime") && !file.includes("webpack-api-runtime") && file.endsWith(".js"));
|
||||
// Skip entries which are empty
|
||||
if (!files.length) {
|
||||
continue;
|
||||
}
|
||||
// Write filename, replace any backslashes in path (on windows) with forwardslashes for cross-platform consistency.
|
||||
let file = files[files.length - 1];
|
||||
if (!this.dev) {
|
||||
if (!this.isEdgeRuntime) {
|
||||
file = file.slice(3);
|
||||
}
|
||||
}
|
||||
file = (0, _normalizepathsep.normalizePathSep)(file);
|
||||
if (entrypoint.name.startsWith("app/")) {
|
||||
appPaths[pagePath] = file;
|
||||
} else {
|
||||
pages[pagePath] = file;
|
||||
}
|
||||
}
|
||||
// This plugin is used by both the Node server and Edge server compilers,
|
||||
// we need to merge both pages to generate the full manifest.
|
||||
if (this.isEdgeRuntime) {
|
||||
edgeServerPages = pages;
|
||||
edgeServerAppPaths = appPaths;
|
||||
} else {
|
||||
nodeServerPages = pages;
|
||||
nodeServerAppPaths = appPaths;
|
||||
}
|
||||
// handle parallel compilers writing to the same
|
||||
// manifest path by merging existing manifest with new
|
||||
const writeMergedManifest = async (manifestPath, entries)=>{
|
||||
await _promises.default.mkdir(_path.default.dirname(manifestPath), {
|
||||
recursive: true
|
||||
});
|
||||
await _promises.default.writeFile(manifestPath, JSON.stringify({
|
||||
...await _promises.default.readFile(manifestPath, "utf8").then((res)=>JSON.parse(res)).catch(()=>({})),
|
||||
...entries
|
||||
}, null, 2));
|
||||
};
|
||||
if (this.distDir) {
|
||||
const pagesManifestPath = _path.default.join(this.distDir, "server", _constants.PAGES_MANIFEST);
|
||||
await writeMergedManifest(pagesManifestPath, {
|
||||
...edgeServerPages,
|
||||
...nodeServerPages
|
||||
});
|
||||
} else {
|
||||
const pagesManifestPath = (!this.dev && !this.isEdgeRuntime ? "../" : "") + _constants.PAGES_MANIFEST;
|
||||
assets[pagesManifestPath] = new _webpack.sources.RawSource(JSON.stringify({
|
||||
...edgeServerPages,
|
||||
...nodeServerPages
|
||||
}, null, 2));
|
||||
}
|
||||
if (this.appDirEnabled) {
|
||||
if (this.distDir) {
|
||||
const appPathsManifestPath = _path.default.join(this.distDir, "server", _constants.APP_PATHS_MANIFEST);
|
||||
await writeMergedManifest(appPathsManifestPath, {
|
||||
...edgeServerAppPaths,
|
||||
...nodeServerAppPaths
|
||||
});
|
||||
} else {
|
||||
assets[(!this.dev && !this.isEdgeRuntime ? "../" : "") + _constants.APP_PATHS_MANIFEST] = new _webpack.sources.RawSource(JSON.stringify({
|
||||
...edgeServerAppPaths,
|
||||
...nodeServerAppPaths
|
||||
}, null, 2));
|
||||
}
|
||||
}
|
||||
}
|
||||
apply(compiler) {
|
||||
compiler.hooks.make.tap("NextJsPagesManifest", (compilation)=>{
|
||||
compilation.hooks.processAssets.tapPromise({
|
||||
name: "NextJsPagesManifest",
|
||||
stage: _webpack.webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS
|
||||
}, (assets)=>this.createAssets(compilation, assets));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=pages-manifest-plugin.js.map
|
||||
284
.next/standalone/node_modules/next/dist/build/webpack/plugins/profiling-plugin.js
generated
vendored
Normal file
284
.next/standalone/node_modules/next/dist/build/webpack/plugins/profiling-plugin.js
generated
vendored
Normal file
@@ -0,0 +1,284 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
0 && (module.exports = {
|
||||
ProfilingPlugin: null,
|
||||
spans: null,
|
||||
webpackInvalidSpans: null
|
||||
});
|
||||
function _export(target, all) {
|
||||
for(var name in all)Object.defineProperty(target, name, {
|
||||
enumerable: true,
|
||||
get: all[name]
|
||||
});
|
||||
}
|
||||
_export(exports, {
|
||||
ProfilingPlugin: function() {
|
||||
return ProfilingPlugin;
|
||||
},
|
||||
spans: function() {
|
||||
return spans;
|
||||
},
|
||||
webpackInvalidSpans: function() {
|
||||
return webpackInvalidSpans;
|
||||
}
|
||||
});
|
||||
const _webpack = require("next/dist/compiled/webpack/webpack");
|
||||
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
||||
function _interop_require_default(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
const pluginName = "ProfilingPlugin";
|
||||
const spans = new WeakMap();
|
||||
const moduleSpansByCompilation = new WeakMap();
|
||||
const makeSpanByCompilation = new WeakMap();
|
||||
const sealSpanByCompilation = new WeakMap();
|
||||
const webpackInvalidSpans = new WeakMap();
|
||||
const TRACE_LABELS_SEAL = [
|
||||
"module assets",
|
||||
"create chunk assets",
|
||||
"asset render",
|
||||
"asset emit",
|
||||
"store asset"
|
||||
];
|
||||
function inTraceLabelsSeal(label) {
|
||||
return TRACE_LABELS_SEAL.some((l)=>label.startsWith(l));
|
||||
}
|
||||
class ProfilingPlugin {
|
||||
constructor({ runWebpackSpan, rootDir }){
|
||||
this.runWebpackSpan = runWebpackSpan;
|
||||
this.rootDir = rootDir;
|
||||
}
|
||||
apply(compiler) {
|
||||
this.traceTopLevelHooks(compiler);
|
||||
this.traceCompilationHooks(compiler);
|
||||
this.compiler = compiler;
|
||||
}
|
||||
traceHookPair(spanName, startHook, stopHook, { parentSpan, attrs, onStart, onStop } = {}) {
|
||||
let span;
|
||||
startHook.tap({
|
||||
name: pluginName,
|
||||
stage: -Infinity
|
||||
}, (...params)=>{
|
||||
const name = typeof spanName === "function" ? spanName() : spanName;
|
||||
const attributes = attrs ? attrs(...params) : attrs;
|
||||
span = parentSpan ? parentSpan(...params).traceChild(name, attributes) : this.runWebpackSpan.traceChild(name, attributes);
|
||||
if (onStart) onStart(span, ...params);
|
||||
});
|
||||
stopHook.tap({
|
||||
name: pluginName,
|
||||
stage: Infinity
|
||||
}, (...params)=>{
|
||||
// `stopHook` may be triggered when `startHook` has not in cases
|
||||
// where `stopHook` is used as the terminating event for more
|
||||
// than one pair of hooks.
|
||||
if (!span) {
|
||||
return;
|
||||
}
|
||||
if (onStop) onStop(span, ...params);
|
||||
span.stop();
|
||||
});
|
||||
}
|
||||
traceTopLevelHooks(compiler) {
|
||||
this.traceHookPair("webpack-compilation", compiler.hooks.compilation, compiler.hooks.afterCompile, {
|
||||
parentSpan: ()=>webpackInvalidSpans.get(compiler) || this.runWebpackSpan,
|
||||
attrs: ()=>({
|
||||
name: compiler.name
|
||||
}),
|
||||
onStart: (span, compilation)=>{
|
||||
spans.set(compilation, span);
|
||||
spans.set(compiler, span);
|
||||
moduleSpansByCompilation.set(compilation, new WeakMap());
|
||||
}
|
||||
});
|
||||
if (compiler.options.mode === "development") {
|
||||
this.traceHookPair(()=>`webpack-invalidated-${compiler.name}`, compiler.hooks.invalid, compiler.hooks.done, {
|
||||
onStart: (span)=>webpackInvalidSpans.set(compiler, span),
|
||||
onStop: ()=>webpackInvalidSpans.delete(compiler),
|
||||
attrs: (fileName)=>({
|
||||
trigger: fileName ? _path.default.relative(this.rootDir, fileName).replaceAll(_path.default.sep, "/") : "manual"
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
traceCompilationHooks(compiler) {
|
||||
this.traceHookPair("emit", compiler.hooks.emit, compiler.hooks.afterEmit, {
|
||||
parentSpan: ()=>webpackInvalidSpans.get(compiler) || this.runWebpackSpan
|
||||
});
|
||||
this.traceHookPair("make", compiler.hooks.make, compiler.hooks.finishMake, {
|
||||
parentSpan: (compilation)=>{
|
||||
const compilationSpan = spans.get(compilation);
|
||||
if (!compilationSpan) {
|
||||
return webpackInvalidSpans.get(compiler) || this.runWebpackSpan;
|
||||
}
|
||||
return compilationSpan;
|
||||
},
|
||||
onStart: (span, compilation)=>{
|
||||
makeSpanByCompilation.set(compilation, span);
|
||||
},
|
||||
onStop: (_span, compilation)=>{
|
||||
makeSpanByCompilation.delete(compilation);
|
||||
}
|
||||
});
|
||||
compiler.hooks.compilation.tap({
|
||||
name: pluginName,
|
||||
stage: -Infinity
|
||||
}, (compilation)=>{
|
||||
compilation.hooks.buildModule.tap(pluginName, (module1)=>{
|
||||
var _compilation_moduleGraph;
|
||||
const moduleType = (()=>{
|
||||
const r = module1.userRequest;
|
||||
if (!r || r.endsWith("!")) {
|
||||
return "";
|
||||
} else {
|
||||
const resource = r.split("!").pop();
|
||||
const match = /^[^?]+\.([^?]+)$/.exec(resource);
|
||||
return match ? match[1] : "";
|
||||
}
|
||||
})();
|
||||
const issuerModule = compilation == null ? void 0 : (_compilation_moduleGraph = compilation.moduleGraph) == null ? void 0 : _compilation_moduleGraph.getIssuer(module1);
|
||||
let span;
|
||||
const moduleSpans = moduleSpansByCompilation.get(compilation);
|
||||
const spanName = `build-module${moduleType ? `-${moduleType}` : ""}`;
|
||||
const issuerSpan = issuerModule && (moduleSpans == null ? void 0 : moduleSpans.get(issuerModule));
|
||||
if (issuerSpan) {
|
||||
span = issuerSpan.traceChild(spanName);
|
||||
} else {
|
||||
let parentSpan;
|
||||
for (const incomingConnection of compilation.moduleGraph.getIncomingConnections(module1)){
|
||||
const entrySpan = spans.get(incomingConnection.dependency);
|
||||
if (entrySpan) {
|
||||
parentSpan = entrySpan;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!parentSpan) {
|
||||
const compilationSpan = spans.get(compilation);
|
||||
if (!compilationSpan) {
|
||||
return;
|
||||
}
|
||||
parentSpan = compilationSpan;
|
||||
}
|
||||
span = parentSpan.traceChild(spanName);
|
||||
}
|
||||
span.setAttribute("name", module1.userRequest);
|
||||
span.setAttribute("layer", module1.layer);
|
||||
moduleSpans.set(module1, span);
|
||||
});
|
||||
const moduleHooks = _webpack.NormalModule.getCompilationHooks(compilation);
|
||||
moduleHooks.readResource.for(undefined).intercept({
|
||||
register (tapInfo) {
|
||||
const fn = tapInfo.fn;
|
||||
tapInfo.fn = (loaderContext, callback)=>{
|
||||
const moduleSpan = loaderContext.currentTraceSpan.traceChild(`read-resource`);
|
||||
fn(loaderContext, (err, result)=>{
|
||||
moduleSpan.stop();
|
||||
callback(err, result);
|
||||
});
|
||||
};
|
||||
return tapInfo;
|
||||
}
|
||||
});
|
||||
moduleHooks.loader.tap(pluginName, (loaderContext, module1)=>{
|
||||
var _moduleSpansByCompilation_get;
|
||||
const moduleSpan = (_moduleSpansByCompilation_get = moduleSpansByCompilation.get(compilation)) == null ? void 0 : _moduleSpansByCompilation_get.get(module1);
|
||||
loaderContext.currentTraceSpan = moduleSpan;
|
||||
});
|
||||
compilation.hooks.succeedModule.tap(pluginName, (module1)=>{
|
||||
var _moduleSpansByCompilation_get_get, _moduleSpansByCompilation_get;
|
||||
moduleSpansByCompilation == null ? void 0 : (_moduleSpansByCompilation_get = moduleSpansByCompilation.get(compilation)) == null ? void 0 : (_moduleSpansByCompilation_get_get = _moduleSpansByCompilation_get.get(module1)) == null ? void 0 : _moduleSpansByCompilation_get_get.stop();
|
||||
});
|
||||
compilation.hooks.failedModule.tap(pluginName, (module1)=>{
|
||||
var _moduleSpansByCompilation_get_get, _moduleSpansByCompilation_get;
|
||||
moduleSpansByCompilation == null ? void 0 : (_moduleSpansByCompilation_get = moduleSpansByCompilation.get(compilation)) == null ? void 0 : (_moduleSpansByCompilation_get_get = _moduleSpansByCompilation_get.get(module1)) == null ? void 0 : _moduleSpansByCompilation_get_get.stop();
|
||||
});
|
||||
this.traceHookPair("seal", compilation.hooks.seal, compilation.hooks.afterSeal, {
|
||||
parentSpan: ()=>spans.get(compilation),
|
||||
onStart (span) {
|
||||
sealSpanByCompilation.set(compilation, span);
|
||||
},
|
||||
onStop () {
|
||||
sealSpanByCompilation.delete(compilation);
|
||||
}
|
||||
});
|
||||
compilation.hooks.addEntry.tap(pluginName, (entry)=>{
|
||||
const parentSpan = makeSpanByCompilation.get(compilation) || spans.get(compilation);
|
||||
if (!parentSpan) {
|
||||
return;
|
||||
}
|
||||
const addEntrySpan = parentSpan.traceChild("add-entry");
|
||||
addEntrySpan.setAttribute("request", entry.request);
|
||||
spans.set(entry, addEntrySpan);
|
||||
});
|
||||
compilation.hooks.succeedEntry.tap(pluginName, (entry)=>{
|
||||
var _spans_get;
|
||||
(_spans_get = spans.get(entry)) == null ? void 0 : _spans_get.stop();
|
||||
spans.delete(entry);
|
||||
});
|
||||
compilation.hooks.failedEntry.tap(pluginName, (entry)=>{
|
||||
var _spans_get;
|
||||
(_spans_get = spans.get(entry)) == null ? void 0 : _spans_get.stop();
|
||||
spans.delete(entry);
|
||||
});
|
||||
this.traceHookPair("chunk-graph", compilation.hooks.beforeChunks, compilation.hooks.afterChunks, {
|
||||
parentSpan: ()=>sealSpanByCompilation.get(compilation) || spans.get(compilation)
|
||||
});
|
||||
this.traceHookPair("optimize", compilation.hooks.optimize, compilation.hooks.reviveModules, {
|
||||
parentSpan: ()=>sealSpanByCompilation.get(compilation) || spans.get(compilation)
|
||||
});
|
||||
this.traceHookPair("optimize-modules", compilation.hooks.optimizeModules, compilation.hooks.afterOptimizeModules, {
|
||||
parentSpan: ()=>sealSpanByCompilation.get(compilation) || spans.get(compilation)
|
||||
});
|
||||
this.traceHookPair("optimize-chunks", compilation.hooks.optimizeChunks, compilation.hooks.afterOptimizeChunks, {
|
||||
parentSpan: ()=>sealSpanByCompilation.get(compilation) || spans.get(compilation)
|
||||
});
|
||||
this.traceHookPair("optimize-tree", compilation.hooks.optimizeTree, compilation.hooks.afterOptimizeTree, {
|
||||
parentSpan: ()=>sealSpanByCompilation.get(compilation) || spans.get(compilation)
|
||||
});
|
||||
this.traceHookPair("optimize-chunk-modules", compilation.hooks.optimizeChunkModules, compilation.hooks.afterOptimizeChunkModules, {
|
||||
parentSpan: ()=>sealSpanByCompilation.get(compilation) || spans.get(compilation)
|
||||
});
|
||||
this.traceHookPair("module-hash", compilation.hooks.beforeModuleHash, compilation.hooks.afterModuleHash, {
|
||||
parentSpan: ()=>sealSpanByCompilation.get(compilation) || spans.get(compilation)
|
||||
});
|
||||
this.traceHookPair("code-generation", compilation.hooks.beforeCodeGeneration, compilation.hooks.afterCodeGeneration, {
|
||||
parentSpan: ()=>sealSpanByCompilation.get(compilation) || spans.get(compilation)
|
||||
});
|
||||
this.traceHookPair("hash", compilation.hooks.beforeHash, compilation.hooks.afterHash, {
|
||||
parentSpan: ()=>sealSpanByCompilation.get(compilation) || spans.get(compilation)
|
||||
});
|
||||
this.traceHookPair("code-generation-jobs", compilation.hooks.afterHash, compilation.hooks.beforeModuleAssets, {
|
||||
parentSpan: ()=>sealSpanByCompilation.get(compilation) || spans.get(compilation)
|
||||
});
|
||||
const logs = new Map();
|
||||
const originalTime = compilation.logger.time;
|
||||
const originalTimeEnd = compilation.logger.timeEnd;
|
||||
compilation.logger.time = (label)=>{
|
||||
if (!inTraceLabelsSeal(label)) {
|
||||
return originalTime.call(compilation.logger, label);
|
||||
}
|
||||
const span = sealSpanByCompilation.get(compilation);
|
||||
if (span) {
|
||||
logs.set(label, span.traceChild(label.replace(/ /g, "-")));
|
||||
}
|
||||
return originalTime.call(compilation.logger, label);
|
||||
};
|
||||
compilation.logger.timeEnd = (label)=>{
|
||||
if (!inTraceLabelsSeal(label)) {
|
||||
return originalTimeEnd.call(compilation.logger, label);
|
||||
}
|
||||
const span = logs.get(label);
|
||||
if (span) {
|
||||
span.stop();
|
||||
logs.delete(label);
|
||||
}
|
||||
return originalTimeEnd.call(compilation.logger, label);
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=profiling-plugin.js.map
|
||||
149
.next/standalone/node_modules/next/dist/build/webpack/plugins/react-loadable-plugin.js
generated
vendored
Normal file
149
.next/standalone/node_modules/next/dist/build/webpack/plugins/react-loadable-plugin.js
generated
vendored
Normal file
@@ -0,0 +1,149 @@
|
||||
/**
|
||||
COPYRIGHT (c) 2017-present James Kyle <me@thejameskyle.com>
|
||||
MIT License
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWAR
|
||||
*/ // Implementation of this PR: https://github.com/jamiebuilds/react-loadable/pull/132
|
||||
// Modified to strip out unneeded results for Next's specific use case
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "ReactLoadablePlugin", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return ReactLoadablePlugin;
|
||||
}
|
||||
});
|
||||
const _webpack = require("next/dist/compiled/webpack/webpack");
|
||||
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
||||
function _interop_require_default(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
function getModuleId(compilation, module) {
|
||||
return compilation.chunkGraph.getModuleId(module);
|
||||
}
|
||||
function getModuleFromDependency(compilation, dep) {
|
||||
return compilation.moduleGraph.getModule(dep);
|
||||
}
|
||||
function getOriginModuleFromDependency(compilation, dep) {
|
||||
return compilation.moduleGraph.getParentModule(dep);
|
||||
}
|
||||
function getChunkGroupFromBlock(compilation, block) {
|
||||
return compilation.chunkGraph.getBlockChunkGroup(block);
|
||||
}
|
||||
function buildManifest(_compiler, compilation, projectSrcDir, dev) {
|
||||
if (!projectSrcDir) {
|
||||
return {};
|
||||
}
|
||||
let manifest = {};
|
||||
// This is allowed:
|
||||
// import("./module"); <- ImportDependency
|
||||
// We don't support that:
|
||||
// import(/* webpackMode: "eager" */ "./module") <- ImportEagerDependency
|
||||
// import(`./module/${param}`) <- ImportContextDependency
|
||||
// Find all dependencies blocks which contains a `import()` dependency
|
||||
const handleBlock = (block)=>{
|
||||
block.blocks.forEach(handleBlock);
|
||||
const chunkGroup = getChunkGroupFromBlock(compilation, block);
|
||||
for (const dependency of block.dependencies){
|
||||
if (dependency.type.startsWith("import()")) {
|
||||
// get the referenced module
|
||||
const module = getModuleFromDependency(compilation, dependency);
|
||||
if (!module) return;
|
||||
// get the module containing the import()
|
||||
const originModule = getOriginModuleFromDependency(compilation, dependency);
|
||||
const originRequest = originModule == null ? void 0 : originModule.resource;
|
||||
if (!originRequest) return;
|
||||
// We construct a "unique" key from origin module and request
|
||||
// It's not perfect unique, but that will be fine for us.
|
||||
// We also need to construct the same in the babel plugin.
|
||||
const key = `${_path.default.relative(projectSrcDir, originRequest)} -> ${dependency.request}`;
|
||||
// Capture all files that need to be loaded.
|
||||
const files = new Set();
|
||||
if (manifest[key]) {
|
||||
// In the "rare" case where multiple chunk groups
|
||||
// are created for the same `import()` or multiple
|
||||
// import()s reference the same module, we merge
|
||||
// the files to make sure to not miss files
|
||||
// This may cause overfetching in edge cases.
|
||||
for (const file of manifest[key].files){
|
||||
files.add(file);
|
||||
}
|
||||
}
|
||||
// There might not be a chunk group when all modules
|
||||
// are already loaded. In this case we only need need
|
||||
// the module id and no files
|
||||
if (chunkGroup) {
|
||||
for (const chunk of chunkGroup.chunks){
|
||||
chunk.files.forEach((file)=>{
|
||||
if ((file.endsWith(".js") || file.endsWith(".css")) && file.match(/^static\/(chunks|css)\//)) {
|
||||
files.add(file);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
// usually we have to add the parent chunk groups too
|
||||
// but we assume that all parents are also imported by
|
||||
// next/dynamic so they are loaded by the same technique
|
||||
// add the id and files to the manifest
|
||||
const id = dev ? key : getModuleId(compilation, module);
|
||||
manifest[key] = {
|
||||
id,
|
||||
files: Array.from(files)
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
for (const module of compilation.modules){
|
||||
module.blocks.forEach(handleBlock);
|
||||
}
|
||||
manifest = Object.keys(manifest).sort()// eslint-disable-next-line no-sequences
|
||||
.reduce((a, c)=>(a[c] = manifest[c], a), {});
|
||||
return manifest;
|
||||
}
|
||||
class ReactLoadablePlugin {
|
||||
constructor(opts){
|
||||
this.filename = opts.filename;
|
||||
this.pagesOrAppDir = opts.pagesDir || opts.appDir;
|
||||
this.runtimeAsset = opts.runtimeAsset;
|
||||
this.dev = opts.dev;
|
||||
}
|
||||
createAssets(compiler, compilation, assets) {
|
||||
const projectSrcDir = this.pagesOrAppDir ? _path.default.dirname(this.pagesOrAppDir) : undefined;
|
||||
const manifest = buildManifest(compiler, compilation, projectSrcDir, this.dev);
|
||||
assets[this.filename] = new _webpack.sources.RawSource(JSON.stringify(manifest, null, 2));
|
||||
if (this.runtimeAsset) {
|
||||
assets[this.runtimeAsset] = new _webpack.sources.RawSource(`self.__REACT_LOADABLE_MANIFEST=${JSON.stringify(JSON.stringify(manifest))}`);
|
||||
}
|
||||
return assets;
|
||||
}
|
||||
apply(compiler) {
|
||||
compiler.hooks.make.tap("ReactLoadableManifest", (compilation)=>{
|
||||
compilation.hooks.processAssets.tap({
|
||||
name: "ReactLoadableManifest",
|
||||
stage: _webpack.webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS
|
||||
}, (assets)=>{
|
||||
this.createAssets(compiler, compilation, assets);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=react-loadable-plugin.js.map
|
||||
58
.next/standalone/node_modules/next/dist/build/webpack/plugins/subresource-integrity-plugin.js
generated
vendored
Normal file
58
.next/standalone/node_modules/next/dist/build/webpack/plugins/subresource-integrity-plugin.js
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "SubresourceIntegrityPlugin", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return SubresourceIntegrityPlugin;
|
||||
}
|
||||
});
|
||||
const _webpack = require("next/dist/compiled/webpack/webpack");
|
||||
const _crypto = /*#__PURE__*/ _interop_require_default(require("crypto"));
|
||||
const _constants = require("../../../shared/lib/constants");
|
||||
function _interop_require_default(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
const PLUGIN_NAME = "SubresourceIntegrityPlugin";
|
||||
class SubresourceIntegrityPlugin {
|
||||
constructor(algorithm){
|
||||
this.algorithm = algorithm;
|
||||
}
|
||||
apply(compiler) {
|
||||
compiler.hooks.make.tap(PLUGIN_NAME, (compilation)=>{
|
||||
compilation.hooks.afterOptimizeAssets.tap({
|
||||
name: PLUGIN_NAME,
|
||||
stage: _webpack.webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS
|
||||
}, (assets)=>{
|
||||
// Collect all the assets.
|
||||
let files = new Set();
|
||||
for (const asset of compilation.getAssets()){
|
||||
files.add(asset.name);
|
||||
}
|
||||
// For each file, deduped, calculate the file hash.
|
||||
const hashes = {};
|
||||
for (const file of files.values()){
|
||||
// Get the buffer for the asset.
|
||||
const asset = assets[file];
|
||||
if (!asset) {
|
||||
throw new Error(`could not get asset: ${file}`);
|
||||
}
|
||||
// Get the buffer for the asset.
|
||||
const buffer = asset.buffer();
|
||||
// Create the hash for the content.
|
||||
const hash = _crypto.default.createHash(this.algorithm).update(buffer).digest().toString("base64");
|
||||
hashes[file] = `${this.algorithm}-${hash}`;
|
||||
}
|
||||
const json = JSON.stringify(hashes, null, 2);
|
||||
const file = "server/" + _constants.SUBRESOURCE_INTEGRITY_MANIFEST;
|
||||
assets[file + ".js"] = new _webpack.sources.RawSource(`self.__SUBRESOURCE_INTEGRITY_MANIFEST=${JSON.stringify(json)}`);
|
||||
assets[file + ".json"] = new _webpack.sources.RawSource(json);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=subresource-integrity-plugin.js.map
|
||||
173
.next/standalone/node_modules/next/dist/build/webpack/plugins/telemetry-plugin.js
generated
vendored
Normal file
173
.next/standalone/node_modules/next/dist/build/webpack/plugins/telemetry-plugin.js
generated
vendored
Normal file
@@ -0,0 +1,173 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "TelemetryPlugin", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return TelemetryPlugin;
|
||||
}
|
||||
});
|
||||
const _webpack = require("next/dist/compiled/webpack/webpack");
|
||||
// Map of a feature module to the file it belongs in the next package.
|
||||
const FEATURE_MODULE_MAP = new Map([
|
||||
[
|
||||
"next/image",
|
||||
"/next/image.js"
|
||||
],
|
||||
[
|
||||
"next/future/image",
|
||||
"/next/future/image.js"
|
||||
],
|
||||
[
|
||||
"next/legacy/image",
|
||||
"/next/legacy/image.js"
|
||||
],
|
||||
[
|
||||
"next/script",
|
||||
"/next/script.js"
|
||||
],
|
||||
[
|
||||
"next/dynamic",
|
||||
"/next/dynamic.js"
|
||||
]
|
||||
]);
|
||||
const FEATURE_MODULE_REGEXP_MAP = new Map([
|
||||
[
|
||||
"@next/font/google",
|
||||
/\/@next\/font\/google\/target.css?.+$/
|
||||
],
|
||||
[
|
||||
"@next/font/local",
|
||||
/\/@next\/font\/local\/target.css?.+$/
|
||||
],
|
||||
[
|
||||
"next/font/google",
|
||||
/\/next\/font\/google\/target.css?.+$/
|
||||
],
|
||||
[
|
||||
"next/font/local",
|
||||
/\/next\/font\/local\/target.css?.+$/
|
||||
]
|
||||
]);
|
||||
// List of build features used in webpack configuration
|
||||
const BUILD_FEATURES = [
|
||||
"swcLoader",
|
||||
"swcMinify",
|
||||
"swcRelay",
|
||||
"swcStyledComponents",
|
||||
"swcReactRemoveProperties",
|
||||
"swcExperimentalDecorators",
|
||||
"swcRemoveConsole",
|
||||
"swcImportSource",
|
||||
"swcEmotion",
|
||||
"swc/target/x86_64-apple-darwin",
|
||||
"swc/target/x86_64-unknown-linux-gnu",
|
||||
"swc/target/x86_64-pc-windows-msvc",
|
||||
"swc/target/i686-pc-windows-msvc",
|
||||
"swc/target/aarch64-unknown-linux-gnu",
|
||||
"swc/target/armv7-unknown-linux-gnueabihf",
|
||||
"swc/target/aarch64-apple-darwin",
|
||||
"swc/target/aarch64-linux-android",
|
||||
"swc/target/arm-linux-androideabi",
|
||||
"swc/target/x86_64-unknown-freebsd",
|
||||
"swc/target/x86_64-unknown-linux-musl",
|
||||
"swc/target/aarch64-unknown-linux-musl",
|
||||
"swc/target/aarch64-pc-windows-msvc",
|
||||
"turbotrace",
|
||||
"transpilePackages",
|
||||
"skipMiddlewareUrlNormalize",
|
||||
"skipTrailingSlashRedirect",
|
||||
"modularizeImports"
|
||||
];
|
||||
const eliminatedPackages = new Set();
|
||||
/**
|
||||
* Determine if there is a feature of interest in the specified 'module'.
|
||||
*/ function findFeatureInModule(module) {
|
||||
if (module.type !== "javascript/auto") {
|
||||
return;
|
||||
}
|
||||
const normalizedIdentifier = module.identifier().replace(/\\/g, "/");
|
||||
for (const [feature, path] of FEATURE_MODULE_MAP){
|
||||
if (normalizedIdentifier.endsWith(path)) {
|
||||
return feature;
|
||||
}
|
||||
}
|
||||
for (const [feature, regexp] of FEATURE_MODULE_REGEXP_MAP){
|
||||
if (regexp.test(normalizedIdentifier)) {
|
||||
return feature;
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Find unique origin modules in the specified 'connections', which possibly
|
||||
* contains more than one connection for a module due to different types of
|
||||
* dependency.
|
||||
*/ function findUniqueOriginModulesInConnections(connections, originModule) {
|
||||
const originModules = new Set();
|
||||
for (const connection of connections){
|
||||
if (!originModules.has(connection.originModule) && connection.originModule !== originModule) {
|
||||
originModules.add(connection.originModule);
|
||||
}
|
||||
}
|
||||
return originModules;
|
||||
}
|
||||
class TelemetryPlugin {
|
||||
// Build feature usage is on/off and is known before the build starts
|
||||
constructor(buildFeaturesMap){
|
||||
this.usageTracker = new Map();
|
||||
for (const featureName of BUILD_FEATURES){
|
||||
this.usageTracker.set(featureName, {
|
||||
featureName,
|
||||
invocationCount: buildFeaturesMap.get(featureName) ? 1 : 0
|
||||
});
|
||||
}
|
||||
for (const featureName of FEATURE_MODULE_MAP.keys()){
|
||||
this.usageTracker.set(featureName, {
|
||||
featureName,
|
||||
invocationCount: 0
|
||||
});
|
||||
}
|
||||
for (const featureName of FEATURE_MODULE_REGEXP_MAP.keys()){
|
||||
this.usageTracker.set(featureName, {
|
||||
featureName,
|
||||
invocationCount: 0
|
||||
});
|
||||
}
|
||||
}
|
||||
apply(compiler) {
|
||||
compiler.hooks.make.tapAsync(TelemetryPlugin.name, async (compilation, callback)=>{
|
||||
compilation.hooks.finishModules.tapAsync(TelemetryPlugin.name, async (modules, modulesFinish)=>{
|
||||
for (const module of modules){
|
||||
const feature = findFeatureInModule(module);
|
||||
if (!feature) {
|
||||
continue;
|
||||
}
|
||||
const connections = compilation.moduleGraph.getIncomingConnections(module);
|
||||
const originModules = findUniqueOriginModulesInConnections(connections, module);
|
||||
this.usageTracker.get(feature).invocationCount = originModules.size;
|
||||
}
|
||||
modulesFinish();
|
||||
});
|
||||
callback();
|
||||
});
|
||||
if (compiler.options.mode === "production" && !compiler.watchMode) {
|
||||
compiler.hooks.compilation.tap(TelemetryPlugin.name, (compilation)=>{
|
||||
const moduleHooks = _webpack.NormalModule.getCompilationHooks(compilation);
|
||||
moduleHooks.loader.tap(TelemetryPlugin.name, (loaderContext)=>{
|
||||
loaderContext.eliminatedPackages = eliminatedPackages;
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
usages() {
|
||||
return [
|
||||
...this.usageTracker.values()
|
||||
];
|
||||
}
|
||||
packagesUsedInServerSideProps() {
|
||||
return Array.from(eliminatedPackages);
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=telemetry-plugin.js.map
|
||||
270
.next/standalone/node_modules/next/dist/build/webpack/plugins/terser-webpack-plugin/src/index.js
generated
vendored
Normal file
270
.next/standalone/node_modules/next/dist/build/webpack/plugins/terser-webpack-plugin/src/index.js
generated
vendored
Normal file
@@ -0,0 +1,270 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "TerserPlugin", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return TerserPlugin;
|
||||
}
|
||||
});
|
||||
const _path = /*#__PURE__*/ _interop_require_wildcard(require("path"));
|
||||
const _webpack = require("next/dist/compiled/webpack/webpack");
|
||||
const _plimit = /*#__PURE__*/ _interop_require_default(require("next/dist/compiled/p-limit"));
|
||||
const _jestworker = require("next/dist/compiled/jest-worker");
|
||||
const _profilingplugin = require("../../profiling-plugin");
|
||||
function _interop_require_default(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
function _getRequireWildcardCache(nodeInterop) {
|
||||
if (typeof WeakMap !== "function") return null;
|
||||
var cacheBabelInterop = new WeakMap();
|
||||
var cacheNodeInterop = new WeakMap();
|
||||
return (_getRequireWildcardCache = function(nodeInterop) {
|
||||
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
||||
})(nodeInterop);
|
||||
}
|
||||
function _interop_require_wildcard(obj, nodeInterop) {
|
||||
if (!nodeInterop && obj && obj.__esModule) {
|
||||
return obj;
|
||||
}
|
||||
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
||||
return {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
var cache = _getRequireWildcardCache(nodeInterop);
|
||||
if (cache && cache.has(obj)) {
|
||||
return cache.get(obj);
|
||||
}
|
||||
var newObj = {
|
||||
__proto__: null
|
||||
};
|
||||
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
||||
for(var key in obj){
|
||||
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
||||
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
||||
if (desc && (desc.get || desc.set)) {
|
||||
Object.defineProperty(newObj, key, desc);
|
||||
} else {
|
||||
newObj[key] = obj[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
newObj.default = obj;
|
||||
if (cache) {
|
||||
cache.set(obj, newObj);
|
||||
}
|
||||
return newObj;
|
||||
}
|
||||
function getEcmaVersion(environment) {
|
||||
// ES 6th
|
||||
if (environment.arrowFunction || environment.const || environment.destructuring || environment.forOf || environment.module) {
|
||||
return 2015;
|
||||
}
|
||||
// ES 11th
|
||||
if (environment.bigIntLiteral || environment.dynamicImport) {
|
||||
return 2020;
|
||||
}
|
||||
return 5;
|
||||
}
|
||||
function buildError(error, file) {
|
||||
if (error.line) {
|
||||
return new Error(`${file} from Terser\n${error.message} [${file}:${error.line},${error.col}]${error.stack ? `\n${error.stack.split("\n").slice(1).join("\n")}` : ""}`);
|
||||
}
|
||||
if (error.stack) {
|
||||
return new Error(`${file} from Terser\n${error.message}\n${error.stack}`);
|
||||
}
|
||||
return new Error(`${file} from Terser\n${error.message}`);
|
||||
}
|
||||
const debugMinify = process.env.NEXT_DEBUG_MINIFY;
|
||||
class TerserPlugin {
|
||||
constructor(options = {}){
|
||||
const { terserOptions = {}, parallel, swcMinify } = options;
|
||||
this.options = {
|
||||
swcMinify,
|
||||
parallel,
|
||||
terserOptions
|
||||
};
|
||||
}
|
||||
async optimize(compiler, compilation, assets, optimizeOptions, cache, { SourceMapSource, RawSource }) {
|
||||
const compilationSpan = _profilingplugin.spans.get(compilation) || _profilingplugin.spans.get(compiler);
|
||||
const terserSpan = compilationSpan.traceChild("terser-webpack-plugin-optimize");
|
||||
terserSpan.setAttribute("compilationName", compilation.name);
|
||||
terserSpan.setAttribute("swcMinify", this.options.swcMinify);
|
||||
return terserSpan.traceAsyncFn(async ()=>{
|
||||
let numberOfAssetsForMinify = 0;
|
||||
const assetsList = Object.keys(assets);
|
||||
const assetsForMinify = await Promise.all(assetsList.filter((name)=>{
|
||||
if (!_webpack.ModuleFilenameHelpers.matchObject.bind(// eslint-disable-next-line no-undefined
|
||||
undefined, {
|
||||
test: /\.[cm]?js(\?.*)?$/i
|
||||
})(name)) {
|
||||
return false;
|
||||
}
|
||||
const res = compilation.getAsset(name);
|
||||
if (!res) {
|
||||
console.log(name);
|
||||
return false;
|
||||
}
|
||||
const { info } = res;
|
||||
// Skip double minimize assets from child compilation
|
||||
if (info.minimized) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}).map(async (name)=>{
|
||||
const { info, source } = compilation.getAsset(name);
|
||||
const eTag = cache.getLazyHashedEtag(source);
|
||||
const output = await cache.getPromise(name, eTag);
|
||||
if (!output) {
|
||||
numberOfAssetsForMinify += 1;
|
||||
}
|
||||
if (debugMinify && debugMinify === "1") {
|
||||
console.log(JSON.stringify({
|
||||
name,
|
||||
source: source.source().toString()
|
||||
}), {
|
||||
breakLength: Infinity,
|
||||
maxStringLength: Infinity
|
||||
});
|
||||
}
|
||||
return {
|
||||
name,
|
||||
info,
|
||||
inputSource: source,
|
||||
output,
|
||||
eTag
|
||||
};
|
||||
}));
|
||||
const numberOfWorkers = Math.min(numberOfAssetsForMinify, optimizeOptions.availableNumberOfCores);
|
||||
let initializedWorker;
|
||||
// eslint-disable-next-line consistent-return
|
||||
const getWorker = ()=>{
|
||||
if (this.options.swcMinify) {
|
||||
return {
|
||||
minify: async (options)=>{
|
||||
const result = await require("../../../../swc").minify(options.input, {
|
||||
...options.inputSourceMap ? {
|
||||
sourceMap: {
|
||||
content: JSON.stringify(options.inputSourceMap)
|
||||
}
|
||||
} : {},
|
||||
compress: true,
|
||||
mangle: true
|
||||
});
|
||||
return result;
|
||||
}
|
||||
};
|
||||
}
|
||||
if (initializedWorker) {
|
||||
return initializedWorker;
|
||||
}
|
||||
initializedWorker = new _jestworker.Worker(_path.join(__dirname, "./minify.js"), {
|
||||
numWorkers: numberOfWorkers,
|
||||
enableWorkerThreads: true
|
||||
});
|
||||
initializedWorker.getStdout().pipe(process.stdout);
|
||||
initializedWorker.getStderr().pipe(process.stderr);
|
||||
return initializedWorker;
|
||||
};
|
||||
const limit = (0, _plimit.default)(// When using the SWC minifier the limit will be handled by Node.js
|
||||
this.options.swcMinify ? Infinity : numberOfAssetsForMinify > 0 ? numberOfWorkers : Infinity);
|
||||
const scheduledTasks = [];
|
||||
for (const asset of assetsForMinify){
|
||||
scheduledTasks.push(limit(async ()=>{
|
||||
const { name, inputSource, info, eTag } = asset;
|
||||
let { output } = asset;
|
||||
const minifySpan = terserSpan.traceChild("minify-js");
|
||||
minifySpan.setAttribute("name", name);
|
||||
minifySpan.setAttribute("cache", typeof output === "undefined" ? "MISS" : "HIT");
|
||||
return minifySpan.traceAsyncFn(async ()=>{
|
||||
if (!output) {
|
||||
const { source: sourceFromInputSource, map: inputSourceMap } = inputSource.sourceAndMap();
|
||||
const input = Buffer.isBuffer(sourceFromInputSource) ? sourceFromInputSource.toString() : sourceFromInputSource;
|
||||
const options = {
|
||||
name,
|
||||
input,
|
||||
inputSourceMap,
|
||||
terserOptions: {
|
||||
...this.options.terserOptions
|
||||
}
|
||||
};
|
||||
if (typeof options.terserOptions.module === "undefined") {
|
||||
if (typeof info.javascriptModule !== "undefined") {
|
||||
options.terserOptions.module = info.javascriptModule;
|
||||
} else if (/\.mjs(\?.*)?$/i.test(name)) {
|
||||
options.terserOptions.module = true;
|
||||
} else if (/\.cjs(\?.*)?$/i.test(name)) {
|
||||
options.terserOptions.module = false;
|
||||
}
|
||||
}
|
||||
try {
|
||||
output = await getWorker().minify(options);
|
||||
} catch (error) {
|
||||
compilation.errors.push(buildError(error, name));
|
||||
return;
|
||||
}
|
||||
if (output.map) {
|
||||
output.source = new SourceMapSource(output.code, name, output.map, input, inputSourceMap, true);
|
||||
} else {
|
||||
output.source = new RawSource(output.code);
|
||||
}
|
||||
await cache.storePromise(name, eTag, {
|
||||
source: output.source
|
||||
});
|
||||
}
|
||||
const newInfo = {
|
||||
minimized: true
|
||||
};
|
||||
const { source } = output;
|
||||
compilation.updateAsset(name, source, newInfo);
|
||||
});
|
||||
}));
|
||||
}
|
||||
await Promise.all(scheduledTasks);
|
||||
if (initializedWorker) {
|
||||
await initializedWorker.end();
|
||||
}
|
||||
});
|
||||
}
|
||||
apply(compiler) {
|
||||
var _compiler_webpack;
|
||||
const { SourceMapSource, RawSource } = (compiler == null ? void 0 : (_compiler_webpack = compiler.webpack) == null ? void 0 : _compiler_webpack.sources) || _webpack.sources;
|
||||
const { output } = compiler.options;
|
||||
if (typeof this.options.terserOptions.ecma === "undefined") {
|
||||
this.options.terserOptions.ecma = getEcmaVersion(output.environment || {});
|
||||
}
|
||||
const pluginName = this.constructor.name;
|
||||
const availableNumberOfCores = this.options.parallel;
|
||||
compiler.hooks.thisCompilation.tap(pluginName, (compilation)=>{
|
||||
const cache = compilation.getCache("TerserWebpackPlugin");
|
||||
const handleHashForChunk = (hash, _chunk)=>{
|
||||
// increment 'c' to invalidate cache
|
||||
hash.update("c");
|
||||
};
|
||||
const JSModulesHooks = _webpack.webpack.javascript.JavascriptModulesPlugin.getCompilationHooks(compilation);
|
||||
JSModulesHooks.chunkHash.tap(pluginName, (chunk, hash)=>{
|
||||
if (!chunk.hasRuntime()) return;
|
||||
return handleHashForChunk(hash, chunk);
|
||||
});
|
||||
compilation.hooks.processAssets.tapPromise({
|
||||
name: pluginName,
|
||||
stage: _webpack.webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE
|
||||
}, (assets)=>this.optimize(compiler, compilation, assets, {
|
||||
availableNumberOfCores
|
||||
}, cache, {
|
||||
SourceMapSource,
|
||||
RawSource
|
||||
}));
|
||||
compilation.hooks.statsPrinter.tap(pluginName, (stats)=>{
|
||||
stats.hooks.print.for("asset.info.minimized").tap("terser-webpack-plugin", (minimized, { green, formatFlag })=>// eslint-disable-next-line no-undefined
|
||||
minimized ? green(formatFlag("minimized")) : undefined);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=index.js.map
|
||||
89
.next/standalone/node_modules/next/dist/build/webpack/plugins/wellknown-errors-plugin/getModuleTrace.js
generated
vendored
Normal file
89
.next/standalone/node_modules/next/dist/build/webpack/plugins/wellknown-errors-plugin/getModuleTrace.js
generated
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
0 && (module.exports = {
|
||||
formatModuleTrace: null,
|
||||
getModuleTrace: null
|
||||
});
|
||||
function _export(target, all) {
|
||||
for(var name in all)Object.defineProperty(target, name, {
|
||||
enumerable: true,
|
||||
get: all[name]
|
||||
});
|
||||
}
|
||||
_export(exports, {
|
||||
formatModuleTrace: function() {
|
||||
return formatModuleTrace;
|
||||
},
|
||||
getModuleTrace: function() {
|
||||
return getModuleTrace;
|
||||
}
|
||||
});
|
||||
const _loaderutils3 = /*#__PURE__*/ _interop_require_default(require("next/dist/compiled/loader-utils3"));
|
||||
const _path = require("path");
|
||||
function _interop_require_default(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
function formatModule(compiler, module1) {
|
||||
const relativePath = (0, _path.relative)(compiler.context, module1.resource).replace(/\?.+$/, "");
|
||||
return _loaderutils3.default.isUrlRequest(relativePath) ? _loaderutils3.default.urlToRequest(relativePath) : relativePath;
|
||||
}
|
||||
function formatModuleTrace(compiler, moduleTrace) {
|
||||
let importTrace = [];
|
||||
let firstExternalModule;
|
||||
for(let i = moduleTrace.length - 1; i >= 0; i--){
|
||||
const mod = moduleTrace[i];
|
||||
if (!mod.resource) continue;
|
||||
if (!mod.resource.includes("node_modules/")) {
|
||||
importTrace.unshift(formatModule(compiler, mod));
|
||||
} else {
|
||||
firstExternalModule = mod;
|
||||
break;
|
||||
}
|
||||
}
|
||||
let invalidImportMessage = "";
|
||||
if (firstExternalModule) {
|
||||
var _firstExternalModule_resourceResolveData_descriptionFileData, _firstExternalModule_resourceResolveData;
|
||||
const firstExternalPackageName = (_firstExternalModule_resourceResolveData = firstExternalModule.resourceResolveData) == null ? void 0 : (_firstExternalModule_resourceResolveData_descriptionFileData = _firstExternalModule_resourceResolveData.descriptionFileData) == null ? void 0 : _firstExternalModule_resourceResolveData_descriptionFileData.name;
|
||||
if (firstExternalPackageName === "styled-jsx") {
|
||||
invalidImportMessage += `\n\nThe error was caused by using 'styled-jsx' in '${importTrace[0]}'. It only works in a Client Component but none of its parents are marked with "use client", so they're Server Components by default.`;
|
||||
} else {
|
||||
let formattedExternalFile = firstExternalModule.resource.split("node_modules");
|
||||
formattedExternalFile = formattedExternalFile[formattedExternalFile.length - 1];
|
||||
invalidImportMessage += `\n\nThe error was caused by importing '${formattedExternalFile.slice(1)}' in '${importTrace[0]}'.`;
|
||||
}
|
||||
}
|
||||
return {
|
||||
lastInternalFileName: importTrace[0],
|
||||
invalidImportMessage,
|
||||
formattedModuleTrace: importTrace.map((mod)=>" " + mod).join("\n")
|
||||
};
|
||||
}
|
||||
function getModuleTrace(module1, compilation, compiler) {
|
||||
// Get the module trace:
|
||||
// https://cs.github.com/webpack/webpack/blob/9fcaa243573005d6fdece9a3f8d89a0e8b399613/lib/stats/DefaultStatsFactoryPlugin.js#L414
|
||||
const visitedModules = new Set();
|
||||
const moduleTrace = [];
|
||||
let current = module1;
|
||||
let isPagesDir = false;
|
||||
while(current){
|
||||
if (visitedModules.has(current)) break;
|
||||
if (/[\\/]pages/.test(current.resource.replace(compiler.context, ""))) {
|
||||
isPagesDir = true;
|
||||
}
|
||||
visitedModules.add(current);
|
||||
moduleTrace.push(current);
|
||||
const origin = compilation.moduleGraph.getIssuer(current);
|
||||
if (!origin) break;
|
||||
current = origin;
|
||||
}
|
||||
return {
|
||||
moduleTrace,
|
||||
isPagesDir
|
||||
};
|
||||
}
|
||||
|
||||
//# sourceMappingURL=getModuleTrace.js.map
|
||||
43
.next/standalone/node_modules/next/dist/build/webpack/plugins/wellknown-errors-plugin/index.js
generated
vendored
Normal file
43
.next/standalone/node_modules/next/dist/build/webpack/plugins/wellknown-errors-plugin/index.js
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "WellKnownErrorsPlugin", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return WellKnownErrorsPlugin;
|
||||
}
|
||||
});
|
||||
const _webpackModuleError = require("./webpackModuleError");
|
||||
const NAME = "WellKnownErrorsPlugin";
|
||||
class WellKnownErrorsPlugin {
|
||||
apply(compiler) {
|
||||
compiler.hooks.compilation.tap(NAME, (compilation)=>{
|
||||
compilation.hooks.afterSeal.tapPromise(NAME, async ()=>{
|
||||
var _compilation_warnings, _compilation_errors;
|
||||
if ((_compilation_warnings = compilation.warnings) == null ? void 0 : _compilation_warnings.length) {
|
||||
await Promise.all(compilation.warnings.map(async (warn, i)=>{
|
||||
var _warn_module_context, _warn_module;
|
||||
if (warn.name === "ModuleDependencyWarning" && ((_warn_module = warn.module) == null ? void 0 : (_warn_module_context = _warn_module.context) == null ? void 0 : _warn_module_context.includes("node_modules"))) {
|
||||
compilation.warnings.splice(i, 1);
|
||||
}
|
||||
}));
|
||||
}
|
||||
if ((_compilation_errors = compilation.errors) == null ? void 0 : _compilation_errors.length) {
|
||||
await Promise.all(compilation.errors.map(async (err, i)=>{
|
||||
try {
|
||||
const moduleError = await (0, _webpackModuleError.getModuleBuildError)(compiler, compilation, err);
|
||||
if (moduleError !== false) {
|
||||
compilation.errors[i] = moduleError;
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
}));
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=index.js.map
|
||||
19
.next/standalone/node_modules/next/dist/build/webpack/plugins/wellknown-errors-plugin/parse-dynamic-code-evaluation-error.js
generated
vendored
Normal file
19
.next/standalone/node_modules/next/dist/build/webpack/plugins/wellknown-errors-plugin/parse-dynamic-code-evaluation-error.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "getDynamicCodeEvaluationError", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return getDynamicCodeEvaluationError;
|
||||
}
|
||||
});
|
||||
const _getModuleTrace = require("./getModuleTrace");
|
||||
const _simpleWebpackError = require("./simpleWebpackError");
|
||||
function getDynamicCodeEvaluationError(message, module, compilation, compiler) {
|
||||
const { moduleTrace } = (0, _getModuleTrace.getModuleTrace)(module, compilation, compiler);
|
||||
const { formattedModuleTrace, lastInternalFileName, invalidImportMessage } = (0, _getModuleTrace.formatModuleTrace)(compiler, moduleTrace);
|
||||
return new _simpleWebpackError.SimpleWebpackError(lastInternalFileName, message + invalidImportMessage + "\n\nImport trace for requested module:\n" + formattedModuleTrace);
|
||||
}
|
||||
|
||||
//# sourceMappingURL=parse-dynamic-code-evaluation-error.js.map
|
||||
29
.next/standalone/node_modules/next/dist/build/webpack/plugins/wellknown-errors-plugin/parseBabel.js
generated
vendored
Normal file
29
.next/standalone/node_modules/next/dist/build/webpack/plugins/wellknown-errors-plugin/parseBabel.js
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "getBabelError", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return getBabelError;
|
||||
}
|
||||
});
|
||||
const _picocolors = require("../../../../lib/picocolors");
|
||||
const _simpleWebpackError = require("./simpleWebpackError");
|
||||
function getBabelError(fileName, err) {
|
||||
if (err.code !== "BABEL_PARSE_ERROR") {
|
||||
return false;
|
||||
}
|
||||
// https://github.com/babel/babel/blob/34693d6024da3f026534dd8d569f97ac0109602e/packages/babel-core/src/parser/index.js
|
||||
if (err.loc) {
|
||||
const lineNumber = Math.max(1, err.loc.line);
|
||||
const column = Math.max(1, err.loc.column);
|
||||
let message = err.message// Remove file information, which instead is provided by webpack.
|
||||
.replace(/^.+?: /, "")// Remove column information from message
|
||||
.replace(new RegExp(`[^\\S\\r\\n]*\\(${lineNumber}:${column}\\)[^\\S\\r\\n]*`), "");
|
||||
return new _simpleWebpackError.SimpleWebpackError(`${(0, _picocolors.cyan)(fileName)}:${(0, _picocolors.yellow)(lineNumber.toString())}:${(0, _picocolors.yellow)(column.toString())}`, (0, _picocolors.red)((0, _picocolors.bold)("Syntax error")).concat(`: ${message}`));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//# sourceMappingURL=parseBabel.js.map
|
||||
29
.next/standalone/node_modules/next/dist/build/webpack/plugins/wellknown-errors-plugin/parseCss.js
generated
vendored
Normal file
29
.next/standalone/node_modules/next/dist/build/webpack/plugins/wellknown-errors-plugin/parseCss.js
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "getCssError", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return getCssError;
|
||||
}
|
||||
});
|
||||
const _picocolors = require("../../../../lib/picocolors");
|
||||
const _simpleWebpackError = require("./simpleWebpackError");
|
||||
const regexCssError = /^(?:CssSyntaxError|SyntaxError)\n\n\((\d+):(\d*)\) (.*)$/s;
|
||||
function getCssError(fileName, err) {
|
||||
if (!((err.name === "CssSyntaxError" || err.name === "SyntaxError") && err.stack === false && !(err instanceof SyntaxError))) {
|
||||
return false;
|
||||
}
|
||||
// https://github.com/postcss/postcss-loader/blob/d6931da177ac79707bd758436e476036a55e4f59/src/Error.js
|
||||
const res = regexCssError.exec(err.message);
|
||||
if (res) {
|
||||
const [, _lineNumber, _column, reason] = res;
|
||||
const lineNumber = Math.max(1, parseInt(_lineNumber, 10));
|
||||
const column = Math.max(1, parseInt(_column, 10));
|
||||
return new _simpleWebpackError.SimpleWebpackError(`${(0, _picocolors.cyan)(fileName)}:${(0, _picocolors.yellow)(lineNumber.toString())}:${(0, _picocolors.yellow)(column.toString())}`, (0, _picocolors.red)((0, _picocolors.bold)("Syntax error")).concat(`: ${reason}`));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//# sourceMappingURL=parseCss.js.map
|
||||
25
.next/standalone/node_modules/next/dist/build/webpack/plugins/wellknown-errors-plugin/parseNextAppLoaderError.js
generated
vendored
Normal file
25
.next/standalone/node_modules/next/dist/build/webpack/plugins/wellknown-errors-plugin/parseNextAppLoaderError.js
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "getNextAppLoaderError", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return getNextAppLoaderError;
|
||||
}
|
||||
});
|
||||
const _path = require("path");
|
||||
const _simpleWebpackError = require("./simpleWebpackError");
|
||||
function getNextAppLoaderError(err, module, compiler) {
|
||||
try {
|
||||
if (!module.loaders[0].loader.includes("next-app-loader.js")) {
|
||||
return false;
|
||||
}
|
||||
const file = (0, _path.relative)(compiler.context, module.buildInfo.route.absolutePagePath);
|
||||
return new _simpleWebpackError.SimpleWebpackError(file, err.message);
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=parseNextAppLoaderError.js.map
|
||||
33
.next/standalone/node_modules/next/dist/build/webpack/plugins/wellknown-errors-plugin/parseNextFontError.js
generated
vendored
Normal file
33
.next/standalone/node_modules/next/dist/build/webpack/plugins/wellknown-errors-plugin/parseNextFontError.js
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "getNextFontError", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return getNextFontError;
|
||||
}
|
||||
});
|
||||
const _simpleWebpackError = require("./simpleWebpackError");
|
||||
function getNextFontError(err, module) {
|
||||
try {
|
||||
const resourceResolveData = module.resourceResolveData;
|
||||
if (!module.loaders.find((loader)=>/next-font-loader[/\\]index.js/.test(loader.loader))) {
|
||||
return false;
|
||||
}
|
||||
// Parse the query and get the path of the file where the font function was called.
|
||||
// provided by next-swc next-transform-font
|
||||
const file = JSON.parse(resourceResolveData.query.slice(1)).path;
|
||||
if (err.name === "NextFontError") {
|
||||
// Known error thrown by @next/font, display the error message
|
||||
return new _simpleWebpackError.SimpleWebpackError(file, `\`next/font\` error:\n${err.message}`);
|
||||
} else {
|
||||
// Unknown error thrown by @next/font
|
||||
return new _simpleWebpackError.SimpleWebpackError(file, `An error occurred in \`next/font\`.\n\n${err.stack}`);
|
||||
}
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=parseNextFontError.js.map
|
||||
26
.next/standalone/node_modules/next/dist/build/webpack/plugins/wellknown-errors-plugin/parseNextInvalidImportError.js
generated
vendored
Normal file
26
.next/standalone/node_modules/next/dist/build/webpack/plugins/wellknown-errors-plugin/parseNextInvalidImportError.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "getNextInvalidImportError", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return getNextInvalidImportError;
|
||||
}
|
||||
});
|
||||
const _getModuleTrace = require("./getModuleTrace");
|
||||
const _simpleWebpackError = require("./simpleWebpackError");
|
||||
function getNextInvalidImportError(err, module, compilation, compiler) {
|
||||
try {
|
||||
if (!module.loaders.find((loader)=>loader.loader.includes("next-invalid-import-error-loader.js"))) {
|
||||
return false;
|
||||
}
|
||||
const { moduleTrace } = (0, _getModuleTrace.getModuleTrace)(module, compilation, compiler);
|
||||
const { formattedModuleTrace, lastInternalFileName, invalidImportMessage } = (0, _getModuleTrace.formatModuleTrace)(compiler, moduleTrace);
|
||||
return new _simpleWebpackError.SimpleWebpackError(lastInternalFileName, err.message + invalidImportMessage + "\n\nImport trace for requested module:\n" + formattedModuleTrace);
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=parseNextInvalidImportError.js.map
|
||||
150
.next/standalone/node_modules/next/dist/build/webpack/plugins/wellknown-errors-plugin/parseNotFoundError.js
generated
vendored
Normal file
150
.next/standalone/node_modules/next/dist/build/webpack/plugins/wellknown-errors-plugin/parseNotFoundError.js
generated
vendored
Normal file
@@ -0,0 +1,150 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
0 && (module.exports = {
|
||||
getImageError: null,
|
||||
getNotFoundError: null
|
||||
});
|
||||
function _export(target, all) {
|
||||
for(var name in all)Object.defineProperty(target, name, {
|
||||
enumerable: true,
|
||||
get: all[name]
|
||||
});
|
||||
}
|
||||
_export(exports, {
|
||||
getImageError: function() {
|
||||
return getImageError;
|
||||
},
|
||||
getNotFoundError: function() {
|
||||
return getNotFoundError;
|
||||
}
|
||||
});
|
||||
const _picocolors = require("../../../../lib/picocolors");
|
||||
const _simpleWebpackError = require("./simpleWebpackError");
|
||||
const _middleware = require("../../../../client/components/react-dev-overlay/server/middleware");
|
||||
// Based on https://github.com/webpack/webpack/blob/fcdd04a833943394bbb0a9eeb54a962a24cc7e41/lib/stats/DefaultStatsFactoryPlugin.js#L422-L431
|
||||
/*
|
||||
Copyright JS Foundation and other contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
'Software'), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/ function getModuleTrace(input, compilation) {
|
||||
const visitedModules = new Set();
|
||||
const moduleTrace = [];
|
||||
let current = input.module;
|
||||
while(current){
|
||||
if (visitedModules.has(current)) break; // circular (technically impossible, but who knows)
|
||||
visitedModules.add(current);
|
||||
const origin = compilation.moduleGraph.getIssuer(current);
|
||||
if (!origin) break;
|
||||
moduleTrace.push({
|
||||
origin,
|
||||
module: current
|
||||
});
|
||||
current = origin;
|
||||
}
|
||||
return moduleTrace;
|
||||
}
|
||||
async function getSourceFrame(input, fileName, compilation) {
|
||||
try {
|
||||
var _result_originalStackFrame_lineNumber, _result_originalStackFrame, _result_originalStackFrame_column, _result_originalStackFrame1;
|
||||
const loc = input.loc || input.dependencies.map((d)=>d.loc).filter(Boolean)[0];
|
||||
const originalSource = input.module.originalSource();
|
||||
const result = await (0, _middleware.createOriginalStackFrame)({
|
||||
source: originalSource,
|
||||
rootDirectory: compilation.options.context,
|
||||
modulePath: fileName,
|
||||
frame: {
|
||||
arguments: [],
|
||||
file: fileName,
|
||||
methodName: "",
|
||||
lineNumber: loc.start.line,
|
||||
column: loc.start.column
|
||||
}
|
||||
});
|
||||
return {
|
||||
frame: (result == null ? void 0 : result.originalCodeFrame) ?? "",
|
||||
lineNumber: (result == null ? void 0 : (_result_originalStackFrame = result.originalStackFrame) == null ? void 0 : (_result_originalStackFrame_lineNumber = _result_originalStackFrame.lineNumber) == null ? void 0 : _result_originalStackFrame_lineNumber.toString()) ?? "",
|
||||
column: (result == null ? void 0 : (_result_originalStackFrame1 = result.originalStackFrame) == null ? void 0 : (_result_originalStackFrame_column = _result_originalStackFrame1.column) == null ? void 0 : _result_originalStackFrame_column.toString()) ?? ""
|
||||
};
|
||||
} catch {
|
||||
return {
|
||||
frame: "",
|
||||
lineNumber: "",
|
||||
column: ""
|
||||
};
|
||||
}
|
||||
}
|
||||
function getFormattedFileName(fileName, module1, lineNumber, column) {
|
||||
var _module_loaders;
|
||||
if ((_module_loaders = module1.loaders) == null ? void 0 : _module_loaders.find((loader)=>/next-font-loader[/\\]index.js/.test(loader.loader))) {
|
||||
// Parse the query and get the path of the file where the font function was called.
|
||||
// provided by next-swc next-transform-font
|
||||
return JSON.parse(module1.resourceResolveData.query.slice(1)).path;
|
||||
} else {
|
||||
let formattedFileName = (0, _picocolors.cyan)(fileName);
|
||||
if (lineNumber && column) {
|
||||
formattedFileName += `:${(0, _picocolors.yellow)(lineNumber)}:${(0, _picocolors.yellow)(column)}`;
|
||||
}
|
||||
return formattedFileName;
|
||||
}
|
||||
}
|
||||
async function getNotFoundError(compilation, input, fileName, module1) {
|
||||
if (input.name !== "ModuleNotFoundError" && !(input.name === "ModuleBuildError" && /Error: Can't resolve '.+' in /.test(input.message))) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
const { frame, lineNumber, column } = await getSourceFrame(input, fileName, compilation);
|
||||
const errorMessage = input.error.message.replace(/ in '.*?'/, "").replace(/Can't resolve '(.*)'/, `Can't resolve '${(0, _picocolors.green)("$1")}'`);
|
||||
const importTrace = ()=>{
|
||||
const moduleTrace = getModuleTrace(input, compilation).map(({ origin })=>origin.readableIdentifier(compilation.requestShortener)).filter((name)=>name && !/next-(app|middleware|client-pages|route|flight-(client|server|client-entry))-loader\.js/.test(name) && !/next-route-loader\/index\.js/.test(name) && !/css-loader.+\.js/.test(name));
|
||||
if (moduleTrace.length === 0) return "";
|
||||
return `\nImport trace for requested module:\n${moduleTrace.join("\n")}`;
|
||||
};
|
||||
let message = (0, _picocolors.red)((0, _picocolors.bold)("Module not found")) + `: ${errorMessage}` + "\n" + frame + (frame !== "" ? "\n" : "") + "\nhttps://nextjs.org/docs/messages/module-not-found\n" + importTrace();
|
||||
const formattedFileName = getFormattedFileName(fileName, module1, lineNumber, column);
|
||||
return new _simpleWebpackError.SimpleWebpackError(formattedFileName, message);
|
||||
} catch (err) {
|
||||
// Don't fail on failure to resolve sourcemaps
|
||||
return input;
|
||||
}
|
||||
}
|
||||
async function getImageError(compilation, input, err) {
|
||||
if (err.name !== "InvalidImageFormatError") {
|
||||
return false;
|
||||
}
|
||||
const moduleTrace = getModuleTrace(input, compilation);
|
||||
const { origin, module: module1 } = moduleTrace[0] || {};
|
||||
if (!origin || !module1) {
|
||||
return false;
|
||||
}
|
||||
const page = origin.rawRequest.replace(/^private-next-pages/, "./pages");
|
||||
const importedFile = module1.rawRequest;
|
||||
const source = origin.originalSource().buffer().toString("utf8");
|
||||
let lineNumber = -1;
|
||||
source.split("\n").some((line)=>{
|
||||
lineNumber++;
|
||||
return line.includes(importedFile);
|
||||
});
|
||||
return new _simpleWebpackError.SimpleWebpackError(`${(0, _picocolors.cyan)(page)}:${(0, _picocolors.yellow)(lineNumber.toString())}`, (0, _picocolors.red)((0, _picocolors.bold)("Error")).concat(`: Image import "${importedFile}" is not a valid image file. The image may be corrupted or an unsupported format.`));
|
||||
}
|
||||
|
||||
//# sourceMappingURL=parseNotFoundError.js.map
|
||||
97
.next/standalone/node_modules/next/dist/build/webpack/plugins/wellknown-errors-plugin/parseRSC.js
generated
vendored
Normal file
97
.next/standalone/node_modules/next/dist/build/webpack/plugins/wellknown-errors-plugin/parseRSC.js
generated
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "getRscError", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return getRscError;
|
||||
}
|
||||
});
|
||||
const _getModuleTrace = require("./getModuleTrace");
|
||||
const _simpleWebpackError = require("./simpleWebpackError");
|
||||
function formatRSCErrorMessage(message, isPagesDir, fileName) {
|
||||
let formattedMessage = message;
|
||||
let formattedVerboseMessage = "";
|
||||
// Comes from the "React Server Components" transform in SWC, always
|
||||
// attach the module trace.
|
||||
const NEXT_RSC_ERR_REACT_API = /.+NEXT_RSC_ERR_REACT_API: (.*?)\n/s;
|
||||
const NEXT_RSC_ERR_SERVER_IMPORT = /.+NEXT_RSC_ERR_SERVER_IMPORT: (.*?)\n/s;
|
||||
const NEXT_RSC_ERR_CLIENT_IMPORT = /.+NEXT_RSC_ERR_CLIENT_IMPORT: (.*?)\n/s;
|
||||
const NEXT_RSC_ERR_CLIENT_METADATA_EXPORT = /.+NEXT_RSC_ERR_CLIENT_METADATA_EXPORT: (.*?)\n/s;
|
||||
const NEXT_RSC_ERR_CONFLICT_METADATA_EXPORT = /NEXT_RSC_ERR_CONFLICT_METADATA_EXPORT/s;
|
||||
const NEXT_RSC_ERR_CLIENT_DIRECTIVE = /.+NEXT_RSC_ERR_CLIENT_DIRECTIVE\n/s;
|
||||
const NEXT_RSC_ERR_CLIENT_DIRECTIVE_PAREN = /.+NEXT_RSC_ERR_CLIENT_DIRECTIVE_PAREN\n/s;
|
||||
const NEXT_RSC_ERR_INVALID_API = /.+NEXT_RSC_ERR_INVALID_API: (.*?)\n/s;
|
||||
const NEXT_RSC_ERR_ERROR_FILE_SERVER_COMPONENT = /.+NEXT_RSC_ERR_ERROR_FILE_SERVER_COMPONENT/;
|
||||
if (NEXT_RSC_ERR_REACT_API.test(message)) {
|
||||
const matches = message.match(NEXT_RSC_ERR_REACT_API);
|
||||
if (matches && matches[1] === "Component") {
|
||||
formattedMessage = `\n\nYou’re importing a class component. It only works in a Client Component but none of its parents are marked with "use client", so they're Server Components by default.\nLearn more: https://nextjs.org/docs/getting-started/react-essentials#client-components\n\n`;
|
||||
} else {
|
||||
formattedMessage = message.replace(NEXT_RSC_ERR_REACT_API, `\n\nYou're importing a component that needs $1. It only works in a Client Component but none of its parents are marked with "use client", so they're Server Components by default.\nLearn more: https://nextjs.org/docs/getting-started/react-essentials\n\n`);
|
||||
}
|
||||
formattedVerboseMessage = '\n\nMaybe one of these should be marked as a client entry with "use client":\n';
|
||||
} else if (NEXT_RSC_ERR_SERVER_IMPORT.test(message)) {
|
||||
let shouldAddUseClient = true;
|
||||
const matches = message.match(NEXT_RSC_ERR_SERVER_IMPORT);
|
||||
switch(matches && matches[1]){
|
||||
case "react-dom/server":
|
||||
// If importing "react-dom/server", we should show a different error.
|
||||
formattedMessage = `\n\nYou're importing a component that imports react-dom/server. To fix it, render or return the content directly as a Server Component instead for perf and security.\nLearn more: https://nextjs.org/docs/getting-started/react-essentials`;
|
||||
break;
|
||||
case "next/router":
|
||||
// If importing "next/router", we should tell them to use "next/navigation".
|
||||
formattedMessage = `\n\nYou have a Server Component that imports next/router. Use next/navigation instead.\nLearn more: https://nextjs.org/docs/app/api-reference/functions/use-router`;
|
||||
shouldAddUseClient = false;
|
||||
break;
|
||||
default:
|
||||
formattedMessage = message.replace(NEXT_RSC_ERR_SERVER_IMPORT, `\n\nYou're importing a component that imports $1. It only works in a Client Component but none of its parents are marked with "use client", so they're Server Components by default.\nLearn more: https://nextjs.org/docs/getting-started/react-essentials\n\n`);
|
||||
}
|
||||
formattedVerboseMessage = shouldAddUseClient ? '\n\nMaybe one of these should be marked as a client entry "use client":\n' : "\n\nImport trace:\n";
|
||||
} else if (NEXT_RSC_ERR_CLIENT_IMPORT.test(message)) {
|
||||
if (isPagesDir) {
|
||||
formattedMessage = message.replace(NEXT_RSC_ERR_CLIENT_IMPORT, `\n\nYou're importing a component that needs $1. That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/getting-started/react-essentials#server-components\n\n`);
|
||||
formattedVerboseMessage = "\n\nImport trace for requested module:\n";
|
||||
} else {
|
||||
formattedMessage = message.replace(NEXT_RSC_ERR_CLIENT_IMPORT, `\n\nYou're importing a component that needs $1. That only works in a Server Component but one of its parents is marked with "use client", so it's a Client Component.\nLearn more: https://nextjs.org/docs/getting-started/react-essentials\n\n`);
|
||||
formattedVerboseMessage = '\n\nOne of these is marked as a client entry with "use client":\n';
|
||||
}
|
||||
} else if (NEXT_RSC_ERR_CLIENT_DIRECTIVE.test(message)) {
|
||||
formattedMessage = message.replace(NEXT_RSC_ERR_CLIENT_DIRECTIVE, `\n\nThe "use client" directive must be placed before other expressions. Move it to the top of the file to resolve this issue.\n\n`);
|
||||
formattedVerboseMessage = "\n\nImport path:\n";
|
||||
} else if (NEXT_RSC_ERR_CLIENT_DIRECTIVE_PAREN.test(message)) {
|
||||
formattedMessage = message.replace(NEXT_RSC_ERR_CLIENT_DIRECTIVE_PAREN, `\n\n"use client" must be a directive, and placed before other expressions. Remove the parentheses and move it to the top of the file to resolve this issue.\nLearn more: https://nextjs.org/docs/getting-started/react-essentials#the-use-client-directive\n\n`);
|
||||
formattedVerboseMessage = "\n\nImport path:\n";
|
||||
} else if (NEXT_RSC_ERR_INVALID_API.test(message)) {
|
||||
formattedMessage = message.replace(NEXT_RSC_ERR_INVALID_API, `\n\n"$1" is not supported in app/. Read more: https://nextjs.org/docs/app/building-your-application/data-fetching\n\n`);
|
||||
formattedVerboseMessage = "\n\nFile path:\n";
|
||||
} else if (NEXT_RSC_ERR_ERROR_FILE_SERVER_COMPONENT.test(message)) {
|
||||
formattedMessage = message.replace(NEXT_RSC_ERR_ERROR_FILE_SERVER_COMPONENT, `\n\n${fileName} must be a Client Component. Add the "use client" directive the top of the file to resolve this issue.\nLearn more: https://nextjs.org/docs/getting-started/react-essentials#client-components\n\n`);
|
||||
formattedVerboseMessage = "\n\nImport path:\n";
|
||||
} else if (NEXT_RSC_ERR_CLIENT_METADATA_EXPORT.test(message)) {
|
||||
formattedMessage = message.replace(NEXT_RSC_ERR_CLIENT_METADATA_EXPORT, `\n\nYou are attempting to export "$1" from a component marked with "use client", which is disallowed. Either remove the export, or the "use client" directive. Read more: https://nextjs.org/docs/getting-started/react-essentials#the-use-client-directive\n\n`);
|
||||
formattedVerboseMessage = "\n\nFile path:\n";
|
||||
} else if (NEXT_RSC_ERR_CONFLICT_METADATA_EXPORT.test(message)) {
|
||||
formattedMessage = message.replace(NEXT_RSC_ERR_CONFLICT_METADATA_EXPORT, `\n\n"metadata" and "generateMetadata" cannot be exported at the same time, please keep one of them. Read more: https://nextjs.org/docs/app/api-reference/file-conventions/metadata\n\n`);
|
||||
formattedVerboseMessage = "\n\nFile path:\n";
|
||||
}
|
||||
return [
|
||||
formattedMessage,
|
||||
formattedVerboseMessage
|
||||
];
|
||||
}
|
||||
function getRscError(fileName, err, module, compilation, compiler) {
|
||||
if (!err.message || !/NEXT_RSC_ERR_/.test(err.message)) {
|
||||
return false;
|
||||
}
|
||||
const { isPagesDir, moduleTrace } = (0, _getModuleTrace.getModuleTrace)(module, compilation, compiler);
|
||||
const formattedError = formatRSCErrorMessage(err.message, isPagesDir, fileName);
|
||||
const { formattedModuleTrace, lastInternalFileName, invalidImportMessage } = (0, _getModuleTrace.formatModuleTrace)(compiler, moduleTrace);
|
||||
const error = new _simpleWebpackError.SimpleWebpackError(lastInternalFileName, "ReactServerComponentsError:\n" + formattedError[0] + invalidImportMessage + formattedError[1] + formattedModuleTrace);
|
||||
// Delete the stack because it's created here.
|
||||
error.stack = "";
|
||||
return error;
|
||||
}
|
||||
|
||||
//# sourceMappingURL=parseRSC.js.map
|
||||
42
.next/standalone/node_modules/next/dist/build/webpack/plugins/wellknown-errors-plugin/parseScss.js
generated
vendored
Normal file
42
.next/standalone/node_modules/next/dist/build/webpack/plugins/wellknown-errors-plugin/parseScss.js
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "getScssError", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return getScssError;
|
||||
}
|
||||
});
|
||||
const _picocolors = require("../../../../lib/picocolors");
|
||||
const _simpleWebpackError = require("./simpleWebpackError");
|
||||
const regexScssError = /SassError: (.+)\n\s+on line (\d+) [\s\S]*?>> (.+)\n\s*(-+)\^$/m;
|
||||
function getScssError(fileName, fileContent, err) {
|
||||
if (err.name !== "SassError") {
|
||||
return false;
|
||||
}
|
||||
const res = regexScssError.exec(err.message);
|
||||
if (res) {
|
||||
const [, reason, _lineNumer, backupFrame, columnString] = res;
|
||||
const lineNumber = Math.max(1, parseInt(_lineNumer, 10));
|
||||
const column = (columnString == null ? void 0 : columnString.length) ?? 1;
|
||||
let frame;
|
||||
if (fileContent) {
|
||||
try {
|
||||
const { codeFrameColumns } = require("next/dist/compiled/babel/code-frame");
|
||||
frame = codeFrameColumns(fileContent, {
|
||||
start: {
|
||||
line: lineNumber,
|
||||
column
|
||||
}
|
||||
}, {
|
||||
forceColor: true
|
||||
});
|
||||
} catch {}
|
||||
}
|
||||
return new _simpleWebpackError.SimpleWebpackError(`${(0, _picocolors.cyan)(fileName)}:${(0, _picocolors.yellow)(lineNumber.toString())}:${(0, _picocolors.yellow)(column.toString())}`, (0, _picocolors.red)((0, _picocolors.bold)("Syntax error")).concat(`: ${reason}\n\n${frame ?? backupFrame}`));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//# sourceMappingURL=parseScss.js.map
|
||||
18
.next/standalone/node_modules/next/dist/build/webpack/plugins/wellknown-errors-plugin/simpleWebpackError.js
generated
vendored
Normal file
18
.next/standalone/node_modules/next/dist/build/webpack/plugins/wellknown-errors-plugin/simpleWebpackError.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "SimpleWebpackError", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return SimpleWebpackError;
|
||||
}
|
||||
});
|
||||
class SimpleWebpackError extends Error {
|
||||
constructor(file, message){
|
||||
super(message);
|
||||
this.file = file;
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=simpleWebpackError.js.map
|
||||
143
.next/standalone/node_modules/next/dist/build/webpack/plugins/wellknown-errors-plugin/webpackModuleError.js
generated
vendored
Normal file
143
.next/standalone/node_modules/next/dist/build/webpack/plugins/wellknown-errors-plugin/webpackModuleError.js
generated
vendored
Normal file
@@ -0,0 +1,143 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "getModuleBuildError", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return getModuleBuildError;
|
||||
}
|
||||
});
|
||||
const _fs = require("fs");
|
||||
const _path = /*#__PURE__*/ _interop_require_wildcard(require("path"));
|
||||
const _parseBabel = require("./parseBabel");
|
||||
const _parseCss = require("./parseCss");
|
||||
const _parseScss = require("./parseScss");
|
||||
const _parseNotFoundError = require("./parseNotFoundError");
|
||||
const _iserror = /*#__PURE__*/ _interop_require_default(require("../../../../lib/is-error"));
|
||||
const _parseRSC = require("./parseRSC");
|
||||
const _parseNextFontError = require("./parseNextFontError");
|
||||
const _parseNextAppLoaderError = require("./parseNextAppLoaderError");
|
||||
const _parseNextInvalidImportError = require("./parseNextInvalidImportError");
|
||||
function _interop_require_default(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
function _getRequireWildcardCache(nodeInterop) {
|
||||
if (typeof WeakMap !== "function") return null;
|
||||
var cacheBabelInterop = new WeakMap();
|
||||
var cacheNodeInterop = new WeakMap();
|
||||
return (_getRequireWildcardCache = function(nodeInterop) {
|
||||
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
||||
})(nodeInterop);
|
||||
}
|
||||
function _interop_require_wildcard(obj, nodeInterop) {
|
||||
if (!nodeInterop && obj && obj.__esModule) {
|
||||
return obj;
|
||||
}
|
||||
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
||||
return {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
var cache = _getRequireWildcardCache(nodeInterop);
|
||||
if (cache && cache.has(obj)) {
|
||||
return cache.get(obj);
|
||||
}
|
||||
var newObj = {
|
||||
__proto__: null
|
||||
};
|
||||
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
||||
for(var key in obj){
|
||||
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
||||
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
||||
if (desc && (desc.get || desc.set)) {
|
||||
Object.defineProperty(newObj, key, desc);
|
||||
} else {
|
||||
newObj[key] = obj[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
newObj.default = obj;
|
||||
if (cache) {
|
||||
cache.set(obj, newObj);
|
||||
}
|
||||
return newObj;
|
||||
}
|
||||
function getFileData(compilation, m) {
|
||||
var _compilation_compiler;
|
||||
let resolved;
|
||||
let ctx = ((_compilation_compiler = compilation.compiler) == null ? void 0 : _compilation_compiler.context) ?? null;
|
||||
if (ctx !== null && typeof m.resource === "string") {
|
||||
const res = _path.relative(ctx, m.resource).replace(/\\/g, _path.posix.sep);
|
||||
resolved = res.startsWith(".") ? res : `.${_path.posix.sep}${res}`;
|
||||
} else {
|
||||
const requestShortener = compilation.requestShortener;
|
||||
if (typeof (m == null ? void 0 : m.readableIdentifier) === "function") {
|
||||
resolved = m.readableIdentifier(requestShortener);
|
||||
} else {
|
||||
resolved = m.request ?? m.userRequest;
|
||||
}
|
||||
}
|
||||
if (resolved) {
|
||||
let content = null;
|
||||
try {
|
||||
content = (0, _fs.readFileSync)(ctx ? _path.resolve(ctx, resolved) : resolved, "utf8");
|
||||
} catch {}
|
||||
return [
|
||||
resolved,
|
||||
content
|
||||
];
|
||||
}
|
||||
return [
|
||||
"<unknown>",
|
||||
null
|
||||
];
|
||||
}
|
||||
async function getModuleBuildError(compiler, compilation, input) {
|
||||
if (!(typeof input === "object" && ((input == null ? void 0 : input.name) === "ModuleBuildError" || (input == null ? void 0 : input.name) === "ModuleNotFoundError") && Boolean(input.module) && (0, _iserror.default)(input.error))) {
|
||||
return false;
|
||||
}
|
||||
const err = input.error;
|
||||
const [sourceFilename, sourceContent] = getFileData(compilation, input.module);
|
||||
const notFoundError = await (0, _parseNotFoundError.getNotFoundError)(compilation, input, sourceFilename, input.module);
|
||||
if (notFoundError !== false) {
|
||||
return notFoundError;
|
||||
}
|
||||
const imageError = await (0, _parseNotFoundError.getImageError)(compilation, input, err);
|
||||
if (imageError !== false) {
|
||||
return imageError;
|
||||
}
|
||||
const babel = (0, _parseBabel.getBabelError)(sourceFilename, err);
|
||||
if (babel !== false) {
|
||||
return babel;
|
||||
}
|
||||
const css = (0, _parseCss.getCssError)(sourceFilename, err);
|
||||
if (css !== false) {
|
||||
return css;
|
||||
}
|
||||
const scss = (0, _parseScss.getScssError)(sourceFilename, sourceContent, err);
|
||||
if (scss !== false) {
|
||||
return scss;
|
||||
}
|
||||
const rsc = (0, _parseRSC.getRscError)(sourceFilename, err, input.module, compilation, compiler);
|
||||
if (rsc !== false) {
|
||||
return rsc;
|
||||
}
|
||||
const nextFont = (0, _parseNextFontError.getNextFontError)(err, input.module);
|
||||
if (nextFont !== false) {
|
||||
return nextFont;
|
||||
}
|
||||
const nextAppLoader = (0, _parseNextAppLoaderError.getNextAppLoaderError)(err, input.module, compiler);
|
||||
if (nextAppLoader !== false) {
|
||||
return nextAppLoader;
|
||||
}
|
||||
const invalidImportError = (0, _parseNextInvalidImportError.getNextInvalidImportError)(err, input.module, compilation, compiler);
|
||||
if (invalidImportError !== false) {
|
||||
return invalidImportError;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//# sourceMappingURL=webpackModuleError.js.map
|
||||
Reference in New Issue
Block a user