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

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

@@ -0,0 +1,13 @@
export function isWasm(): Promise<boolean>
export function transform(src: string, options?: any): Promise<any>
export function transformSync(src: string, options?: any): any
export function minify(src: string, options: any): Promise<string>
export function minifySync(src: string, options: any): string
export function parse(src: string, options: any): any
export const lockfilePatchPromise: { cur?: Promise<void> }
export function initCustomTraceSubscriber(traceFileName?: string): void
export function teardownTraceSubscriber(): void
export function teardownCrashReporter(): void
export function loadBindings(): Promise<void>
export function __isCustomTurbopackBinary(): Promise<boolean>

505
kitabcitab/node_modules/next/dist/build/swc/index.js generated vendored Normal file
View File

@@ -0,0 +1,505 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.loadBindings = loadBindings;
exports.isWasm = isWasm;
exports.transform = transform;
exports.transformSync = transformSync;
exports.minify = minify;
exports.minifySync = minifySync;
exports.parse = parse;
exports.getBinaryMetadata = getBinaryMetadata;
exports.teardownCrashReporter = exports.teardownTraceSubscriber = exports.initCustomTraceSubscriber = exports.lockfilePatchPromise = exports.__isCustomTurbopackBinary = void 0;
var _path = _interopRequireDefault(require("path"));
var _url = require("url");
var _os = require("os");
var _triples = require("next/dist/compiled/@napi-rs/triples");
var Log = _interopRequireWildcard(require("../output/log"));
var _options = require("./options");
var _swcLoadFailure = require("../../telemetry/events/swc-load-failure");
var _patchIncorrectLockfile = require("../../lib/patch-incorrect-lockfile");
var _downloadWasmSwc = require("../../lib/download-wasm-swc");
var _packageJson = require("next/package.json");
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 ArchName = (0, _os).arch();
const PlatformName = (0, _os).platform();
const triples = _triples.platformArchTriples[PlatformName][ArchName] || [];
// Allow to specify an absolute path to the custom turbopack binary to load.
// If one of env variables is set, `loadNative` will try to use any turbo-* interfaces from specified
// binary instead. This will not affect existing swc's transform, or other interfaces. This is thin,
// naive interface - `loadBindings` will not validate neither path nor the binary.
//
// Note these are internal flag: there's no stability, feature gaurentee.
const __INTERNAL_CUSTOM_TURBOPACK_BINARY = process.env.__INTERNAL_CUSTOM_TURBOPACK_BINARY;
const __INTERNAL_CUSTOM_TURBOPACK_BINDINGS = process.env.__INTERNAL_CUSTOM_TURBOPACK_BINDINGS;
const __isCustomTurbopackBinary = async ()=>{
if (!!__INTERNAL_CUSTOM_TURBOPACK_BINARY && !!__INTERNAL_CUSTOM_TURBOPACK_BINDINGS) {
throw new Error("Cannot use TURBOPACK_BINARY and TURBOPACK_BINDINGS both");
}
return !!__INTERNAL_CUSTOM_TURBOPACK_BINARY || !!__INTERNAL_CUSTOM_TURBOPACK_BINDINGS;
};
exports.__isCustomTurbopackBinary = __isCustomTurbopackBinary;
// These are the platforms we'll try to load wasm bindings first,
// only try to load native bindings if loading wasm binding somehow fails.
// Fallback to native binding is for migration period only,
// once we can verify loading-wasm-first won't cause visible regressions,
// we'll not include native bindings for these platform at all.
const knownDefaultWasmFallbackTriples = [
"aarch64-linux-android",
"x86_64-unknown-freebsd",
"aarch64-pc-windows-msvc",
"arm-linux-androideabi",
"armv7-unknown-linux-gnueabihf",
"i686-pc-windows-msvc",
];
let nativeBindings;
let wasmBindings;
let downloadWasmPromise;
let pendingBindings;
let swcTraceFlushGuard;
let swcCrashReporterFlushGuard;
const lockfilePatchPromise = {};
exports.lockfilePatchPromise = lockfilePatchPromise;
async function loadBindings() {
if (pendingBindings) {
return pendingBindings;
}
const isCustomTurbopack = await __isCustomTurbopackBinary();
pendingBindings = new Promise(async (resolve, reject)=>{
if (!lockfilePatchPromise.cur) {
// always run lockfile check once so that it gets patched
// even if it doesn't fail to load locally
lockfilePatchPromise.cur = (0, _patchIncorrectLockfile).patchIncorrectLockfile(process.cwd()).catch(console.error);
}
let attempts = [];
const shouldLoadWasmFallbackFirst = triples.some((triple)=>{
return !!(triple == null ? void 0 : triple.raw) && knownDefaultWasmFallbackTriples.includes(triple.raw);
});
if (shouldLoadWasmFallbackFirst) {
const fallbackBindings = await tryLoadWasmWithFallback(attempts);
if (fallbackBindings) {
return resolve(fallbackBindings);
}
}
try {
return resolve(loadNative(isCustomTurbopack));
} catch (a) {
attempts = attempts.concat(a);
}
// For these platforms we already tried to load wasm and failed, skip reattempt
if (!shouldLoadWasmFallbackFirst) {
const fallbackBindings = await tryLoadWasmWithFallback(attempts);
if (fallbackBindings) {
return resolve(fallbackBindings);
}
}
logLoadFailure(attempts, true);
});
return pendingBindings;
}
async function tryLoadWasmWithFallback(attempts) {
try {
let bindings = await loadWasm();
(0, _swcLoadFailure).eventSwcLoadFailure({
wasm: "enabled"
});
return bindings;
} catch (a) {
attempts = attempts.concat(a);
}
try {
// if not installed already download wasm package on-demand
// we download to a custom directory instead of to node_modules
// as node_module import attempts are cached and can't be re-attempted
// x-ref: https://github.com/nodejs/modules/issues/307
const wasmDirectory = _path.default.join(_path.default.dirname(require.resolve("next/package.json")), "wasm");
if (!downloadWasmPromise) {
downloadWasmPromise = (0, _downloadWasmSwc).downloadWasmSwc(_packageJson.version, wasmDirectory);
}
await downloadWasmPromise;
let bindings = await loadWasm((0, _url).pathToFileURL(wasmDirectory).href);
(0, _swcLoadFailure).eventSwcLoadFailure({
wasm: "fallback"
});
// still log native load attempts so user is
// aware it failed and should be fixed
for (const attempt of attempts){
Log.warn(attempt);
}
return bindings;
} catch (a1) {
attempts = attempts.concat(a1);
}
}
function loadBindingsSync() {
let attempts = [];
try {
return loadNative();
} catch (a) {
attempts = attempts.concat(a);
}
// we can leverage the wasm bindings if they are already
// loaded
if (wasmBindings) {
return wasmBindings;
}
logLoadFailure(attempts);
}
let loggingLoadFailure = false;
function logLoadFailure(attempts, triedWasm = false) {
// make sure we only emit the event and log the failure once
if (loggingLoadFailure) return;
loggingLoadFailure = true;
for (let attempt of attempts){
Log.warn(attempt);
}
(0, _swcLoadFailure).eventSwcLoadFailure({
wasm: triedWasm ? "failed" : undefined
}).then(()=>lockfilePatchPromise.cur || Promise.resolve()).finally(()=>{
Log.error(`Failed to load SWC binary for ${PlatformName}/${ArchName}, see more info here: https://nextjs.org/docs/messages/failed-loading-swc`);
process.exit(1);
});
}
async function loadWasm(importPath = "") {
if (wasmBindings) {
return wasmBindings;
}
let attempts = [];
for (let pkg of [
"@next/swc-wasm-nodejs",
"@next/swc-wasm-web"
]){
try {
let pkgPath = pkg;
if (importPath) {
// the import path must be exact when not in node_modules
pkgPath = _path.default.join(importPath, pkg, "wasm.js");
}
let bindings = await import(pkgPath);
if (pkg === "@next/swc-wasm-web") {
bindings = await bindings.default();
}
Log.info("Using wasm build of next-swc");
// Note wasm binary does not support async intefaces yet, all async
// interface coereces to sync interfaces.
wasmBindings = {
isWasm: true,
transform (src, options) {
// TODO: we can remove fallback to sync interface once new stable version of next-swc gets published (current v12.2)
return (bindings == null ? void 0 : bindings.transform) ? bindings.transform(src.toString(), options) : Promise.resolve(bindings.transformSync(src.toString(), options));
},
transformSync (src, options) {
return bindings.transformSync(src.toString(), options);
},
minify (src, options) {
return (bindings == null ? void 0 : bindings.minify) ? bindings.minify(src.toString(), options) : Promise.resolve(bindings.minifySync(src.toString(), options));
},
minifySync (src, options) {
return bindings.minifySync(src.toString(), options);
},
parse (src, options) {
return (bindings == null ? void 0 : bindings.parse) ? bindings.parse(src.toString(), options) : Promise.resolve(bindings.parseSync(src.toString(), options));
},
parseSync (src, options) {
const astStr = bindings.parseSync(src.toString(), options);
return astStr;
},
getTargetTriple () {
return undefined;
},
turbo: {
startDev: ()=>{
Log.error("Wasm binding does not support --turbo yet");
},
startTrace: ()=>{
Log.error("Wasm binding does not support trace yet");
}
},
mdx: {
compile: (src, options)=>bindings.mdxCompile(src, options),
compileSync: (src, options)=>bindings.mdxCompileSync(src, options)
}
};
return wasmBindings;
} catch (e) {
// Only log attempts for loading wasm when loading as fallback
if (importPath) {
if ((e == null ? void 0 : e.code) === "ERR_MODULE_NOT_FOUND") {
attempts.push(`Attempted to load ${pkg}, but it was not installed`);
} else {
attempts.push(`Attempted to load ${pkg}, but an error occurred: ${e.message ?? e}`);
}
}
}
}
throw attempts;
}
function loadNative(isCustomTurbopack = false) {
if (nativeBindings) {
return nativeBindings;
}
let bindings;
let attempts = [];
for (const triple of triples){
try {
bindings = require(`@next/swc/native/next-swc.${triple.platformArchABI}.node`);
Log.info("Using locally built binary of @next/swc");
break;
} catch (e) {}
}
if (!bindings) {
for (const triple of triples){
let pkg = `@next/swc-${triple.platformArchABI}`;
try {
bindings = require(pkg);
break;
} catch (e) {
if ((e == null ? void 0 : e.code) === "MODULE_NOT_FOUND") {
attempts.push(`Attempted to load ${pkg}, but it was not installed`);
} else {
attempts.push(`Attempted to load ${pkg}, but an error occurred: ${e.message ?? e}`);
}
}
}
}
if (bindings) {
// Initialize crash reporter, as earliest as possible from any point of import.
// The first-time import to next-swc is not predicatble in the import tree of next.js, which makes
// we can't rely on explicit manual initialization as similar to trace reporter.
if (!swcCrashReporterFlushGuard) {
// Crash reports in next-swc should be treated in the same way we treat telemetry to opt out.
/* TODO: temporarily disable initialization while confirming logistics.
let telemetry = new Telemetry({ distDir: process.cwd() })
if (telemetry.isEnabled) {
swcCrashReporterFlushGuard = bindings.initCrashReporter?.()
}*/ }
nativeBindings = {
isWasm: false,
transform (src, options) {
var ref;
const isModule = typeof src !== undefined && typeof src !== "string" && !Buffer.isBuffer(src);
options = options || {};
if (options == null ? void 0 : (ref = options.jsc) == null ? void 0 : ref.parser) {
options.jsc.parser.syntax = options.jsc.parser.syntax ?? "ecmascript";
}
return bindings.transform(isModule ? JSON.stringify(src) : src, isModule, toBuffer(options));
},
transformSync (src, options) {
var ref;
if (typeof src === undefined) {
throw new Error("transformSync doesn't implement reading the file from filesystem");
} else if (Buffer.isBuffer(src)) {
throw new Error("transformSync doesn't implement taking the source code as Buffer");
}
const isModule = typeof src !== "string";
options = options || {};
if (options == null ? void 0 : (ref = options.jsc) == null ? void 0 : ref.parser) {
options.jsc.parser.syntax = options.jsc.parser.syntax ?? "ecmascript";
}
return bindings.transformSync(isModule ? JSON.stringify(src) : src, isModule, toBuffer(options));
},
minify (src, options) {
return bindings.minify(toBuffer(src), toBuffer(options ?? {}));
},
minifySync (src, options) {
return bindings.minifySync(toBuffer(src), toBuffer(options ?? {}));
},
parse (src, options) {
return bindings.parse(src, toBuffer(options ?? {}));
},
getTargetTriple: bindings.getTargetTriple,
initCustomTraceSubscriber: bindings.initCustomTraceSubscriber,
teardownTraceSubscriber: bindings.teardownTraceSubscriber,
teardownCrashReporter: bindings.teardownCrashReporter,
turbo: {
startDev: (options)=>{
const devOptions = {
...options,
noOpen: options.noOpen ?? true
};
if (!isCustomTurbopack) {
bindings.startTurboDev(toBuffer(devOptions));
} else if (!!__INTERNAL_CUSTOM_TURBOPACK_BINARY) {
console.warn(`Loading custom turbopack binary from ${__INTERNAL_CUSTOM_TURBOPACK_BINARY}`);
return new Promise((resolve, reject)=>{
const spawn = require("next/dist/compiled/cross-spawn");
const args = [];
Object.entries(devOptions).forEach(([key, value])=>{
let cli_key = `--${key.replace(/[A-Z]/g, (m)=>"-" + m.toLowerCase())}`;
if (key === "dir") {
args.push(value);
} else if (typeof value === "boolean" && value === true) {
args.push(cli_key);
} else if (typeof value !== "boolean" && !!value) {
args.push(cli_key, value);
}
});
console.warn(`Running turbopack with args: [${args.join(" ")}]`);
const child = spawn(__INTERNAL_CUSTOM_TURBOPACK_BINARY, args, {
stdio: "inherit",
env: {
...process.env
}
});
child.on("message", (message)=>{
console.log(message);
});
child.on("close", (code)=>{
if (code !== 0) {
reject({
command: `${__INTERNAL_CUSTOM_TURBOPACK_BINARY} ${args.join(" ")}`
});
return;
}
resolve(0);
});
});
} else if (!!__INTERNAL_CUSTOM_TURBOPACK_BINDINGS) {
console.warn(`Loading custom turbopack bindings from ${__INTERNAL_CUSTOM_TURBOPACK_BINARY}`);
console.warn(`Running turbopack with args: `, devOptions);
require(__INTERNAL_CUSTOM_TURBOPACK_BINDINGS).startDev(devOptions);
}
},
startTrace: (options = {})=>bindings.runTurboTracing(toBuffer({
exact: true,
...options
}))
},
mdx: {
compile: (src, options)=>bindings.mdxCompile(src, toBuffer(options ?? {})),
compileSync: (src, options)=>bindings.mdxCompileSync(src, toBuffer(options ?? {}))
}
};
return nativeBindings;
}
throw attempts;
}
function toBuffer(t) {
return Buffer.from(JSON.stringify(t));
}
async function isWasm() {
let bindings = await loadBindings();
return bindings.isWasm;
}
async function transform(src, options) {
let bindings = await loadBindings();
return bindings.transform(src, options);
}
function transformSync(src, options) {
let bindings = loadBindingsSync();
return bindings.transformSync(src, options);
}
async function minify(src, options) {
let bindings = await loadBindings();
return bindings.minify(src, options);
}
function minifySync(src, options) {
let bindings = loadBindingsSync();
return bindings.minifySync(src, options);
}
async function parse(src, options) {
let bindings = await loadBindings();
let parserOptions = (0, _options).getParserOptions(options);
return bindings.parse(src, parserOptions).then((astStr)=>JSON.parse(astStr));
}
function getBinaryMetadata() {
let bindings;
try {
bindings = loadNative();
} catch (e) {
// Suppress exceptions, this fn allows to fail to load native bindings
}
return {
target: bindings == null ? void 0 : bindings.getTargetTriple == null ? void 0 : bindings.getTargetTriple()
};
}
const initCustomTraceSubscriber = (()=>{
return (filename)=>{
if (!swcTraceFlushGuard) {
// Wasm binary doesn't support trace emission
let bindings = loadNative();
swcTraceFlushGuard = bindings.initCustomTraceSubscriber(filename);
}
};
})();
exports.initCustomTraceSubscriber = initCustomTraceSubscriber;
const teardownTraceSubscriber = (()=>{
let flushed = false;
return ()=>{
if (!flushed) {
flushed = true;
try {
let bindings = loadNative();
if (swcTraceFlushGuard) {
bindings.teardownTraceSubscriber(swcTraceFlushGuard);
}
} catch (e) {
// Suppress exceptions, this fn allows to fail to load native bindings
}
}
};
})();
exports.teardownTraceSubscriber = teardownTraceSubscriber;
const teardownCrashReporter = (()=>{
let flushed = false;
return ()=>{
if (!flushed) {
flushed = true;
try {
let bindings = loadNative();
if (swcCrashReporterFlushGuard) {
bindings.teardownCrashReporter(swcCrashReporterFlushGuard);
}
} catch (e) {
// Suppress exceptions, this fn allows to fail to load native bindings
}
}
};
})();
exports.teardownCrashReporter = teardownCrashReporter;
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,43 @@
"use strict";
var _vm = _interopRequireDefault(require("vm"));
var _index = require("./index");
var _options = require("./options");
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
// Jest use the `vm` [Module API](https://nodejs.org/api/vm.html#vm_class_vm_module) for ESM.
// see https://github.com/facebook/jest/issues/9430
const isSupportEsm = "Module" in _vm.default;
module.exports = {
createTransformer: (inputOptions)=>({
process (src, filename, jestOptions) {
const jestConfig = getJestConfig(jestOptions);
let swcTransformOpts = (0, _options).getJestSWCOptions({
// When target is node it's similar to the server option set in SWC.
isServer: jestConfig.testEnvironment && jestConfig.testEnvironment === "node",
filename,
nextConfig: inputOptions.nextConfig,
jsConfig: inputOptions.jsConfig,
resolvedBaseUrl: inputOptions.resolvedBaseUrl,
pagesDir: inputOptions.pagesDir,
hasServerComponents: inputOptions.hasServerComponents,
esm: isSupportEsm && isEsm(Boolean(inputOptions.isEsmProject), filename, jestConfig)
});
return (0, _index).transformSync(src, {
...swcTransformOpts,
filename
});
}
})
};
function getJestConfig(jestConfig) {
return "config" in jestConfig ? jestConfig.config : jestConfig;
}
function isEsm(isEsmProject, filename, jestConfig) {
var ref;
return /\.jsx?$/.test(filename) && isEsmProject || ((ref = jestConfig.extensionsToTreatAsEsm) == null ? void 0 : ref.find((ext)=>filename.endsWith(ext)));
}
//# sourceMappingURL=jest-transformer.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../build/swc/jest-transformer.js"],"names":["isSupportEsm","vm","module","exports","createTransformer","inputOptions","process","src","filename","jestOptions","jestConfig","getJestConfig","swcTransformOpts","getJestSWCOptions","isServer","testEnvironment","nextConfig","jsConfig","resolvedBaseUrl","pagesDir","hasServerComponents","esm","isEsm","Boolean","isEsmProject","transformSync","config","test","extensionsToTreatAsEsm","find","ext","endsWith"],"mappings":"AA4BA;AAAe,IAAA,GAAI,kCAAJ,IAAI,EAAA;AACW,IAAA,MAAS,WAAT,SAAS,CAAA;AACL,IAAA,QAAW,WAAX,WAAW,CAAA;;;;;;AAE7C,6FAA6F;AAC7F,mDAAmD;AACnD,MAAMA,YAAY,GAAG,QAAQ,IAAIC,GAAE,QAAA;AAEnCC,MAAM,CAACC,OAAO,GAAG;IACfC,iBAAiB,EAAE,CAACC,YAAY,GAAK,CAAC;YACpCC,OAAO,EAACC,GAAG,EAAEC,QAAQ,EAAEC,WAAW,EAAE;gBAClC,MAAMC,UAAU,GAAGC,aAAa,CAACF,WAAW,CAAC;gBAE7C,IAAIG,gBAAgB,GAAGC,CAAAA,GAAAA,QAAiB,AAatC,CAAA,kBAbsC,CAAC;oBACvC,oEAAoE;oBACpEC,QAAQ,EACNJ,UAAU,CAACK,eAAe,IAAIL,UAAU,CAACK,eAAe,KAAK,MAAM;oBACrEP,QAAQ;oBACRQ,UAAU,EAAEX,YAAY,CAACW,UAAU;oBACnCC,QAAQ,EAAEZ,YAAY,CAACY,QAAQ;oBAC/BC,eAAe,EAAEb,YAAY,CAACa,eAAe;oBAC7CC,QAAQ,EAAEd,YAAY,CAACc,QAAQ;oBAC/BC,mBAAmB,EAAEf,YAAY,CAACe,mBAAmB;oBACrDC,GAAG,EACDrB,YAAY,IACZsB,KAAK,CAACC,OAAO,CAAClB,YAAY,CAACmB,YAAY,CAAC,EAAEhB,QAAQ,EAAEE,UAAU,CAAC;iBAClE,CAAC;gBAEF,OAAOe,CAAAA,GAAAA,MAAa,AAAwC,CAAA,cAAxC,CAAClB,GAAG,EAAE;oBAAE,GAAGK,gBAAgB;oBAAEJ,QAAQ;iBAAE,CAAC,CAAA;aAC7D;SACF,CAAC;CACH;AAED,SAASG,aAAa,CAACD,UAAU,EAAE;IACjC,OAAO,QAAQ,IAAIA,UAAU,GAEzBA,UAAU,CAACgB,MAAM,GAEjBhB,UAAU,CAAA;CACf;AAED,SAASY,KAAK,CAACE,YAAY,EAAEhB,QAAQ,EAAEE,UAAU,EAAE;QAG/CA,GAAiC;IAFnC,OACE,AAAC,UAAUiB,IAAI,CAACnB,QAAQ,CAAC,IAAIgB,YAAY,KACzCd,CAAAA,GAAiC,GAAjCA,UAAU,CAACkB,sBAAsB,SAAM,GAAvClB,KAAAA,CAAuC,GAAvCA,GAAiC,CAAEmB,IAAI,CAAC,CAACC,GAAG,GAAKtB,QAAQ,CAACuB,QAAQ,CAACD,GAAG,CAAC,CAAC,CAAA,CACzE;CACF"}

View File

@@ -0,0 +1,7 @@
export function getParserOptions(options: {
filename: string
jsConfig?: any
[key: string]: any
}): any
export function getJestSWCOptions(...args: any[]): any
export function getLoaderSWCOptions(...args: any[]): any

236
kitabcitab/node_modules/next/dist/build/swc/options.js generated vendored Normal file
View File

@@ -0,0 +1,236 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getParserOptions = getParserOptions;
exports.getJestSWCOptions = getJestSWCOptions;
exports.getLoaderSWCOptions = getLoaderSWCOptions;
const nextDistPath = /(next[\\/]dist[\\/]shared[\\/]lib)|(next[\\/]dist[\\/]client)|(next[\\/]dist[\\/]pages)/;
const regeneratorRuntimePath = require.resolve("next/dist/compiled/regenerator-runtime");
function getParserOptions({ filename , jsConfig , ...rest }) {
var ref;
const isTSFile = filename.endsWith(".ts");
const isTypeScript = isTSFile || filename.endsWith(".tsx");
const enableDecorators = Boolean(jsConfig == null ? void 0 : (ref = jsConfig.compilerOptions) == null ? void 0 : ref.experimentalDecorators);
return {
...rest,
syntax: isTypeScript ? "typescript" : "ecmascript",
dynamicImport: true,
decorators: enableDecorators,
// Exclude regular TypeScript files from React transformation to prevent e.g. generic parameters and angle-bracket type assertion from being interpreted as JSX tags.
[isTypeScript ? "tsx" : "jsx"]: !isTSFile,
importAssertions: true
};
}
function getBaseSWCOptions({ filename , jest , development , hasReactRefresh , globalWindow , nextConfig , resolvedBaseUrl , jsConfig , swcCacheDir , isServerLayer , hasServerComponents , }) {
var ref, ref1, ref2, ref3, ref4, ref5, ref6, ref7, ref8, ref9;
const parserConfig = getParserOptions({
filename,
jsConfig
});
const paths = jsConfig == null ? void 0 : (ref = jsConfig.compilerOptions) == null ? void 0 : ref.paths;
const enableDecorators = Boolean(jsConfig == null ? void 0 : (ref1 = jsConfig.compilerOptions) == null ? void 0 : ref1.experimentalDecorators);
const emitDecoratorMetadata = Boolean(jsConfig == null ? void 0 : (ref2 = jsConfig.compilerOptions) == null ? void 0 : ref2.emitDecoratorMetadata);
const useDefineForClassFields = Boolean(jsConfig == null ? void 0 : (ref3 = jsConfig.compilerOptions) == null ? void 0 : ref3.useDefineForClassFields);
const plugins = ((nextConfig == null ? void 0 : (ref4 = nextConfig.experimental) == null ? void 0 : ref4.swcPlugins) ?? []).filter(Array.isArray).map(([name, options])=>[
require.resolve(name),
options
]);
return {
jsc: {
...resolvedBaseUrl && paths ? {
baseUrl: resolvedBaseUrl,
paths
} : {},
externalHelpers: !process.versions.pnp && !jest,
parser: parserConfig,
experimental: {
keepImportAssertions: true,
plugins,
cacheRoot: swcCacheDir
},
transform: {
// Enables https://github.com/swc-project/swc/blob/0359deb4841be743d73db4536d4a22ac797d7f65/crates/swc_ecma_ext_transforms/src/jest.rs
...jest ? {
hidden: {
jest: true
}
} : {},
legacyDecorator: enableDecorators,
decoratorMetadata: emitDecoratorMetadata,
useDefineForClassFields: useDefineForClassFields,
react: {
importSource: (jsConfig == null ? void 0 : (ref5 = jsConfig.compilerOptions) == null ? void 0 : ref5.jsxImportSource) ?? ((nextConfig == null ? void 0 : (ref6 = nextConfig.compiler) == null ? void 0 : ref6.emotion) ? "@emotion/react" : "react"),
runtime: "automatic",
pragma: "React.createElement",
pragmaFrag: "React.Fragment",
throwIfNamespace: true,
development: !!development,
useBuiltins: true,
refresh: !!hasReactRefresh
},
optimizer: {
simplify: false,
globals: jest ? null : {
typeofs: {
window: globalWindow ? "object" : "undefined"
},
envs: {
NODE_ENV: development ? '"development"' : '"production"'
}
}
},
regenerator: {
importPath: regeneratorRuntimePath
}
}
},
sourceMaps: jest ? "inline" : undefined,
removeConsole: nextConfig == null ? void 0 : (ref7 = nextConfig.compiler) == null ? void 0 : ref7.removeConsole,
// disable "reactRemoveProperties" when "jest" is true
// otherwise the setting from next.config.js will be used
reactRemoveProperties: jest ? false : nextConfig == null ? void 0 : (ref8 = nextConfig.compiler) == null ? void 0 : ref8.reactRemoveProperties,
modularizeImports: nextConfig == null ? void 0 : nextConfig.modularizeImports,
relay: nextConfig == null ? void 0 : (ref9 = nextConfig.compiler) == null ? void 0 : ref9.relay,
// Always transform styled-jsx and error when `client-only` condition is triggered
styledJsx: true,
// Disable css-in-js libs (without client-only integration) transform on server layer for server components
...!isServerLayer && {
emotion: getEmotionOptions(nextConfig, development),
styledComponents: getStyledComponentsOptions(nextConfig, development)
},
serverComponents: hasServerComponents ? {
isServer: !!isServerLayer
} : undefined
};
}
function getStyledComponentsOptions(nextConfig, development) {
var ref;
let styledComponentsOptions = nextConfig == null ? void 0 : (ref = nextConfig.compiler) == null ? void 0 : ref.styledComponents;
if (!styledComponentsOptions) {
return null;
}
return {
...styledComponentsOptions,
displayName: styledComponentsOptions.displayName ?? Boolean(development)
};
}
function getEmotionOptions(nextConfig, development) {
var ref, ref10, ref11, ref12, ref13, ref14, ref15, ref16, ref17;
if (!(nextConfig == null ? void 0 : (ref = nextConfig.compiler) == null ? void 0 : ref.emotion)) {
return null;
}
let autoLabel = false;
switch(nextConfig == null ? void 0 : (ref10 = nextConfig.compiler) == null ? void 0 : (ref11 = ref10.emotion) == null ? void 0 : ref11.autoLabel){
case "never":
autoLabel = false;
break;
case "always":
autoLabel = true;
break;
case "dev-only":
default:
autoLabel = !!development;
break;
}
return {
enabled: true,
autoLabel,
importMap: nextConfig == null ? void 0 : (ref12 = nextConfig.compiler) == null ? void 0 : (ref13 = ref12.emotion) == null ? void 0 : ref13.importMap,
labelFormat: nextConfig == null ? void 0 : (ref14 = nextConfig.compiler) == null ? void 0 : (ref15 = ref14.emotion) == null ? void 0 : ref15.labelFormat,
sourcemap: development ? (nextConfig == null ? void 0 : (ref16 = nextConfig.compiler) == null ? void 0 : (ref17 = ref16.emotion) == null ? void 0 : ref17.sourceMap) ?? true : false
};
}
function getJestSWCOptions({ isServer , filename , esm , nextConfig , jsConfig , pagesDir , hasServerComponents , }) {
let baseOptions = getBaseSWCOptions({
filename,
jest: true,
development: false,
hasReactRefresh: false,
globalWindow: !isServer,
nextConfig,
jsConfig,
hasServerComponents
});
const isNextDist = nextDistPath.test(filename);
return {
...baseOptions,
env: {
targets: {
// Targets the current version of Node.js
node: process.versions.node
}
},
module: {
type: esm && !isNextDist ? "es6" : "commonjs"
},
disableNextSsg: true,
disablePageConfig: true,
pagesDir
};
}
function getLoaderSWCOptions({ filename , development , isServer , isServerLayer , pagesDir , isPageFile , hasReactRefresh , nextConfig , jsConfig , supportedBrowsers , swcCacheDir , relativeFilePathFromRoot , hasServerComponents , }) {
var ref;
let baseOptions = getBaseSWCOptions({
filename,
development,
globalWindow: !isServer,
hasReactRefresh,
nextConfig,
jsConfig,
// resolvedBaseUrl,
swcCacheDir,
isServerLayer,
relativeFilePathFromRoot,
hasServerComponents
});
if ((nextConfig == null ? void 0 : (ref = nextConfig.experimental) == null ? void 0 : ref.fontLoaders) && relativeFilePathFromRoot) {
baseOptions.fontLoaders = {
fontLoaders: nextConfig.experimental.fontLoaders.map(({ loader })=>loader),
relativeFilePathFromRoot
};
}
const isNextDist = nextDistPath.test(filename);
if (isServer) {
return {
...baseOptions,
// Disables getStaticProps/getServerSideProps tree shaking on the server compilation for pages
disableNextSsg: true,
disablePageConfig: true,
isDevelopment: development,
isServer,
pagesDir,
isPageFile,
env: {
targets: {
// Targets the current version of Node.js
node: process.versions.node
}
}
};
} else {
// Matches default @babel/preset-env behavior
baseOptions.jsc.target = "es5";
return {
...baseOptions,
// Ensure Next.js internals are output as commonjs modules
...isNextDist ? {
module: {
type: "commonjs"
}
} : {},
disableNextSsg: !isPageFile,
isDevelopment: development,
isServer,
pagesDir,
isPageFile,
...supportedBrowsers && supportedBrowsers.length > 0 ? {
env: {
targets: supportedBrowsers
}
} : {}
};
}
}
//# sourceMappingURL=options.js.map

File diff suppressed because one or more lines are too long