create project

This commit is contained in:
ismailsosic
2022-12-27 12:05:56 +01:00
parent 2a33a2d3de
commit cd2143287c
16035 changed files with 2489703 additions and 0 deletions

67
kitabcitab/node_modules/next/README.md generated vendored Normal file
View File

@@ -0,0 +1,67 @@
<p align="center">
<a href="https://nextjs.org">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://assets.vercel.com/image/upload/v1662130559/nextjs/Icon_dark_background.png">
<img src="https://assets.vercel.com/image/upload/v1662130559/nextjs/Icon_light_background.png" height="128">
</picture>
<h1 align="center">Next.js</h1>
</a>
</p>
<p align="center">
<a aria-label="Vercel logo" href="https://vercel.com">
<img src="https://img.shields.io/badge/MADE%20BY%20Vercel-000000.svg?style=for-the-badge&logo=Vercel&labelColor=000">
</a>
<a aria-label="NPM version" href="https://www.npmjs.com/package/next">
<img alt="" src="https://img.shields.io/npm/v/next.svg?style=for-the-badge&labelColor=000000">
</a>
<a aria-label="License" href="https://github.com/vercel/next.js/blob/canary/license.md">
<img alt="" src="https://img.shields.io/npm/l/next.svg?style=for-the-badge&labelColor=000000">
</a>
<a aria-label="Join the community on GitHub" href="https://github.com/vercel/next.js/discussions">
<img alt="" src="https://img.shields.io/badge/Join%20the%20community-blueviolet.svg?style=for-the-badge&logo=Next.js&labelColor=000000&logoWidth=20">
</a>
</p>
## Getting Started
Visit <a aria-label="next.js learn" href="https://nextjs.org/learn">https://nextjs.org/learn</a> to get started with Next.js.
## Documentation
Visit [https://nextjs.org/docs](https://nextjs.org/docs) to view the full documentation.
## Who is using Next.js?
Next.js is used by the world's leading companies. Check out the [Next.js Showcase](https://nextjs.org/showcase) to learn more.
## Community
The Next.js community can be found on [GitHub Discussions](https://github.com/vercel/next.js/discussions), where you can ask questions, voice ideas, and share your projects.
To chat with other community members you can join the [Next.js Discord](https://nextjs.org/discord).
Our [Code of Conduct](https://github.com/vercel/next.js/blob/canary/CODE_OF_CONDUCT.md) applies to all Next.js community channels.
## Contributing
Please see our [contributing.md](/contributing.md).
### Good First Issues
We have a list of [good first issues](https://github.com/vercel/next.js/labels/good%20first%20issue) that contain bugs that have a relatively limited scope. This is a great place to get started, gain experience, and get familiar with our contribution process.
## Authors
- Tim Neutkens ([@timneutkens](https://twitter.com/timneutkens))
- Naoyuki Kanezawa ([@nkzawa](https://twitter.com/nkzawa))
- Guillermo Rauch ([@rauchg](https://twitter.com/rauchg))
- Arunoda Susiripala ([@arunoda](https://twitter.com/arunoda))
- Tony Kovanen ([@tonykovanen](https://twitter.com/tonykovanen))
- Dan Zajdband ([@impronunciable](https://twitter.com/impronunciable))
## Security
If you believe you have found a security vulnerability in Next.js, we encourage you to responsibly disclose this and not open a public issue. We will investigate all legitimate reports. Email `security@vercel.com` to disclose any security vulnerabilities.
https://vercel.com/security

1
kitabcitab/node_modules/next/amp.d.ts generated vendored Normal file
View File

@@ -0,0 +1 @@
export * from './dist/shared/lib/amp'

1
kitabcitab/node_modules/next/amp.js generated vendored Normal file
View File

@@ -0,0 +1 @@
module.exports = require('./dist/shared/lib/amp')

3
kitabcitab/node_modules/next/app.d.ts generated vendored Normal file
View File

@@ -0,0 +1,3 @@
import App from './dist/pages/_app'
export * from './dist/pages/_app'
export default App

1
kitabcitab/node_modules/next/app.js generated vendored Normal file
View File

@@ -0,0 +1 @@
module.exports = require('./dist/pages/_app')

1
kitabcitab/node_modules/next/babel.d.ts generated vendored Normal file
View File

@@ -0,0 +1 @@
export * from './dist/build/babel/preset'

1
kitabcitab/node_modules/next/babel.js generated vendored Normal file
View File

@@ -0,0 +1 @@
module.exports = require('./dist/build/babel/preset')

1
kitabcitab/node_modules/next/client.d.ts generated vendored Normal file
View File

@@ -0,0 +1 @@
export * from './dist/client/index'

1
kitabcitab/node_modules/next/client.js generated vendored Normal file
View File

@@ -0,0 +1 @@
module.exports = require('./dist/client/index')

1
kitabcitab/node_modules/next/compat/router.d.ts generated vendored Normal file
View File

@@ -0,0 +1 @@
export * from '../dist/client/compat/router'

1
kitabcitab/node_modules/next/compat/router.js generated vendored Normal file
View File

@@ -0,0 +1 @@
module.exports = require('../dist/client/compat/router')

3
kitabcitab/node_modules/next/config.d.ts generated vendored Normal file
View File

@@ -0,0 +1,3 @@
import getConfig from './dist/shared/lib/runtime-config'
export * from './dist/shared/lib/runtime-config'
export default getConfig

1
kitabcitab/node_modules/next/config.js generated vendored Normal file
View File

@@ -0,0 +1 @@
module.exports = require('./dist/shared/lib/runtime-config')

1
kitabcitab/node_modules/next/constants.d.ts generated vendored Normal file
View File

@@ -0,0 +1 @@
export * from './dist/shared/lib/constants'

1
kitabcitab/node_modules/next/constants.js generated vendored Normal file
View File

@@ -0,0 +1 @@
module.exports = require('./dist/shared/lib/constants')

149
kitabcitab/node_modules/next/dist/bin/next generated vendored Executable file
View File

@@ -0,0 +1,149 @@
#!/usr/bin/env node
"use strict";
var log = _interopRequireWildcard(require("../build/output/log"));
var _indexJs = _interopRequireDefault(require("next/dist/compiled/arg/index.js"));
var _constants = require("../lib/constants");
var _commands = require("../lib/commands");
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
function _getRequireWildcardCache() {
if (typeof WeakMap !== "function") return null;
var cache = new WeakMap();
_getRequireWildcardCache = function() {
return cache;
};
return cache;
}
function _interopRequireWildcard(obj) {
if (obj && obj.__esModule) {
return obj;
}
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
return {
default: obj
};
}
var cache = _getRequireWildcardCache();
if (cache && cache.has(obj)) {
return cache.get(obj);
}
var newObj = {};
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
for(var key in obj){
if (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;
}
[
"react",
"react-dom"
].forEach((dependency)=>{
try {
// When 'npm link' is used it checks the clone location. Not the project.
require.resolve(dependency);
} catch (err) {
console.warn(`The module '${dependency}' was not found. Next.js requires that you include it in 'dependencies' of your 'package.json'. To add it, run 'npm install ${dependency}'`);
}
});
const defaultCommand = "dev";
const args = (0, _indexJs).default({
// Types
"--version": Boolean,
"--help": Boolean,
"--inspect": Boolean,
// Aliases
"-v": "--version",
"-h": "--help"
}, {
permissive: true
});
// Version is inlined into the file using taskr build pipeline
if (args["--version"]) {
console.log(`Next.js v${"13.1.1"}`);
process.exit(0);
}
// Check if we are running `next <subcommand>` or `next`
const foundCommand = Boolean(_commands.commands[args._[0]]);
// Makes sure the `next --help` case is covered
// This help message is only showed for `next --help`
// `next <subcommand> --help` falls through to be handled later
if (!foundCommand && args["--help"]) {
console.log(`
Usage
$ next <command>
Available commands
${Object.keys(_commands.commands).join(", ")}
Options
--version, -v Version number
--help, -h Displays this message
For more information run a command with the --help flag
$ next build --help
`);
process.exit(0);
}
const command = foundCommand ? args._[0] : defaultCommand;
const forwardedArgs = foundCommand ? args._.slice(1) : args._;
if (args["--inspect"]) throw new Error(`--inspect flag is deprecated. Use env variable NODE_OPTIONS instead: NODE_OPTIONS='--inspect' next ${command}`);
// Make sure the `next <subcommand> --help` case is covered
if (args["--help"]) {
forwardedArgs.push("--help");
}
const defaultEnv = command === "dev" ? "development" : "production";
const standardEnv = [
"production",
"development",
"test"
];
if (process.env.NODE_ENV) {
const isNotStandard = !standardEnv.includes(process.env.NODE_ENV);
const shouldWarnCommands = process.env.NODE_ENV === "development" ? [
"start",
"build"
] : process.env.NODE_ENV === "production" ? [
"dev"
] : [];
if (isNotStandard || shouldWarnCommands.includes(command)) {
log.warn(_constants.NON_STANDARD_NODE_ENV);
}
}
process.env.NODE_ENV = process.env.NODE_ENV || defaultEnv;
process.env.NEXT_RUNTIME = "nodejs";
// x-ref: https://github.com/vercel/next.js/pull/34688#issuecomment-1047994505
if (process.versions.pnp === "3") {
const nodeVersionParts = process.versions.node.split(".").map((v)=>Number(v));
if (nodeVersionParts[0] < 16 || nodeVersionParts[0] === 16 && nodeVersionParts[1] < 14) {
log.warn("Node.js 16.14+ is required for Yarn PnP 3.20+. More info: https://github.com/vercel/next.js/pull/34688#issuecomment-1047994505");
}
}
// Make sure commands gracefully respect termination signals (e.g. from Docker)
// Allow the graceful termination to be manually configurable
if (!process.env.NEXT_MANUAL_SIG_HANDLE && command !== "dev") {
process.on("SIGTERM", ()=>process.exit(0));
process.on("SIGINT", ()=>process.exit(0));
}
_commands.commands[command]().then((exec)=>exec(forwardedArgs)).then(()=>{
if (command === "build") {
// ensure process exits after build completes so open handles/connections
// don't cause process to hang
process.exit(0);
}
});
//# sourceMappingURL=next.map

2
kitabcitab/node_modules/next/dist/bin/next.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
#!/usr/bin/env node
export {};

1
kitabcitab/node_modules/next/dist/bin/next.map generated vendored Executable file
View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../bin/next.ts"],"names":["log","forEach","dependency","require","resolve","err","console","warn","defaultCommand","args","arg","Boolean","permissive","process","env","__NEXT_VERSION","exit","foundCommand","commands","_","Object","keys","join","command","forwardedArgs","slice","Error","push","defaultEnv","standardEnv","NODE_ENV","isNotStandard","includes","shouldWarnCommands","NON_STANDARD_NODE_ENV","NEXT_RUNTIME","versions","pnp","nodeVersionParts","node","split","map","v","Number","NEXT_MANUAL_SIG_HANDLE","on","then","exec"],"mappings":"AAAA;;AACYA,IAAAA,GAAG,mCAAM,qBAAqB,EAA3B;AACC,IAAA,QAAiC,kCAAjC,iCAAiC,EAAA;AACX,IAAA,UAAkB,WAAlB,kBAAkB,CAAA;AAC/B,IAAA,SAAiB,WAAjB,iBAAiB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACzC;IAAC,OAAO;IAAE,WAAW;CAAC,CAACC,OAAO,CAAC,CAACC,UAAU,GAAK;IAC9C,IAAI;QACF,yEAAyE;QACzEC,OAAO,CAACC,OAAO,CAACF,UAAU,CAAC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AC,GAAG,CAAC,CACVC,GAAG,CAAC,CAACC,CAAC,GAAKC,MAAM,CAACD,CAAC,CAAC,CAAC;IAExB,IACEJ,gBAAgB,CAAC,CAAC,CAAC,GAAG,EAAE,IACvBA,gBAAgB,CAAC,CAAC,CAAC,KAAK,EAAE,IAAIA,gBAAgB,CAAC,CAAC,CAAC,GAAG,EAAE,AAAC,EACxD;QACAtC,GAAG,CAACO,IAAI,CACN,gIAAgI,CACjI;KACF;CACF;AAED,+EAA+E;AAC/E,6DAA6D;AAC7D,IAAI,CAACM,OAAO,CAACC,GAAG,CAAC8B,sBAAsB,IAAIrB,OAAO,KAAK,KAAK,EAAE;IAC5DV,OAAO,CAACgC,EAAE,CAAC,SAAS,EAAE,IAAMhC,OAAO,CAACG,IAAI,CAAC,CAAC,CAAC,CAAC;IAC5CH,OAAO,CAACgC,EAAE,CAAC,QAAQ,EAAE,IAAMhC,OAAO,CAACG,IAAI,CAAC,CAAC,CAAC,CAAC;CAC5C;AAEDE,SAAQ,SAAA,CAACK,OAAO,CAAC,EAAE,CAChBuB,IAAI,CAAC,CAACC,IAAI,GAAKA,IAAI,CAACvB,aAAa,CAAC,CAAC,CACnCsB,IAAI,CAAC,IAAM;IACV,IAAIvB,OAAO,KAAK,OAAO,EAAE;QACvB,yEAAyE;QACzE,8BAA8B;QAC9BV,OAAO,CAACG,IAAI,CAAC,CAAC,CAAC;KAChB;CACF,CAAC"}

View File

@@ -0,0 +1,23 @@
import type { Module } from '@swc/core';
export declare class NoSuchDeclarationError extends Error {
}
export declare class UnsupportedValueError extends Error {
/** @example `config.runtime[0].value` */
path?: string;
constructor(message: string, paths?: string[]);
}
/**
* Extracts the value of an exported const variable named `exportedName`
* (e.g. "export const config = { runtime: 'edge' }") from swc's AST.
* The value must be one of (or throws UnsupportedValueError):
* - string
* - boolean
* - number
* - null
* - undefined
* - array containing values listed in this list
* - object containing values listed in this list
*
* Throws NoSuchDeclarationError if the declaration is not found.
*/
export declare function extractExportedConstValue(module: Module, exportedName: string): any;

View File

@@ -0,0 +1,181 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.extractExportedConstValue = extractExportedConstValue;
class NoSuchDeclarationError extends Error {
}
exports.NoSuchDeclarationError = NoSuchDeclarationError;
function isExportDeclaration(node) {
return node.type === "ExportDeclaration";
}
function isVariableDeclaration(node) {
return node.type === "VariableDeclaration";
}
function isIdentifier(node) {
return node.type === "Identifier";
}
function isBooleanLiteral(node) {
return node.type === "BooleanLiteral";
}
function isNullLiteral(node) {
return node.type === "NullLiteral";
}
function isStringLiteral(node) {
return node.type === "StringLiteral";
}
function isNumericLiteral(node) {
return node.type === "NumericLiteral";
}
function isArrayExpression(node) {
return node.type === "ArrayExpression";
}
function isObjectExpression(node) {
return node.type === "ObjectExpression";
}
function isKeyValueProperty(node) {
return node.type === "KeyValueProperty";
}
function isRegExpLiteral(node) {
return node.type === "RegExpLiteral";
}
function isTemplateLiteral(node) {
return node.type === "TemplateLiteral";
}
class UnsupportedValueError extends Error {
constructor(message, paths){
super(message);
// Generating "path" that looks like "config.runtime[0].value"
let codePath;
if (paths) {
codePath = "";
for (const path of paths){
if (path[0] === "[") {
// "array" + "[0]"
codePath += path;
} else {
if (codePath === "") {
codePath = path;
} else {
// "object" + ".key"
codePath += `.${path}`;
}
}
}
}
this.path = codePath;
}
}
exports.UnsupportedValueError = UnsupportedValueError;
function extractValue(node, path) {
if (isNullLiteral(node)) {
return null;
} else if (isBooleanLiteral(node)) {
// e.g. true / false
return node.value;
} else if (isStringLiteral(node)) {
// e.g. "abc"
return node.value;
} else if (isNumericLiteral(node)) {
// e.g. 123
return node.value;
} else if (isRegExpLiteral(node)) {
// e.g. /abc/i
return new RegExp(node.pattern, node.flags);
} else if (isIdentifier(node)) {
switch(node.value){
case "undefined":
return undefined;
default:
throw new UnsupportedValueError(`Unknown identifier "${node.value}"`, path);
}
} else if (isArrayExpression(node)) {
// e.g. [1, 2, 3]
const arr = [];
for(let i = 0, len = node.elements.length; i < len; i++){
const elem = node.elements[i];
if (elem) {
if (elem.spread) {
// e.g. [ ...a ]
throw new UnsupportedValueError("Unsupported spread operator in the Array Expression", path);
}
arr.push(extractValue(elem.expression, path && [
...path,
`[${i}]`
]));
} else {
// e.g. [1, , 2]
// ^^
arr.push(undefined);
}
}
return arr;
} else if (isObjectExpression(node)) {
// e.g. { a: 1, b: 2 }
const obj = {};
for (const prop of node.properties){
if (!isKeyValueProperty(prop)) {
// e.g. { ...a }
throw new UnsupportedValueError("Unsupported spread operator in the Object Expression", path);
}
let key;
if (isIdentifier(prop.key)) {
// e.g. { a: 1, b: 2 }
key = prop.key.value;
} else if (isStringLiteral(prop.key)) {
// e.g. { "a": 1, "b": 2 }
key = prop.key.value;
} else {
throw new UnsupportedValueError(`Unsupported key type "${prop.key.type}" in the Object Expression`, path);
}
obj[key] = extractValue(prop.value, path && [
...path,
key
]);
}
return obj;
} else if (isTemplateLiteral(node)) {
// e.g. `abc`
if (node.expressions.length !== 0) {
// TODO: should we add support for `${'e'}d${'g'}'e'`?
throw new UnsupportedValueError("Unsupported template literal with expressions", path);
}
// When TemplateLiteral has 0 expressions, the length of quasis is always 1.
// Because when parsing TemplateLiteral, the parser yields the first quasi,
// then the first expression, then the next quasi, then the next expression, etc.,
// until the last quasi.
// Thus if there is no expression, the parser ends at the frst and also last quasis
//
// A "cooked" interpretation where backslashes have special meaning, while a
// "raw" interpretation where backslashes do not have special meaning
// https://exploringjs.com/impatient-js/ch_template-literals.html#template-strings-cooked-vs-raw
const [{ cooked , raw }] = node.quasis;
return cooked ?? raw;
} else {
throw new UnsupportedValueError(`Unsupported node type "${node.type}"`, path);
}
}
function extractExportedConstValue(module, exportedName) {
for (const moduleItem of module.body){
if (!isExportDeclaration(moduleItem)) {
continue;
}
const declaration = moduleItem.declaration;
if (!isVariableDeclaration(declaration)) {
continue;
}
if (declaration.kind !== "const") {
continue;
}
for (const decl of declaration.declarations){
if (isIdentifier(decl.id) && decl.id.value === exportedName && decl.init) {
return extractValue(decl.init, [
exportedName
]);
}
}
}
throw new NoSuchDeclarationError();
}
//# sourceMappingURL=extract-const-value.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,37 @@
import type { NextConfig } from '../../server/config-shared';
import type { RouteHas } from '../../lib/load-custom-routes';
import { ServerRuntime } from 'next/types';
export interface MiddlewareConfig {
matchers: MiddlewareMatcher[];
unstable_allowDynamicGlobs: string[];
regions: string[] | string;
}
export interface MiddlewareMatcher {
regexp: string;
locale?: false;
has?: RouteHas[];
missing?: RouteHas[];
}
export interface PageStaticInfo {
runtime?: ServerRuntime;
ssg?: boolean;
ssr?: boolean;
rsc?: RSCModuleType;
middleware?: Partial<MiddlewareConfig>;
}
export declare type RSCModuleType = 'server' | 'client';
export declare function getRSCModuleType(source: string): RSCModuleType;
/**
* For a given pageFilePath and nextConfig, if the config supports it, this
* function will read the file and return the runtime that should be used.
* It will look into the file content only if the page *requires* a runtime
* to be specified, that is, when gSSP or gSP is used.
* Related discussion: https://github.com/vercel/next.js/discussions/34179
*/
export declare function getPageStaticInfo(params: {
nextConfig: Partial<NextConfig>;
pageFilePath: string;
isDev?: boolean;
page?: string;
pageType?: 'pages' | 'app';
}): Promise<PageStaticInfo>;

View File

@@ -0,0 +1,287 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getRSCModuleType = getRSCModuleType;
exports.getPageStaticInfo = getPageStaticInfo;
var _fs = require("fs");
var _micromatch = require("next/dist/compiled/micromatch");
var _extractConstValue = require("./extract-const-value");
var _parseModule = require("./parse-module");
var Log = _interopRequireWildcard(require("../output/log"));
var _constants = require("../../lib/constants");
var _loadCustomRoutes = require("../../lib/load-custom-routes");
var _tryToParsePath = require("../../lib/try-to-parse-path");
var _isApiRoute = require("../../lib/is-api-route");
var _isEdgeRuntime = require("../../lib/is-edge-runtime");
var _constants1 = require("../../shared/lib/constants");
function _getRequireWildcardCache() {
if (typeof WeakMap !== "function") return null;
var cache = new WeakMap();
_getRequireWildcardCache = function() {
return cache;
};
return cache;
}
function _interopRequireWildcard(obj) {
if (obj && obj.__esModule) {
return obj;
}
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
return {
default: obj
};
}
var cache = _getRequireWildcardCache();
if (cache && cache.has(obj)) {
return cache.get(obj);
}
var newObj = {};
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
for(var key in obj){
if (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 CLIENT_MODULE_LABEL = `/* __next_internal_client_entry_do_not_use__ */`;
function getRSCModuleType(source) {
return source.includes(CLIENT_MODULE_LABEL) ? _constants1.RSC_MODULE_TYPES.client : _constants1.RSC_MODULE_TYPES.server;
}
/**
* Receives a parsed AST from SWC and checks if it belongs to a module that
* requires a runtime to be specified. Those are:
* - Modules with `export function getStaticProps | getServerSideProps`
* - Modules with `export { getStaticProps | getServerSideProps } <from ...>`
* - Modules with `export const runtime = ...`
*/ function checkExports(swcAST) {
if (Array.isArray(swcAST == null ? void 0 : swcAST.body)) {
try {
let runtime;
let ssr = false;
let ssg = false;
for (const node of swcAST.body){
var ref11, ref1, ref2, ref3;
if (node.type === "ExportDeclaration" && ((ref11 = node.declaration) == null ? void 0 : ref11.type) === "VariableDeclaration") {
var ref4, ref5;
const id = (ref5 = (ref4 = node.declaration) == null ? void 0 : ref4.declarations[0]) == null ? void 0 : ref5.id.value;
if (id === "runtime") {
var ref6, ref7;
runtime = (ref7 = (ref6 = node.declaration) == null ? void 0 : ref6.declarations[0]) == null ? void 0 : ref7.init.value;
}
}
if (node.type === "ExportDeclaration" && ((ref1 = node.declaration) == null ? void 0 : ref1.type) === "FunctionDeclaration" && [
"getStaticProps",
"getServerSideProps"
].includes((ref2 = node.declaration.identifier) == null ? void 0 : ref2.value)) {
ssg = node.declaration.identifier.value === "getStaticProps";
ssr = node.declaration.identifier.value === "getServerSideProps";
}
if (node.type === "ExportDeclaration" && ((ref3 = node.declaration) == null ? void 0 : ref3.type) === "VariableDeclaration") {
var ref8, ref9;
const id = (ref9 = (ref8 = node.declaration) == null ? void 0 : ref8.declarations[0]) == null ? void 0 : ref9.id.value;
if ([
"getStaticProps",
"getServerSideProps"
].includes(id)) {
ssg = id === "getStaticProps";
ssr = id === "getServerSideProps";
}
}
if (node.type === "ExportNamedDeclaration") {
const values = node.specifiers.map((specifier)=>{
var ref, ref10;
return specifier.type === "ExportSpecifier" && ((ref = specifier.orig) == null ? void 0 : ref.type) === "Identifier" && ((ref10 = specifier.orig) == null ? void 0 : ref10.value);
});
ssg = values.some((value)=>[
"getStaticProps"
].includes(value));
ssr = values.some((value)=>[
"getServerSideProps"
].includes(value));
}
}
return {
ssr,
ssg,
runtime
};
} catch (err) {}
}
return {
ssg: false,
ssr: false
};
}
async function tryToReadFile(filePath, shouldThrow) {
try {
return await _fs.promises.readFile(filePath, {
encoding: "utf8"
});
} catch (error) {
if (shouldThrow) {
throw error;
}
}
}
function getMiddlewareMatchers(matcherOrMatchers, nextConfig) {
let matchers = [];
if (Array.isArray(matcherOrMatchers)) {
matchers = matcherOrMatchers;
} else {
matchers.push(matcherOrMatchers);
}
const { i18n } = nextConfig;
let routes = matchers.map((m)=>typeof m === "string" ? {
source: m
} : m);
// check before we process the routes and after to ensure
// they are still valid
(0, _loadCustomRoutes).checkCustomRoutes(routes, "middleware");
routes = routes.map((r)=>{
let { source } = r;
const isRoot = source === "/";
if ((i18n == null ? void 0 : i18n.locales) && r.locale !== false) {
source = `/:nextInternalLocale([^/.]{1,})${isRoot ? "" : source}`;
}
source = `/:nextData(_next/data/[^/]{1,})?${source}${isRoot ? `(${nextConfig.i18n ? "|\\.json|" : ""}/?index|/?index\\.json)?` : "(.json)?"}`;
if (nextConfig.basePath) {
source = `${nextConfig.basePath}${source}`;
}
return {
...r,
source
};
});
(0, _loadCustomRoutes).checkCustomRoutes(routes, "middleware");
return routes.map((r)=>{
const { source , ...rest } = r;
const parsedPage = (0, _tryToParsePath).tryToParsePath(source);
if (parsedPage.error || !parsedPage.regexStr) {
throw new Error(`Invalid source: ${source}`);
}
return {
...rest,
regexp: parsedPage.regexStr
};
});
}
function getMiddlewareConfig(pageFilePath, config, nextConfig) {
const result = {};
if (config.matcher) {
result.matchers = getMiddlewareMatchers(config.matcher, nextConfig);
}
if (typeof config.regions === "string" || Array.isArray(config.regions)) {
result.regions = config.regions;
} else if (typeof config.regions !== "undefined") {
Log.warn(`The \`regions\` config was ignored: config must be empty, a string or an array of strings. (${pageFilePath})`);
}
if (config.unstable_allowDynamic) {
result.unstable_allowDynamicGlobs = Array.isArray(config.unstable_allowDynamic) ? config.unstable_allowDynamic : [
config.unstable_allowDynamic
];
for (const glob of result.unstable_allowDynamicGlobs ?? []){
try {
(0, _micromatch).matcher(glob);
} catch (err) {
throw new Error(`${pageFilePath} exported 'config.unstable_allowDynamic' contains invalid pattern '${glob}': ${err.message}`);
}
}
}
return result;
}
let warnedAboutExperimentalEdge = false;
function warnAboutExperimentalEdge() {
if (warnedAboutExperimentalEdge) {
return;
}
Log.warn(`You are using an experimental edge runtime, the API might change.`);
warnedAboutExperimentalEdge = true;
}
const warnedUnsupportedValueMap = new Map();
function warnAboutUnsupportedValue(pageFilePath, page, error) {
if (warnedUnsupportedValueMap.has(pageFilePath)) {
return;
}
Log.warn(`Next.js can't recognize the exported \`config\` field in ` + (page ? `route "${page}"` : `"${pageFilePath}"`) + ":\n" + error.message + (error.path ? ` at "${error.path}"` : "") + ".\n" + "The default config will be used instead.\n" + "Read More - https://nextjs.org/docs/messages/invalid-page-config");
warnedUnsupportedValueMap.set(pageFilePath, true);
}
async function getPageStaticInfo(params) {
var ref;
const { isDev , pageFilePath , nextConfig , page , pageType } = params;
const fileContent = await tryToReadFile(pageFilePath, !isDev) || "";
if (/runtime|getStaticProps|getServerSideProps|export const config/.test(fileContent)) {
var ref15;
const swcAST = await (0, _parseModule).parseModule(pageFilePath, fileContent);
const { ssg , ssr , runtime } = checkExports(swcAST);
const rsc = getRSCModuleType(fileContent);
// default / failsafe value for config
let config = {};
try {
config = (0, _extractConstValue).extractExportedConstValue(swcAST, "config");
} catch (e) {
if (e instanceof _extractConstValue.UnsupportedValueError) {
warnAboutUnsupportedValue(pageFilePath, page, e);
}
// `export config` doesn't exist, or other unknown error throw by swc, silence them
}
// Currently, we use `export const config = { runtime: '...' }` to specify the page runtime.
// But in the new app directory, we prefer to use `export const runtime = '...'`
// and deprecate the old way. To prevent breaking changes for `pages`, we use the exported config
// as the fallback value.
let resolvedRuntime = runtime || config.runtime;
if (typeof resolvedRuntime !== "undefined" && resolvedRuntime !== _constants.SERVER_RUNTIME.nodejs && !(0, _isEdgeRuntime).isEdgeRuntime(resolvedRuntime)) {
const options = Object.values(_constants.SERVER_RUNTIME).join(", ");
if (typeof resolvedRuntime !== "string") {
Log.error(`The \`runtime\` config must be a string. Please leave it empty or choose one of: ${options}`);
} else {
Log.error(`Provided runtime "${resolvedRuntime}" is not supported. Please leave it empty or choose one of: ${options}`);
}
if (!isDev) {
process.exit(1);
}
}
const requiresServerRuntime = ssr || ssg || pageType === "app";
resolvedRuntime = (0, _isEdgeRuntime).isEdgeRuntime(resolvedRuntime) ? resolvedRuntime : requiresServerRuntime ? resolvedRuntime || ((ref15 = nextConfig.experimental) == null ? void 0 : ref15.runtime) : undefined;
if (resolvedRuntime === _constants.SERVER_RUNTIME.experimentalEdge) {
warnAboutExperimentalEdge();
}
if (resolvedRuntime === _constants.SERVER_RUNTIME.edge && pageType === "pages" && page && !(0, _isApiRoute).isAPIRoute(page.replace(/^\/pages\//, "/"))) {
const message = `Page ${page} provided runtime 'edge', the edge runtime for rendering is currently experimental. Use runtime 'experimental-edge' instead.`;
Log.error(message);
if (!isDev) {
process.exit(1);
}
}
const middlewareConfig = getMiddlewareConfig(page ?? "middleware/edge API route", config, nextConfig);
return {
ssr,
ssg,
rsc,
...middlewareConfig && {
middleware: middlewareConfig
},
...resolvedRuntime && {
runtime: resolvedRuntime
}
};
}
return {
ssr: false,
ssg: false,
rsc: _constants1.RSC_MODULE_TYPES.server,
runtime: (ref = nextConfig.experimental) == null ? void 0 : ref.runtime
};
}
//# sourceMappingURL=get-page-static-info.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,5 @@
/**
* Parses a module with SWC using an LRU cache where the parsed module will
* be indexed by a sha of its content holding up to 500 entries.
*/
export declare const parseModule: (_: string, content: string) => Promise<any>;

View File

@@ -0,0 +1,23 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.parseModule = void 0;
var _lruCache = _interopRequireDefault(require("next/dist/compiled/lru-cache"));
var _withPromiseCache = require("../../lib/with-promise-cache");
var _crypto = require("crypto");
var _swc = require("../swc");
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
const parseModule = (0, _withPromiseCache).withPromiseCache(new _lruCache.default({
max: 500
}), async (filename, content)=>(0, _swc).parse(content, {
isModule: "unknown",
filename
}).catch(()=>null), (_, content)=>(0, _crypto).createHash("sha1").update(content).digest("hex"));
exports.parseModule = parseModule;
//# sourceMappingURL=parse-module.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../build/analysis/parse-module.ts"],"names":["parseModule","withPromiseCache","LRUCache","max","filename","content","parse","isModule","catch","_","createHash","update","digest"],"mappings":"AAAA;;;;;AAAqB,IAAA,SAA8B,kCAA9B,8BAA8B,EAAA;AAClB,IAAA,iBAA8B,WAA9B,8BAA8B,CAAA;AACpC,IAAA,OAAQ,WAAR,QAAQ,CAAA;AACb,IAAA,IAAQ,WAAR,QAAQ,CAAA;;;;;;AAMvB,MAAMA,WAAW,GAAGC,CAAAA,GAAAA,iBAAgB,AAK1C,CAAA,iBAL0C,CACzC,IAAIC,SAAQ,QAAA,CAAc;IAAEC,GAAG,EAAE,GAAG;CAAE,CAAC,EACvC,OAAOC,QAAgB,EAAEC,OAAe,GACtCC,CAAAA,GAAAA,IAAK,AAA4C,CAAA,MAA5C,CAACD,OAAO,EAAE;QAAEE,QAAQ,EAAE,SAAS;QAAEH,QAAQ;KAAE,CAAC,CAACI,KAAK,CAAC,IAAM,IAAI,CAAC,EACrE,CAACC,CAAC,EAAEJ,OAAO,GAAKK,CAAAA,GAAAA,OAAU,AAAQ,CAAA,WAAR,CAAC,MAAM,CAAC,CAACC,MAAM,CAACN,OAAO,CAAC,CAACO,MAAM,CAAC,KAAK,CAAC,CACjE;QALYZ,WAAW,GAAXA,WAAW"}

View File

@@ -0,0 +1,10 @@
import { NextBabelLoaderOptions, NextJsLoaderContext } from './types';
declare type BabelConfig = any;
export default function getConfig(this: NextJsLoaderContext, { source, target, loaderOptions, filename, inputSourceMap, }: {
source: string;
loaderOptions: NextBabelLoaderOptions;
target: string;
filename: string;
inputSourceMap?: object | null;
}): BabelConfig;
export {};

View File

@@ -0,0 +1,268 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = getConfig;
var _fs = require("fs");
var _json5 = _interopRequireDefault(require("next/dist/compiled/json5"));
var _core = require("next/dist/compiled/babel/core");
var _coreLibConfig = _interopRequireDefault(require("next/dist/compiled/babel/core-lib-config"));
var _util = require("./util");
var Log = _interopRequireWildcard(require("../../output/log"));
function getConfig({ source , target , loaderOptions , filename , inputSourceMap }) {
const cacheCharacteristics = getCacheCharacteristics(loaderOptions, source, filename);
if (loaderOptions.configFile) {
// Ensures webpack invalidates the cache for this loader when the config file changes
this.addDependency(loaderOptions.configFile);
}
const cacheKey = getCacheKey(cacheCharacteristics);
if (configCache.has(cacheKey)) {
const cachedConfig = configCache.get(cacheKey);
return {
...cachedConfig,
options: {
...cachedConfig.options,
cwd: loaderOptions.cwd,
root: loaderOptions.cwd,
filename,
sourceFileName: filename
}
};
}
if (loaderOptions.configFile && !configFiles.has(loaderOptions.configFile)) {
configFiles.add(loaderOptions.configFile);
Log.info(`Using external babel configuration from ${loaderOptions.configFile}`);
}
const freshConfig = getFreshConfig.call(this, cacheCharacteristics, loaderOptions, target, filename, inputSourceMap);
configCache.set(cacheKey, freshConfig);
return freshConfig;
}
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
function _getRequireWildcardCache() {
if (typeof WeakMap !== "function") return null;
var cache = new WeakMap();
_getRequireWildcardCache = function() {
return cache;
};
return cache;
}
function _interopRequireWildcard(obj) {
if (obj && obj.__esModule) {
return obj;
}
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
return {
default: obj
};
}
var cache = _getRequireWildcardCache();
if (cache && cache.has(obj)) {
return cache.get(obj);
}
var newObj = {};
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
for(var key in obj){
if (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 nextDistPath = /(next[\\/]dist[\\/]shared[\\/]lib)|(next[\\/]dist[\\/]client)|(next[\\/]dist[\\/]pages)/;
const fileExtensionRegex = /\.([a-z]+)$/;
function getCacheCharacteristics(loaderOptions, source, filename) {
var ref;
const { isServer , pagesDir } = loaderOptions;
const isPageFile = filename.startsWith(pagesDir);
const isNextDist = nextDistPath.test(filename);
const hasModuleExports = source.indexOf("module.exports") !== -1;
const fileExt = ((ref = fileExtensionRegex.exec(filename)) == null ? void 0 : ref[1]) || "unknown";
return {
isServer,
isPageFile,
isNextDist,
hasModuleExports,
fileExt
};
}
/**
* Return an array of Babel plugins, conditioned upon loader options and
* source file characteristics.
*/ function getPlugins(loaderOptions, cacheCharacteristics) {
const { isServer , isPageFile , isNextDist , hasModuleExports } = cacheCharacteristics;
const { hasReactRefresh , development } = loaderOptions;
const applyCommonJsItem = hasModuleExports ? (0, _core).createConfigItem(require("../plugins/commonjs"), {
type: "plugin"
}) : null;
const reactRefreshItem = hasReactRefresh ? (0, _core).createConfigItem([
require("next/dist/compiled/react-refresh/babel"),
{
skipEnvCheck: true
},
], {
type: "plugin"
}) : null;
const pageConfigItem = !isServer && isPageFile ? (0, _core).createConfigItem([
require("../plugins/next-page-config")
], {
type: "plugin"
}) : null;
const disallowExportAllItem = !isServer && isPageFile ? (0, _core).createConfigItem([
require("../plugins/next-page-disallow-re-export-all-exports")
], {
type: "plugin"
}) : null;
const transformDefineItem = (0, _core).createConfigItem([
require.resolve("next/dist/compiled/babel/plugin-transform-define"),
{
"process.env.NODE_ENV": development ? "development" : "production",
"typeof window": isServer ? "undefined" : "object",
"process.browser": isServer ? false : true
},
"next-js-transform-define-instance",
], {
type: "plugin"
});
const nextSsgItem = !isServer && isPageFile ? (0, _core).createConfigItem([
require.resolve("../plugins/next-ssg-transform")
], {
type: "plugin"
}) : null;
const commonJsItem = isNextDist ? (0, _core).createConfigItem(require("next/dist/compiled/babel/plugin-transform-modules-commonjs"), {
type: "plugin"
}) : null;
const nextFontUnsupported = (0, _core).createConfigItem([
require("../plugins/next-font-unsupported")
], {
type: "plugin"
});
return [
reactRefreshItem,
pageConfigItem,
disallowExportAllItem,
applyCommonJsItem,
transformDefineItem,
nextSsgItem,
commonJsItem,
nextFontUnsupported,
].filter(Boolean);
}
const isJsonFile = /\.(json|babelrc)$/;
const isJsFile = /\.js$/;
/**
* While this function does block execution while reading from disk, it
* should not introduce any issues. The function is only invoked when
* generating a fresh config, and only a small handful of configs should
* be generated during compilation.
*/ function getCustomBabelConfig(configFilePath) {
if (isJsonFile.exec(configFilePath)) {
const babelConfigRaw = (0, _fs).readFileSync(configFilePath, "utf8");
return _json5.default.parse(babelConfigRaw);
} else if (isJsFile.exec(configFilePath)) {
return require(configFilePath);
}
throw new Error("The Next.js Babel loader does not support .mjs or .cjs config files.");
}
/**
* Generate a new, flat Babel config, ready to be handed to Babel-traverse.
* This config should have no unresolved overrides, presets, etc.
*/ function getFreshConfig(cacheCharacteristics, loaderOptions, target, filename, inputSourceMap) {
let { isServer , pagesDir , development , hasJsxRuntime , configFile } = loaderOptions;
let customConfig = configFile ? getCustomBabelConfig(configFile) : undefined;
let options = {
babelrc: false,
cloneInputAst: false,
filename,
inputSourceMap: inputSourceMap || undefined,
// Set the default sourcemap behavior based on Webpack's mapping flag,
// but allow users to override if they want.
sourceMaps: loaderOptions.sourceMaps === undefined ? this.sourceMap : loaderOptions.sourceMaps,
// Ensure that Webpack will get a full absolute path in the sourcemap
// so that it can properly map the module back to its internal cached
// modules.
sourceFileName: filename,
plugins: [
...getPlugins(loaderOptions, cacheCharacteristics),
...(customConfig == null ? void 0 : customConfig.plugins) || [],
],
// target can be provided in babelrc
target: isServer ? undefined : customConfig == null ? void 0 : customConfig.target,
// env can be provided in babelrc
env: customConfig == null ? void 0 : customConfig.env,
presets: (()=>{
// If presets is defined the user will have next/babel in their babelrc
if (customConfig == null ? void 0 : customConfig.presets) {
return customConfig.presets;
}
// If presets is not defined the user will likely have "env" in their babelrc
if (customConfig) {
return undefined;
}
// If no custom config is provided the default is to use next/babel
return [
"next/babel"
];
})(),
overrides: loaderOptions.overrides,
caller: {
name: "next-babel-turbo-loader",
supportsStaticESM: true,
supportsDynamicImport: true,
// Provide plugins with insight into webpack target.
// https://github.com/babel/babel-loader/issues/787
target: target,
// Webpack 5 supports TLA behind a flag. We enable it by default
// for Babel, and then webpack will throw an error if the experimental
// flag isn't enabled.
supportsTopLevelAwait: true,
isServer,
pagesDir,
isDev: development,
hasJsxRuntime,
...loaderOptions.caller
}
};
// Babel does strict checks on the config so undefined is not allowed
if (typeof options.target === "undefined") {
delete options.target;
}
Object.defineProperty(options.caller, "onWarning", {
enumerable: false,
writable: false,
value: (reason)=>{
if (!(reason instanceof Error)) {
reason = new Error(reason);
}
this.emitWarning(reason);
}
});
const loadedOptions = (0, _core).loadOptions(options);
const config = (0, _util).consumeIterator((0, _coreLibConfig).default(loadedOptions));
return config;
}
/**
* Each key returned here corresponds with a Babel config that can be shared.
* The conditions of permissible sharing between files is dependent on specific
* file attributes and Next.js compiler states: `CharacteristicsGermaneToCaching`.
*/ function getCacheKey(cacheCharacteristics) {
const { isServer , isPageFile , isNextDist , hasModuleExports , fileExt } = cacheCharacteristics;
const flags = 0 | (isServer ? 0b0001 : 0) | (isPageFile ? 0b0010 : 0) | (isNextDist ? 0b0100 : 0) | (hasModuleExports ? 0b1000 : 0);
return fileExt + flags;
}
const configCache = new Map();
const configFiles = new Set();
//# sourceMappingURL=get-config.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,3 @@
import { NextJsLoaderContext } from './types';
declare const nextBabelLoaderOuter: (this: NextJsLoaderContext, inputSource: string, inputSourceMap: object | null | undefined) => void;
export default nextBabelLoaderOuter;

View File

@@ -0,0 +1,36 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _transform = _interopRequireDefault(require("./transform"));
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
async function nextBabelLoader(parentTrace, inputSource, inputSourceMap) {
const filename = this.resourcePath;
const target = this.target;
const loaderOptions = parentTrace.traceChild("get-options")// @ts-ignore TODO: remove ignore once webpack 5 types are used
.traceFn(()=>this.getOptions());
const loaderSpanInner = parentTrace.traceChild("next-babel-turbo-transform");
const { code: transformedSource , map: outputSourceMap } = loaderSpanInner.traceFn(()=>_transform.default.call(this, inputSource, inputSourceMap, loaderOptions, filename, target, loaderSpanInner));
return [
transformedSource,
outputSourceMap
];
}
const nextBabelLoaderOuter = function nextBabelLoaderOuter(inputSource, inputSourceMap) {
const callback = this.async();
const loaderSpan = this.currentTraceSpan.traceChild("next-babel-turbo-loader");
loaderSpan.traceAsyncFn(()=>nextBabelLoader.call(this, loaderSpan, inputSource, inputSourceMap)).then(([transformedSource, outputSourceMap])=>{
return callback == null ? void 0 : callback(null, transformedSource, outputSourceMap || inputSourceMap);
}, (err)=>{
callback == null ? void 0 : callback(err);
});
};
var _default = nextBabelLoaderOuter;
exports.default = _default;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../build/babel/loader/index.ts"],"names":["nextBabelLoader","parentTrace","inputSource","inputSourceMap","filename","resourcePath","target","loaderOptions","traceChild","traceFn","getOptions","loaderSpanInner","code","transformedSource","map","outputSourceMap","transform","call","nextBabelLoaderOuter","callback","async","loaderSpan","currentTraceSpan","traceAsyncFn","then","err"],"mappings":"AAAA;;;;;AACsB,IAAA,UAAa,kCAAb,aAAa,EAAA;;;;;;AAGnC,eAAeA,eAAe,CAE5BC,WAAiB,EACjBC,WAAmB,EACnBC,cAAyC,EACzC;IACA,MAAMC,QAAQ,GAAG,IAAI,CAACC,YAAY;IAClC,MAAMC,MAAM,GAAG,IAAI,CAACA,MAAM;IAC1B,MAAMC,aAAa,GAAGN,WAAW,CAC9BO,UAAU,CAAC,aAAa,CAAC,AAC1B,+DAA+D;KAC9DC,OAAO,CAAC,IAAM,IAAI,CAACC,UAAU,EAAE,CAAC;IAEnC,MAAMC,eAAe,GAAGV,WAAW,CAACO,UAAU,CAAC,4BAA4B,CAAC;IAC5E,MAAM,EAAEI,IAAI,EAAEC,iBAAiB,CAAA,EAAEC,GAAG,EAAEC,eAAe,CAAA,EAAE,GACrDJ,eAAe,CAACF,OAAO,CAAC,IACtBO,UAAS,QAAA,CAACC,IAAI,CACZ,IAAI,EACJf,WAAW,EACXC,cAAc,EACdI,aAAa,EACbH,QAAQ,EACRE,MAAM,EACNK,eAAe,CAChB,CACF;IAEH,OAAO;QAACE,iBAAiB;QAAEE,eAAe;KAAC,CAAA;CAC5C;AAED,MAAMG,oBAAoB,GAAG,SAASA,oBAAoB,CAExDhB,WAAmB,EACnBC,cAAyC,EACzC;IACA,MAAMgB,QAAQ,GAAG,IAAI,CAACC,KAAK,EAAE;IAE7B,MAAMC,UAAU,GAAG,IAAI,CAACC,gBAAgB,CAACd,UAAU,CAAC,yBAAyB,CAAC;IAC9Ea,UAAU,CACPE,YAAY,CAAC,IACZvB,eAAe,CAACiB,IAAI,CAAC,IAAI,EAAEI,UAAU,EAAEnB,WAAW,EAAEC,cAAc,CAAC,CACpE,CACAqB,IAAI,CACH,CAAC,CAACX,iBAAiB,EAAEE,eAAe,CAAM;QACxCI,OAAAA,QAAQ,QAA8D,GAAtEA,KAAAA,CAAsE,GAAtEA,QAAQ,CAAG,IAAI,EAAEN,iBAAiB,EAAEE,eAAe,IAAIZ,cAAc,CAAC,CAAA;KAAA,EACxE,CAACsB,GAAG,GAAK;QACPN,QAAQ,QAAO,GAAfA,KAAAA,CAAe,GAAfA,QAAQ,CAAGM,GAAG,CAAC,CAAA;KAChB,CACF;CACJ;eAEcP,oBAAoB"}

View File

@@ -0,0 +1,14 @@
import { Span } from '../../../trace';
import { NextJsLoaderContext } from './types';
export default function transform(this: NextJsLoaderContext, source: string, inputSourceMap: object | null | undefined, loaderOptions: any, filename: string, target: string, parentSpan: Span): {
code: string;
map: {
version: number;
sources: string[];
names: string[];
sourceRoot?: string | undefined;
sourcesContent?: string[] | undefined;
mappings: string;
file: string;
} | null;
};

View File

@@ -0,0 +1,90 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = transform;
var _traverse = _interopRequireDefault(require("next/dist/compiled/babel/traverse"));
var _generator = _interopRequireDefault(require("next/dist/compiled/babel/generator"));
var _coreLibNormalizeFile = _interopRequireDefault(require("next/dist/compiled/babel/core-lib-normalize-file"));
var _coreLibNormalizeOpts = _interopRequireDefault(require("next/dist/compiled/babel/core-lib-normalize-opts"));
var _coreLibBlockHoistPlugin = _interopRequireDefault(require("next/dist/compiled/babel/core-lib-block-hoist-plugin"));
var _coreLibPluginPass = _interopRequireDefault(require("next/dist/compiled/babel/core-lib-plugin-pass"));
var _getConfig = _interopRequireDefault(require("./get-config"));
var _util = require("./util");
function transform(source, inputSourceMap, loaderOptions, filename, target, parentSpan) {
const getConfigSpan = parentSpan.traceChild("babel-turbo-get-config");
const babelConfig = _getConfig.default.call(this, {
source,
loaderOptions,
inputSourceMap,
target,
filename
});
getConfigSpan.stop();
const normalizeSpan = parentSpan.traceChild("babel-turbo-normalize-file");
const file = (0, _util).consumeIterator((0, _coreLibNormalizeFile).default(babelConfig.passes, (0, _coreLibNormalizeOpts).default(babelConfig), source));
normalizeSpan.stop();
const transformSpan = parentSpan.traceChild("babel-turbo-transform");
transformAst(file, babelConfig, transformSpan);
transformSpan.stop();
const generateSpan = parentSpan.traceChild("babel-turbo-generate");
const { code , map } = (0, _generator).default(file.ast, file.opts.generatorOpts, file.code);
generateSpan.stop();
return {
code,
map
};
}
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
function getTraversalParams(file, pluginPairs) {
const passPairs = [];
const passes = [];
const visitors = [];
for (const plugin of pluginPairs.concat((0, _coreLibBlockHoistPlugin).default())){
const pass = new _coreLibPluginPass.default(file, plugin.key, plugin.options);
passPairs.push([
plugin,
pass
]);
passes.push(pass);
visitors.push(plugin.visitor);
}
return {
passPairs,
passes,
visitors
};
}
function invokePluginPre(file, passPairs) {
for (const [{ pre }, pass] of passPairs){
if (pre) {
pre.call(pass, file);
}
}
}
function invokePluginPost(file, passPairs) {
for (const [{ post }, pass] of passPairs){
if (post) {
post.call(pass, file);
}
}
}
function transformAstPass(file, pluginPairs, parentSpan) {
const { passPairs , passes , visitors } = getTraversalParams(file, pluginPairs);
invokePluginPre(file, passPairs);
const visitor = _traverse.default.visitors.merge(visitors, passes, // @ts-ignore - the exported types are incorrect here
file.opts.wrapPluginVisitorMethod);
parentSpan.traceChild("babel-turbo-traverse").traceFn(()=>(0, _traverse).default(file.ast, visitor, file.scope));
invokePluginPost(file, passPairs);
}
function transformAst(file, babelConfig, parentSpan) {
for (const pluginPairs of babelConfig.passes){
transformAstPass(file, pluginPairs, parentSpan);
}
}
//# sourceMappingURL=transform.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../build/babel/loader/transform.ts"],"names":["transform","source","inputSourceMap","loaderOptions","filename","target","parentSpan","getConfigSpan","traceChild","babelConfig","getConfig","call","stop","normalizeSpan","file","consumeIterator","normalizeFile","passes","normalizeOpts","transformSpan","transformAst","generateSpan","code","map","generate","ast","opts","generatorOpts","getTraversalParams","pluginPairs","passPairs","visitors","plugin","concat","loadBlockHoistPlugin","pass","PluginPass","key","options","push","visitor","invokePluginPre","pre","invokePluginPost","post","transformAstPass","traverse","merge","wrapPluginVisitorMethod","traceFn","scope"],"mappings":"AAIA;;;;kBAmEwBA,SAAS;AAnEZ,IAAA,SAAmC,kCAAnC,mCAAmC,EAAA;AACnC,IAAA,UAAoC,kCAApC,oCAAoC,EAAA;AAC/B,IAAA,qBAAkD,kCAAlD,kDAAkD,EAAA;AAClD,IAAA,qBAAkD,kCAAlD,kDAAkD,EAAA;AAC3C,IAAA,wBAAsD,kCAAtD,sDAAsD,EAAA;AAChE,IAAA,kBAA+C,kCAA/C,+CAA+C,EAAA;AAEhD,IAAA,UAAc,kCAAd,cAAc,EAAA;AACJ,IAAA,KAAQ,WAAR,QAAQ,CAAA;AA2DzB,SAASA,SAAS,CAE/BC,MAAc,EACdC,cAAyC,EACzCC,aAAkB,EAClBC,QAAgB,EAChBC,MAAc,EACdC,UAAgB,EAChB;IACA,MAAMC,aAAa,GAAGD,UAAU,CAACE,UAAU,CAAC,wBAAwB,CAAC;IACrE,MAAMC,WAAW,GAAGC,UAAS,QAAA,CAACC,IAAI,CAAC,IAAI,EAAE;QACvCV,MAAM;QACNE,aAAa;QACbD,cAAc;QACdG,MAAM;QACND,QAAQ;KACT,CAAC;IACFG,aAAa,CAACK,IAAI,EAAE;IAEpB,MAAMC,aAAa,GAAGP,UAAU,CAACE,UAAU,CAAC,4BAA4B,CAAC;IACzE,MAAMM,IAAI,GAAGC,CAAAA,GAAAA,KAAe,AAE3B,CAAA,gBAF2B,CAC1BC,CAAAA,GAAAA,qBAAa,AAAw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AAY,CAACN,IAAS,EAAEL,WAAgB,EAAEH,UAAgB,EAAE;IACnE,KAAK,MAAMuB,WAAW,IAAIpB,WAAW,CAACQ,MAAM,CAAE;QAC5C4B,gBAAgB,CAAC/B,IAAI,EAAEe,WAAW,EAAEvB,UAAU,CAAC;KAChD;CACF"}

View File

@@ -0,0 +1,20 @@
import { webpack } from 'next/dist/compiled/webpack/webpack'
import { Span } from '../../../trace'
export interface NextJsLoaderContext extends webpack.LoaderContext<{}> {
currentTraceSpan: Span
target: string
}
export interface NextBabelLoaderOptions {
hasJsxRuntime: boolean
hasReactRefresh: boolean
isServer: boolean
development: boolean
pagesDir: string
sourceMaps?: any[]
overrides: any
caller: any
configFile: string | undefined
cwd: string
}

View File

@@ -0,0 +1 @@
export declare function consumeIterator(iter: Iterator<any>): any;

View File

@@ -0,0 +1,15 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.consumeIterator = consumeIterator;
function consumeIterator(iter) {
while(true){
const { value , done } = iter.next();
if (done) {
return value;
}
}
}
//# sourceMappingURL=util.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../build/babel/loader/util.ts"],"names":["consumeIterator","iter","value","done","next"],"mappings":"AAAA;;;;QAAgBA,eAAe,GAAfA,eAAe;AAAxB,SAASA,eAAe,CAACC,IAAmB,EAAE;IACnD,MAAO,IAAI,CAAE;QACX,MAAM,EAAEC,KAAK,CAAA,EAAEC,IAAI,CAAA,EAAE,GAAGF,IAAI,CAACG,IAAI,EAAE;QACnC,IAAID,IAAI,EAAE;YACR,OAAOD,KAAK,CAAA;SACb;KACF;CACF"}

View File

@@ -0,0 +1,2 @@
import { PluginObj } from 'next/dist/compiled/babel/core';
export default function AmpAttributePatcher(): PluginObj;

View File

@@ -0,0 +1,31 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = AmpAttributePatcher;
function AmpAttributePatcher() {
return {
visitor: {
JSXOpeningElement (path) {
const openingElement = path.node;
const { name , attributes } = openingElement;
if (!(name && name.type === "JSXIdentifier")) {
return;
}
if (!name.name.startsWith("amp-")) {
return;
}
for (const attribute of attributes){
if (attribute.type !== "JSXAttribute") {
continue;
}
if (attribute.name.name === "className") {
attribute.name.name = "class";
}
}
}
}
};
}
//# sourceMappingURL=amp-attributes.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../build/babel/plugins/amp-attributes.ts"],"names":["AmpAttributePatcher","visitor","JSXOpeningElement","path","openingElement","node","name","attributes","type","startsWith","attribute"],"mappings":"AAAA;;;;kBAEwBA,mBAAmB;AAA5B,SAASA,mBAAmB,GAAc;IACvD,OAAO;QACLC,OAAO,EAAE;YACPC,iBAAiB,EAACC,IAAuC,EAAE;gBACzD,MAAMC,cAAc,GAAGD,IAAI,CAACE,IAAI;gBAEhC,MAAM,EAAEC,IAAI,CAAA,EAAEC,UAAU,CAAA,EAAE,GAAGH,cAAc;gBAC3C,IAAI,CAAC,CAACE,IAAI,IAAIA,IAAI,CAACE,IAAI,KAAK,eAAe,CAAC,EAAE;oBAC5C,OAAM;iBACP;gBAED,IAAI,CAACF,IAAI,CAACA,IAAI,CAACG,UAAU,CAAC,MAAM,CAAC,EAAE;oBACjC,OAAM;iBACP;gBAED,KAAK,MAAMC,SAAS,IAAIH,UAAU,CAAE;oBAClC,IAAIG,SAAS,CAACF,IAAI,KAAK,cAAc,EAAE;wBACrC,SAAQ;qBACT;oBAED,IAAIE,SAAS,CAACJ,IAAI,CAACA,IAAI,KAAK,WAAW,EAAE;wBACvCI,SAAS,CAACJ,IAAI,CAACA,IAAI,GAAG,OAAO;qBAC9B;iBACF;aACF;SACF;KACF,CAAA;CACF"}

View File

@@ -0,0 +1,2 @@
import { PluginObj } from 'next/dist/compiled/babel/core';
export default function CommonJSModulePlugin(...args: any): PluginObj;

View File

@@ -0,0 +1,36 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = CommonJSModulePlugin;
var _pluginTransformModulesCommonjs = _interopRequireDefault(require("next/dist/compiled/babel/plugin-transform-modules-commonjs"));
function CommonJSModulePlugin(...args) {
const commonjs = (0, _pluginTransformModulesCommonjs).default(...args);
return {
visitor: {
Program: {
exit (path, state) {
let foundModuleExports = false;
path.traverse({
MemberExpression (expressionPath) {
if (expressionPath.node.object.name !== "module") return;
if (expressionPath.node.property.name !== "exports") return;
foundModuleExports = true;
}
});
if (!foundModuleExports) {
return;
}
commonjs.visitor.Program.exit.call(this, path, state);
}
}
}
};
}
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
//# sourceMappingURL=commonjs.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../build/babel/plugins/commonjs.ts"],"names":["CommonJSModulePlugin","args","commonjs","commonjsPlugin","visitor","Program","exit","path","state","foundModuleExports","traverse","MemberExpression","expressionPath","node","object","name","property","call"],"mappings":"AAAA;;;;kBAIwBA,oBAAoB;AAHjB,IAAA,+BAA4D,kCAA5D,4DAA4D,EAAA;AAGxE,SAASA,oBAAoB,CAAC,GAAGC,IAAI,AAAK,EAAa;IACpE,MAAMC,QAAQ,GAAGC,CAAAA,GAAAA,+BAAc,AAAS,CAAA,QAAT,IAAIF,IAAI,CAAC;IACxC,OAAO;QACLG,OAAO,EAAE;YACPC,OAAO,EAAE;gBACPC,IAAI,EAACC,IAA6B,EAAEC,KAAK,EAAE;oBACzC,IAAIC,kBAAkB,GAAG,KAAK;oBAC9BF,IAAI,CAACG,QAAQ,CAAC;wBACZC,gBAAgB,EAACC,cAAmB,EAAE;4BACpC,IAAIA,cAAc,CAACC,IAAI,CAACC,MAAM,CAACC,IAAI,KAAK,QAAQ,EAAE,OAAM;4BACxD,IAAIH,cAAc,CAACC,IAAI,CAACG,QAAQ,CAACD,IAAI,KAAK,SAAS,EAAE,OAAM;4BAC3DN,kBAAkB,GAAG,IAAI;yBAC1B;qBACF,CAAC;oBAEF,IAAI,CAACA,kBAAkB,EAAE;wBACvB,OAAM;qBACP;oBAEDP,QAAQ,CAACE,OAAO,CAACC,OAAO,CAACC,IAAI,CAACW,IAAI,CAAC,IAAI,EAAEV,IAAI,EAAEC,KAAK,CAAC;iBACtD;aACF;SACF;KACF,CAAA;CACF"}

View File

@@ -0,0 +1,4 @@
import { PluginObj, types as BabelTypes } from 'next/dist/compiled/babel/core';
export default function ({ types: t, }: {
types: typeof BabelTypes;
}): PluginObj<any>;

View File

@@ -0,0 +1,69 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
var _pluginSyntaxJsx = _interopRequireDefault(require("next/dist/compiled/babel/plugin-syntax-jsx"));
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
function _default({ types: t }) {
return {
inherits: _pluginSyntaxJsx.default,
visitor: {
JSXElement (_path, state) {
state.set("jsx", true);
},
// Fragment syntax is still JSX since it compiles to createElement(),
// but JSXFragment is not a JSXElement
JSXFragment (_path, state) {
state.set("jsx", true);
},
Program: {
exit (path, state) {
if (state.get("jsx")) {
const pragma = t.identifier(state.opts.pragma);
let importAs = pragma;
// if there's already a React in scope, use that instead of adding an import
const existingBinding = state.opts.reuseImport !== false && state.opts.importAs && path.scope.getBinding(state.opts.importAs);
// var _jsx = _pragma.createElement;
if (state.opts.property) {
if (state.opts.importAs) {
importAs = t.identifier(state.opts.importAs);
} else {
importAs = path.scope.generateUidIdentifier("pragma");
}
const mapping = t.variableDeclaration("var", [
t.variableDeclarator(pragma, t.memberExpression(importAs, t.identifier(state.opts.property))),
]);
// if the React binding came from a require('react'),
// make sure that our usage comes after it.
let newPath;
if (existingBinding && t.isVariableDeclarator(existingBinding.path.node) && t.isCallExpression(existingBinding.path.node.init) && t.isIdentifier(existingBinding.path.node.init.callee) && existingBinding.path.node.init.callee.name === "require") {
[newPath] = existingBinding.path.parentPath.insertAfter(mapping);
} else {
[newPath] = path.unshiftContainer("body", mapping);
}
for (const declar of newPath.get("declarations")){
path.scope.registerBinding(newPath.node.kind, declar);
}
}
if (!existingBinding) {
const importSpecifier = t.importDeclaration([
state.opts.import ? t.importSpecifier(importAs, t.identifier(state.opts.import)) : state.opts.importNamespace ? t.importNamespaceSpecifier(importAs) : t.importDefaultSpecifier(importAs),
], t.stringLiteral(state.opts.module || "react"));
const [newPath] = path.unshiftContainer("body", importSpecifier);
for (const specifier of newPath.get("specifiers")){
path.scope.registerBinding("module", specifier);
}
}
}
}
}
}
};
}
//# sourceMappingURL=jsx-pragma.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../build/babel/plugins/jsx-pragma.ts"],"names":["types","t","inherits","jsx","visitor","JSXElement","_path","state","set","JSXFragment","Program","exit","path","get","pragma","identifier","opts","importAs","existingBinding","reuseImport","scope","getBinding","property","generateUidIdentifier","mapping","variableDeclaration","variableDeclarator","memberExpression","newPath","isVariableDeclarator","node","isCallExpression","init","isIdentifier","callee","name","parentPath","insertAfter","unshiftContainer","declar","registerBinding","kind","importSpecifier","importDeclaration","import","importNamespace","importNamespaceSpecifier","importDefaultSpecifier","stringLiteral","module","specifier"],"mappings":"AAAA;;;;;AAKgB,IAAA,gBAA4C,kCAA5C,4CAA4C,EAAA;;;;;;AAE7C,kBAAU,EACvBA,KAAK,EAAEC,CAAC,CAAA,EAGT,EAAkB;IACjB,OAAO;QACLC,QAAQ,EAAEC,gBAAG,QAAA;QACbC,OAAO,EAAE;YACPC,UAAU,EAACC,KAAK,EAAEC,KAAK,EAAE;gBACvBA,KAAK,CAACC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC;aACvB;YAED,qEAAqE;YACrE,sCAAsC;YACtCC,WAAW,EAACH,KAAK,EAAEC,KAAK,EAAE;gBACxBA,KAAK,CAACC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC;aACvB;YAEDE,OAAO,EAAE;gBACPC,IAAI,EAACC,IAAkC,EAAEL,KAAK,EAAE;oBAC9C,IAAIA,KAAK,CAACM,GAAG,CAAC,KAAK,CAAC,EAAE;wBACpB,MAAMC,MAAM,GAAGb,CAAC,CAAC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 @@
import { PluginObj } from 'next/dist/compiled/babel/core';
export default function NextPageDisallowReExportAllExports(): PluginObj<any>;

View File

@@ -0,0 +1,25 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = NextPageDisallowReExportAllExports;
function NextPageDisallowReExportAllExports() {
return {
visitor: {
ImportDeclaration (path) {
if ([
"@next/font/local",
"@next/font/google"
].includes(path.node.source.value)) {
var ref, ref1;
const err = new SyntaxError(`"@next/font" requires SWC although Babel is being used due to a custom babel config being present.\nRead more: https://nextjs.org/docs/messages/babel-font-loader-conflict`);
err.code = "BABEL_PARSE_ERROR";
err.loc = (((ref = path.node.loc) == null ? void 0 : ref.start) ?? ((ref1 = path.node.loc) == null ? void 0 : ref1.end)) ?? path.node.loc;
throw err;
}
}
}
};
}
//# sourceMappingURL=next-font-unsupported.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../build/babel/plugins/next-font-unsupported.ts"],"names":["NextPageDisallowReExportAllExports","visitor","ImportDeclaration","path","includes","node","source","value","err","SyntaxError","code","loc","start","end"],"mappings":"AAAA;;;;kBAEwBA,kCAAkC;AAA3C,SAASA,kCAAkC,GAAmB;IAC3E,OAAO;QACLC,OAAO,EAAE;YACPC,iBAAiB,EAACC,IAAuC,EAAE;gBACzD,IACE;oBAAC,kBAAkB;oBAAE,mBAAmB;iBAAC,CAACC,QAAQ,CAChDD,IAAI,CAACE,IAAI,CAACC,MAAM,CAACC,KAAK,CACvB,EACD;wBAMEJ,GAAa,EAAWA,IAAa;oBALvC,MAAMK,GAAG,GAAG,IAAIC,WAAW,CACzB,CAAC,0KAA0K,CAAC,CAC7K,AACA;oBAAA,AAACD,GAAG,CAASE,IAAI,GAAG,mBAAmB,CACvC;oBAAA,AAACF,GAAG,CAASG,GAAG,GACfR,CAAAA,CAAAA,CAAAA,GAAa,GAAbA,IAAI,CAACE,IAAI,CAACM,GAAG,SAAO,GAApBR,KAAAA,CAAoB,GAApBA,GAAa,CAAES,KAAK,CAAA,IAAIT,CAAAA,CAAAA,IAAa,GAAbA,IAAI,CAACE,IAAI,CAACM,GAAG,SAAK,GAAlBR,KAAAA,CAAkB,GAAlBA,IAAa,CAAEU,GAAG,CAAA,CAAA,IAAIV,IAAI,CAACE,IAAI,CAACM,GAAG;oBAC7D,MAAMH,GAAG,CAAA;iBACV;aACF;SACF;KACF,CAAA;CACF"}

View File

@@ -0,0 +1,4 @@
import { PluginObj, types as BabelTypes } from 'next/dist/compiled/babel/core';
export default function nextPageConfig({ types: t, }: {
types: typeof BabelTypes;
}): PluginObj;

View File

@@ -0,0 +1,110 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = nextPageConfig;
var _core = require("next/dist/compiled/babel/core");
var _constants = require("../../../shared/lib/constants");
function nextPageConfig({ types: t }) {
return {
visitor: {
Program: {
enter (path, state) {
path.traverse({
ExportDeclaration (exportPath, exportState) {
var ref;
if (_core.types.isExportNamedDeclaration(exportPath) && ((ref = exportPath.node.specifiers) == null ? void 0 : ref.some((specifier)=>{
return (t.isIdentifier(specifier.exported) ? specifier.exported.name : specifier.exported.value) === CONFIG_KEY;
})) && _core.types.isStringLiteral(exportPath.node.source)) {
throw new Error(errorMessage(exportState, "Expected object but got export from"));
}
},
ExportNamedDeclaration (exportPath, exportState) {
var ref, ref1;
if (exportState.bundleDropped || !exportPath.node.declaration && exportPath.node.specifiers.length === 0) {
return;
}
const config = {};
const declarations = [
...((ref = exportPath.node.declaration) == null ? void 0 : ref.declarations) || [],
(ref1 = exportPath.scope.getBinding(CONFIG_KEY)) == null ? void 0 : ref1.path.node,
].filter(Boolean);
for (const specifier of exportPath.node.specifiers){
if ((t.isIdentifier(specifier.exported) ? specifier.exported.name : specifier.exported.value) === CONFIG_KEY) {
// export {} from 'somewhere'
if (_core.types.isStringLiteral(exportPath.node.source)) {
throw new Error(errorMessage(exportState, `Expected object but got import`));
// import hello from 'world'
// export { hello as config }
} else if (_core.types.isIdentifier(specifier.local)) {
var ref2;
if (_core.types.isImportSpecifier((ref2 = exportPath.scope.getBinding(specifier.local.name)) == null ? void 0 : ref2.path.node)) {
throw new Error(errorMessage(exportState, `Expected object but got import`));
}
}
}
}
for (const declaration of declarations){
if (!_core.types.isIdentifier(declaration.id, {
name: CONFIG_KEY
})) {
continue;
}
let { init } = declaration;
if (_core.types.isTSAsExpression(init)) {
init = init.expression;
}
if (!_core.types.isObjectExpression(init)) {
const got = init ? init.type : "undefined";
throw new Error(errorMessage(exportState, `Expected object but got ${got}`));
}
for (const prop of init.properties){
if (_core.types.isSpreadElement(prop)) {
throw new Error(errorMessage(exportState, `Property spread is not allowed`));
}
const { name } = prop.key;
if (_core.types.isIdentifier(prop.key, {
name: "amp"
})) {
if (!_core.types.isObjectProperty(prop)) {
throw new Error(errorMessage(exportState, `Invalid property "${name}"`));
}
if (!_core.types.isBooleanLiteral(prop.value) && !_core.types.isStringLiteral(prop.value)) {
throw new Error(errorMessage(exportState, `Invalid value for "${name}"`));
}
config.amp = prop.value.value;
}
}
}
if (config.amp === true) {
var ref3, ref4;
if (!((ref3 = exportState.file) == null ? void 0 : (ref4 = ref3.opts) == null ? void 0 : ref4.caller.isDev)) {
// don't replace bundle in development so HMR can track
// dependencies and trigger reload when they are changed
replaceBundle(exportPath, t);
}
exportState.bundleDropped = true;
return;
}
}
}, state);
}
}
}
};
}
const CONFIG_KEY = "config";
// replace program path with just a variable with the drop identifier
function replaceBundle(path, t) {
path.parentPath.replaceWith(t.program([
t.variableDeclaration("const", [
t.variableDeclarator(t.identifier(_constants.STRING_LITERAL_DROP_BUNDLE), t.stringLiteral(`${_constants.STRING_LITERAL_DROP_BUNDLE} ${Date.now()}`)),
]),
], []));
}
function errorMessage(state, details) {
const pageName = (state.filename || "").split(state.cwd || "").pop() || "unknown";
return `Invalid page config export found. ${details} in file ${pageName}. See: https://nextjs.org/docs/messages/invalid-page-config`;
}
//# sourceMappingURL=next-page-config.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,2 @@
import { PluginObj } from 'next/dist/compiled/babel/core';
export default function NextPageDisallowReExportAllExports(): PluginObj<any>;

View File

@@ -0,0 +1,20 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = NextPageDisallowReExportAllExports;
function NextPageDisallowReExportAllExports() {
return {
visitor: {
ExportAllDeclaration (path) {
var ref, ref1;
const err = new SyntaxError(`Using \`export * from '...'\` in a page is disallowed. Please use \`export { default } from '...'\` instead.\n` + `Read more: https://nextjs.org/docs/messages/export-all-in-page`);
err.code = "BABEL_PARSE_ERROR";
err.loc = (((ref = path.node.loc) == null ? void 0 : ref.start) ?? ((ref1 = path.node.loc) == null ? void 0 : ref1.end)) ?? path.node.loc;
throw err;
}
}
};
}
//# sourceMappingURL=next-page-disallow-re-export-all-exports.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../build/babel/plugins/next-page-disallow-re-export-all-exports.ts"],"names":["NextPageDisallowReExportAllExports","visitor","ExportAllDeclaration","path","err","SyntaxError","code","loc","node","start","end"],"mappings":"AAAA;;;;kBAEwBA,kCAAkC;AAA3C,SAASA,kCAAkC,GAAmB;IAC3E,OAAO;QACLC,OAAO,EAAE;YACPC,oBAAoB,EAACC,IAA0C,EAAE;oBAO7DA,GAAa,EAAWA,IAAa;gBANvC,MAAMC,GAAG,GAAG,IAAIC,WAAW,CACzB,CAAC,8GAA8G,CAAC,GAC9G,CAAC,8DAA8D,CAAC,CACnE,AACA;gBAAA,AAACD,GAAG,CAASE,IAAI,GAAG,mBAAmB,CACvC;gBAAA,AAACF,GAAG,CAASG,GAAG,GACfJ,CAAAA,CAAAA,CAAAA,GAAa,GAAbA,IAAI,CAACK,IAAI,CAACD,GAAG,SAAO,GAApBJ,KAAAA,CAAoB,GAApBA,GAAa,CAAEM,KAAK,CAAA,IAAIN,CAAAA,CAAAA,IAAa,GAAbA,IAAI,CAACK,IAAI,CAACD,GAAG,SAAK,GAAlBJ,KAAAA,CAAkB,GAAlBA,IAAa,CAAEO,GAAG,CAAA,CAAA,IAAIP,IAAI,CAACK,IAAI,CAACD,GAAG;gBAC7D,MAAMH,GAAG,CAAA;aACV;SACF;KACF,CAAA;CACF"}

View File

@@ -0,0 +1,14 @@
import { NodePath, PluginObj, types as BabelTypes } from 'next/dist/compiled/babel/core';
export declare const EXPORT_NAME_GET_STATIC_PROPS = "getStaticProps";
export declare const EXPORT_NAME_GET_STATIC_PATHS = "getStaticPaths";
export declare const EXPORT_NAME_GET_SERVER_PROPS = "getServerSideProps";
declare type PluginState = {
refs: Set<NodePath<BabelTypes.Identifier>>;
isPrerender: boolean;
isServerProps: boolean;
done: boolean;
};
export default function nextTransformSsg({ types: t, }: {
types: typeof BabelTypes;
}): PluginObj<PluginState>;
export {};

View File

@@ -0,0 +1,307 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = nextTransformSsg;
exports.EXPORT_NAME_GET_SERVER_PROPS = exports.EXPORT_NAME_GET_STATIC_PATHS = exports.EXPORT_NAME_GET_STATIC_PROPS = void 0;
var _constants = require("../../../lib/constants");
var _constants1 = require("../../../shared/lib/constants");
function nextTransformSsg({ types: t }) {
function getIdentifier(path) {
const parentPath = path.parentPath;
if (parentPath.type === "VariableDeclarator") {
const pp = parentPath;
const name = pp.get("id");
return name.node.type === "Identifier" ? name : null;
}
if (parentPath.type === "AssignmentExpression") {
const pp = parentPath;
const name = pp.get("left");
return name.node.type === "Identifier" ? name : null;
}
if (path.node.type === "ArrowFunctionExpression") {
return null;
}
return path.node.id && path.node.id.type === "Identifier" ? path.get("id") : null;
}
function isIdentifierReferenced(ident) {
const b = ident.scope.getBinding(ident.node.name);
if (b == null ? void 0 : b.referenced) {
// Functions can reference themselves, so we need to check if there's a
// binding outside the function scope or not.
if (b.path.type === "FunctionDeclaration") {
return !b.constantViolations.concat(b.referencePaths)// Check that every reference is contained within the function:
.every((ref)=>ref.findParent((p)=>p === b.path));
}
return true;
}
return false;
}
function markFunction(path, state) {
const ident = getIdentifier(path);
if ((ident == null ? void 0 : ident.node) && isIdentifierReferenced(ident)) {
state.refs.add(ident);
}
}
function markImport(path, state) {
const local = path.get("local");
if (isIdentifierReferenced(local)) {
state.refs.add(local);
}
}
return {
visitor: {
Program: {
enter (path, state) {
state.refs = new Set();
state.isPrerender = false;
state.isServerProps = false;
state.done = false;
path.traverse({
VariableDeclarator (variablePath, variableState) {
if (variablePath.node.id.type === "Identifier") {
const local = variablePath.get("id");
if (isIdentifierReferenced(local)) {
variableState.refs.add(local);
}
} else if (variablePath.node.id.type === "ObjectPattern") {
const pattern = variablePath.get("id");
const properties = pattern.get("properties");
properties.forEach((p)=>{
const local = p.get(p.node.type === "ObjectProperty" ? "value" : p.node.type === "RestElement" ? "argument" : function() {
throw new Error("invariant");
}());
if (isIdentifierReferenced(local)) {
variableState.refs.add(local);
}
});
} else if (variablePath.node.id.type === "ArrayPattern") {
const pattern = variablePath.get("id");
const elements = pattern.get("elements");
elements.forEach((e)=>{
var ref, ref1;
let local;
if (((ref = e.node) == null ? void 0 : ref.type) === "Identifier") {
local = e;
} else if (((ref1 = e.node) == null ? void 0 : ref1.type) === "RestElement") {
local = e.get("argument");
} else {
return;
}
if (isIdentifierReferenced(local)) {
variableState.refs.add(local);
}
});
}
},
FunctionDeclaration: markFunction,
FunctionExpression: markFunction,
ArrowFunctionExpression: markFunction,
ImportSpecifier: markImport,
ImportDefaultSpecifier: markImport,
ImportNamespaceSpecifier: markImport,
ExportNamedDeclaration (exportNamedPath, exportNamedState) {
const specifiers = exportNamedPath.get("specifiers");
if (specifiers.length) {
specifiers.forEach((s)=>{
if (isDataIdentifier(t.isIdentifier(s.node.exported) ? s.node.exported.name : s.node.exported.value, exportNamedState)) {
s.remove();
}
});
if (exportNamedPath.node.specifiers.length < 1) {
exportNamedPath.remove();
}
return;
}
const decl = exportNamedPath.get("declaration");
if (decl == null || decl.node == null) {
return;
}
switch(decl.node.type){
case "FunctionDeclaration":
{
const name = decl.node.id.name;
if (isDataIdentifier(name, exportNamedState)) {
exportNamedPath.remove();
}
break;
}
case "VariableDeclaration":
{
const inner = decl.get("declarations");
inner.forEach((d)=>{
if (d.node.id.type !== "Identifier") {
return;
}
const name = d.node.id.name;
if (isDataIdentifier(name, exportNamedState)) {
d.remove();
}
});
break;
}
default:
{
break;
}
}
}
}, state);
if (!state.isPrerender && !state.isServerProps) {
return;
}
const refs = state.refs;
let count;
function sweepFunction(sweepPath) {
const ident = getIdentifier(sweepPath);
if ((ident == null ? void 0 : ident.node) && refs.has(ident) && !isIdentifierReferenced(ident)) {
++count;
if (t.isAssignmentExpression(sweepPath.parentPath) || t.isVariableDeclarator(sweepPath.parentPath)) {
sweepPath.parentPath.remove();
} else {
sweepPath.remove();
}
}
}
function sweepImport(sweepPath) {
const local = sweepPath.get("local");
if (refs.has(local) && !isIdentifierReferenced(local)) {
++count;
sweepPath.remove();
if (sweepPath.parent.specifiers.length === 0) {
sweepPath.parentPath.remove();
}
}
}
do {
path.scope.crawl();
count = 0;
path.traverse({
// eslint-disable-next-line no-loop-func
VariableDeclarator (variablePath) {
if (variablePath.node.id.type === "Identifier") {
const local = variablePath.get("id");
if (refs.has(local) && !isIdentifierReferenced(local)) {
++count;
variablePath.remove();
}
} else if (variablePath.node.id.type === "ObjectPattern") {
const pattern = variablePath.get("id");
const beforeCount = count;
const properties = pattern.get("properties");
properties.forEach((p)=>{
const local = p.get(p.node.type === "ObjectProperty" ? "value" : p.node.type === "RestElement" ? "argument" : function() {
throw new Error("invariant");
}());
if (refs.has(local) && !isIdentifierReferenced(local)) {
++count;
p.remove();
}
});
if (beforeCount !== count && pattern.get("properties").length < 1) {
variablePath.remove();
}
} else if (variablePath.node.id.type === "ArrayPattern") {
const pattern = variablePath.get("id");
const beforeCount = count;
const elements = pattern.get("elements");
elements.forEach((e)=>{
var ref, ref2;
let local;
if (((ref = e.node) == null ? void 0 : ref.type) === "Identifier") {
local = e;
} else if (((ref2 = e.node) == null ? void 0 : ref2.type) === "RestElement") {
local = e.get("argument");
} else {
return;
}
if (refs.has(local) && !isIdentifierReferenced(local)) {
++count;
e.remove();
}
});
if (beforeCount !== count && pattern.get("elements").length < 1) {
variablePath.remove();
}
}
},
FunctionDeclaration: sweepFunction,
FunctionExpression: sweepFunction,
ArrowFunctionExpression: sweepFunction,
ImportSpecifier: sweepImport,
ImportDefaultSpecifier: sweepImport,
ImportNamespaceSpecifier: sweepImport
});
}while (count);
decorateSsgExport(t, path, state);
}
}
}
};
}
const EXPORT_NAME_GET_STATIC_PROPS = "getStaticProps";
exports.EXPORT_NAME_GET_STATIC_PROPS = EXPORT_NAME_GET_STATIC_PROPS;
const EXPORT_NAME_GET_STATIC_PATHS = "getStaticPaths";
exports.EXPORT_NAME_GET_STATIC_PATHS = EXPORT_NAME_GET_STATIC_PATHS;
const EXPORT_NAME_GET_SERVER_PROPS = "getServerSideProps";
exports.EXPORT_NAME_GET_SERVER_PROPS = EXPORT_NAME_GET_SERVER_PROPS;
const ssgExports = new Set([
EXPORT_NAME_GET_STATIC_PROPS,
EXPORT_NAME_GET_STATIC_PATHS,
EXPORT_NAME_GET_SERVER_PROPS,
// legacy methods added so build doesn't fail from importing
// server-side only methods
`unstable_getStaticProps`,
`unstable_getStaticPaths`,
`unstable_getServerProps`,
`unstable_getServerSideProps`,
]);
function decorateSsgExport(t, path, state) {
const gsspName = state.isPrerender ? _constants1.STATIC_PROPS_ID : _constants1.SERVER_PROPS_ID;
const gsspId = t.identifier(gsspName);
const addGsspExport = (exportPath)=>{
if (state.done) {
return;
}
state.done = true;
const [pageCompPath] = exportPath.replaceWithMultiple([
t.exportNamedDeclaration(t.variableDeclaration(// We use 'var' instead of 'let' or 'const' for ES5 support. Since
// this runs in `Program#exit`, no ES2015 transforms (preset env)
// will be ran against this code.
"var", [
t.variableDeclarator(gsspId, t.booleanLiteral(true))
]), [
t.exportSpecifier(gsspId, gsspId)
]),
exportPath.node,
]);
exportPath.scope.registerDeclaration(pageCompPath);
};
path.traverse({
ExportDefaultDeclaration (exportDefaultPath) {
addGsspExport(exportDefaultPath);
},
ExportNamedDeclaration (exportNamedPath) {
addGsspExport(exportNamedPath);
}
});
}
const isDataIdentifier = (name, state)=>{
if (ssgExports.has(name)) {
if (name === EXPORT_NAME_GET_SERVER_PROPS) {
if (state.isPrerender) {
throw new Error(_constants.SERVER_PROPS_SSG_CONFLICT);
}
state.isServerProps = true;
} else {
if (state.isServerProps) {
throw new Error(_constants.SERVER_PROPS_SSG_CONFLICT);
}
state.isPrerender = true;
}
return true;
}
return false;
};
//# sourceMappingURL=next-ssg-transform.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,4 @@
import { PluginObj, types as BabelTypes } from 'next/dist/compiled/babel/core';
export default function ({ types: t, }: {
types: typeof BabelTypes;
}): PluginObj<any>;

View File

@@ -0,0 +1,54 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
// matches any hook-like (the default)
const isHook = /^use[A-Z]/;
// matches only built-in hooks provided by React et al
const isBuiltInHook = /^use(Callback|Context|DebugValue|Effect|ImperativeHandle|LayoutEffect|Memo|Reducer|Ref|State)$/;
function _default({ types: t }) {
const visitor = {
CallExpression (path, state) {
const onlyBuiltIns = state.opts.onlyBuiltIns;
// if specified, options.lib is a list of libraries that provide hook functions
const libs = state.opts.lib && (state.opts.lib === true ? [
"react",
"preact/hooks"
] : [].concat(state.opts.lib));
// skip function calls that are not the init of a variable declaration:
if (!t.isVariableDeclarator(path.parent)) return;
// skip function calls where the return value is not Array-destructured:
if (!t.isArrayPattern(path.parent.id)) return;
// name of the (hook) function being called:
const hookName = path.node.callee.name;
if (libs) {
const binding = path.scope.getBinding(hookName);
// not an import
if (!binding || binding.kind !== "module") return;
const specifier = binding.path.parent.source.value;
// not a match
if (!libs.some((lib)=>lib === specifier)) return;
}
// only match function calls with names that look like a hook
if (!(onlyBuiltIns ? isBuiltInHook : isHook).test(hookName)) return;
path.parent.id = t.objectPattern(path.parent.id.elements.reduce((patterns, element, i)=>{
if (element === null) {
return patterns;
}
return patterns.concat(t.objectProperty(t.numericLiteral(i), element));
}, []));
}
};
return {
name: "optimize-hook-destructuring",
visitor: {
// this is a workaround to run before preset-env destroys destructured assignments
Program (path, state) {
path.traverse(visitor, state);
}
}
};
}
//# sourceMappingURL=optimize-hook-destructuring.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../build/babel/plugins/optimize-hook-destructuring.ts"],"names":["isHook","isBuiltInHook","types","t","visitor","CallExpression","path","state","onlyBuiltIns","opts","libs","lib","concat","isVariableDeclarator","parent","isArrayPattern","id","hookName","node","callee","name","binding","scope","getBinding","kind","specifier","source","value","some","test","objectPattern","elements","reduce","patterns","element","i","objectProperty","numericLiteral","Program","traverse"],"mappings":"AAAA;;;;;AAMA,sCAAsC;AACtC,MAAMA,MAAM,cAAc;AAE1B,sDAAsD;AACtD,MAAMC,aAAa,mGAC+E;AAEnF,kBAAU,EACvBC,KAAK,EAAEC,CAAC,CAAA,EAGT,EAAkB;IACjB,MAAMC,OAAO,GAAG;QACdC,cAAc,EAACC,IAAyC,EAAEC,KAAU,EAAE;YACpE,MAAMC,YAAY,GAAGD,KAAK,CAACE,IAAI,CAACD,YAAY;YAE5C,+EAA+E;YAC/E,MAAME,IAAI,GACRH,KAAK,CAACE,IAAI,CAACE,GAAG,IACd,CAACJ,KAAK,CAACE,IAAI,CAACE,GAAG,KAAK,IAAI,GACpB;gBAAC,OAAO;gBAAE,cAAc;aAAC,GACzB,EAAE,CAACC,MAAM,CAACL,KAAK,CAACE,IAAI,CAACE,GAAG,CAAC,CAAC;YAEhC,uEAAuE;YACvE,IAAI,CAACR,CAAC,CAACU,oBAAoB,CAACP,IAAI,CAACQ,MAAM,CAAC,EAAE,OAAM;YAEhD,wEAAwE;YACxE,IAAI,CAACX,CAAC,CAACY,cAAc,CAACT,IAAI,CAACQ,MAAM,CAACE,EAAE,CAAC,EAAE,OAAM;YAE7C,4CAA4C;YAC5C,MAAMC,QAAQ,GAAG,AAACX,IAAI,CAACY,IAAI,CAACC,MA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017-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
*/
import { PluginObj, types as BabelTypes } from 'next/dist/compiled/babel/core';
export default function ({ types: t, }: {
types: typeof BabelTypes;
}): PluginObj;

View File

@@ -0,0 +1,110 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
var _path = require("path");
function _default({ types: t }) {
return {
visitor: {
ImportDeclaration (path, state) {
let source = path.node.source.value;
if (source !== "next/dynamic") return;
let defaultSpecifier = path.get("specifiers").find((specifier)=>{
return specifier.isImportDefaultSpecifier();
});
if (!defaultSpecifier) return;
const bindingName = defaultSpecifier.node.local.name;
const binding = path.scope.getBinding(bindingName);
if (!binding) {
return;
}
binding.referencePaths.forEach((refPath)=>{
var ref2, ref1;
let callExpression = refPath.parentPath;
if (callExpression.isMemberExpression() && callExpression.node.computed === false) {
const property = callExpression.get("property");
if (!Array.isArray(property) && property.isIdentifier({
name: "Map"
})) {
callExpression = callExpression.parentPath;
}
}
if (!callExpression.isCallExpression()) return;
const callExpression_ = callExpression;
let args = callExpression_.get("arguments");
if (args.length > 2) {
throw callExpression_.buildCodeFrameError("next/dynamic only accepts 2 arguments");
}
if (!args[0]) {
return;
}
let loader;
let options;
if (args[0].isObjectExpression()) {
options = args[0];
} else {
if (!args[1]) {
callExpression_.node.arguments.push(t.objectExpression([]));
}
// This is needed as the code is modified above
args = callExpression_.get("arguments");
loader = args[0];
options = args[1];
}
if (!options.isObjectExpression()) return;
const options_ = options;
let properties = options_.get("properties");
let propertiesMap = {};
properties.forEach((property)=>{
const key = property.get("key");
propertiesMap[key.node.name] = property;
});
if (propertiesMap.loadableGenerated) {
return;
}
if (propertiesMap.loader) {
loader = propertiesMap.loader.get("value");
}
if (propertiesMap.modules) {
loader = propertiesMap.modules.get("value");
}
if (!loader || Array.isArray(loader)) {
return;
}
const dynamicImports = [];
const dynamicKeys = [];
loader.traverse({
Import (importPath) {
var ref;
const importArguments = importPath.parentPath.get("arguments");
if (!Array.isArray(importArguments)) return;
const node = importArguments[0].node;
dynamicImports.push(node);
dynamicKeys.push(t.binaryExpression("+", t.stringLiteral((((ref = state.file.opts.caller) == null ? void 0 : ref.pagesDir) ? (0, _path).relative(state.file.opts.caller.pagesDir, state.file.opts.filename) : state.file.opts.filename) + " -> "), node));
}
});
if (!dynamicImports.length) return;
options.node.properties.push(t.objectProperty(t.identifier("loadableGenerated"), t.objectExpression(((ref2 = state.file.opts.caller) == null ? void 0 : ref2.isDev) || ((ref1 = state.file.opts.caller) == null ? void 0 : ref1.isServer) ? [
t.objectProperty(t.identifier("modules"), t.arrayExpression(dynamicKeys)),
] : [
t.objectProperty(t.identifier("webpack"), t.arrowFunctionExpression([], t.arrayExpression(dynamicImports.map((dynamicImport)=>{
return t.callExpression(t.memberExpression(t.identifier("require"), t.identifier("resolveWeak")), [
dynamicImport
]);
})))),
])));
// Turns `dynamic(import('something'))` into `dynamic(() => import('something'))` for backwards compat.
// This is the replicate the behavior in versions below Next.js 7 where we magically handled not executing the `import()` too.
// We'll deprecate this behavior and provide a codemod for it in 7.1.
if (loader.isCallExpression()) {
const arrowFunction = t.arrowFunctionExpression([], loader.node);
loader.replaceWith(arrowFunction);
}
});
}
}
};
}
//# sourceMappingURL=react-loadable-plugin.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,25 @@
import { PluginItem } from 'next/dist/compiled/babel/core';
declare type StyledJsxPlugin = [string, any] | string;
declare type StyledJsxBabelOptions = {
plugins?: StyledJsxPlugin[];
styleModule?: string;
'babel-test'?: boolean;
} | undefined;
declare type NextBabelPresetOptions = {
'preset-env'?: any;
'preset-react'?: any;
'class-properties'?: any;
'transform-runtime'?: any;
'styled-jsx'?: StyledJsxBabelOptions;
'preset-typescript'?: any;
};
declare type BabelPreset = {
presets?: PluginItem[] | null;
plugins?: PluginItem[] | null;
sourceType?: 'script' | 'module' | 'unambiguous';
overrides?: Array<{
test: RegExp;
} & Omit<BabelPreset, 'overrides'>>;
};
declare const _default: (api: any, options?: NextBabelPresetOptions) => BabelPreset;
export default _default;

160
kitabcitab/node_modules/next/dist/build/babel/preset.js generated vendored Normal file
View File

@@ -0,0 +1,160 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _path = require("path");
const isLoadIntentTest = process.env.NODE_ENV === "test";
const isLoadIntentDevelopment = process.env.NODE_ENV === "development";
// Resolve styled-jsx plugins
function styledJsxOptions(options) {
options = options || {};
options.styleModule = "styled-jsx/style";
if (!Array.isArray(options.plugins)) {
return options;
}
options.plugins = options.plugins.map((plugin)=>{
if (Array.isArray(plugin)) {
const [name, pluginOptions] = plugin;
return [
require.resolve(name),
pluginOptions
];
}
return require.resolve(plugin);
});
return options;
}
// Taken from https://github.com/babel/babel/commit/d60c5e1736543a6eac4b549553e107a9ba967051#diff-b4beead8ad9195361b4537601cc22532R158
function supportsStaticESM(caller) {
return !!(caller == null ? void 0 : caller.supportsStaticESM);
}
var _default = (api, options = {})=>{
var ref, ref1;
const supportsESM = api.caller(supportsStaticESM);
const isServer = api.caller((caller)=>!!caller && caller.isServer);
const isCallerDevelopment = api.caller((caller)=>{
return caller == null ? void 0 : caller.isDev;
});
// Look at external intent if used without a caller (e.g. via Jest):
const isTest = isCallerDevelopment == null && isLoadIntentTest;
// Look at external intent if used without a caller (e.g. Storybook):
const isDevelopment = isCallerDevelopment === true || isCallerDevelopment == null && isLoadIntentDevelopment;
// Default to production mode if not `test` nor `development`:
const isProduction = !(isTest || isDevelopment);
const isBabelLoader = api.caller((caller)=>!!caller && (caller.name === "babel-loader" || caller.name === "next-babel-turbo-loader"));
const useJsxRuntime = ((ref = options["preset-react"]) == null ? void 0 : ref.runtime) === "automatic" || Boolean(api.caller((caller)=>!!caller && caller.hasJsxRuntime)) && ((ref1 = options["preset-react"]) == null ? void 0 : ref1.runtime) !== "classic";
const presetEnvConfig = {
// In the test environment `modules` is often needed to be set to true, babel figures that out by itself using the `'auto'` option
// In production/development this option is set to `false` so that webpack can handle import/export with tree-shaking
modules: "auto",
exclude: [
"transform-typeof-symbol"
],
...options["preset-env"]
};
// When transpiling for the server or tests, target the current Node version
// if not explicitly specified:
if ((isServer || isTest) && (!presetEnvConfig.targets || !(typeof presetEnvConfig.targets === "object" && "node" in presetEnvConfig.targets))) {
presetEnvConfig.targets = {
// Targets the current process' version of Node. This requires apps be
// built and deployed on the same version of Node.
// This is the same as using "current" but explicit
node: process.versions.node
};
}
return {
sourceType: "unambiguous",
presets: [
[
require("next/dist/compiled/babel/preset-env"),
presetEnvConfig
],
[
require("next/dist/compiled/babel/preset-react"),
{
// This adds @babel/plugin-transform-react-jsx-source and
// @babel/plugin-transform-react-jsx-self automatically in development
development: isDevelopment || isTest,
...useJsxRuntime ? {
runtime: "automatic"
} : {
pragma: "__jsx"
},
...options["preset-react"]
},
],
[
require("next/dist/compiled/babel/preset-typescript"),
{
allowNamespaces: true,
...options["preset-typescript"]
},
],
],
plugins: [
!useJsxRuntime && [
require("./plugins/jsx-pragma"),
{
// This produces the following injected import for modules containing JSX:
// import React from 'react';
// var __jsx = React.createElement;
module: "react",
importAs: "React",
pragma: "__jsx",
property: "createElement"
},
],
[
require("./plugins/optimize-hook-destructuring"),
{
// only optimize hook functions imported from React/Preact
lib: true
},
],
require("next/dist/compiled/babel/plugin-syntax-dynamic-import"),
require("next/dist/compiled/babel/plugin-syntax-import-assertions"),
require("./plugins/react-loadable-plugin"),
[
require("next/dist/compiled/babel/plugin-proposal-class-properties"),
options["class-properties"] || {},
],
[
require("next/dist/compiled/babel/plugin-proposal-object-rest-spread"),
{
useBuiltIns: true
},
],
!isServer && [
require("next/dist/compiled/babel/plugin-transform-runtime"),
{
corejs: false,
helpers: true,
regenerator: true,
useESModules: supportsESM && presetEnvConfig.modules !== "commonjs",
absoluteRuntime: isBabelLoader ? (0, _path).dirname(require.resolve("next/dist/compiled/@babel/runtime/package.json")) : undefined,
...options["transform-runtime"]
},
],
[
isTest && options["styled-jsx"] && options["styled-jsx"]["babel-test"] ? require("styled-jsx/babel-test") : require("styled-jsx/babel"),
styledJsxOptions(options["styled-jsx"]),
],
require("./plugins/amp-attributes"),
isProduction && [
require("next/dist/compiled/babel/plugin-transform-react-remove-prop-types"),
{
removeImport: true
},
],
isServer && require("next/dist/compiled/babel/plugin-syntax-bigint"),
// Always compile numeric separator because the resulting number is
// smaller.
require("next/dist/compiled/babel/plugin-proposal-numeric-separator"),
require("next/dist/compiled/babel/plugin-proposal-export-namespace-from"),
].filter(Boolean)
};
};
exports.default = _default;
//# sourceMappingURL=preset.js.map

File diff suppressed because one or more lines are too long

10
kitabcitab/node_modules/next/dist/build/compiler.d.ts generated vendored Normal file
View File

@@ -0,0 +1,10 @@
import { webpack } from 'next/dist/compiled/webpack/webpack';
import { Span } from '../trace';
export declare type CompilerResult = {
errors: webpack.StatsError[];
warnings: webpack.StatsError[];
stats: webpack.Stats | undefined;
};
export declare function runCompiler(config: webpack.Configuration, { runWebpackSpan }: {
runWebpackSpan: Span;
}): Promise<CompilerResult>;

63
kitabcitab/node_modules/next/dist/build/compiler.js generated vendored Normal file
View File

@@ -0,0 +1,63 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.runCompiler = runCompiler;
var _webpack = require("next/dist/compiled/webpack/webpack");
function generateStats(result, stat) {
const { errors , warnings } = stat.toJson({
preset: "errors-warnings",
moduleTrace: true
});
if (errors && errors.length > 0) {
result.errors.push(...errors);
}
if (warnings && warnings.length > 0) {
result.warnings.push(...warnings);
}
return result;
}
// Webpack 5 requires the compiler to be closed (to save caches)
// Webpack 4 does not have this close method so in order to be backwards compatible we check if it exists
function closeCompiler(compiler) {
return new Promise((resolve, reject)=>{
// @ts-ignore Close only exists on the compiler in webpack 5
return compiler.close((err)=>err ? reject(err) : resolve());
});
}
function runCompiler(config, { runWebpackSpan }) {
return new Promise((resolve, reject)=>{
const compiler = (0, _webpack).webpack(config);
compiler.run((err, stats)=>{
const webpackCloseSpan = runWebpackSpan.traceChild("webpack-close", {
name: config.name
});
webpackCloseSpan.traceAsyncFn(()=>closeCompiler(compiler)).then(()=>{
if (err) {
const reason = err.stack ?? err.toString();
if (reason) {
return resolve({
errors: [
{
message: reason,
details: err.details
}
],
warnings: [],
stats
});
}
return reject(err);
} else if (!stats) throw new Error("No Stats from webpack");
const result = webpackCloseSpan.traceChild("webpack-generate-error-stats").traceFn(()=>generateStats({
errors: [],
warnings: [],
stats
}, stats));
return resolve(result);
});
});
});
}
//# sourceMappingURL=compiler.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../build/compiler.ts"],"names":["runCompiler","generateStats","result","stat","errors","warnings","toJson","preset","moduleTrace","length","push","closeCompiler","compiler","Promise","resolve","reject","close","err","config","runWebpackSpan","webpack","run","stats","webpackCloseSpan","traceChild","name","traceAsyncFn","then","reason","stack","toString","message","details","Error","traceFn"],"mappings":"AAAA;;;;QAqCgBA,WAAW,GAAXA,WAAW;AArCH,IAAA,QAAoC,WAApC,oCAAoC,CAAA;AAS5D,SAASC,aAAa,CACpBC,MAAsB,EACtBC,IAAmB,EACH;IAChB,MAAM,EAAEC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AM;gBACV,IAAIV,GAAG,EAAE;oBACP,MAAMW,MAAM,GAAGX,GAAG,CAACY,KAAK,IAAIZ,GAAG,CAACa,QAAQ,EAAE;oBAC1C,IAAIF,MAAM,EAAE;wBACV,OAAOd,OAAO,CAAC;4BACbV,MAAM,EAAE;gCAAC;oCAAE2B,OAAO,EAAEH,MAAM;oCAAEI,OAAO,EAAE,AAACf,GAAG,CAASe,OAAO;iCAAE;6BAAC;4BAC5D3B,QAAQ,EAAE,EAAE;4BACZiB,KAAK;yBACN,CAAC,CAAA;qBACH;oBACD,OAAOP,MAAM,CAACE,GAAG,CAAC,CAAA;iBACnB,MAAM,IAAI,CAACK,KAAK,EAAE,MAAM,IAAIW,KAAK,CAAC,uBAAuB,CAAC,CAAA;gBAE3D,MAAM/B,MAAM,GAAGqB,gBAAgB,CAC5BC,UAAU,CAAC,8BAA8B,CAAC,CAC1CU,OAAO,CAAC,IACPjC,aAAa,CAAC;wBAAEG,MAAM,EAAE,EAAE;wBAAEC,QAAQ,EAAE,EAAE;wBAAEiB,KAAK;qBAAE,EAAEA,KAAK,CAAC,CAC1D;gBACH,OAAOR,OAAO,CAACZ,MAAM,CAAC,CAAA;aACvB,CAAC;SACL,CAAC;KACH,CAAC,CAAA;CACH"}

View File

@@ -0,0 +1,4 @@
"use strict";
module.exports = require("next/dist/compiled/cssnano-simple")(require("postcss"));
//# sourceMappingURL=cssnano-simple.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../build/cssnano-simple.js"],"names":["module","exports","require"],"mappings":"AAAAA;AAAAA,MAAM,CAACC,OAAO,GAAGC,OAAO,CAAC,mCAAmC,CAAC,CAC3DA,OAAO,CAAC,SAAS,CAAC,CACnB"}

96
kitabcitab/node_modules/next/dist/build/entries.d.ts generated vendored Normal file
View File

@@ -0,0 +1,96 @@
import type { NextConfigComplete } from '../server/config-shared';
import type { webpack } from 'next/dist/compiled/webpack/webpack';
import type { MiddlewareConfig } from './analysis/get-page-static-info';
import type { LoadedEnvFiles } from '@next/env';
import { CompilerNameValues } from '../shared/lib/constants';
import { __ApiPreviewProps } from '../server/api-utils';
import { ServerRuntime } from '../types';
declare type ObjectValue<T> = T extends {
[key: string]: infer V;
} ? V : never;
/**
* For a given page path removes the provided extensions.
*/
export declare function getPageFromPath(pagePath: string, pageExtensions: string[]): string;
export declare function createPagesMapping({ isDev, pageExtensions, pagePaths, pagesType, pagesDir, }: {
isDev: boolean;
pageExtensions: string[];
pagePaths: string[];
pagesType: 'pages' | 'root' | 'app';
pagesDir: string | undefined;
}): {
[page: string]: string;
};
interface CreateEntrypointsParams {
buildId: string;
config: NextConfigComplete;
envFiles: LoadedEnvFiles;
isDev?: boolean;
pages: {
[page: string]: string;
};
pagesDir?: string;
previewMode: __ApiPreviewProps;
rootDir: string;
rootPaths?: Record<string, string>;
appDir?: string;
appPaths?: Record<string, string>;
pageExtensions: string[];
}
export declare function getEdgeServerEntry(opts: {
rootDir: string;
absolutePagePath: string;
buildId: string;
bundlePath: string;
config: NextConfigComplete;
isDev: boolean;
isServerComponent: boolean;
page: string;
pages: {
[page: string]: string;
};
middleware?: Partial<MiddlewareConfig>;
pagesType: 'app' | 'pages' | 'root';
appDirLoader?: string;
}): string | {
import: string;
layer: string | undefined;
};
export declare function getAppEntry(opts: {
name: string;
pagePath: string;
appDir: string;
appPaths: string[] | null;
pageExtensions: string[];
isDev?: boolean;
rootDir?: string;
tsconfigPath?: string;
}): {
import: string;
layer: string;
};
export declare function getClientEntry(opts: {
absolutePagePath: string;
page: string;
}): string | string[];
export declare function runDependingOnPageType<T>(params: {
onClient: () => T;
onEdgeServer: () => T;
onServer: () => T;
page: string;
pageRuntime: ServerRuntime;
}): Promise<void>;
export declare function createEntrypoints(params: CreateEntrypointsParams): Promise<{
client: webpack.EntryObject;
server: webpack.EntryObject;
edgeServer: webpack.EntryObject;
middlewareMatchers: undefined;
}>;
export declare function finalizeEntrypoint({ name, compilerType, value, isServerComponent, hasAppDir, }: {
compilerType?: CompilerNameValues;
name: string;
value: ObjectValue<webpack.EntryObject>;
isServerComponent?: boolean;
hasAppDir?: boolean;
}): ObjectValue<webpack.EntryObject>;
export {};

366
kitabcitab/node_modules/next/dist/build/entries.js generated vendored Normal file
View File

@@ -0,0 +1,366 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getPageFromPath = getPageFromPath;
exports.createPagesMapping = createPagesMapping;
exports.getEdgeServerEntry = getEdgeServerEntry;
exports.getAppEntry = getAppEntry;
exports.getClientEntry = getClientEntry;
exports.runDependingOnPageType = runDependingOnPageType;
exports.createEntrypoints = createEntrypoints;
exports.finalizeEntrypoint = finalizeEntrypoint;
var _chalk = _interopRequireDefault(require("next/dist/compiled/chalk"));
var _path = require("path");
var _querystring = require("querystring");
var _constants = require("../lib/constants");
var _isApiRoute = require("../lib/is-api-route");
var _isEdgeRuntime = require("../lib/is-edge-runtime");
var _constants1 = require("../shared/lib/constants");
var _log = require("./output/log");
var _utils = require("./utils");
var _getPageStaticInfo = require("./analysis/get-page-static-info");
var _normalizePathSep = require("../shared/lib/page-path/normalize-path-sep");
var _normalizePagePath = require("../shared/lib/page-path/normalize-page-path");
var _appPaths = require("../shared/lib/router/utils/app-paths");
var _nextMiddlewareLoader = require("./webpack/loaders/next-middleware-loader");
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
function getPageFromPath(pagePath, pageExtensions) {
let page = (0, _normalizePathSep).normalizePathSep(pagePath.replace(new RegExp(`\\.+(${pageExtensions.join("|")})$`), ""));
page = page.replace(/\/index$/, "");
return page === "" ? "/" : page;
}
function createPagesMapping({ isDev , pageExtensions , pagePaths , pagesType , pagesDir }) {
const previousPages = {};
const pages = pagePaths.reduce((result, pagePath)=>{
// Do not process .d.ts files inside the `pages` folder
if (pagePath.endsWith(".d.ts") && pageExtensions.includes("ts")) {
return result;
}
const pageKey = getPageFromPath(pagePath, pageExtensions);
if (pageKey in result) {
(0, _log).warn(`Duplicate page detected. ${_chalk.default.cyan((0, _path).join("pages", previousPages[pageKey]))} and ${_chalk.default.cyan((0, _path).join("pages", pagePath))} both resolve to ${_chalk.default.cyan(pageKey)}.`);
} else {
previousPages[pageKey] = pagePath;
}
result[pageKey] = (0, _normalizePathSep).normalizePathSep((0, _path).join(pagesType === "pages" ? _constants.PAGES_DIR_ALIAS : pagesType === "app" ? _constants.APP_DIR_ALIAS : _constants.ROOT_DIR_ALIAS, pagePath));
return result;
}, {});
if (pagesType !== "pages") {
return pages;
}
if (isDev) {
delete pages["/_app"];
delete pages["/_error"];
delete pages["/_document"];
}
// In development we always alias these to allow Webpack to fallback to
// the correct source file so that HMR can work properly when a file is
// added or removed.
const root = isDev && pagesDir ? _constants.PAGES_DIR_ALIAS : "next/dist/pages";
return {
"/_app": `${root}/_app`,
"/_error": `${root}/_error`,
"/_document": `${root}/_document`,
...pages
};
}
function getEdgeServerEntry(opts) {
var ref;
if ((0, _utils).isMiddlewareFile(opts.page)) {
var ref1;
const loaderParams = {
absolutePagePath: opts.absolutePagePath,
page: opts.page,
rootDir: opts.rootDir,
matchers: ((ref1 = opts.middleware) == null ? void 0 : ref1.matchers) ? (0, _nextMiddlewareLoader).encodeMatchers(opts.middleware.matchers) : ""
};
return `next-middleware-loader?${(0, _querystring).stringify(loaderParams)}!`;
}
if ((0, _isApiRoute).isAPIRoute(opts.page)) {
const loaderParams = {
absolutePagePath: opts.absolutePagePath,
page: opts.page,
rootDir: opts.rootDir
};
return `next-edge-function-loader?${(0, _querystring).stringify(loaderParams)}!`;
}
const loaderParams = {
absolute500Path: opts.pages["/500"] || "",
absoluteAppPath: opts.pages["/_app"],
absoluteDocumentPath: opts.pages["/_document"],
absoluteErrorPath: opts.pages["/_error"],
absolutePagePath: opts.absolutePagePath,
buildId: opts.buildId,
dev: opts.isDev,
isServerComponent: opts.isServerComponent,
page: opts.page,
stringifiedConfig: JSON.stringify(opts.config),
pagesType: opts.pagesType,
appDirLoader: Buffer.from(opts.appDirLoader || "").toString("base64"),
sriEnabled: !opts.isDev && !!((ref = opts.config.experimental.sri) == null ? void 0 : ref.algorithm),
hasFontLoaders: !!opts.config.experimental.fontLoaders
};
return {
import: `next-edge-ssr-loader?${(0, _querystring).stringify(loaderParams)}!`,
// The Edge bundle includes the server in its entrypoint, so it has to
// be in the SSR layer — we later convert the page request to the RSC layer
// via a webpack rule.
layer: opts.appDirLoader ? _constants.WEBPACK_LAYERS.client : undefined
};
}
function getAppEntry(opts) {
return {
import: `next-app-loader?${(0, _querystring).stringify(opts)}!`,
layer: _constants.WEBPACK_LAYERS.server
};
}
function getClientEntry(opts) {
const loaderOptions = {
absolutePagePath: opts.absolutePagePath,
page: opts.page
};
const pageLoader = `next-client-pages-loader?${(0, _querystring).stringify(loaderOptions)}!`;
// Make sure next/router is a dependency of _app or else chunk splitting
// might cause the router to not be able to load causing hydration
// to fail
return opts.page === "/_app" ? [
pageLoader,
require.resolve("../client/router")
] : pageLoader;
}
async function runDependingOnPageType(params) {
if ((0, _utils).isMiddlewareFile(params.page)) {
await params.onEdgeServer();
return;
}
if ((0, _isApiRoute).isAPIRoute(params.page)) {
if ((0, _isEdgeRuntime).isEdgeRuntime(params.pageRuntime)) {
await params.onEdgeServer();
return;
}
await params.onServer();
return;
}
if (params.page === "/_document") {
await params.onServer();
return;
}
if (params.page === "/_app" || params.page === "/_error" || params.page === "/404" || params.page === "/500") {
await Promise.all([
params.onClient(),
params.onServer()
]);
return;
}
if ((0, _isEdgeRuntime).isEdgeRuntime(params.pageRuntime)) {
await Promise.all([
params.onClient(),
params.onEdgeServer()
]);
return;
}
await Promise.all([
params.onClient(),
params.onServer()
]);
return;
}
async function createEntrypoints(params) {
const { config , pages , pagesDir , isDev , rootDir , rootPaths , appDir , appPaths , pageExtensions , } = params;
const edgeServer = {};
const server = {};
const client = {};
const nestedMiddleware = [];
let middlewareMatchers = undefined;
let appPathsPerRoute = {};
if (appDir && appPaths) {
for(const pathname in appPaths){
const normalizedPath = (0, _appPaths).normalizeAppPath(pathname) || "/";
if (!appPathsPerRoute[normalizedPath]) {
appPathsPerRoute[normalizedPath] = [];
}
appPathsPerRoute[normalizedPath].push(pathname);
}
// Make sure to sort parallel routes to make the result deterministic.
appPathsPerRoute = Object.fromEntries(Object.entries(appPathsPerRoute).map(([k, v])=>[
k,
v.sort()
]));
}
const getEntryHandler = (mappings, pagesType)=>{
return async (page)=>{
const bundleFile = (0, _normalizePagePath).normalizePagePath(page);
const clientBundlePath = _path.posix.join(pagesType, bundleFile);
const serverBundlePath = pagesType === "pages" ? _path.posix.join("pages", bundleFile) : pagesType === "app" ? _path.posix.join("app", bundleFile) : bundleFile.slice(1);
const absolutePagePath = mappings[page];
// Handle paths that have aliases
const pageFilePath = (()=>{
if (absolutePagePath.startsWith(_constants.PAGES_DIR_ALIAS) && pagesDir) {
return absolutePagePath.replace(_constants.PAGES_DIR_ALIAS, pagesDir);
}
if (absolutePagePath.startsWith(_constants.APP_DIR_ALIAS) && appDir) {
return absolutePagePath.replace(_constants.APP_DIR_ALIAS, appDir);
}
if (absolutePagePath.startsWith(_constants.ROOT_DIR_ALIAS)) {
return absolutePagePath.replace(_constants.ROOT_DIR_ALIAS, rootDir);
}
return require.resolve(absolutePagePath);
})();
/**
* When we find a middleware file that is not in the ROOT_DIR we fail.
* There is no need to check on `dev` as this should only happen when
* building for production.
*/ if (!absolutePagePath.startsWith(_constants.ROOT_DIR_ALIAS) && /[\\\\/]_middleware$/.test(page)) {
nestedMiddleware.push(page);
}
const isInsideAppDir = !!appDir && (absolutePagePath.startsWith(_constants.APP_DIR_ALIAS) || absolutePagePath.startsWith(appDir));
const staticInfo = await (0, _getPageStaticInfo).getPageStaticInfo({
nextConfig: config,
pageFilePath,
isDev,
page,
pageType: isInsideAppDir ? "app" : "pages"
});
const isServerComponent = isInsideAppDir && staticInfo.rsc !== _constants1.RSC_MODULE_TYPES.client;
if ((0, _utils).isMiddlewareFile(page)) {
var ref;
middlewareMatchers = ((ref = staticInfo.middleware) == null ? void 0 : ref.matchers) ?? [
{
regexp: ".*"
},
];
}
await runDependingOnPageType({
page,
pageRuntime: staticInfo.runtime,
onClient: ()=>{
if (isServerComponent || isInsideAppDir) {
// We skip the initial entries for server component pages and let the
// server compiler inject them instead.
} else {
client[clientBundlePath] = getClientEntry({
absolutePagePath: mappings[page],
page
});
}
},
onServer: ()=>{
if (pagesType === "app" && appDir) {
const matchedAppPaths = appPathsPerRoute[(0, _appPaths).normalizeAppPath(page) || "/"];
server[serverBundlePath] = getAppEntry({
name: serverBundlePath,
pagePath: mappings[page],
appDir,
appPaths: matchedAppPaths,
pageExtensions
});
} else {
server[serverBundlePath] = [
mappings[page]
];
}
},
onEdgeServer: ()=>{
let appDirLoader = "";
if (pagesType === "app") {
const matchedAppPaths = appPathsPerRoute[(0, _appPaths).normalizeAppPath(page) || "/"];
appDirLoader = getAppEntry({
name: serverBundlePath,
pagePath: mappings[page],
appDir: appDir,
appPaths: matchedAppPaths,
pageExtensions
}).import;
}
edgeServer[serverBundlePath] = getEdgeServerEntry({
...params,
rootDir,
absolutePagePath: mappings[page],
bundlePath: clientBundlePath,
isDev: false,
isServerComponent,
page,
middleware: staticInfo == null ? void 0 : staticInfo.middleware,
pagesType,
appDirLoader
});
}
});
};
};
if (appDir && appPaths) {
const entryHandler = getEntryHandler(appPaths, "app");
await Promise.all(Object.keys(appPaths).map(entryHandler));
}
if (rootPaths) {
await Promise.all(Object.keys(rootPaths).map(getEntryHandler(rootPaths, "root")));
}
await Promise.all(Object.keys(pages).map(getEntryHandler(pages, "pages")));
if (nestedMiddleware.length > 0) {
throw new _utils.NestedMiddlewareError(nestedMiddleware, rootDir, appDir || pagesDir);
}
return {
client,
server,
edgeServer,
middlewareMatchers
};
}
function finalizeEntrypoint({ name , compilerType , value , isServerComponent , hasAppDir }) {
const entry = typeof value !== "object" || Array.isArray(value) ? {
import: value
} : value;
const isApi = name.startsWith("pages/api/");
if (compilerType === _constants1.COMPILER_NAMES.server) {
return {
publicPath: isApi ? "" : undefined,
runtime: isApi ? "webpack-api-runtime" : "webpack-runtime",
layer: isApi ? _constants.WEBPACK_LAYERS.api : isServerComponent ? _constants.WEBPACK_LAYERS.server : undefined,
...entry
};
}
if (compilerType === _constants1.COMPILER_NAMES.edgeServer) {
return {
layer: (0, _utils).isMiddlewareFilename(name) || isApi ? _constants.WEBPACK_LAYERS.middleware : undefined,
library: {
name: [
"_ENTRIES",
`middleware_[name]`
],
type: "assign"
},
runtime: _constants1.EDGE_RUNTIME_WEBPACK,
asyncChunks: false,
...entry
};
}
const isAppLayer = hasAppDir && (name === _constants1.CLIENT_STATIC_FILES_RUNTIME_MAIN_APP || name === _constants1.APP_CLIENT_INTERNALS || name.startsWith("app/"));
if (// Client special cases
name !== _constants1.CLIENT_STATIC_FILES_RUNTIME_POLYFILLS && name !== _constants1.CLIENT_STATIC_FILES_RUNTIME_MAIN && name !== _constants1.CLIENT_STATIC_FILES_RUNTIME_MAIN_APP && name !== _constants1.CLIENT_STATIC_FILES_RUNTIME_AMP && name !== _constants1.CLIENT_STATIC_FILES_RUNTIME_REACT_REFRESH) {
if (isAppLayer) {
return {
dependOn: _constants1.CLIENT_STATIC_FILES_RUNTIME_MAIN_APP,
layer: _constants.WEBPACK_LAYERS.appClient,
...entry
};
}
return {
dependOn: name.startsWith("pages/") && name !== "pages/_app" ? "pages/_app" : _constants1.CLIENT_STATIC_FILES_RUNTIME_MAIN,
...entry
};
}
if (isAppLayer) {
return {
layer: _constants.WEBPACK_LAYERS.appClient,
...entry
};
}
return entry;
}
//# sourceMappingURL=entries.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
export declare function generateBuildId(generate: () => string | null | Promise<string | null>, fallback: () => string): Promise<string>;

View File

@@ -0,0 +1,22 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.generateBuildId = generateBuildId;
async function generateBuildId(generate, fallback) {
let buildId = await generate();
// If there's no buildId defined we'll fall back
if (buildId === null) {
// We also create a new buildId if it contains the word `ad` to avoid false
// positives with ad blockers
while(!buildId || /ad/i.test(buildId)){
buildId = fallback();
}
}
if (typeof buildId !== "string") {
throw new Error("generateBuildId did not return a string. https://nextjs.org/docs/messages/generatebuildid-not-a-string");
}
return buildId.trim();
}
//# sourceMappingURL=generate-build-id.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../build/generate-build-id.ts"],"names":["generateBuildId","generate","fallback","buildId","test","Error","trim"],"mappings":"AAAA;;;;QAAsBA,eAAe,GAAfA,eAAe;AAA9B,eAAeA,eAAe,CACnCC,QAAsD,EACtDC,QAAsB,EACL;IACjB,IAAIC,OAAO,GAAG,MAAMF,QAAQ,EAAE;IAC9B,gDAAgD;IAChD,IAAIE,OAAO,KAAK,IAAI,EAAE;QACpB,2EAA2E;QAC3E,6BAA6B;QAC7B,MAAO,CAACA,OAAO,IAAI,MAAMC,IAAI,CAACD,OAAO,CAAC,CAAE;YACtCA,OAAO,GAAGD,QAAQ,EAAE;SACrB;KACF;IAED,IAAI,OAAOC,OAAO,KAAK,QAAQ,EAAE;QAC/B,MAAM,IAAIE,KAAK,CACb,wGAAwG,CACzG,CAAA;KACF;IAED,OAAOF,OAAO,CAACG,IAAI,EAAE,CAAA;CACtB"}

24
kitabcitab/node_modules/next/dist/build/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,24 @@
import { __ApiPreviewProps } from '../server/api-utils';
export declare type SsgRoute = {
initialRevalidateSeconds: number | false;
srcRoute: string | null;
dataRoute: string;
};
export declare type DynamicSsgRoute = {
routeRegex: string;
fallback: string | null | false;
dataRoute: string;
dataRouteRegex: string;
};
export declare type PrerenderManifest = {
version: 3;
routes: {
[route: string]: SsgRoute;
};
dynamicRoutes: {
[route: string]: DynamicSsgRoute;
};
notFoundRoutes: string[];
preview: __ApiPreviewProps;
};
export default function build(dir: string, conf?: null, reactProductionProfiling?: boolean, debugOutput?: boolean, runLint?: boolean, noMangling?: boolean): Promise<void>;

1816
kitabcitab/node_modules/next/dist/build/index.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

1
kitabcitab/node_modules/next/dist/build/index.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
export declare function isWriteable(directory: string): Promise<boolean>;

View File

@@ -0,0 +1,21 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.isWriteable = isWriteable;
var _fs = _interopRequireDefault(require("fs"));
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
async function isWriteable(directory) {
try {
await _fs.default.promises.access(directory, (_fs.default.constants || _fs.default).W_OK);
return true;
} catch (err) {
return false;
}
}
//# sourceMappingURL=is-writeable.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../build/is-writeable.ts"],"names":["isWriteable","directory","fs","promises","access","constants","W_OK","err"],"mappings":"AAAA;;;;QAEsBA,WAAW,GAAXA,WAAW;AAFlB,IAAA,GAAI,kCAAJ,IAAI,EAAA;;;;;;AAEZ,eAAeA,WAAW,CAACC,SAAiB,EAAoB;IACrE,IAAI;QACF,MAAMC,GAAE,QAAA,CAACC,QAAQ,CAACC,MAAM,CAACH,SAAS,EAAE,CAACC,GAAE,QAAA,CAACG,SAAS,IAAIH,GAAE,QAAA,CAAC,CAACI,IAAI,CAAC;QAC9D,OAAO,IAAI,CAAA;KACZ,CAAC,OAAOC,GAAG,EAAE;QACZ,OAAO,KAAK,CAAA;KACb;CACF"}

View File

@@ -0,0 +1,15 @@
"use strict";
module.exports = {
src: "/img.jpg",
height: 40,
width: 40,
blurDataURL: "data:image/png;base64,imagedata"
};
if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
Object.defineProperty(exports.default, '__esModule', { value: true });
Object.assign(exports.default, exports);
module.exports = exports.default;
}
//# sourceMappingURL=fileMock.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../build/jest/__mocks__/fileMock.js"],"names":["module","exports","src","height","width","blurDataURL"],"mappings":"AAAAA;AAAAA,MAAM,CAACC,OAAO,GAAG;IACfC,GAAG,EAAE,UAAU;IACfC,MAAM,EAAE,EAAE;IACVC,KAAK,EAAE,EAAE;IACTC,WAAW,EAAE,iCAAiC;CAC/C"}

View File

@@ -0,0 +1,20 @@
"use strict";
module.exports = new Proxy({}, {
get: function getter() {
return ()=>({
className: "className",
variable: "variable",
style: {
fontFamily: "fontFamily"
}
});
}
});
if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
Object.defineProperty(exports.default, '__esModule', { value: true });
Object.assign(exports.default, exports);
module.exports = exports.default;
}
//# sourceMappingURL=nextFontMock.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../build/jest/__mocks__/nextFontMock.js"],"names":["module","exports","Proxy","get","getter","className","variable","style","fontFamily"],"mappings":"AAAAA;AAAAA,MAAM,CAACC,OAAO,GAAG,IAAIC,KAAK,CACxB,EAAE,EACF;IACEC,GAAG,EAAE,SAASC,MAAM,GAAG;QACrB,OAAO,IAAM,CAAC;gBACZC,SAAS,EAAE,WAAW;gBACtBC,QAAQ,EAAE,UAAU;gBACpBC,KAAK,EAAE;oBAAEC,UAAU,EAAE,YAAY;iBAAE;aACpC,CAAC,CAAA;KACH;CACF,CACF"}

View File

@@ -0,0 +1,10 @@
"use strict";
module.exports = {};
if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
Object.defineProperty(exports.default, '__esModule', { value: true });
Object.assign(exports.default, exports);
module.exports = exports.default;
}
//# sourceMappingURL=styleMock.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../build/jest/__mocks__/styleMock.js"],"names":["module","exports"],"mappings":"AAAAA;AAAAA,MAAM,CAACC,OAAO,GAAG,EAAE"}

View File

@@ -0,0 +1,3 @@
export default function nextJest(options?: {
dir?: string;
}): (customJestConfig?: any) => () => Promise<any>;

191
kitabcitab/node_modules/next/dist/build/jest/jest.js generated vendored Normal file
View File

@@ -0,0 +1,191 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = nextJest;
var _env = require("@next/env");
var _path = require("path");
var _config = _interopRequireDefault(require("../../server/config"));
var _constants = require("../../shared/lib/constants");
var _loadJsconfig = _interopRequireDefault(require("../load-jsconfig"));
var Log = _interopRequireWildcard(require("../output/log"));
var _findPagesDir = require("../../lib/find-pages-dir");
var _swc = require("../swc");
function nextJest(options = {}) {
// createJestConfig
return (customJestConfig)=>{
// Function that is provided as the module.exports of jest.config.js
// Will be called and awaited by Jest
return async ()=>{
let nextConfig;
let jsConfig;
let resolvedBaseUrl;
let isEsmProject = false;
let pagesDir;
let hasServerComponents;
if (options.dir) {
const resolvedDir = (0, _path).resolve(options.dir);
const packageConfig = loadClosestPackageJson(resolvedDir);
isEsmProject = packageConfig.type === "module";
nextConfig = await getConfig(resolvedDir);
const isAppDirEnabled = !!nextConfig.experimental.appDir;
const findPagesDirResult = (0, _findPagesDir).findPagesDir(resolvedDir, isAppDirEnabled);
hasServerComponents = !!findPagesDirResult.appDir;
pagesDir = findPagesDirResult.pagesDir;
setUpEnv(resolvedDir, nextConfig);
// TODO: revisit when bug in SWC is fixed that strips `.css`
const result = await (0, _loadJsconfig).default(resolvedDir, nextConfig);
jsConfig = result.jsConfig;
resolvedBaseUrl = result.resolvedBaseUrl;
}
// Ensure provided async config is supported
const resolvedJestConfig = (typeof customJestConfig === "function" ? await customJestConfig() : customJestConfig) ?? {};
// eagerly load swc bindings instead of waiting for transform calls
await (0, _swc).loadBindings();
if (_swc.lockfilePatchPromise.cur) {
await _swc.lockfilePatchPromise.cur;
}
const transpiled = ((nextConfig == null ? void 0 : nextConfig.transpilePackages) ?? []).join("|");
return {
...resolvedJestConfig,
moduleNameMapper: {
// Handle CSS imports (with CSS modules)
// https://jestjs.io/docs/webpack#mocking-css-modules
"^.+\\.module\\.(css|sass|scss)$": require.resolve("./object-proxy.js"),
// Handle CSS imports (without CSS modules)
"^.+\\.(css|sass|scss)$": require.resolve("./__mocks__/styleMock.js"),
// Handle image imports
"^.+\\.(png|jpg|jpeg|gif|webp|avif|ico|bmp)$": require.resolve(`./__mocks__/fileMock.js`),
// Keep .svg to it's own rule to make overriding easy
"^.+\\.(svg)$": require.resolve(`./__mocks__/fileMock.js`),
// Handle @next/font
"@next/font/(.*)": require.resolve("./__mocks__/nextFontMock.js"),
// custom config comes last to ensure the above rules are matched,
// fixes the case where @pages/(.*) -> src/pages/$! doesn't break
// CSS/image mocks
...resolvedJestConfig.moduleNameMapper || {}
},
testPathIgnorePatterns: [
// Don't look for tests in node_modules
"/node_modules/",
// Don't look for tests in the Next.js build output
"/.next/",
// Custom config can append to testPathIgnorePatterns but not modify it
// This is to ensure `.next` and `node_modules` are always excluded
...resolvedJestConfig.testPathIgnorePatterns || [],
],
transform: {
// Use SWC to compile tests
"^.+\\.(js|jsx|ts|tsx|mjs)$": [
require.resolve("../swc/jest-transformer"),
{
nextConfig,
jsConfig,
resolvedBaseUrl,
hasServerComponents,
isEsmProject,
pagesDir
},
],
// Allow for appending/overriding the default transforms
...resolvedJestConfig.transform || {}
},
transformIgnorePatterns: [
// To match Next.js behavior node_modules is not transformed, only `transpiledPackages`
...transpiled ? [
`/node_modules/(?!.pnpm)(?!(${transpiled})/)`,
`/node_modules/.pnpm/(?!(${transpiled.replace(/\//g, "\\+")})@)`,
] : [
"/node_modules/"
],
// CSS modules are mocked so they don't need to be transformed
"^.+\\.module\\.(css|sass|scss)$",
// Custom config can append to transformIgnorePatterns but not modify it
// This is to ensure `node_modules` and .module.css/sass/scss are always excluded
...resolvedJestConfig.transformIgnorePatterns || [],
],
watchPathIgnorePatterns: [
// Don't re-run tests when the Next.js build output changes
"/.next/",
...resolvedJestConfig.watchPathIgnorePatterns || [],
]
};
};
};
}
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
function _getRequireWildcardCache() {
if (typeof WeakMap !== "function") return null;
var cache = new WeakMap();
_getRequireWildcardCache = function() {
return cache;
};
return cache;
}
function _interopRequireWildcard(obj) {
if (obj && obj.__esModule) {
return obj;
}
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
return {
default: obj
};
}
var cache = _getRequireWildcardCache();
if (cache && cache.has(obj)) {
return cache.get(obj);
}
var newObj = {};
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
for(var key in obj){
if (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;
}
async function getConfig(dir) {
const conf = await (0, _config).default(_constants.PHASE_TEST, dir);
return conf;
}
/**
* Loads closest package.json in the directory hierarchy
*/ function loadClosestPackageJson(dir, attempts = 1) {
if (attempts > 5) {
throw new Error("Can't resolve main package.json file");
}
var mainPath = attempts === 1 ? "./" : Array(attempts).join("../");
try {
return require((0, _path).join(dir, mainPath + "package.json"));
} catch (e) {
return loadClosestPackageJson(dir, attempts + 1);
}
}
/** Loads dotenv files and sets environment variables based on next config. */ function setUpEnv(dir, nextConfig) {
const dev = false;
(0, _env).loadEnvConfig(dir, dev, Log);
if (nextConfig.experimental.newNextLinkBehavior) {
process.env.__NEXT_NEW_LINK_BEHAVIOR = "true";
}
}
if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
Object.defineProperty(exports.default, '__esModule', { value: true });
Object.assign(exports.default, exports);
module.exports = exports.default;
}
//# sourceMappingURL=jest.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../build/jest/jest.ts"],"names":["nextJest","Log","options","customJestConfig","nextConfig","jsConfig","resolvedBaseUrl","isEsmProject","pagesDir","hasServerComponents","dir","resolvedDir","resolve","packageConfig","loadClosestPackageJson","type","getConfig","isAppDirEnabled","experimental","appDir","findPagesDirResult","findPagesDir","setUpEnv","result","loadJsConfig","resolvedJestConfig","loadBindings","lockfilePatchPromise","cur","transpiled","transpilePackages","join","moduleNameMapper","require","testPathIgnorePatterns","transform","transformIgnorePatterns","replace","watchPathIgnorePatterns","conf","loadConfig","PHASE_TEST","attempts","Error","mainPath","Array","e","dev","loadEnvConfig","newNextLinkBehavior","process","env","__NEXT_NEW_LINK_BEHAVIOR"],"mappings":"AAAA;;;;kBAuDwBA,QAAQ;AAvDF,IAAA,IAAW,WAAX,WAAW,CAAA;AACX,IAAA,KAAM,WAAN,MAAM,CAAA;AACb,IAAA,OAAqB,kCAArB,qBAAqB,EAAA;AAEjB,IAAA,UAA4B,WAA5B,4BAA4B,CAAA;AAC9B,IAAA,aAAkB,kCAAlB,kBAAkB,EAAA;AAC/BC,IAAAA,GAAG,mCAAM,eAAe,EAArB;AACc,IAAA,aAA0B,WAA1B,0BAA0B,CAAA;AACJ,IAAA,IAAQ,WAAR,QAAQ,CAAA;AA+C5C,SAASD,QAAQ,CAACE,OAAyB,GAAG,EAAE,EAAE;IAC/D,mBAAmB;IACnB,OAAO,CAACC,gBAAsB,GAAK;QACjC,oEAAoE;QACpE,qCAAqC;QACrC,OAAO,UAAY;YACjB,IAAIC,UAAU;YACd,IAAIC,QAAQ;YACZ,IAAIC,eAAe;YACnB,IAAIC,YAAY,GAAG,KAAK;YACxB,IAAIC,QAAQ,AAAoB;YAChC,IAAIC,mBAAmB,AAAqB;YAE5C,IAAIP,OAAO,CAACQ,GAAG,EAAE;gBACf,MAAMC,WAAW,GAAGC,CAAAA,GAAAA,KAAO,AAAa,CAAA,QAAb,CAACV,OAAO,CAACQ,GAAG,CAAC;gBACxC,MAAMG,aAAa,GAAGC,sBAAsB,CAACH,WAAW,CAAC;gBACzDJ,YAAY,GAAGM,aAAa,CAACE,IAAI,KAAK,QAAQ;gBAE9CX,UAAU,GAAG,MAAMY,SAAS,CAACL,WAAW,CAAC;gBACzC,MAAMM,eAAe,GAA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_default = new Proxy({}, {
get: function getter(target, key) {
if (key === "__esModule") {
return false;
}
return key;
}
});
exports.default = _default;
if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
Object.defineProperty(exports.default, '__esModule', { value: true });
Object.assign(exports.default, exports);
module.exports = exports.default;
}
//# sourceMappingURL=object-proxy.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../build/jest/object-proxy.js"],"names":["Proxy","get","getter","target","key"],"mappings":"AA0BA;;;;;eAAe,IAAIA,KAAK,CACtB,EAAE,EACF;IACEC,GAAG,EAAE,SAASC,MAAM,CAACC,MAAM,EAAEC,GAAG,EAAE;QAChC,IAAIA,GAAG,KAAK,YAAY,EAAE;YACxB,OAAO,KAAK,CAAA;SACb;QACD,OAAOA,GAAG,CAAA;KACX;CACF,CACF"}

View File

@@ -0,0 +1,6 @@
import { NextConfigComplete } from '../server/config-shared';
export default function loadJsConfig(dir: string, config: NextConfigComplete): Promise<{
useTypeScript: boolean;
jsConfig: any;
resolvedBaseUrl: string | undefined;
}>;

View File

@@ -0,0 +1,132 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = loadJsConfig;
var _path = _interopRequireDefault(require("path"));
var _fileExists = require("../lib/file-exists");
var Log = _interopRequireWildcard(require("./output/log"));
var _getTypeScriptConfiguration = require("../lib/typescript/getTypeScriptConfiguration");
var _fs = require("fs");
var _isError = _interopRequireDefault(require("../lib/is-error"));
var _hasNecessaryDependencies = require("../lib/has-necessary-dependencies");
async function loadJsConfig(dir, config) {
let typeScriptPath;
try {
const deps = await (0, _hasNecessaryDependencies).hasNecessaryDependencies(dir, [
{
pkg: "typescript",
file: "typescript/lib/typescript.js",
exportsRestrict: true
},
]);
typeScriptPath = deps.resolved.get("typescript");
} catch (_) {}
const tsConfigPath = _path.default.join(dir, config.typescript.tsconfigPath);
const useTypeScript = Boolean(typeScriptPath && await (0, _fileExists).fileExists(tsConfigPath));
let implicitBaseurl;
let jsConfig;
// jsconfig is a subset of tsconfig
if (useTypeScript) {
if (config.typescript.tsconfigPath !== "tsconfig.json" && TSCONFIG_WARNED === false) {
TSCONFIG_WARNED = true;
Log.info(`Using tsconfig file: ${config.typescript.tsconfigPath}`);
}
const ts = await Promise.resolve(require(typeScriptPath));
const tsConfig = await (0, _getTypeScriptConfiguration).getTypeScriptConfiguration(ts, tsConfigPath, true);
jsConfig = {
compilerOptions: tsConfig.options
};
implicitBaseurl = _path.default.dirname(tsConfigPath);
}
const jsConfigPath = _path.default.join(dir, "jsconfig.json");
if (!useTypeScript && await (0, _fileExists).fileExists(jsConfigPath)) {
jsConfig = parseJsonFile(jsConfigPath);
implicitBaseurl = _path.default.dirname(jsConfigPath);
}
let resolvedBaseUrl;
if (jsConfig) {
var ref;
if ((ref = jsConfig.compilerOptions) == null ? void 0 : ref.baseUrl) {
resolvedBaseUrl = _path.default.resolve(dir, jsConfig.compilerOptions.baseUrl);
} else {
resolvedBaseUrl = implicitBaseurl;
}
}
return {
useTypeScript,
jsConfig,
resolvedBaseUrl
};
}
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
function _getRequireWildcardCache() {
if (typeof WeakMap !== "function") return null;
var cache = new WeakMap();
_getRequireWildcardCache = function() {
return cache;
};
return cache;
}
function _interopRequireWildcard(obj) {
if (obj && obj.__esModule) {
return obj;
}
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
return {
default: obj
};
}
var cache = _getRequireWildcardCache();
if (cache && cache.has(obj)) {
return cache.get(obj);
}
var newObj = {};
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
for(var key in obj){
if (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;
}
let TSCONFIG_WARNED = false;
function parseJsonFile(filePath) {
const JSON5 = require("next/dist/compiled/json5");
const contents = (0, _fs).readFileSync(filePath, "utf8");
// Special case an empty file
if (contents.trim() === "") {
return {};
}
try {
return JSON5.parse(contents);
} catch (err) {
if (!(0, _isError).default(err)) throw err;
const { codeFrameColumns } = require("next/dist/compiled/babel/code-frame");
const codeFrame = codeFrameColumns(String(contents), {
start: {
line: err.lineNumber || 0,
column: err.columnNumber || 0
}
}, {
message: err.message,
highlightCode: true
});
throw new Error(`Failed to parse "${filePath}":\n${codeFrame}`);
}
}
//# sourceMappingURL=load-jsconfig.js.map

Some files were not shown because too many files have changed in this diff Show More