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

View File

@@ -0,0 +1,4 @@
/// <reference types="lodash" />
import { webpack } from 'next/dist/compiled/webpack/webpack';
import { ConfigurationContext } from '../utils';
export declare const base: import("lodash").CurriedFunction2<ConfigurationContext, webpack.Configuration, webpack.Configuration>;

View File

@@ -0,0 +1,54 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.base = void 0;
var _lodashCurry = _interopRequireDefault(require("next/dist/compiled/lodash.curry"));
var _constants = require("../../../../shared/lib/constants");
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
const base = (0, _lodashCurry).default(function base(ctx, config) {
config.mode = ctx.isDevelopment ? "development" : "production";
config.name = ctx.isServer ? ctx.isEdgeRuntime ? _constants.COMPILER_NAMES.edgeServer : _constants.COMPILER_NAMES.server : _constants.COMPILER_NAMES.client;
// @ts-ignore TODO webpack 5 typings
config.target = !ctx.targetWeb ? "node12.22" : ctx.isEdgeRuntime ? [
"web",
"es6"
] : [
"web",
"es5"
];
// https://webpack.js.org/configuration/devtool/#development
if (ctx.isDevelopment) {
if (process.env.__NEXT_TEST_MODE && !process.env.__NEXT_TEST_WITH_DEVTOOL) {
config.devtool = false;
} else {
// `eval-source-map` provides full-fidelity source maps for the
// original source, including columns and original variable names.
// This is desirable so the in-browser debugger can correctly pause
// and show scoped variables with their original names.
config.devtool = "eval-source-map";
}
} else {
if (ctx.isEdgeRuntime || // Enable browser sourcemaps:
(ctx.productionBrowserSourceMaps && ctx.isClient)) {
config.devtool = "source-map";
} else {
config.devtool = false;
}
}
if (!config.module) {
config.module = {
rules: []
};
}
// TODO: add codemod for "Should not import the named export" with JSON files
// config.module.strictExportPresence = !isWebpack5
return config;
});
exports.base = base;
//# sourceMappingURL=base.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../build/webpack/config/blocks/base.ts"],"names":["base","curry","ctx","config","mode","isDevelopment","name","isServer","isEdgeRuntime","COMPILER_NAMES","edgeServer","server","client","target","targetWeb","process","env","__NEXT_TEST_MODE","__NEXT_TEST_WITH_DEVTOOL","devtool","productionBrowserSourceMaps","isClient","module","rules"],"mappings":"AAAA;;;;;AAAkB,IAAA,YAAiC,kCAAjC,iCAAiC,EAAA;AAEpB,IAAA,UAAkC,WAAlC,kCAAkC,CAAA;;;;;;AAG1D,MAAMA,IAAI,GAAGC,CAAAA,GAAAA,YAAK,AAiDvB,CAAA,QAjDuB,CAAC,SAASD,IAAI,CACrCE,GAAyB,EACzBC,MAA6B,EAC7B;IACAA,MAAM,CAACC,IAAI,GAAGF,GAAG,CAACG,aAAa,GAAG,aAAa,GAAG,YAAY;IAC9DF,MAAM,CAACG,IAAI,GAAGJ,GAAG,CAACK,QAAQ,GACtBL,GAAG,CAACM,aAAa,GACfC,UAAc,eAAA,CAACC,UAAU,GACzBD,UAAc,eAAA,CAACE,MAAM,GACvBF,UAAc,eAAA,CAACG,MAAM;IAEzB,oCAAoC;IACpCT,MAAM,CAACU,MAAM,GAAG,CAACX,GAAG,CAACY,SAAS,GAC1B,WAAW,GACXZ,GAAG,CAACM,aAAa,GACjB;QAAC,KAAK;QAAE,KAAK;KAAC,GACd;QAAC,KAAK;QAAE,KAAK;KAAC;IAElB,4DAA4D;IAC5D,IAAIN,GAAG,CAACG,aAAa,EAAE;QACrB,IAAIU,OAAO,CAACC,GAAG,CAACC,gBAAgB,IAAI,CAACF,OAAO,CAACC,GAAG,CAACE,wBAAwB,EAAE;YACzEf,MAAM,CAACgB,OAAO,GAAG,KAAK;SACvB,MAAM;YACL,+DAA+D;YAC/D,kEAAkE;YAClE,mEAAmE;YACnE,uDAAuD;YACvDhB,MAAM,CAACgB,OAAO,GAAG,iBAAiB;SACnC;KACF,MAAM;QACL,IACEjB,GAAG,CAACM,aAAa,IACjB,6BAA6B;QAC7B,CAACN,GAAG,CAACkB,2BAA2B,IAAIlB,GAAG,CAACmB,QAAQ,CAAC,EACjD;YACAlB,MAAM,CAACgB,OAAO,GAAG,YAAY;SAC9B,MAAM;YACLhB,MAAM,CAACgB,OAAO,GAAG,KAAK;SACvB;KACF;IAED,IAAI,CAAChB,MAAM,CAACmB,MAAM,EAAE;QAClBnB,MAAM,CAACmB,MAAM,GAAG;YAAEC,KAAK,EAAE,EAAE;SAAE;KAC9B;IAED,6EAA6E;IAC7E,mDAAmD;IAEnD,OAAOpB,MAAM,CAAA;CACd,CAAC;QAjDWH,IAAI,GAAJA,IAAI"}

View File

@@ -0,0 +1,6 @@
/// <reference types="lodash" />
import { webpack } from 'next/dist/compiled/webpack/webpack';
import { ConfigurationContext } from '../../utils';
export declare const regexLikeCss: RegExp;
export declare function lazyPostCSS(rootDirectory: string, supportedBrowsers: string[] | undefined, disablePostcssPresetEnv: boolean | undefined): Promise<any>;
export declare const css: import("lodash").CurriedFunction2<ConfigurationContext, webpack.Configuration, Promise<webpack.Configuration>>;

View File

@@ -0,0 +1,486 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.lazyPostCSS = lazyPostCSS;
exports.css = exports.regexLikeCss = void 0;
var _path = _interopRequireDefault(require("path"));
var _lodashCurry = _interopRequireDefault(require("next/dist/compiled/lodash.curry"));
var _helpers = require("../../helpers");
var _utils = require("../../utils");
var _loaders = require("./loaders");
var _nextFont = require("./loaders/next-font");
var _messages = require("./messages");
var _plugins = require("./plugins");
var _nonNullable = require("../../../../../lib/non-nullable");
var _constants = require("../../../../../lib/constants");
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
const regexLikeCss = /\.(css|scss|sass)$/;
exports.regexLikeCss = regexLikeCss;
// RegExps for Style Sheets
const regexCssGlobal = /(?<!\.module)\.css$/;
const regexCssModules = /\.module\.css$/;
// RegExps for Syntactically Awesome Style Sheets
const regexSassGlobal = /(?<!\.module)\.(scss|sass)$/;
const regexSassModules = /\.module\.(scss|sass)$/;
/**
* Mark a rule as removable if built-in CSS support is disabled
*/ function markRemovable(r) {
Object.defineProperty(r, Symbol.for("__next_css_remove"), {
enumerable: false,
value: true
});
return r;
}
let postcssInstancePromise;
async function lazyPostCSS(rootDirectory, supportedBrowsers, disablePostcssPresetEnv) {
if (!postcssInstancePromise) {
postcssInstancePromise = (async ()=>{
const postcss = require("postcss");
// @ts-ignore backwards compat
postcss.plugin = function postcssPlugin(name, initializer) {
function creator(...args) {
let transformer = initializer(...args);
transformer.postcssPlugin = name;
// transformer.postcssVersion = new Processor().version
return transformer;
}
let cache;
Object.defineProperty(creator, "postcss", {
get () {
if (!cache) cache = creator();
return cache;
}
});
creator.process = function(css1, processOpts, pluginOpts) {
return postcss([
creator(pluginOpts)
]).process(css1, processOpts);
};
return creator;
};
// @ts-ignore backwards compat
postcss.vendor = {
/**
* Returns the vendor prefix extracted from an input string.
*
* @example
* postcss.vendor.prefix('-moz-tab-size') //=> '-moz-'
* postcss.vendor.prefix('tab-size') //=> ''
*/ prefix: function prefix(prop) {
const match = prop.match(/^(-\w+-)/);
if (match) {
return match[0];
}
return "";
},
/**
* Returns the input string stripped of its vendor prefix.
*
* @example
* postcss.vendor.unprefixed('-moz-tab-size') //=> 'tab-size'
*/ unprefixed: function unprefixed(/**
* String with or without vendor prefix.
*/ prop) {
return prop.replace(/^-\w+-/, "");
}
};
const postCssPlugins = await (0, _plugins).getPostCssPlugins(rootDirectory, supportedBrowsers, disablePostcssPresetEnv);
return {
postcss,
postcssWithPlugins: postcss(postCssPlugins)
};
})();
}
return postcssInstancePromise;
}
const css = (0, _lodashCurry).default(async function css(ctx, config) {
const { prependData: sassPrependData , additionalData: sassAdditionalData , ...sassOptions } = ctx.sassOptions;
const lazyPostCSSInitializer = ()=>lazyPostCSS(ctx.rootDirectory, ctx.supportedBrowsers, ctx.experimental.disablePostcssPresetEnv);
const sassPreprocessors = [
// First, process files with `sass-loader`: this inlines content, and
// compiles away the proprietary syntax.
{
loader: require.resolve("next/dist/compiled/sass-loader"),
options: {
// Source maps are required so that `resolve-url-loader` can locate
// files original to their source directory.
sourceMap: true,
sassOptions,
additionalData: sassPrependData || sassAdditionalData
}
},
// Then, `sass-loader` will have passed-through CSS imports as-is instead
// of inlining them. Because they were inlined, the paths are no longer
// correct.
// To fix this, we use `resolve-url-loader` to rewrite the CSS
// imports to real file paths.
{
loader: require.resolve("../../../loaders/resolve-url-loader/index"),
options: {
postcss: lazyPostCSSInitializer,
// Source maps are not required here, but we may as well emit
// them.
sourceMap: true
}
},
];
const fns = [];
// Resolve the configured font loaders, the resolved files are noop files that next-font-loader will match
let fontLoaders = ctx.experimental.fontLoaders ? ctx.experimental.fontLoaders.map(({ loader: fontLoader , options })=>[
_path.default.join(require.resolve(fontLoader), "../target.css"),
options,
]) : undefined;
fontLoaders == null ? void 0 : fontLoaders.forEach(([fontLoaderPath, fontLoaderOptions])=>{
// Matches the resolved font loaders noop files to run next-font-loader
fns.push((0, _helpers).loader({
oneOf: [
markRemovable({
sideEffects: false,
test: fontLoaderPath,
use: (0, _nextFont).getNextFontLoader(ctx, lazyPostCSSInitializer, fontLoaderOptions)
}),
]
}));
});
// CSS cannot be imported in _document. This comes before everything because
// global CSS nor CSS modules work in said file.
fns.push((0, _helpers).loader({
oneOf: [
markRemovable({
test: regexLikeCss,
// Use a loose regex so we don't have to crawl the file system to
// find the real file name (if present).
issuer: /pages[\\/]_document\./,
use: {
loader: "error-loader",
options: {
reason: (0, _messages).getCustomDocumentError()
}
}
}),
]
}));
const shouldIncludeExternalCSSImports = !!ctx.experimental.craCompat || !!ctx.transpilePackages;
// CSS modules & SASS modules support. They are allowed to be imported in anywhere.
fns.push(// CSS Modules should never have side effects. This setting will
// allow unused CSS to be removed from the production build.
// We ensure this by disallowing `:global()` CSS at the top-level
// via the `pure` mode in `css-loader`.
(0, _helpers).loader({
oneOf: [
// For app dir, it has to match one of the 2 layers and then apply a
// specific loader.
ctx.hasAppDir && !ctx.isProduction ? markRemovable({
sideEffects: false,
test: regexCssModules,
issuerLayer: {
or: [
_constants.WEBPACK_LAYERS.server,
_constants.WEBPACK_LAYERS.client
]
},
use: [
require.resolve("../../../loaders/next-flight-css-dev-loader"),
...(0, _loaders).getCssModuleLoader(ctx, lazyPostCSSInitializer),
]
}) : null,
ctx.hasAppDir && !ctx.isServer ? markRemovable({
sideEffects: false,
test: regexCssModules,
use: [
require.resolve("../../../loaders/next-flight-css-dev-loader"),
...(0, _loaders).getCssModuleLoader(ctx, lazyPostCSSInitializer),
]
}) : null,
markRemovable({
sideEffects: false,
test: regexCssModules,
use: (0, _loaders).getCssModuleLoader(ctx, lazyPostCSSInitializer)
}),
].filter(_nonNullable.nonNullable)
}), // Opt-in support for Sass (using .scss or .sass extensions).
// Sass Modules should never have side effects. This setting will
// allow unused Sass to be removed from the production build.
// We ensure this by disallowing `:global()` Sass at the top-level
// via the `pure` mode in `css-loader`.
(0, _helpers).loader({
oneOf: [
// For app dir, we match both server and client layers.
ctx.hasAppDir && !ctx.isProduction ? markRemovable({
sideEffects: false,
test: regexSassModules,
issuerLayer: {
or: [
_constants.WEBPACK_LAYERS.server,
_constants.WEBPACK_LAYERS.client
]
},
use: [
require.resolve("../../../loaders/next-flight-css-dev-loader"),
...(0, _loaders).getCssModuleLoader(ctx, lazyPostCSSInitializer, sassPreprocessors),
]
}) : null,
ctx.hasAppDir && !ctx.isServer ? markRemovable({
sideEffects: false,
test: regexSassModules,
use: [
require.resolve("../../../loaders/next-flight-css-dev-loader"),
...(0, _loaders).getCssModuleLoader(ctx, lazyPostCSSInitializer, sassPreprocessors),
]
}) : null,
markRemovable({
sideEffects: false,
test: regexSassModules,
use: (0, _loaders).getCssModuleLoader(ctx, lazyPostCSSInitializer, sassPreprocessors)
}),
].filter(_nonNullable.nonNullable)
}), // Throw an error for CSS Modules used outside their supported scope
(0, _helpers).loader({
oneOf: [
markRemovable({
test: [
regexCssModules,
regexSassModules
],
use: {
loader: "error-loader",
options: {
reason: (0, _messages).getLocalModuleImportError()
}
}
}),
]
}));
// Global CSS and SASS support.
if (ctx.isServer) {
fns.push((0, _helpers).loader({
oneOf: [
ctx.hasAppDir && !ctx.isProduction ? markRemovable({
sideEffects: true,
test: [
regexCssGlobal,
regexSassGlobal
],
issuerLayer: {
or: [
_constants.WEBPACK_LAYERS.server,
_constants.WEBPACK_LAYERS.client
]
},
use: require.resolve("../../../loaders/next-flight-css-dev-loader")
}) : null,
markRemovable({
// CSS imports have side effects, even on the server side.
sideEffects: true,
test: [
regexCssGlobal,
regexSassGlobal
],
use: require.resolve("next/dist/compiled/ignore-loader")
}),
].filter(_nonNullable.nonNullable)
}));
} else {
// They are allowed to be loaded when any of the following is true:
// - hasAppDir: If the issuerLayer is RSC
// - If the CSS file is located in `node_modules`
// - If the CSS file is located in another package in a monorepo (outside of the current rootDir)
// - If the issuer is pages/_app (matched later)
const allowedExternalCSSImports = {
and: [
{
or: [
/node_modules/,
{
not: [
ctx.rootDirectory
]
},
]
},
]
};
fns.push((0, _helpers).loader({
oneOf: [
ctx.hasAppDir ? markRemovable({
sideEffects: true,
test: regexCssGlobal,
use: [
require.resolve("../../../loaders/next-flight-css-dev-loader"),
...(0, _loaders).getGlobalCssLoader(ctx, lazyPostCSSInitializer),
]
}) : null,
ctx.hasAppDir ? markRemovable({
sideEffects: true,
test: regexSassGlobal,
use: [
require.resolve("../../../loaders/next-flight-css-dev-loader"),
...(0, _loaders).getGlobalCssLoader(ctx, lazyPostCSSInitializer, sassPreprocessors),
]
}) : null,
!ctx.hasAppDir ? markRemovable({
sideEffects: true,
test: regexCssGlobal,
include: allowedExternalCSSImports,
issuer: shouldIncludeExternalCSSImports ? undefined : {
and: [
ctx.rootDirectory
],
not: [
/node_modules/
]
},
use: (0, _loaders).getGlobalCssLoader(ctx, lazyPostCSSInitializer)
}) : null,
!ctx.hasAppDir ? markRemovable({
sideEffects: true,
test: regexSassGlobal,
include: allowedExternalCSSImports,
issuer: shouldIncludeExternalCSSImports ? undefined : {
and: [
ctx.rootDirectory
],
not: [
/node_modules/
]
},
use: (0, _loaders).getGlobalCssLoader(ctx, lazyPostCSSInitializer, sassPreprocessors)
}) : null,
].filter(_nonNullable.nonNullable)
}));
if (ctx.customAppFile) {
fns.push((0, _helpers).loader({
oneOf: [
markRemovable({
sideEffects: true,
test: regexCssGlobal,
issuer: {
and: [
ctx.customAppFile
]
},
use: (0, _loaders).getGlobalCssLoader(ctx, lazyPostCSSInitializer)
}),
]
}), (0, _helpers).loader({
oneOf: [
markRemovable({
sideEffects: true,
test: regexSassGlobal,
issuer: {
and: [
ctx.customAppFile
]
},
use: (0, _loaders).getGlobalCssLoader(ctx, lazyPostCSSInitializer, sassPreprocessors)
}),
]
}));
}
}
// Throw an error for Global CSS used inside of `node_modules`
if (!shouldIncludeExternalCSSImports) {
fns.push((0, _helpers).loader({
oneOf: [
markRemovable({
test: [
regexCssGlobal,
regexSassGlobal
],
issuer: {
and: [
/node_modules/
]
},
use: {
loader: "error-loader",
options: {
reason: (0, _messages).getGlobalModuleImportError()
}
}
}),
]
}));
}
// Throw an error for Global CSS used outside of our custom <App> file
fns.push((0, _helpers).loader({
oneOf: [
markRemovable({
test: [
regexCssGlobal,
regexSassGlobal
],
issuer: ctx.hasAppDir ? {
// If it's inside the app dir, but not importing from a layout file,
// throw an error.
and: [
ctx.rootDirectory
],
not: [
/layout\.(js|mjs|jsx|ts|tsx)$/
]
} : undefined,
use: {
loader: "error-loader",
options: {
reason: (0, _messages).getGlobalImportError()
}
}
}),
]
}));
if (ctx.isClient) {
// Automatically transform references to files (i.e. url()) into URLs
// e.g. url(./logo.svg)
fns.push((0, _helpers).loader({
oneOf: [
markRemovable({
// This should only be applied to CSS files
issuer: regexLikeCss,
// Exclude extensions that webpack handles by default
exclude: [
/\.(js|mjs|jsx|ts|tsx)$/,
/\.html$/,
/\.json$/,
/\.webpack\[[^\]]+\]$/,
],
// `asset/resource` always emits a URL reference, where `asset`
// might inline the asset as a data URI
type: "asset/resource"
}),
]
}));
}
// Enable full mini-css-extract-plugin hmr for prod mode pages or app dir
if (ctx.isClient && (ctx.isProduction || ctx.hasAppDir)) {
// Extract CSS as CSS file(s) in the client-side production bundle.
const MiniCssExtractPlugin = require("../../../plugins/mini-css-extract-plugin").default;
fns.push((0, _helpers).plugin(// @ts-ignore webpack 5 compat
new MiniCssExtractPlugin({
filename: ctx.isProduction ? "static/css/[contenthash].css" : "static/css/[name].css",
chunkFilename: ctx.isProduction ? "static/css/[contenthash].css" : "static/css/[name].css",
// Next.js guarantees that CSS order "doesn't matter", due to imposed
// restrictions:
// 1. Global CSS can only be defined in a single entrypoint (_app)
// 2. CSS Modules generate scoped class names by default and cannot
// include Global CSS (:global() selector).
//
// While not a perfect guarantee (e.g. liberal use of `:global()`
// selector), this assumption is required to code-split CSS.
//
// If this warning were to trigger, it'd be unactionable by the user,
// but likely not valid -- so we disable it.
ignoreOrder: true
})));
}
const fn = (0, _utils).pipe(...fns);
return fn(config);
});
exports.css = css;
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,6 @@
import type { webpack } from 'next/dist/compiled/webpack/webpack';
export declare function getClientStyleLoader({ hasAppDir, isDevelopment, assetPrefix, }: {
hasAppDir: boolean;
isDevelopment: boolean;
assetPrefix: string;
}): webpack.RuleSetUseItem;

View File

@@ -0,0 +1,41 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getClientStyleLoader = getClientStyleLoader;
function getClientStyleLoader({ hasAppDir , isDevelopment , assetPrefix }) {
// Keep next-style-loader for development mode in `pages/`
if (isDevelopment && !hasAppDir) {
return {
loader: "next-style-loader",
options: {
insert: function(element) {
// By default, style-loader injects CSS into the bottom
// of <head>. This causes ordering problems between dev
// and prod. To fix this, we render a <noscript> tag as
// an anchor for the styles to be placed before. These
// styles will be applied _before_ <style jsx global>.
// These elements should always exist. If they do not,
// this code should fail.
var anchorElement = document.querySelector("#__next_css__DO_NOT_USE__");
var parentNode = anchorElement.parentNode// Normally <head>
;
// Each style tag should be placed right before our
// anchor. By inserting before and not after, we do not
// need to track the last inserted element.
parentNode.insertBefore(element, anchorElement);
}
}
};
}
const MiniCssExtractPlugin = require("../../../../plugins/mini-css-extract-plugin").default;
return {
loader: MiniCssExtractPlugin.loader,
options: {
publicPath: `${assetPrefix}/_next/`,
esModule: false
}
};
}
//# sourceMappingURL=client.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../../build/webpack/config/blocks/css/loaders/client.ts"],"names":["getClientStyleLoader","hasAppDir","isDevelopment","assetPrefix","loader","options","insert","element","anchorElement","document","querySelector","parentNode","insertBefore","MiniCssExtractPlugin","require","default","publicPath","esModule"],"mappings":"AAAA;;;;QAEgBA,oBAAoB,GAApBA,oBAAoB;AAA7B,SAASA,oBAAoB,CAAC,EACnCC,SAAS,CAAA,EACTC,aAAa,CAAA,EACbC,WAAW,CAAA,EAKZ,EAA0B;IACzB,0DAA0D;IAC1D,IAAID,aAAa,IAAI,CAACD,SAAS,EAAE;QAC/B,OAAO;YACLG,MAAM,EAAE,mBAAmB;YAC3BC,OAAO,EAAE;gBACPC,MAAM,EAAE,SAAUC,OAAa,EAAE;oBAC/B,uDAAuD;oBACvD,uDAAuD;oBACvD,uDAAuD;oBACvD,sDAAsD;oBACtD,sDAAsD;oBAEtD,sDAAsD;oBACtD,yBAAyB;oBACzB,IAAIC,aAAa,GAAGC,QAAQ,CAACC,aAAa,CACxC,2BAA2B,CAC5B,AAAC;oBACF,IAAIC,UAAU,GAAGH,aAAa,CAACG,UAAU,AAAC,AAAC,kBAAkB;oBAAnB;oBAE1C,mDAAmD;oBACnD,uDAAuD;oBACvD,2CAA2C;oBAC3CA,UAAU,CAACC,YAAY,CAACL,OAAO,EAAEC,aAAa,CAAC;iBAChD;aACF;SACF,CAAA;KACF;IAED,MAAMK,oBAAoB,GACxBC,OAAO,CAAC,6CAA6C,CAAC,CAACC,OAAO;IAChE,OAAO;QACLX,MAAM,EAAES,oBAAoB,CAACT,MAAM;QACnCC,OAAO,EAAE;YACPW,UAAU,EAAE,CAAC,EAAEb,WAAW,CAAC,OAAO,CAAC;YACnCc,QAAQ,EAAE,KAAK;SAChB;KACF,CAAA;CACF"}

View File

@@ -0,0 +1 @@
export declare function cssFileResolve(url: string, _resourcePath: string, urlImports: any): boolean;

View File

@@ -0,0 +1,16 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.cssFileResolve = cssFileResolve;
function cssFileResolve(url, _resourcePath, urlImports) {
if (url.startsWith("/")) {
return false;
}
if (!urlImports && /^[a-z][a-z0-9+.-]*:/i.test(url)) {
return false;
}
return true;
}
//# sourceMappingURL=file-resolve.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../../build/webpack/config/blocks/css/loaders/file-resolve.ts"],"names":["cssFileResolve","url","_resourcePath","urlImports","startsWith","test"],"mappings":"AAAA;;;;QAAgBA,cAAc,GAAdA,cAAc;AAAvB,SAASA,cAAc,CAC5BC,GAAW,EACXC,aAAqB,EACrBC,UAAe,EACf;IACA,IAAIF,GAAG,CAACG,UAAU,CAAC,GAAG,CAAC,EAAE;QACvB,OAAO,KAAK,CAAA;KACb;IACD,IAAI,CAACD,UAAU,IAAI,uBAAuBE,IAAI,CAACJ,GAAG,CAAC,EAAE;QACnD,OAAO,KAAK,CAAA;KACb;IACD,OAAO,IAAI,CAAA;CACZ"}

View File

@@ -0,0 +1,2 @@
import { webpack } from 'next/dist/compiled/webpack/webpack';
export declare function getCssModuleLocalIdent(context: webpack.LoaderContext<{}>, _: any, exportName: string, options: object): any;

View File

@@ -0,0 +1,32 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getCssModuleLocalIdent = getCssModuleLocalIdent;
var _loaderUtils3 = _interopRequireDefault(require("next/dist/compiled/loader-utils3"));
var _path = _interopRequireDefault(require("path"));
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
const regexLikeIndexModule = /(?<!pages[\\/])index\.module\.(scss|sass|css)$/;
function getCssModuleLocalIdent(context, _, exportName, options) {
const relativePath = _path.default.relative(context.rootContext, context.resourcePath).replace(/\\+/g, "/");
// Generate a more meaningful name (parent folder) when the user names the
// file `index.module.css`.
const fileNameOrFolder = regexLikeIndexModule.test(relativePath) ? "[folder]" : "[name]";
// Generate a hash to make the class name unique.
const hash = _loaderUtils3.default.getHashDigest(Buffer.from(`filePath:${relativePath}#className:${exportName}`), "md5", "base64", 5);
// Have webpack interpolate the `[folder]` or `[name]` to its real value.
return _loaderUtils3.default.interpolateName(context, fileNameOrFolder + "_" + exportName + "__" + hash, options).replace(// Webpack name interpolation returns `about.module_root__2oFM9` for
// `.root {}` inside a file named `about.module.css`. Let's simplify
// this.
/\.module_/, "_")// Replace invalid symbols with underscores instead of escaping
// https://mathiasbynens.be/notes/css-escapes#identifiers-strings
.replace(/[^a-zA-Z0-9-_]/g, "_")// "they cannot start with a digit, two hyphens, or a hyphen followed by a digit [sic]"
// https://www.w3.org/TR/CSS21/syndata.html#characters
.replace(/^(\d|--|-\d)/, "__$1");
}
//# sourceMappingURL=getCssModuleLocalIdent.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../../build/webpack/config/blocks/css/loaders/getCssModuleLocalIdent.ts"],"names":["getCssModuleLocalIdent","regexLikeIndexModule","context","_","exportName","options","relativePath","path","relative","rootContext","resourcePath","replace","fileNameOrFolder","test","hash","loaderUtils","getHashDigest","Buffer","from","interpolateName"],"mappings":"AAAA;;;;QAMgBA,sBAAsB,GAAtBA,sBAAsB;AANd,IAAA,aAAkC,kCAAlC,kCAAkC,EAAA;AACzC,IAAA,KAAM,kCAAN,MAAM,EAAA;;;;;;AAGvB,MAAMC,oBAAoB,mDAAmD;AAEtE,SAASD,sBAAsB,CACpCE,OAAkC,EAClCC,CAAM,EACNC,UAAkB,EAClBC,OAAe,EACf;IACA,MAAMC,YAAY,GAAGC,KAAI,QAAA,CACtBC,QAAQ,CAACN,OAAO,CAACO,WAAW,EAAEP,OAAO,CAACQ,YAAY,CAAC,CACnDC,OAAO,SAAS,GAAG,CAAC;IAEvB,0EAA0E;IAC1E,2BAA2B;IAC3B,MAAMC,gBAAgB,GAAGX,oBAAoB,CAACY,IAAI,CAACP,YAAY,CAAC,GAC5D,UAAU,GACV,QAAQ;IAEZ,iDAAiD;IACjD,MAAMQ,IAAI,GAAGC,aAAW,QAAA,CAACC,aAAa,CACpCC,MAAM,CAACC,IAAI,CAAC,CAAC,SAAS,EAAEZ,YAAY,CAAC,WAAW,EAAEF,UAAU,CAAC,CAAC,CAAC,EAC/D,KAAK,EACL,QAAQ,EACR,CAAC,CACF;IAED,yEAAyE;IACzE,OACEW,aAAW,QAAA,CACRI,eAAe,CACdjB,OAAO,EACPU,gBAAgB,GAAG,GAAG,GAAGR,UAAU,GAAG,IAAI,GAAGU,IAAI,EACjDT,OAAO,CACR,CACAM,OAAO,CACN,oEAAoE;IACpE,oEAAoE;IACpE,QAAQ;iBAER,GAAG,CACJ,AACD,+DAA+D;IAC/D,iEAAiE;KAChEA,OAAO,oBAAoB,GAAG,CAAC,AAChC,uFAAuF;IACvF,sDAAsD;KACrDA,OAAO,iBAAiB,MAAM,CAAC,CACnC;CACF"}

View File

@@ -0,0 +1,3 @@
import type { webpack } from 'next/dist/compiled/webpack/webpack';
import type { ConfigurationContext } from '../../../utils';
export declare function getGlobalCssLoader(ctx: ConfigurationContext, postcss: any, preProcessors?: readonly webpack.RuleSetUseItem[]): webpack.RuleSetUseItem[];

View File

@@ -0,0 +1,44 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getGlobalCssLoader = getGlobalCssLoader;
var _client = require("./client");
var _fileResolve = require("./file-resolve");
function getGlobalCssLoader(ctx, postcss, preProcessors = []) {
const loaders = [];
if (ctx.isClient) {
// Add appropriate development more or production mode style
// loader
loaders.push((0, _client).getClientStyleLoader({
hasAppDir: ctx.hasAppDir,
isDevelopment: ctx.isDevelopment,
assetPrefix: ctx.assetPrefix
}));
}
// Resolve CSS `@import`s and `url()`s
loaders.push({
loader: require.resolve("../../../../loaders/css-loader/src"),
options: {
postcss,
importLoaders: 1 + preProcessors.length,
// Next.js controls CSS Modules eligibility:
modules: false,
url: (url, resourcePath)=>(0, _fileResolve).cssFileResolve(url, resourcePath, ctx.experimental.urlImports),
import: (url, _, resourcePath)=>(0, _fileResolve).cssFileResolve(url, resourcePath, ctx.experimental.urlImports)
}
});
// Compile CSS
loaders.push({
loader: require.resolve("../../../../loaders/postcss-loader/src"),
options: {
postcss
}
});
loaders.push(// Webpack loaders run like a stack, so we need to reverse the natural
// order of preprocessors.
...preProcessors.slice().reverse());
return loaders;
}
//# sourceMappingURL=global.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../../build/webpack/config/blocks/css/loaders/global.ts"],"names":["getGlobalCssLoader","ctx","postcss","preProcessors","loaders","isClient","push","getClientStyleLoader","hasAppDir","isDevelopment","assetPrefix","loader","require","resolve","options","importLoaders","length","modules","url","resourcePath","cssFileResolve","experimental","urlImports","import","_","slice","reverse"],"mappings":"AAAA;;;;QAMgBA,kBAAkB,GAAlBA,kBAAkB;AAHG,IAAA,OAAU,WAAV,UAAU,CAAA;AAChB,IAAA,YAAgB,WAAhB,gBAAgB,CAAA;AAExC,SAASA,kBAAkB,CAChCC,GAAyB,EACzBC,OAAY,EACZC,aAAgD,GAAG,EAAE,EAC3B;IAC1B,MAAMC,OAAO,GAA6B,EAAE;IAE5C,IAAIH,GAAG,CAACI,QAAQ,EAAE;QAChB,4DAA4D;QAC5D,SAAS;QACTD,OAAO,CAACE,IAAI,CACVC,CAAAA,GAAAA,OAAoB,AAIlB,CAAA,qBAJkB,CAAC;YACnBC,SAAS,EAAEP,GAAG,CAACO,SAAS;YACxBC,aAAa,EAAER,GAAG,CAACQ,aAAa;YAChCC,WAAW,EAAET,GAAG,CAACS,WAAW;SAC7B,CAAC,CACH;KACF;IAED,sCAAsC;IACtCN,OAAO,CAACE,IAAI,CAAC;QACXK,MAAM,EAAEC,OAAO,CAACC,OAAO,CAAC,oCAAoC,CAAC;QAC7DC,OAAO,EAAE;YACPZ,OAAO;YACPa,aAAa,EAAE,CAAC,GAAGZ,aAAa,CAACa,MAAM;YACvC,4CAA4C;YAC5CC,OAAO,EAAE,KAAK;YACdC,GAAG,EAAE,CAACA,GAAW,EAAEC,YAAoB,GACrCC,CAAAA,GAAAA,YAAc,AAAgD,CAAA,eAAhD,CAACF,GAAG,EAAEC,YAAY,EAAElB,GAAG,CAACoB,YAAY,CAACC,UAAU,CAAC;YAChEC,MAAM,EAAE,CAACL,GAAW,EAAEM,CAAM,EAAEL,YAAoB,GAChDC,CAAAA,GAAAA,YAAc,AAAgD,CAAA,eAAhD,CAACF,GAAG,EAAEC,YAAY,EAAElB,GAAG,CAACoB,YAAY,CAACC,UAAU,CAAC;SACjE;KACF,CAAC;IAEF,cAAc;IACdlB,OAAO,CAACE,IAAI,CAAC;QACXK,MAAM,EAAEC,OAAO,CAACC,OAAO,CAAC,wCAAwC,CAAC;QACjEC,OAAO,EAAE;YACPZ,OAAO;SACR;KACF,CAAC;IAEFE,OAAO,CAACE,IAAI,CACV,sEAAsE;IACtE,0BAA0B;OACvBH,aAAa,CAACsB,KAAK,EAAE,CAACC,OAAO,EAAE,CACnC;IAED,OAAOtB,OAAO,CAAA;CACf"}

View File

@@ -0,0 +1,2 @@
export * from './global';
export * from './modules';

View File

@@ -0,0 +1,70 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _exportNames = {};
var _global = _interopRequireWildcard(require("./global"));
Object.keys(_global).forEach(function(key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
if (key in exports && exports[key] === _global[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function() {
return _global[key];
}
});
});
var _modules = _interopRequireWildcard(require("./modules"));
Object.keys(_modules).forEach(function(key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
if (key in exports && exports[key] === _modules[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function() {
return _modules[key];
}
});
});
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;
}
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../../build/webpack/config/blocks/css/loaders/index.ts"],"names":[],"mappings":"AAAA;;;;;8CAAc,UAAU;AAAxB,YAAA,OAAwB;;;2CAAxB,OAAwB;;;;mBAAxB,OAAwB;;;EAAA;+CACV,WAAW;AAAzB,YAAA,QAAyB;;;2CAAzB,QAAyB;;;;mBAAzB,QAAyB;;;EAAA"}

View File

@@ -0,0 +1,3 @@
import { webpack } from 'next/dist/compiled/webpack/webpack';
import { ConfigurationContext } from '../../../utils';
export declare function getCssModuleLoader(ctx: ConfigurationContext, postcss: any, preProcessors?: readonly webpack.RuleSetUseItem[]): webpack.RuleSetUseItem[];

View File

@@ -0,0 +1,60 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getCssModuleLoader = getCssModuleLoader;
var _client = require("./client");
var _fileResolve = require("./file-resolve");
var _getCssModuleLocalIdent = require("./getCssModuleLocalIdent");
function getCssModuleLoader(ctx, postcss, preProcessors = []) {
const loaders = [];
if (ctx.isClient) {
// Add appropriate development more or production mode style
// loader
loaders.push((0, _client).getClientStyleLoader({
hasAppDir: ctx.hasAppDir,
isDevelopment: ctx.isDevelopment,
assetPrefix: ctx.assetPrefix
}));
}
// Resolve CSS `@import`s and `url()`s
loaders.push({
loader: require.resolve("../../../../loaders/css-loader/src"),
options: {
postcss,
importLoaders: 1 + preProcessors.length,
// Use CJS mode for backwards compatibility:
esModule: false,
url: (url, resourcePath)=>(0, _fileResolve).cssFileResolve(url, resourcePath, ctx.experimental.urlImports),
import: (url, _, resourcePath)=>(0, _fileResolve).cssFileResolve(url, resourcePath, ctx.experimental.urlImports),
modules: {
// Do not transform class names (CJS mode backwards compatibility):
exportLocalsConvention: "asIs",
// Server-side (Node.js) rendering support:
exportOnlyLocals: ctx.isServer,
// Disallow global style exports so we can code-split CSS and
// not worry about loading order.
mode: "pure",
// Generate a friendly production-ready name so it's
// reasonably understandable. The same name is used for
// development.
// TODO: Consider making production reduce this to a single
// character?
getLocalIdent: _getCssModuleLocalIdent.getCssModuleLocalIdent
}
}
});
// Compile CSS
loaders.push({
loader: require.resolve("../../../../loaders/postcss-loader/src"),
options: {
postcss
}
});
loaders.push(// Webpack loaders run like a stack, so we need to reverse the natural
// order of preprocessors.
...preProcessors.slice().reverse());
return loaders;
}
//# sourceMappingURL=modules.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../../build/webpack/config/blocks/css/loaders/modules.ts"],"names":["getCssModuleLoader","ctx","postcss","preProcessors","loaders","isClient","push","getClientStyleLoader","hasAppDir","isDevelopment","assetPrefix","loader","require","resolve","options","importLoaders","length","esModule","url","resourcePath","cssFileResolve","experimental","urlImports","import","_","modules","exportLocalsConvention","exportOnlyLocals","isServer","mode","getLocalIdent","getCssModuleLocalIdent","slice","reverse"],"mappings":"AAAA;;;;QAMgBA,kBAAkB,GAAlBA,kBAAkB;AAJG,IAAA,OAAU,WAAV,UAAU,CAAA;AAChB,IAAA,YAAgB,WAAhB,gBAAgB,CAAA;AACR,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Ae;gBACf,2DAA2D;gBAC3D,aAAa;gBACbC,aAAa,EAAEC,uBAAsB,uBAAA;aACtC;SACF;KACF,CAAC;IAEF,cAAc;IACd3B,OAAO,CAACE,IAAI,CAAC;QACXK,MAAM,EAAEC,OAAO,CAACC,OAAO,CAAC,wCAAwC,CAAC;QACjEC,OAAO,EAAE;YACPZ,OAAO;SACR;KACF,CAAC;IAEFE,OAAO,CAACE,IAAI,CACV,sEAAsE;IACtE,0BAA0B;OACvBH,aAAa,CAAC6B,KAAK,EAAE,CAACC,OAAO,EAAE,CACnC;IAED,OAAO7B,OAAO,CAAA;CACf"}

View File

@@ -0,0 +1,3 @@
import { webpack } from 'next/dist/compiled/webpack/webpack';
import { ConfigurationContext } from '../../../utils';
export declare function getNextFontLoader(ctx: ConfigurationContext, postcss: any, fontLoaderOptions: any): webpack.RuleSetUseItem[];

View File

@@ -0,0 +1,57 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getNextFontLoader = getNextFontLoader;
var _client = require("./client");
var _fileResolve = require("./file-resolve");
function getNextFontLoader(ctx, postcss, fontLoaderOptions) {
const loaders = [];
if (ctx.isClient) {
// Add appropriate development mode or production mode style
// loader
loaders.push((0, _client).getClientStyleLoader({
hasAppDir: ctx.hasAppDir,
isDevelopment: ctx.isDevelopment,
assetPrefix: ctx.assetPrefix
}));
}
loaders.push({
loader: require.resolve("../../../../loaders/css-loader/src"),
options: {
postcss,
importLoaders: 1,
// Use CJS mode for backwards compatibility:
esModule: false,
url: (url, resourcePath)=>(0, _fileResolve).cssFileResolve(url, resourcePath, ctx.experimental.urlImports),
import: (url, _, resourcePath)=>(0, _fileResolve).cssFileResolve(url, resourcePath, ctx.experimental.urlImports),
modules: {
// Do not transform class names (CJS mode backwards compatibility):
exportLocalsConvention: "asIs",
// Server-side (Node.js) rendering support:
exportOnlyLocals: ctx.isServer,
// Disallow global style exports so we can code-split CSS and
// not worry about loading order.
mode: "pure",
getLocalIdent: (_context, _localIdentName, exportName, _options, meta)=>{
// hash from next-font-loader
return `__${exportName}_${meta.fontFamilyHash}`;
}
},
fontLoader: true
}
});
loaders.push({
loader: "next-font-loader",
options: {
isDev: ctx.isDevelopment,
isServer: ctx.isServer,
assetPrefix: ctx.assetPrefix,
fontLoaderOptions,
postcss
}
});
return loaders;
}
//# sourceMappingURL=next-font.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../../build/webpack/config/blocks/css/loaders/next-font.ts"],"names":["getNextFontLoader","ctx","postcss","fontLoaderOptions","loaders","isClient","push","getClientStyleLoader","hasAppDir","isDevelopment","assetPrefix","loader","require","resolve","options","importLoaders","esModule","url","resourcePath","cssFileResolve","experimental","urlImports","import","_","modules","exportLocalsConvention","exportOnlyLocals","isServer","mode","getLocalIdent","_context","_localIdentName","exportName","_options","meta","fontFamilyHash","fontLoader","isDev"],"mappings":"AAAA;;;;QAKgBA,iBAAiB,GAAjBA,iBAAiB;AAHI,IAAA,OAAU,WAAV,UAAU,CAAA;AAChB,IAAA,YAAgB,WAAhB,gBAAgB,CAAA;AAExC,SAASA,iBAAiB,CAC/BC,GAAyB,EACzBC,OAAY,EACZC,iBAAsB,EACI;IAC1B,MAAMC,OAAO,GAA6B,EAAE;IAE5C,IAAIH,GAAG,CAACI,QAAQ,EAAE;QAChB,4DAA4D;QAC5D,SAAS;QACTD,OAAO,CAACE,IAAI,CACVC,CAAAA,GAAAA,OAAoB,AAIlB,CAAA,qBAJkB,CAAC;YACnBC,SAAS,EAAEP,GAAG,CAACO,SAAS;YACxBC,aAAa,EAAER,GAAG,CAACQ,aAAa;YAChCC,WAAW,EAAET,GAAG,CAACS,WAAW;SAC7B,CAAC,CACH;KACF;IAEDN,OAAO,CAACE,IAAI,CAAC;QACXK,MAAM,EAAEC,OAAO,CAACC,OAAO,CAAC,oCAAoC,CAAC;QAC7DC,OAAO,EAAE;YACPZ,OAAO;YACPa,aAAa,EAAE,CAAC;YAChB,4CAA4C;YAC5CC,QAAQ,EAAE,KAAK;YACfC,GAAG,EAAE,CAACA,GAAW,EAAEC,YAAoB,GACrCC,CAAAA,GAAAA,YAAc,AAAgD,CAAA,eAAhD,CAACF,GAAG,EAAEC,YAAY,EAAEjB,GAAG,CAACmB,YAAY,CAACC,UAAU,CAAC;YAChEC,MAAM,EAAE,CAACL,GAAW,EAAEM,CAAM,EAAEL,YAAoB,GAChDC,CAAAA,GAAAA,YAAc,AAAgD,CAAA,eAAhD,CAACF,GAAG,EAAEC,YAAY,EAAEjB,GAAG,CAACmB,YAAY,CAACC,UAAU,CAAC;YAChEG,OAAO,EAAE;gBACP,mEAAmE;gBACnEC,sBAAsB,EAAE,MAAM;gBAC9B,2CAA2C;gBAC3CC,gBAAgB,EAAEzB,GAAG,CAAC0B,QAAQ;gBAC9B,6DAA6D;gBAC7D,iCAAiC;gBACjCC,IAAI,EAAE,MAAM;gBACZC,aAAa,EAAE,CACbC,QAAa,EACbC,eAAoB,EACpBC,UAAkB,EAClBC,QAAa,EACbC,IAAS,GACN;oBACH,6BAA6B;oBAC7B,OAAO,CAAC,EAAE,EAAEF,UAAU,CAAC,CAAC,EAAEE,IAAI,CAACC,cAAc,CAAC,CAAC,CAAA;iBAChD;aACF;YACDC,UAAU,EAAE,IAAI;SACjB;KACF,CAAC;IAEFhC,OAAO,CAACE,IAAI,CAAC;QACXK,MAAM,EAAE,kBAAkB;QAC1BG,OAAO,EAAE;YACPuB,KAAK,EAAEpC,GAAG,CAACQ,aAAa;YACxBkB,QAAQ,EAAE1B,GAAG,CAAC0B,QAAQ;YACtBjB,WAAW,EAAET,GAAG,CAACS,WAAW;YAC5BP,iBAAiB;YACjBD,OAAO;SACR;KACF,CAAC;IAEF,OAAOE,OAAO,CAAA;CACf"}

View File

@@ -0,0 +1,4 @@
export declare function getGlobalImportError(): string;
export declare function getGlobalModuleImportError(): string;
export declare function getLocalModuleImportError(): string;
export declare function getCustomDocumentError(): string;

View File

@@ -0,0 +1,28 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getGlobalImportError = getGlobalImportError;
exports.getGlobalModuleImportError = getGlobalModuleImportError;
exports.getLocalModuleImportError = getLocalModuleImportError;
exports.getCustomDocumentError = getCustomDocumentError;
var _chalk = _interopRequireDefault(require("next/dist/compiled/chalk"));
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
function getGlobalImportError() {
return `Global CSS ${_chalk.default.bold("cannot")} be imported from files other than your ${_chalk.default.bold("Custom <App>")}. Due to the Global nature of stylesheets, and to avoid conflicts, Please move all first-party global CSS imports to ${_chalk.default.cyan("pages/_app.js")}. Or convert the import to Component-Level CSS (CSS Modules).\nRead more: https://nextjs.org/docs/messages/css-global`;
}
function getGlobalModuleImportError() {
return `Global CSS ${_chalk.default.bold("cannot")} be imported from within ${_chalk.default.bold("node_modules")}.\nRead more: https://nextjs.org/docs/messages/css-npm`;
}
function getLocalModuleImportError() {
return `CSS Modules ${_chalk.default.bold("cannot")} be imported from within ${_chalk.default.bold("node_modules")}.\nRead more: https://nextjs.org/docs/messages/css-modules-npm`;
}
function getCustomDocumentError() {
return `CSS ${_chalk.default.bold("cannot")} be imported within ${_chalk.default.cyan("pages/_document.js")}. Please move global styles to ${_chalk.default.cyan("pages/_app.js")}.`;
}
//# sourceMappingURL=messages.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../build/webpack/config/blocks/css/messages.ts"],"names":["getGlobalImportError","getGlobalModuleImportError","getLocalModuleImportError","getCustomDocumentError","chalk","bold","cyan"],"mappings":"AAAA;;;;QAEgBA,oBAAoB,GAApBA,oBAAoB;QAUpBC,0BAA0B,GAA1BA,0BAA0B;QAQ1BC,yBAAyB,GAAzBA,yBAAyB;QAQzBC,sBAAsB,GAAtBA,sBAAsB;AA5BpB,IAAA,MAA0B,kCAA1B,0BAA0B,EAAA;;;;;;AAErC,SAASH,oBAAoB,GAAG;IACrC,OAAO,CAAC,WAAW,EAAEI,MAAK,QAAA,CAACC,IAAI,CAC7B,QAAQ,CACT,CAAC,wCAAwC,EAAED,MAAK,QAAA,CAACC,IAAI,CACpD,cAAc,CACf,CAAC,qHAAqH,EAAED,MAAK,QAAA,CAACE,IAAI,CACjI,eAAe,CAChB,CAAC,qHAAqH,CAAC,CAAA;CACzH;AAEM,SAASL,0BAA0B,GAAG;IAC3C,OAAO,CAAC,WAAW,EAAEG,MAAK,QAAA,CAACC,IAAI,CAC7B,QAAQ,CACT,CAAC,yBAAyB,EAAED,MAAK,QAAA,CAACC,IAAI,CACrC,cAAc,CACf,CAAC,sDAAsD,CAAC,CAAA;CAC1D;AAEM,SAASH,yBAAyB,GAAG;IAC1C,OAAO,CAAC,YAAY,EAAEE,MAAK,QAAA,CAACC,IAAI,CAC9B,QAAQ,CACT,CAAC,yBAAyB,EAAED,MAAK,QAAA,CAACC,IAAI,CACrC,cAAc,CACf,CAAC,8DAA8D,CAAC,CAAA;CAClE;AAEM,SAASF,sBAAsB,GAAG;IACvC,OAAO,CAAC,IAAI,EAAEC,MAAK,QAAA,CAACC,IAAI,CAAC,QAAQ,CAAC,CAAC,oBAAoB,EAAED,MAAK,QAAA,CAACE,IAAI,CACjE,oBAAoB,CACrB,CAAC,+BAA+B,EAAEF,MAAK,QAAA,CAACE,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAA;CAClE"}

View File

@@ -0,0 +1 @@
export declare function getPostCssPlugins(dir: string, supportedBrowsers: string[] | undefined, disablePostcssPresetEnv?: boolean): Promise<import('postcss').AcceptedPlugin[]>;

View File

@@ -0,0 +1,162 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getPostCssPlugins = getPostCssPlugins;
var _chalk = _interopRequireDefault(require("next/dist/compiled/chalk"));
var _findConfig = require("../../../../../lib/find-config");
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
const genericErrorText = "Malformed PostCSS Configuration";
function getError_NullConfig(pluginName) {
return `${_chalk.default.red.bold("Error")}: Your PostCSS configuration for '${pluginName}' cannot have ${_chalk.default.bold("null")} configuration.\nTo disable '${pluginName}', pass ${_chalk.default.bold("false")}, otherwise, pass ${_chalk.default.bold("true")} or a configuration object.`;
}
function isIgnoredPlugin(pluginPath) {
const ignoredRegex = /(?:^|[\\/])(postcss-modules-values|postcss-modules-scope|postcss-modules-extract-imports|postcss-modules-local-by-default|postcss-modules)(?:[\\/]|$)/i;
const match = ignoredRegex.exec(pluginPath);
if (match == null) {
return false;
}
const plugin = match.pop();
console.warn(`${_chalk.default.yellow.bold("Warning")}: Please remove the ${_chalk.default.underline(plugin)} plugin from your PostCSS configuration. ` + `This plugin is automatically configured by Next.js.\n` + "Read more: https://nextjs.org/docs/messages/postcss-ignored-plugin");
return true;
}
const createLazyPostCssPlugin = (fn)=>{
let result = undefined;
const plugin = (...args)=>{
if (result === undefined) result = fn();
if (result.postcss === true) {
return result(...args);
} else if (result.postcss) {
return result.postcss;
}
return result;
};
plugin.postcss = true;
return plugin;
};
async function loadPlugin(dir, pluginName, options) {
if (options === false || isIgnoredPlugin(pluginName)) {
return false;
}
if (options == null) {
console.error(getError_NullConfig(pluginName));
throw new Error(genericErrorText);
}
const pluginPath = require.resolve(pluginName, {
paths: [
dir
]
});
if (isIgnoredPlugin(pluginPath)) {
return false;
} else if (options === true) {
return createLazyPostCssPlugin(()=>require(pluginPath));
} else {
if (typeof options === "object" && Object.keys(options).length === 0) {
return createLazyPostCssPlugin(()=>require(pluginPath));
}
return createLazyPostCssPlugin(()=>require(pluginPath)(options));
}
}
function getDefaultPlugins(supportedBrowsers, disablePostcssPresetEnv) {
return [
require.resolve("next/dist/compiled/postcss-flexbugs-fixes"),
disablePostcssPresetEnv ? false : [
require.resolve("next/dist/compiled/postcss-preset-env"),
{
browsers: supportedBrowsers ?? [
"defaults"
],
autoprefixer: {
// Disable legacy flexbox support
flexbox: "no-2009"
},
// Enable CSS features that have shipped to the
// web platform, i.e. in 2+ browsers unflagged.
stage: 3,
features: {
"custom-properties": false
}
},
],
].filter(Boolean);
}
async function getPostCssPlugins(dir, supportedBrowsers, disablePostcssPresetEnv = false) {
let config = await (0, _findConfig).findConfig(dir, "postcss");
if (config == null) {
config = {
plugins: getDefaultPlugins(supportedBrowsers, disablePostcssPresetEnv)
};
}
if (typeof config === "function") {
throw new Error(`Your custom PostCSS configuration may not export a function. Please export a plain object instead.\n` + "Read more: https://nextjs.org/docs/messages/postcss-function");
}
// Warn user about configuration keys which are not respected
const invalidKey = Object.keys(config).find((key)=>key !== "plugins");
if (invalidKey) {
console.warn(`${_chalk.default.yellow.bold("Warning")}: Your PostCSS configuration defines a field which is not supported (\`${invalidKey}\`). ` + `Please remove this configuration value.`);
}
// Enforce the user provided plugins if the configuration file is present
let plugins = config.plugins;
if (plugins == null || typeof plugins !== "object") {
throw new Error(`Your custom PostCSS configuration must export a \`plugins\` key.`);
}
if (!Array.isArray(plugins)) {
// Capture variable so TypeScript is happy
const pc = plugins;
plugins = Object.keys(plugins).reduce((acc, curr)=>{
const p = pc[curr];
if (typeof p === "undefined") {
console.error(getError_NullConfig(curr));
throw new Error(genericErrorText);
}
acc.push([
curr,
p
]);
return acc;
}, []);
}
const parsed = [];
plugins.forEach((plugin)=>{
if (plugin == null) {
console.warn(`${_chalk.default.yellow.bold("Warning")}: A ${_chalk.default.bold("null")} PostCSS plugin was provided. This entry will be ignored.`);
} else if (typeof plugin === "string") {
parsed.push([
plugin,
true
]);
} else if (Array.isArray(plugin)) {
const pluginName = plugin[0];
const pluginConfig = plugin[1];
if (typeof pluginName === "string" && (typeof pluginConfig === "boolean" || typeof pluginConfig === "object" || typeof pluginConfig === "string")) {
parsed.push([
pluginName,
pluginConfig
]);
} else {
if (typeof pluginName !== "string") {
console.error(`${_chalk.default.red.bold("Error")}: A PostCSS Plugin must be provided as a ${_chalk.default.bold("string")}. Instead, we got: '${pluginName}'.\n` + "Read more: https://nextjs.org/docs/messages/postcss-shape");
} else {
console.error(`${_chalk.default.red.bold("Error")}: A PostCSS Plugin was passed as an array but did not provide its configuration ('${pluginName}').\n` + "Read more: https://nextjs.org/docs/messages/postcss-shape");
}
throw new Error(genericErrorText);
}
} else if (typeof plugin === "function") {
console.error(`${_chalk.default.red.bold("Error")}: A PostCSS Plugin was passed as a function using require(), but it must be provided as a ${_chalk.default.bold("string")}.\nRead more: https://nextjs.org/docs/messages/postcss-shape`);
throw new Error(genericErrorText);
} else {
console.error(`${_chalk.default.red.bold("Error")}: An unknown PostCSS plugin was provided (${plugin}).\n` + "Read more: https://nextjs.org/docs/messages/postcss-shape");
throw new Error(genericErrorText);
}
});
const resolved = await Promise.all(parsed.map((p)=>loadPlugin(dir, p[0], p[1])));
const filtered = resolved.filter(Boolean);
return filtered;
}
//# sourceMappingURL=plugins.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,4 @@
/// <reference types="lodash" />
import { webpack } from 'next/dist/compiled/webpack/webpack';
import { ConfigurationContext } from '../../utils';
export declare const images: import("lodash").CurriedFunction2<ConfigurationContext, webpack.Configuration, Promise<webpack.Configuration>>;

View File

@@ -0,0 +1,38 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.images = void 0;
var _lodashCurry = _interopRequireDefault(require("next/dist/compiled/lodash.curry"));
var _webpackConfig = require("../../../../webpack-config");
var _helpers = require("../../helpers");
var _utils = require("../../utils");
var _messages = require("./messages");
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
const images = (0, _lodashCurry).default(async function images(_ctx, config) {
const fns = [
(0, _helpers).loader({
oneOf: [
{
test: _webpackConfig.nextImageLoaderRegex,
use: {
loader: "error-loader",
options: {
reason: (0, _messages).getCustomDocumentImageError()
}
},
issuer: /pages[\\/]_document\./
},
]
}),
];
const fn = (0, _utils).pipe(...fns);
return fn(config);
});
exports.images = images;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../build/webpack/config/blocks/images/index.ts"],"names":["images","curry","_ctx","config","fns","loader","oneOf","test","nextImageLoaderRegex","use","options","reason","getCustomDocumentImageError","issuer","fn","pipe"],"mappings":"AAAA;;;;;AAAkB,IAAA,YAAiC,kCAAjC,iCAAiC,EAAA;AAEd,IAAA,cAA4B,WAA5B,4BAA4B,CAAA;AAC1C,IAAA,QAAe,WAAf,eAAe,CAAA;AACsB,IAAA,MAAa,WAAb,aAAa,CAAA;AAC7B,IAAA,SAAY,WAAZ,YAAY,CAAA;;;;;;AAEjD,MAAMA,MAAM,GAAGC,CAAAA,GAAAA,YAAK,AAuBzB,CAAA,QAvByB,CAAC,eAAeD,MAAM,CAC/CE,IAA0B,EAC1BC,MAA6B,EAC7B;IACA,MAAMC,GAAG,GAAsB;QAC7BC,CAAAA,GAAAA,QAAM,AAaJ,CAAA,OAbI,CAAC;YACLC,KAAK,EAAE;gBACL;oBACEC,IAAI,EAAEC,cAAoB,qBAAA;oBAC1BC,GAAG,EAAE;wBACHJ,MAAM,EAAE,cAAc;wBACtBK,OAAO,EAAE;4BACPC,MAAM,EAAEC,CAAAA,GAAAA,SAA2B,AAAE,CAAA,4BAAF,EAAE;yBACtC;qBACF;oBACDC,MAAM,yBAAyB;iBAChC;aACF;SACF,CAAC;KACH;IAED,MAAMC,EAAE,GAAGC,CAAAA,GAAAA,MAAI,AAAQ,CAAA,KAAR,IAAIX,GAAG,CAAC;IACvB,OAAOU,EAAE,CAACX,MAAM,CAAC,CAAA;CAClB,CAAC;QAvBWH,MAAM,GAANA,MAAM"}

View File

@@ -0,0 +1 @@
export declare function getCustomDocumentImageError(): string;

View File

@@ -0,0 +1,16 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getCustomDocumentImageError = getCustomDocumentImageError;
var _chalk = _interopRequireDefault(require("next/dist/compiled/chalk"));
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
function getCustomDocumentImageError() {
return `Images ${_chalk.default.bold("cannot")} be imported within ${_chalk.default.cyan("pages/_document.js")}. Please move image imports that need to be displayed on every page into ${_chalk.default.cyan("pages/_app.js")}.\nRead more: https://nextjs.org/docs/messages/custom-document-image-import`;
}
//# sourceMappingURL=messages.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../build/webpack/config/blocks/images/messages.ts"],"names":["getCustomDocumentImageError","chalk","bold","cyan"],"mappings":"AAAA;;;;QAEgBA,2BAA2B,GAA3BA,2BAA2B;AAFzB,IAAA,MAA0B,kCAA1B,0BAA0B,EAAA;;;;;;AAErC,SAASA,2BAA2B,GAAG;IAC5C,OAAO,CAAC,OAAO,EAAEC,MAAK,QAAA,CAACC,IAAI,CAAC,QAAQ,CAAC,CAAC,oBAAoB,EAAED,MAAK,QAAA,CAACE,IAAI,CACpE,oBAAoB,CACrB,CAAC,yEAAyE,EAAEF,MAAK,QAAA,CAACE,IAAI,CACrF,eAAe,CAChB,CAAC,2EAA2E,CAAC,CAAA;CAC/E"}

View File

@@ -0,0 +1,5 @@
/// <reference types="lodash" />
import { webpack } from 'next/dist/compiled/webpack/webpack';
export declare const loader: import("lodash").CurriedFunction2<webpack.RuleSetRule, webpack.Configuration, webpack.Configuration>;
export declare const unshiftLoader: import("lodash").CurriedFunction2<webpack.RuleSetRule, webpack.Configuration, webpack.Configuration>;
export declare const plugin: import("lodash").CurriedFunction2<webpack.WebpackPluginInstance, webpack.Configuration, webpack.Configuration>;

View File

@@ -0,0 +1,60 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.plugin = exports.unshiftLoader = exports.loader = void 0;
var _lodashCurry = _interopRequireDefault(require("next/dist/compiled/lodash.curry"));
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
const loader = (0, _lodashCurry).default(function loader(rule, config) {
var ref;
if (!config.module) {
config.module = {
rules: []
};
}
if (rule.oneOf) {
var ref1;
const existing = (ref1 = config.module.rules) == null ? void 0 : ref1.find((arrayRule)=>arrayRule && typeof arrayRule === "object" && arrayRule.oneOf);
if (existing && typeof existing === "object") {
existing.oneOf.push(...rule.oneOf);
return config;
}
}
(ref = config.module.rules) == null ? void 0 : ref.push(rule);
return config;
});
exports.loader = loader;
const unshiftLoader = (0, _lodashCurry).default(function unshiftLoader(rule, config) {
var ref;
if (!config.module) {
config.module = {
rules: []
};
}
if (rule.oneOf) {
var ref2;
const existing = (ref2 = config.module.rules) == null ? void 0 : ref2.find((arrayRule)=>arrayRule && typeof arrayRule === "object" && arrayRule.oneOf);
if (existing && typeof existing === "object") {
var ref3;
(ref3 = existing.oneOf) == null ? void 0 : ref3.unshift(...rule.oneOf);
return config;
}
}
(ref = config.module.rules) == null ? void 0 : ref.unshift(rule);
return config;
});
exports.unshiftLoader = unshiftLoader;
const plugin = (0, _lodashCurry).default(function plugin(p, config) {
if (!config.plugins) {
config.plugins = [];
}
config.plugins.push(p);
return config;
});
exports.plugin = plugin;
//# sourceMappingURL=helpers.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../build/webpack/config/helpers.ts"],"names":["loader","curry","rule","config","module","rules","oneOf","existing","find","arrayRule","push","unshiftLoader","unshift","plugin","p","plugins"],"mappings":"AAAA;;;;;AAAkB,IAAA,YAAiC,kCAAjC,iCAAiC,EAAA;;;;;;AAG5C,MAAMA,MAAM,GAAGC,CAAAA,GAAAA,YAAK,AAqBzB,CAAA,QArByB,CAAC,SAASD,MAAM,CACzCE,IAAyB,EACzBC,MAA6B,EAC7B;QAgBAA,GAAmB;IAfnB,IAAI,CAACA,MAAM,CAACC,MAAM,EAAE;QAClBD,MAAM,CAACC,MAAM,GAAG;YAAEC,KAAK,EAAE,EAAE;SAAE;KAC9B;IAED,IAAIH,IAAI,CAACI,KAAK,EAAE;YACGH,IAAmB;QAApC,MAAMI,QAAQ,GAAGJ,CAAAA,IAAmB,GAAnBA,MAAM,CAACC,MAAM,CAACC,KAAK,SAAM,GAAzBF,KAAAA,CAAyB,GAAzBA,IAAmB,CAAEK,IAAI,CACxC,CAACC,SAAS,GACRA,SAAS,IAAI,OAAOA,SAAS,KAAK,QAAQ,IAA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,CAACC,KAAK,SAAS,GAA5BF,KAAAA,CAA4B,GAA5BA,GAAmB,CAAES,OAAO,CAACV,IAAI,CAAC,CAAA;IAClC,OAAOC,MAAM,CAAA;CACd,CAAC;QArBWQ,aAAa,GAAbA,aAAa;AAuBnB,MAAME,MAAM,GAAGZ,CAAAA,GAAAA,YAAK,AASzB,CAAA,QATyB,CAAC,SAASY,MAAM,CACzCC,CAAgC,EAChCX,MAA6B,EAC7B;IACA,IAAI,CAACA,MAAM,CAACY,OAAO,EAAE;QACnBZ,MAAM,CAACY,OAAO,GAAG,EAAE;KACpB;IACDZ,MAAM,CAACY,OAAO,CAACL,IAAI,CAACI,CAAC,CAAC;IACtB,OAAOX,MAAM,CAAA;CACd,CAAC;QATWU,MAAM,GAANA,MAAM"}

View File

@@ -0,0 +1,19 @@
import type { webpack } from 'next/dist/compiled/webpack/webpack';
import type { NextConfigComplete } from '../../../server/config-shared';
export declare function buildConfiguration(config: webpack.Configuration, { hasAppDir, supportedBrowsers, rootDirectory, customAppFile, isDevelopment, isServer, isEdgeRuntime, targetWeb, assetPrefix, sassOptions, productionBrowserSourceMaps, future, transpilePackages, experimental, disableStaticImages, }: {
hasAppDir: boolean;
supportedBrowsers: string[] | undefined;
rootDirectory: string;
customAppFile: RegExp | undefined;
isDevelopment: boolean;
isServer: boolean;
isEdgeRuntime: boolean;
targetWeb: boolean;
assetPrefix: string;
sassOptions: any;
productionBrowserSourceMaps: boolean;
transpilePackages: NextConfigComplete['transpilePackages'];
future: NextConfigComplete['future'];
experimental: NextConfigComplete['experimental'];
disableStaticImages: NextConfigComplete['disableStaticImages'];
}): Promise<webpack.Configuration>;

View File

@@ -0,0 +1,40 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.buildConfiguration = buildConfiguration;
var _base = require("./blocks/base");
var _css = require("./blocks/css");
var _images = require("./blocks/images");
var _utils = require("./utils");
async function buildConfiguration(config, { hasAppDir , supportedBrowsers , rootDirectory , customAppFile , isDevelopment , isServer , isEdgeRuntime , targetWeb , assetPrefix , sassOptions , productionBrowserSourceMaps , future , transpilePackages , experimental , disableStaticImages }) {
const ctx = {
hasAppDir,
supportedBrowsers,
rootDirectory,
customAppFile,
isDevelopment,
isProduction: !isDevelopment,
isServer,
isEdgeRuntime,
isClient: !isServer,
targetWeb,
assetPrefix: assetPrefix ? assetPrefix.endsWith("/") ? assetPrefix.slice(0, -1) : assetPrefix : "",
sassOptions,
productionBrowserSourceMaps,
transpilePackages,
future,
experimental
};
let fns = [
(0, _base).base(ctx),
(0, _css).css(ctx)
];
if (!disableStaticImages) {
fns.push((0, _images).images(ctx));
}
const fn = (0, _utils).pipe(...fns);
return fn(config);
}
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../build/webpack/config/index.ts"],"names":["buildConfiguration","config","hasAppDir","supportedBrowsers","rootDirectory","customAppFile","isDevelopment","isServer","isEdgeRuntime","targetWeb","assetPrefix","sassOptions","productionBrowserSourceMaps","future","transpilePackages","experimental","disableStaticImages","ctx","isProduction","isClient","endsWith","slice","fns","base","css","push","images","fn","pipe"],"mappings":"AAAA;;;;QASsBA,kBAAkB,GAAlBA,kBAAkB;AALnB,IAAA,KAAe,WAAf,eAAe,CAAA;AAChB,IAAA,IAAc,WAAd,cAAc,CAAA;AACX,IAAA,OAAiB,WAAjB,iBAAiB,CAAA;AACnB,IAAA,MAAS,WAAT,SAAS,CAAA;AAEvB,eAAeA,kBAAkB,CACtCC,MAA6B,EAC7B,EACEC,SAAS,CAAA,EACTC,iBAAiB,CAAA,EACjBC,aAAa,CAAA,EACbC,aAAa,CAAA,EACbC,aAAa,CAAA,EACbC,QAAQ,CAAA,EACRC,aAAa,CAAA,EACbC,SAAS,CAAA,EACTC,WAAW,CAAA,EACXC,WAAW,CAAA,EACXC,2BAA2B,CAAA,EAC3BC,MAAM,CAAA,EACNC,iBAAiB,CAAA,EACjBC,YAAY,CAAA,EACZC,mBAAmB,CAAA,EAiBpB,EAC+B;IAChC,MAAMC,GAAG,GAAyB;QAChCf,SAAS;QACTC,iBAAiB;QACjBC,aAAa;QACbC,aAAa;QACbC,aAAa;QACbY,YAAY,EAAE,CAACZ,aAAa;QAC5BC,QAAQ;QACRC,aAAa;QACbW,QAAQ,EAAE,CAACZ,QAAQ;QACnBE,SAAS;QACTC,WAAW,EAAEA,WAAW,GACpBA,WAAW,CAACU,QAAQ,CAAC,GAAG,CAAC,GACvBV,WAAW,CAACW,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GACxBX,WAAW,GACb,EAAE;QACNC,WAAW;QACXC,2BAA2B;QAC3BE,iBAAiB;QACjBD,MAAM;QACNE,YAAY;KACb;IAED,IAAIO,GAAG,GAAG;QAACC,CAAAA,GAAAA,KAAI,AAAK,CAAA,KAAL,CAACN,GAAG,CAAC;QAAEO,CAAAA,GAAAA,IAAG,AAAK,CAAA,IAAL,CAACP,GAAG,CAAC;KAAC;IAC/B,IAAI,CAACD,mBAAmB,EAAE;QACxBM,GAAG,CAACG,IAAI,CAACC,CAAAA,GAAAA,OAAM,AAAK,CAAA,OAAL,CAACT,GAAG,CAAC,CAAC;KACtB;IACD,MAAMU,EAAE,GAAGC,CAAAA,GAAAA,MAAI,AAAQ,CAAA,KAAR,IAAIN,GAAG,CAAC;IACvB,OAAOK,EAAE,CAAC1B,MAAM,CAAC,CAAA;CAClB"}

View File

@@ -0,0 +1,22 @@
import type { webpack } from 'next/dist/compiled/webpack/webpack';
import type { NextConfigComplete } from '../../../server/config-shared';
export declare type ConfigurationContext = {
hasAppDir: boolean;
supportedBrowsers: string[] | undefined;
rootDirectory: string;
customAppFile: RegExp | undefined;
isDevelopment: boolean;
isProduction: boolean;
isServer: boolean;
isClient: boolean;
isEdgeRuntime: boolean;
targetWeb: boolean;
assetPrefix: string;
sassOptions: any;
productionBrowserSourceMaps: boolean;
transpilePackages: NextConfigComplete['transpilePackages'];
future: NextConfigComplete['future'];
experimental: NextConfigComplete['experimental'];
};
export declare type ConfigurationFn = (a: webpack.Configuration) => webpack.Configuration;
export declare const pipe: <R>(...fns: ((a: R) => R | Promise<R>)[]) => (param: R) => R | Promise<R>;

View File

@@ -0,0 +1,9 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.pipe = void 0;
const pipe = (...fns)=>(param)=>fns.reduce(async (result, next)=>next(await result), param);
exports.pipe = pipe;
//# sourceMappingURL=utils.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../build/webpack/config/utils.ts"],"names":["pipe","fns","param","reduce","result","next"],"mappings":"AAAA;;;;;AAgCO,MAAMA,IAAI,GACf,CAAI,GAAGC,GAAG,AAAiC,GAC3C,CAACC,KAAQ,GACPD,GAAG,CAACE,MAAM,CACR,OAAOC,MAAsB,EAAEC,IAAI,GAAKA,IAAI,CAAC,MAAMD,MAAM,CAAC,EAC1DF,KAAK,CACN;QANQF,IAAI,GAAJA,IAAI"}

View File

@@ -0,0 +1,28 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
class CssSyntaxError extends Error {
constructor(error){
super(error);
const { reason , line , column } = error;
this.name = "CssSyntaxError";
// Based on https://github.com/postcss/postcss/blob/master/lib/css-syntax-error.es6#L132
// We don't need `plugin` and `file` properties.
this.message = `${this.name}\n\n`;
if (typeof line !== "undefined") {
this.message += `(${line}:${column}) `;
}
this.message += `${reason}`;
const code = error.showSourceCode();
if (code) {
this.message += `\n\n${code}\n`;
}
// We don't need stack https://github.com/postcss/postcss/blob/master/docs/guidelines/runner.md#31-dont-show-js-stack-for-csssyntaxerror
this.stack = false;
}
}
exports.default = CssSyntaxError;
//# sourceMappingURL=CssSyntaxError.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../build/webpack/loaders/css-loader/src/CssSyntaxError.js"],"names":["CssSyntaxError","Error","constructor","error","reason","line","column","name","message","code","showSourceCode","stack"],"mappings":"AAAA;;;;;AAAe,MAAMA,cAAc,SAASC,KAAK;IAC/CC,YAAYC,KAAK,CAAE;QACjB,KAAK,CAACA,KAAK,CAAC;QAEZ,MAAM,EAAEC,MAAM,CAAA,EAAEC,IAAI,CAAA,EAAEC,MAAM,CAAA,EAAE,GAAGH,KAAK;QAEtC,IAAI,CAACI,IAAI,GAAG,gBAAgB;QAE5B,wFAAwF;QACxF,gDAAgD;QAChD,IAAI,CAACC,OAAO,GAAG,CAAC,EAAE,IAAI,CAACD,IAAI,CAAC,IAAI,CAAC;QAEjC,IAAI,OAAOF,IAAI,KAAK,WAAW,EAAE;YAC/B,IAAI,CAACG,OAAO,IAAI,CAAC,CAAC,EAAEH,IAAI,CAAC,CAAC,EAAEC,MAAM,CAAC,EAAE,CAAC;SACvC;QAED,IAAI,CAACE,OAAO,IAAI,CAAC,EAAEJ,MAAM,CAAC,CAAC;QAE3B,MAAMK,IAAI,GAAGN,KAAK,CAACO,cAAc,EAAE;QAEnC,IAAID,IAAI,EAAE;YACR,IAAI,CAACD,OAAO,IAAI,CAAC,IAAI,EAAEC,IAAI,CAAC,EAAE,CAAC;SAChC;QAED,wIAAwI;QACxI,IAAI,CAACE,KAAK,GAAG,KAAK;KACnB;CACF;kBA3BoBX,cAAc"}

View File

@@ -0,0 +1,85 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
/*
MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ const preserveCamelCase = (string, locale)=>{
let isLastCharLower = false;
let isLastCharUpper = false;
let isLastLastCharUpper = false;
for(let i = 0; i < string.length; i++){
const character = string[i];
if (isLastCharLower && /[\p{Lu}]/u.test(character)) {
string = string.slice(0, i) + "-" + string.slice(i);
isLastCharLower = false;
isLastLastCharUpper = isLastCharUpper;
isLastCharUpper = true;
i++;
} else if (isLastCharUpper && isLastLastCharUpper && /[\p{Ll}]/u.test(character)) {
string = string.slice(0, i - 1) + "-" + string.slice(i - 1);
isLastLastCharUpper = isLastCharUpper;
isLastCharUpper = false;
isLastCharLower = true;
} else {
isLastCharLower = character.toLocaleLowerCase(locale) === character && character.toLocaleUpperCase(locale) !== character;
isLastLastCharUpper = isLastCharUpper;
isLastCharUpper = character.toLocaleUpperCase(locale) === character && character.toLocaleLowerCase(locale) !== character;
}
}
return string;
};
const preserveConsecutiveUppercase = (input)=>{
return input.replace(/^[\p{Lu}](?![\p{Lu}])/gu, (m1)=>m1.toLowerCase());
};
const postProcess = (input, options)=>{
return input.replace(/[_.\- ]+([\p{Alpha}\p{N}_]|$)/gu, (_, p1)=>p1.toLocaleUpperCase(options.locale)).replace(/\d+([\p{Alpha}\p{N}_]|$)/gu, (m)=>m.toLocaleUpperCase(options.locale));
};
const camelCase = (input, options)=>{
if (!(typeof input === "string" || Array.isArray(input))) {
throw new TypeError("Expected the input to be `string | string[]`");
}
options = {
pascalCase: false,
preserveConsecutiveUppercase: false,
...options
};
if (Array.isArray(input)) {
input = input.map((x)=>x.trim()).filter((x)=>x.length).join("-");
} else {
input = input.trim();
}
if (input.length === 0) {
return "";
}
if (input.length === 1) {
return options.pascalCase ? input.toLocaleUpperCase(options.locale) : input.toLocaleLowerCase(options.locale);
}
const hasUpperCase = input !== input.toLocaleLowerCase(options.locale);
if (hasUpperCase) {
input = preserveCamelCase(input, options.locale);
}
input = input.replace(/^[_.\- ]+/, "");
if (options.preserveConsecutiveUppercase) {
input = preserveConsecutiveUppercase(input);
} else {
input = input.toLocaleLowerCase();
}
if (options.pascalCase) {
input = input.charAt(0).toLocaleUpperCase(options.locale) + input.slice(1);
}
return postProcess(input, options);
};
var _default = camelCase;
exports.default = _default;
//# sourceMappingURL=camelcase.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../build/webpack/loaders/css-loader/src/camelcase.js"],"names":["preserveCamelCase","string","locale","isLastCharLower","isLastCharUpper","isLastLastCharUpper","i","length","character","test","slice","toLocaleLowerCase","toLocaleUpperCase","preserveConsecutiveUppercase","input","replace","m1","toLowerCase","postProcess","options","_","p1","m","camelCase","Array","isArray","TypeError","pascalCase","map","x","trim","filter","join","hasUpperCase","charAt"],"mappings":"AAYA;;;;;AAZA;;;;;;;;;;EAUE,CAEF,MAAMA,iBAAiB,GAAG,CAACC,MAAM,EAAEC,MAAM,GAAK;IAC5C,IAAIC,eAAe,GAAG,KAAK;IAC3B,IAAIC,eAAe,GAAG,KAAK;IAC3B,IAAIC,mBAAmB,GAAG,KAAK;IAE/B,IAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGL,MAAM,CAACM,MAAM,EAAED,CAAC,EAAE,CAAE;QACtC,MAAME,SAAS,GAAGP,MAAM,CAACK,CAAC,CAAC;QAE3B,IAAIH,eAAe,IAAI,YAAYM,IAAI,CAACD,SAAS,CAAC,EAAE;YAClDP,MAAM,GAAGA,MAAM,CAACS,KAAK,CAAC,CAAC,EAAEJ,CAAC,CAAC,GAAG,GAAG,GAAGL,MAAM,CAACS,KAAK,CAACJ,CAAC,CAAC;YACnDH,eAAe,GAAG,KAAK;YACvBE,mBAAmB,GAAGD,eAAe;YACrCA,eAAe,GAAG,IAAI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Q,UAAU,EAAE;QACtBb,KAAK,GAAGA,KAAK,CAACoB,MAAM,CAAC,CAAC,CAAC,CAACtB,iBAAiB,CAACO,OAAO,CAACjB,MAAM,CAAC,GAAGY,KAAK,CAACJ,KAAK,CAAC,CAAC,CAAC;KAC3E;IAED,OAAOQ,WAAW,CAACJ,KAAK,EAAEK,OAAO,CAAC,CAAA;CACnC;eAEcI,SAAS"}

View File

@@ -0,0 +1,254 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = loader;
var _cssSyntaxError = _interopRequireDefault(require("./CssSyntaxError"));
var _warning = _interopRequireDefault(require("../../postcss-loader/src/Warning"));
var _stringifyRequest = require("../../../stringify-request");
async function loader(content, map, meta) {
const rawOptions = this.getOptions();
const plugins = [];
const callback = this.async();
const loaderSpan = this.currentTraceSpan.traceChild("css-loader");
loaderSpan.traceAsyncFn(async ()=>{
let options;
try {
options = normalizeOptions(rawOptions, this);
} catch (error) {
throw error;
}
const { postcss } = await rawOptions.postcss();
const { shouldUseModulesPlugins , shouldUseImportPlugin , shouldUseURLPlugin , shouldUseIcssPlugin , getPreRequester , getExportCode , getFilter , getImportCode , getModuleCode , getModulesPlugins , normalizeSourceMap , sort , } = require("./utils");
const { icssParser , importParser , urlParser } = require("./plugins");
const replacements = [];
// if it's a font loader next-font-loader will have exports that should be exported as is
const exports = options.fontLoader ? meta.exports : [];
if (shouldUseModulesPlugins(options)) {
plugins.push(...getModulesPlugins(options, this, meta));
}
const importPluginImports = [];
const importPluginApi = [];
if (shouldUseImportPlugin(options)) {
const resolver = this.getResolve({
conditionNames: [
"style"
],
extensions: [
".css"
],
mainFields: [
"css",
"style",
"main",
"..."
],
mainFiles: [
"index",
"..."
],
restrictions: [
/\.css$/i
]
});
plugins.push(importParser({
imports: importPluginImports,
api: importPluginApi,
context: this.context,
rootContext: this.rootContext,
filter: getFilter(options.import, this.resourcePath),
resolver,
urlHandler: (url)=>(0, _stringifyRequest).stringifyRequest(this, getPreRequester(this)(options.importLoaders) + url)
}));
}
const urlPluginImports = [];
if (shouldUseURLPlugin(options)) {
const urlResolver = this.getResolve({
conditionNames: [
"asset"
],
mainFields: [
"asset"
],
mainFiles: [],
extensions: []
});
plugins.push(urlParser({
imports: urlPluginImports,
replacements,
context: this.context,
rootContext: this.rootContext,
filter: getFilter(options.url, this.resourcePath),
resolver: urlResolver,
urlHandler: (url)=>(0, _stringifyRequest).stringifyRequest(this, url)
}));
}
const icssPluginImports = [];
const icssPluginApi = [];
if (shouldUseIcssPlugin(options)) {
const icssResolver = this.getResolve({
conditionNames: [
"style"
],
extensions: [],
mainFields: [
"css",
"style",
"main",
"..."
],
mainFiles: [
"index",
"..."
]
});
plugins.push(icssParser({
imports: icssPluginImports,
api: icssPluginApi,
replacements,
exports,
context: this.context,
rootContext: this.rootContext,
resolver: icssResolver,
urlHandler: (url)=>(0, _stringifyRequest).stringifyRequest(this, getPreRequester(this)(options.importLoaders) + url)
}));
}
// Reuse CSS AST (PostCSS AST e.g 'postcss-loader') to avoid reparsing
if (meta) {
const { ast } = meta;
if (ast && ast.type === "postcss") {
// eslint-disable-next-line no-param-reassign
content = ast.root;
loaderSpan.setAttribute("astUsed", "true");
}
}
const { resourcePath } = this;
let result;
try {
result = await postcss(plugins).process(content, {
from: resourcePath,
to: resourcePath,
map: options.sourceMap ? {
prev: map ? normalizeSourceMap(map, resourcePath) : null,
inline: false,
annotation: false
} : false
});
} catch (error1) {
if (error1.file) {
this.addDependency(error1.file);
}
throw error1.name === "CssSyntaxError" ? new _cssSyntaxError.default(error1) : error1;
}
for (const warning of result.warnings()){
this.emitWarning(new _warning.default(warning));
}
const imports = [].concat(icssPluginImports.sort(sort)).concat(importPluginImports.sort(sort)).concat(urlPluginImports.sort(sort));
const api = [].concat(importPluginApi.sort(sort)).concat(icssPluginApi.sort(sort));
if (options.modules.exportOnlyLocals !== true) {
imports.unshift({
importName: "___CSS_LOADER_API_IMPORT___",
url: (0, _stringifyRequest).stringifyRequest(this, require.resolve("./runtime/api"))
});
}
const importCode = getImportCode(imports, options);
const moduleCode = getModuleCode(result, api, replacements, options, this);
const exportCode = getExportCode(exports, replacements, options);
return `${importCode}${moduleCode}${exportCode}`;
}).then((code)=>{
callback(null, code);
}, (err)=>{
callback(err);
});
}
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
const moduleRegExp = /\.module\.\w+$/i;
function getModulesOptions(rawOptions, loaderContext) {
const { resourcePath } = loaderContext;
if (typeof rawOptions.modules === "undefined") {
const isModules = moduleRegExp.test(resourcePath);
if (!isModules) {
return false;
}
} else if (typeof rawOptions.modules === "boolean" && rawOptions.modules === false) {
return false;
}
let modulesOptions = {
compileType: rawOptions.icss ? "icss" : "module",
auto: true,
mode: "local",
exportGlobals: false,
localIdentName: "[hash:base64]",
localIdentContext: loaderContext.rootContext,
localIdentHashPrefix: "",
// eslint-disable-next-line no-undefined
localIdentRegExp: undefined,
namedExport: false,
exportLocalsConvention: "asIs",
exportOnlyLocals: false
};
if (typeof rawOptions.modules === "boolean" || typeof rawOptions.modules === "string") {
modulesOptions.mode = typeof rawOptions.modules === "string" ? rawOptions.modules : "local";
} else {
if (rawOptions.modules) {
if (typeof rawOptions.modules.auto === "boolean") {
const isModules = rawOptions.modules.auto && moduleRegExp.test(resourcePath);
if (!isModules) {
return false;
}
} else if (rawOptions.modules.auto instanceof RegExp) {
const isModules = rawOptions.modules.auto.test(resourcePath);
if (!isModules) {
return false;
}
} else if (typeof rawOptions.modules.auto === "function") {
const isModule = rawOptions.modules.auto(resourcePath);
if (!isModule) {
return false;
}
}
if (rawOptions.modules.namedExport === true && typeof rawOptions.modules.exportLocalsConvention === "undefined") {
modulesOptions.exportLocalsConvention = "camelCaseOnly";
}
}
modulesOptions = {
...modulesOptions,
...rawOptions.modules || {}
};
}
if (typeof modulesOptions.mode === "function") {
modulesOptions.mode = modulesOptions.mode(loaderContext.resourcePath);
}
if (modulesOptions.namedExport === true) {
if (rawOptions.esModule === false) {
throw new Error('The "modules.namedExport" option requires the "esModules" option to be enabled');
}
if (modulesOptions.exportLocalsConvention !== "camelCaseOnly") {
throw new Error('The "modules.namedExport" option requires the "modules.exportLocalsConvention" option to be "camelCaseOnly"');
}
}
return modulesOptions;
}
function normalizeOptions(rawOptions, loaderContext) {
if (rawOptions.icss) {
loaderContext.emitWarning(new Error('The "icss" option is deprecated, use "modules.compileType: "icss"" instead'));
}
const modulesOptions = getModulesOptions(rawOptions, loaderContext);
return {
url: typeof rawOptions.url === "undefined" ? true : rawOptions.url,
import: typeof rawOptions.import === "undefined" ? true : rawOptions.import,
modules: modulesOptions,
// TODO remove in the next major release
icss: typeof rawOptions.icss === "undefined" ? false : rawOptions.icss,
sourceMap: typeof rawOptions.sourceMap === "boolean" ? rawOptions.sourceMap : loaderContext.sourceMap,
importLoaders: typeof rawOptions.importLoaders === "string" ? parseInt(rawOptions.importLoaders, 10) : rawOptions.importLoaders,
esModule: typeof rawOptions.esModule === "undefined" ? true : rawOptions.esModule,
fontLoader: rawOptions.fontLoader
};
}
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,32 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "importParser", {
enumerable: true,
get: function() {
return _postcssImportParser.default;
}
});
Object.defineProperty(exports, "icssParser", {
enumerable: true,
get: function() {
return _postcssIcssParser.default;
}
});
Object.defineProperty(exports, "urlParser", {
enumerable: true,
get: function() {
return _postcssUrlParser.default;
}
});
var _postcssImportParser = _interopRequireDefault(require("./postcss-import-parser"));
var _postcssIcssParser = _interopRequireDefault(require("./postcss-icss-parser"));
var _postcssUrlParser = _interopRequireDefault(require("./postcss-url-parser"));
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../../build/webpack/loaders/css-loader/src/plugins/index.js"],"names":["importParser","icssParser","urlParser"],"mappings":"AAAA;;;;+BAISA,cAAY;;;eAAZA,oBAAY,QAAA;;;+BAAEC,YAAU;;;eAAVA,kBAAU,QAAA;;;+BAAEC,WAAS;;;eAATA,iBAAS,QAAA;;;AAJnB,IAAA,oBAAyB,kCAAzB,yBAAyB,EAAA;AAC3B,IAAA,kBAAuB,kCAAvB,uBAAuB,EAAA;AACxB,IAAA,iBAAsB,kCAAtB,sBAAsB,EAAA"}

View File

@@ -0,0 +1,103 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _icssUtils = require("next/dist/compiled/icss-utils");
var _utils = require("../utils");
const plugin = (options = {})=>{
return {
postcssPlugin: "postcss-icss-parser",
async OnceExit (root) {
const importReplacements = Object.create(null);
const { icssImports , icssExports } = (0, _icssUtils).extractICSS(root);
const imports = new Map();
const tasks = [];
// eslint-disable-next-line guard-for-in
for(const url in icssImports){
const tokens = icssImports[url];
if (Object.keys(tokens).length === 0) {
continue;
}
let normalizedUrl = url;
let prefix = "";
const queryParts = normalizedUrl.split("!");
if (queryParts.length > 1) {
normalizedUrl = queryParts.pop();
prefix = queryParts.join("!");
}
const request = (0, _utils).requestify((0, _utils).normalizeUrl(normalizedUrl, true), options.rootContext);
const doResolve = async ()=>{
const { resolver , context } = options;
const resolvedUrl = await (0, _utils).resolveRequests(resolver, context, [
...new Set([
normalizedUrl,
request
]),
]);
if (!resolvedUrl) {
return;
}
// eslint-disable-next-line consistent-return
return {
url: resolvedUrl,
prefix,
tokens
};
};
tasks.push(doResolve());
}
const results = await Promise.all(tasks);
for(let index = 0; index <= results.length - 1; index++){
const item = results[index];
if (!item) {
continue;
}
const newUrl = item.prefix ? `${item.prefix}!${item.url}` : item.url;
const importKey = newUrl;
let importName = imports.get(importKey);
if (!importName) {
importName = `___CSS_LOADER_ICSS_IMPORT_${imports.size}___`;
imports.set(importKey, importName);
options.imports.push({
type: "icss_import",
importName,
url: options.urlHandler(newUrl),
icss: true,
index
});
options.api.push({
importName,
dedupe: true,
index
});
}
for (const [replacementIndex, token] of Object.keys(item.tokens).entries()){
const replacementName = `___CSS_LOADER_ICSS_IMPORT_${index}_REPLACEMENT_${replacementIndex}___`;
const localName = item.tokens[token];
importReplacements[token] = replacementName;
options.replacements.push({
replacementName,
importName,
localName
});
}
}
if (Object.keys(importReplacements).length > 0) {
(0, _icssUtils).replaceSymbols(root, importReplacements);
}
for (const name of Object.keys(icssExports)){
const value = (0, _icssUtils).replaceValueSymbols(icssExports[name], importReplacements);
options.exports.push({
name,
value
});
}
}
};
};
plugin.postcss = true;
var _default = plugin;
exports.default = _default;
//# sourceMappingURL=postcss-icss-parser.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../../build/webpack/loaders/css-loader/src/plugins/postcss-icss-parser.js"],"names":["plugin","options","postcssPlugin","OnceExit","root","importReplacements","Object","create","icssImports","icssExports","extractICSS","imports","Map","tasks","url","tokens","keys","length","normalizedUrl","prefix","queryParts","split","pop","join","request","requestify","normalizeUrl","rootContext","doResolve","resolver","context","resolvedUrl","resolveRequests","Set","push","results","Promise","all","index","item","newUrl","importKey","importName","get","size","set","type","urlHandler","icss","api","dedupe","replacementIndex","token","entries","replacementName","localName","replacements","replaceSymbols","name","value","replaceValueSymbols","exports","postcss"],"mappings":"AAAA;;;;;AAIO,IAAA,UAA+B,WAA/B,+BAA+B,CAAA;AAEoB,IAAA,MAAU,WAAV,UAAU,CAAA;AAEpE,MAAMA,MAAM,GAAG,CAACC,OAAO,GAAG,EAAE,GAAK;IAC/B,OAAO;QACLC,aAAa,EAAE,qBAAqB;QACpC,MAAMC,QAAQ,EAACC,IAAI,EAAE;YACnB,MAAMC,kBAAkB,GAAGC,MAAM,CAACC,MAAM,CAAC,IAAI,CAAC;YAC9C,MAAM,EAAEC,WAAW,CAAA,EAAEC,WAAW,CAAA,EAAE,GAAGC,CAAAA,GAAAA,UAAW,AAAM,CAAA,YAAN,CAACN,IAAI,CAAC;YACtD,MAAMO,OAAO,GAAG,IAAIC,GAAG,EA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AC,0BAA0B,EAAEhB,KAAK,CAAC,aAAa,EAAEa,gBAAgB,CAAC,GAAG,CAAC;oBAC/F,MAAMI,SAAS,GAAGhB,IAAI,CAACxB,MAAM,CAACqC,KAAK,CAAC;oBAEpC/C,kBAAkB,CAAC+C,KAAK,CAAC,GAAGE,eAAe;oBAE3CrD,OAAO,CAACuD,YAAY,CAACtB,IAAI,CAAC;wBAAEoB,eAAe;wBAAEZ,UAAU;wBAAEa,SAAS;qBAAE,CAAC;iBACtE;aACF;YAED,IAAIjD,MAAM,CAACU,IAAI,CAACX,kBAAkB,CAAC,CAACY,MAAM,GAAG,CAAC,EAAE;gBAC9CwC,CAAAA,GAAAA,UAAc,AAA0B,CAAA,eAA1B,CAACrD,IAAI,EAAEC,kBAAkB,CAAC;aACzC;YAED,KAAK,MAAMqD,IAAI,IAAIpD,MAAM,CAACU,IAAI,CAACP,WAAW,CAAC,CAAE;gBAC3C,MAAMkD,KAAK,GAAGC,CAAAA,GAAAA,UAAmB,AAAuC,CAAA,oBAAvC,CAACnD,WAAW,CAACiD,IAAI,CAAC,EAAErD,kBAAkB,CAAC;gBAExEJ,OAAO,CAAC4D,OAAO,CAAC3B,IAAI,CAAC;oBAAEwB,IAAI;oBAAEC,KAAK;iBAAE,CAAC;aACtC;SACF;KACF,CAAA;CACF;AAED3D,MAAM,CAAC8D,OAAO,GAAG,IAAI;eAEN9D,MAAM"}

View File

@@ -0,0 +1,202 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _postcssValueParser = _interopRequireDefault(require("next/dist/compiled/postcss-value-parser"));
var _utils = require("../utils");
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
function parseNode(atRule, key) {
// Convert only top-level @import
if (atRule.parent.type !== "root") {
return;
}
if (atRule.raws && atRule.raws.afterName && atRule.raws.afterName.trim().length > 0) {
const lastCommentIndex = atRule.raws.afterName.lastIndexOf("/*");
const matched = atRule.raws.afterName.slice(lastCommentIndex).match(_utils.WEBPACK_IGNORE_COMMENT_REGEXP);
if (matched && matched[2] === "true") {
return;
}
}
const prevNode = atRule.prev();
if (prevNode && prevNode.type === "comment") {
const matched = prevNode.text.match(_utils.WEBPACK_IGNORE_COMMENT_REGEXP);
if (matched && matched[2] === "true") {
return;
}
}
// Nodes do not exists - `@import url('http://') :root {}`
if (atRule.nodes) {
const error = new Error("It looks like you didn't end your @import statement correctly. Child nodes are attached to it.");
error.node = atRule;
throw error;
}
const { nodes: paramsNodes } = (0, _postcssValueParser).default(atRule[key]);
// No nodes - `@import ;`
// Invalid type - `@import foo-bar;`
if (paramsNodes.length === 0 || paramsNodes[0].type !== "string" && paramsNodes[0].type !== "function") {
const error = new Error(`Unable to find uri in "${atRule.toString()}"`);
error.node = atRule;
throw error;
}
let isStringValue;
let url;
if (paramsNodes[0].type === "string") {
isStringValue = true;
url = paramsNodes[0].value;
} else {
// Invalid function - `@import nourl(test.css);`
if (paramsNodes[0].value.toLowerCase() !== "url") {
const error = new Error(`Unable to find uri in "${atRule.toString()}"`);
error.node = atRule;
throw error;
}
isStringValue = paramsNodes[0].nodes.length !== 0 && paramsNodes[0].nodes[0].type === "string";
url = isStringValue ? paramsNodes[0].nodes[0].value : _postcssValueParser.default.stringify(paramsNodes[0].nodes);
}
url = (0, _utils).normalizeUrl(url, isStringValue);
const isRequestable = (0, _utils).isUrlRequestable(url);
let prefix;
if (isRequestable) {
const queryParts = url.split("!");
if (queryParts.length > 1) {
url = queryParts.pop();
prefix = queryParts.join("!");
}
}
// Empty url - `@import "";` or `@import url();`
if (url.trim().length === 0) {
const error = new Error(`Unable to find uri in "${atRule.toString()}"`);
error.node = atRule;
throw error;
}
const mediaNodes = paramsNodes.slice(1);
let media;
if (mediaNodes.length > 0) {
media = _postcssValueParser.default.stringify(mediaNodes).trim().toLowerCase();
}
// eslint-disable-next-line consistent-return
return {
atRule,
prefix,
url,
media,
isRequestable
};
}
const plugin = (options = {})=>{
return {
postcssPlugin: "postcss-import-parser",
prepare (result) {
const parsedAtRules = [];
return {
AtRule: {
import (atRule) {
let parsedAtRule;
try {
parsedAtRule = parseNode(atRule, "params", result);
} catch (error) {
result.warn(error.message, {
node: error.node
});
}
if (!parsedAtRule) {
return;
}
parsedAtRules.push(parsedAtRule);
}
},
async OnceExit () {
if (parsedAtRules.length === 0) {
return;
}
const resolvedAtRules = await Promise.all(parsedAtRules.map(async (parsedAtRule)=>{
const { atRule , isRequestable , prefix , url , media } = parsedAtRule;
if (options.filter) {
const needKeep = await options.filter(url, media);
if (!needKeep) {
return;
}
}
if (isRequestable) {
const request = (0, _utils).requestify(url, options.rootContext);
const { resolver , context } = options;
const resolvedUrl = await (0, _utils).resolveRequests(resolver, context, [
...new Set([
request,
url
]),
]);
if (!resolvedUrl) {
return;
}
if (resolvedUrl === options.resourcePath) {
atRule.remove();
return;
}
atRule.remove();
// eslint-disable-next-line consistent-return
return {
url: resolvedUrl,
media,
prefix,
isRequestable
};
}
atRule.remove();
// eslint-disable-next-line consistent-return
return {
url,
media,
prefix,
isRequestable
};
}));
const urlToNameMap = new Map();
for(let index = 0; index <= resolvedAtRules.length - 1; index++){
const resolvedAtRule = resolvedAtRules[index];
if (!resolvedAtRule) {
continue;
}
const { url , isRequestable , media } = resolvedAtRule;
if (!isRequestable) {
options.api.push({
url,
media,
index
});
continue;
}
const { prefix } = resolvedAtRule;
const newUrl = prefix ? `${prefix}!${url}` : url;
let importName = urlToNameMap.get(newUrl);
if (!importName) {
importName = `___CSS_LOADER_AT_RULE_IMPORT_${urlToNameMap.size}___`;
urlToNameMap.set(newUrl, importName);
options.imports.push({
type: "rule_import",
importName,
url: options.urlHandler(newUrl),
index
});
}
options.api.push({
importName,
media,
index
});
}
}
};
}
};
};
plugin.postcss = true;
var _default = plugin;
exports.default = _default;
//# sourceMappingURL=postcss-import-parser.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,323 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _postcssValueParser = _interopRequireDefault(require("next/dist/compiled/postcss-value-parser"));
var _utils = require("../utils");
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
const isUrlFunc = /url/i;
const isImageSetFunc = /^(?:-webkit-)?image-set$/i;
const needParseDeclaration = /(?:url|(?:-webkit-)?image-set)\(/i;
function getNodeFromUrlFunc(node) {
return node.nodes && node.nodes[0];
}
function getWebpackIgnoreCommentValue(index, nodes, inBetween) {
if (index === 0 && typeof inBetween !== "undefined") {
return inBetween;
}
let prevValueNode = nodes[index - 1];
if (!prevValueNode) {
// eslint-disable-next-line consistent-return
return;
}
if (prevValueNode.type === "space") {
if (!nodes[index - 2]) {
// eslint-disable-next-line consistent-return
return;
}
prevValueNode = nodes[index - 2];
}
if (prevValueNode.type !== "comment") {
// eslint-disable-next-line consistent-return
return;
}
const matched = prevValueNode.value.match(_utils.WEBPACK_IGNORE_COMMENT_REGEXP);
return matched && matched[2] === "true";
}
function shouldHandleURL(url, declaration, result, isSupportDataURLInNewURL) {
if (url.length === 0) {
result.warn(`Unable to find uri in '${declaration.toString()}'`, {
node: declaration
});
return false;
}
if ((0, _utils).isDataUrl(url) && isSupportDataURLInNewURL) {
try {
decodeURIComponent(url);
} catch (ignoreError) {
return false;
}
return true;
}
if (!(0, _utils).isUrlRequestable(url)) {
return false;
}
return true;
}
function parseDeclaration(declaration, key, result, isSupportDataURLInNewURL) {
if (!needParseDeclaration.test(declaration[key])) {
return;
}
const parsed = (0, _postcssValueParser).default(declaration.raws && declaration.raws.value && declaration.raws.value.raw ? declaration.raws.value.raw : declaration[key]);
let inBetween;
if (declaration.raws && declaration.raws.between) {
const lastCommentIndex = declaration.raws.between.lastIndexOf("/*");
const matched = declaration.raws.between.slice(lastCommentIndex).match(_utils.WEBPACK_IGNORE_COMMENT_REGEXP);
if (matched) {
inBetween = matched[2] === "true";
}
}
let isIgnoreOnDeclaration = false;
const prevNode = declaration.prev();
if (prevNode && prevNode.type === "comment") {
const matched = prevNode.text.match(_utils.WEBPACK_IGNORE_COMMENT_REGEXP);
if (matched) {
isIgnoreOnDeclaration = matched[2] === "true";
}
}
let needIgnore;
const parsedURLs = [];
parsed.walk((valueNode, index, valueNodes)=>{
if (valueNode.type !== "function") {
return;
}
if (isUrlFunc.test(valueNode.value)) {
needIgnore = getWebpackIgnoreCommentValue(index, valueNodes, inBetween);
if (isIgnoreOnDeclaration && typeof needIgnore === "undefined" || needIgnore) {
if (needIgnore) {
// eslint-disable-next-line no-undefined
needIgnore = undefined;
}
return;
}
const { nodes } = valueNode;
const isStringValue = nodes.length !== 0 && nodes[0].type === "string";
let url = isStringValue ? nodes[0].value : _postcssValueParser.default.stringify(nodes);
url = (0, _utils).normalizeUrl(url, isStringValue);
// Do not traverse inside `url`
if (!shouldHandleURL(url, declaration, result, isSupportDataURLInNewURL)) {
// eslint-disable-next-line consistent-return
return false;
}
const queryParts = url.split("!");
let prefix;
if (queryParts.length > 1) {
url = queryParts.pop();
prefix = queryParts.join("!");
}
parsedURLs.push({
declaration,
parsed,
node: getNodeFromUrlFunc(valueNode),
prefix,
url,
needQuotes: false
});
// eslint-disable-next-line consistent-return
return false;
} else if (isImageSetFunc.test(valueNode.value)) {
for (const [innerIndex, nNode] of valueNode.nodes.entries()){
const { type , value } = nNode;
if (type === "function" && isUrlFunc.test(value)) {
needIgnore = getWebpackIgnoreCommentValue(innerIndex, valueNode.nodes);
if (isIgnoreOnDeclaration && typeof needIgnore === "undefined" || needIgnore) {
if (needIgnore) {
// eslint-disable-next-line no-undefined
needIgnore = undefined;
}
continue;
}
const { nodes } = nNode;
const isStringValue = nodes.length !== 0 && nodes[0].type === "string";
let url = isStringValue ? nodes[0].value : _postcssValueParser.default.stringify(nodes);
url = (0, _utils).normalizeUrl(url, isStringValue);
// Do not traverse inside `url`
if (!shouldHandleURL(url, declaration, result, isSupportDataURLInNewURL)) {
// eslint-disable-next-line consistent-return
return false;
}
const queryParts = url.split("!");
let prefix;
if (queryParts.length > 1) {
url = queryParts.pop();
prefix = queryParts.join("!");
}
parsedURLs.push({
declaration,
parsed,
node: getNodeFromUrlFunc(nNode),
prefix,
url,
needQuotes: false
});
} else if (type === "string") {
needIgnore = getWebpackIgnoreCommentValue(innerIndex, valueNode.nodes);
if (isIgnoreOnDeclaration && typeof needIgnore === "undefined" || needIgnore) {
if (needIgnore) {
// eslint-disable-next-line no-undefined
needIgnore = undefined;
}
continue;
}
let url = (0, _utils).normalizeUrl(value, true);
// Do not traverse inside `url`
if (!shouldHandleURL(url, declaration, result, isSupportDataURLInNewURL)) {
// eslint-disable-next-line consistent-return
return false;
}
const queryParts = url.split("!");
let prefix;
if (queryParts.length > 1) {
url = queryParts.pop();
prefix = queryParts.join("!");
}
parsedURLs.push({
declaration,
parsed,
node: nNode,
prefix,
url,
needQuotes: true
});
}
}
// Do not traverse inside `image-set`
// eslint-disable-next-line consistent-return
return false;
}
});
// eslint-disable-next-line consistent-return
return parsedURLs;
}
const plugin = (options = {})=>{
return {
postcssPlugin: "postcss-url-parser",
prepare (result) {
const parsedDeclarations = [];
return {
Declaration (declaration) {
const { isSupportDataURLInNewURL } = options;
const parsedURL = parseDeclaration(declaration, "value", result, isSupportDataURLInNewURL);
if (!parsedURL) {
return;
}
parsedDeclarations.push(...parsedURL);
},
async OnceExit () {
if (parsedDeclarations.length === 0) {
return;
}
const resolvedDeclarations = await Promise.all(parsedDeclarations.map(async (parsedDeclaration)=>{
const { url } = parsedDeclaration;
if (options.filter) {
const needKeep = await options.filter(url);
if (!needKeep) {
// eslint-disable-next-line consistent-return
return;
}
}
if ((0, _utils).isDataUrl(url)) {
// eslint-disable-next-line consistent-return
return parsedDeclaration;
}
const splittedUrl = url.split(/(\?)?#/);
const [pathname, query, hashOrQuery] = splittedUrl;
let hash = query ? "?" : "";
hash += hashOrQuery ? `#${hashOrQuery}` : "";
const { needToResolveURL , rootContext } = options;
const request = (0, _utils).requestify(pathname, rootContext, needToResolveURL);
if (!needToResolveURL) {
// eslint-disable-next-line consistent-return
return {
...parsedDeclaration,
url: request,
hash
};
}
const { resolver , context } = options;
const resolvedUrl = await (0, _utils).resolveRequests(resolver, context, [
...new Set([
request,
url
]),
]);
if (!resolvedUrl) {
// eslint-disable-next-line consistent-return
return;
}
// eslint-disable-next-line consistent-return
return {
...parsedDeclaration,
url: resolvedUrl,
hash
};
}));
const urlToNameMap = new Map();
const urlToReplacementMap = new Map();
let hasUrlImportHelper = false;
for(let index = 0; index <= resolvedDeclarations.length - 1; index++){
const item = resolvedDeclarations[index];
if (!item) {
continue;
}
if (!hasUrlImportHelper) {
options.imports.push({
type: "get_url_import",
importName: "___CSS_LOADER_GET_URL_IMPORT___",
url: options.urlHandler(require.resolve("../runtime/getUrl.js")),
index: -1
});
hasUrlImportHelper = true;
}
const { url , prefix } = item;
const newUrl = prefix ? `${prefix}!${url}` : url;
let importName = urlToNameMap.get(newUrl);
if (!importName) {
importName = `___CSS_LOADER_URL_IMPORT_${urlToNameMap.size}___`;
urlToNameMap.set(newUrl, importName);
options.imports.push({
type: "url",
importName,
url: options.needToResolveURL ? options.urlHandler(newUrl) : JSON.stringify(newUrl),
index
});
}
const { hash , needQuotes } = item;
const replacementKey = JSON.stringify({
newUrl,
hash,
needQuotes
});
let replacementName = urlToReplacementMap.get(replacementKey);
if (!replacementName) {
replacementName = `___CSS_LOADER_URL_REPLACEMENT_${urlToReplacementMap.size}___`;
urlToReplacementMap.set(replacementKey, replacementName);
options.replacements.push({
replacementName,
importName,
hash,
needQuotes
});
}
// eslint-disable-next-line no-param-reassign
item.node.type = "word";
// eslint-disable-next-line no-param-reassign
item.node.value = replacementName;
// eslint-disable-next-line no-param-reassign
item.declaration.value = item.parsed.toString();
}
}
};
}
};
};
plugin.postcss = true;
var _default = plugin;
exports.default = _default;
//# sourceMappingURL=postcss-url-parser.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,88 @@
"use strict";
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/ // css base code, injected by the css-loader
// eslint-disable-next-line func-names
module.exports = function(useSourceMap) {
var list = [] // return the list of modules as css string
;
list.toString = function toString() {
return this.map(function(item) {
var content = cssWithMappingToString(item, useSourceMap);
if (item[2]) {
return "@media ".concat(item[2], " {").concat(content, "}");
}
return content;
}).join("");
} // import a list of modules into the list
;
// eslint-disable-next-line func-names
list.i = function(modules, mediaQuery, dedupe) {
if (typeof modules === "string") {
// eslint-disable-next-line no-param-reassign
modules = [
[
null,
modules,
""
]
];
}
var alreadyImportedModules = {};
if (dedupe) {
for(var i = 0; i < this.length; i++){
// eslint-disable-next-line prefer-destructuring
var id = this[i][0];
if (id != null) {
alreadyImportedModules[id] = true;
}
}
}
for(var _i = 0; _i < modules.length; _i++){
var item = [].concat(modules[_i]);
if (dedupe && alreadyImportedModules[item[0]]) {
continue;
}
if (mediaQuery) {
if (!item[2]) {
item[2] = mediaQuery;
} else {
item[2] = "".concat(mediaQuery, " and ").concat(item[2]);
}
}
list.push(item);
}
};
return list;
};
function cssWithMappingToString(item, useSourceMap) {
var content = item[1] || "" // eslint-disable-next-line prefer-destructuring
;
var cssMapping = item[3];
if (!cssMapping) {
return content;
}
if (useSourceMap && typeof btoa === "function") {
var sourceMapping = toComment(cssMapping);
var sourceURLs = cssMapping.sources.map(function(source) {
return "/*# sourceURL=".concat(cssMapping.sourceRoot || "").concat(source, " */");
});
return [
content
].concat(sourceURLs).concat([
sourceMapping
]).join("\n");
}
return [
content
].join("\n");
} // Adapted from convert-source-map (MIT)
function toComment(sourceMap) {
// eslint-disable-next-line no-undef
var base64 = btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap))));
var data = "sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(base64);
return "/*# ".concat(data, " */");
}
//# sourceMappingURL=api.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../../build/webpack/loaders/css-loader/src/runtime/api.js"],"names":["module","exports","useSourceMap","list","toString","map","item","content","cssWithMappingToString","concat","join","i","modules","mediaQuery","dedupe","alreadyImportedModules","length","id","_i","push","cssMapping","btoa","sourceMapping","toComment","sourceURLs","sources","source","sourceRoot","sourceMap","base64","unescape","encodeURIComponent","JSON","stringify","data"],"mappings":"AAMAA;AANA;;;EAGE,CACF,4CAA4C;AAC5C,sCAAsC;AACtCA,MAAM,CAACC,OAAO,GAAG,SAAUC,YAAY,EAAE;IACvC,IAAIC,IAAI,GAAG,EAAE,CAAC,2CAA2C;IAA5C;IAEbA,IAAI,CAACC,QAAQ,GAAG,SAASA,QAAQ,GAAG;QAClC,OAAO,IAAI,CAACC,GAAG,CAAC,SAAUC,IAAI,EAAE;YAC9B,IAAIC,OAAO,GAAGC,sBAAsB,CAACF,IAAI,EAAEJ,YAAY,CAAC;YAExD,IAAII,IAAI,CAAC,CAAC,CAAC,EAAE;gBACX,OAAO,SAAS,CAACG,MAAM,CAACH,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAACG,MAAM,CAACF,OAAO,EAAE,GAAG,CAAC,CAAA;aAC5D;YAED,OAAOA,OAAO,CAAA;SACf,CAAC,CAACG,IAAI,CAAC,EAAE,CAAC,CAAA;KACZ,CAAC,yCAAyC;IAA1C;IACD,sCAAsC;IAEtCP,IAAI,CAACQ,CAAC,GAAG,SAAUC,OAAO,EAAEC,UAAU,EAAEC,MAAM,EAAE;QAC9C,IAAI,OAAOF,OAAO,KAAK,QAAQ,EAAE;YAC/B,6CAA6C;YAC7CA,OAAO,GAAG;gBAAC;oBAAC,IAAI;oBAAEA,OAAO;oBAAE,EAAE;iBAAC;aAAC;SAChC;QAED,IAAIG,sBAAsB,GAAG,EAAE;QAE/B,IAAID,MAAM,EAAE;YACV,IAAK,IAAIH,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAG,IAAI,CAACK,MAAM,EAAEL,CAAC,EAAE,CAAE;gBACpC,gDAAgD;gBAChD,IAAIM,EAAE,GAAG,IAAI,CAACN,CAAC,CAAC,CAAC,CAAC,CAAC;gBAEnB,IAAIM,EA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EAAE,CAAC,CACnClB,MAAM,CAACiB,MAAM,EAAE,KAAK,CAAC,CAAA;SACzB,CAAC;QACF,OAAO;YAACnB,OAAO;SAAC,CAACE,MAAM,CAACe,UAAU,CAAC,CAACf,MAAM,CAAC;YAACa,aAAa;SAAC,CAAC,CAACZ,IAAI,CAAC,IAAI,CAAC,CAAA;KACvE;IAED,OAAO;QAACH,OAAO;KAAC,CAACG,IAAI,CAAC,IAAI,CAAC,CAAA;CAC5B,CAAC,wCAAwC;AAE1C,SAASa,SAAS,CAACK,SAAS,EAAE;IAC5B,oCAAoC;IACpC,IAAIC,MAAM,GAAGR,IAAI,CAACS,QAAQ,CAACC,kBAAkB,CAACC,IAAI,CAACC,SAAS,CAACL,SAAS,CAAC,CAAC,CAAC,CAAC;IAC1E,IAAIM,IAAI,GACN,8DAA8D,CAACzB,MAAM,CACnEoB,MAAM,CACP;IACH,OAAO,MAAM,CAACpB,MAAM,CAACyB,IAAI,EAAE,KAAK,CAAC,CAAA;CAClC"}

View File

@@ -0,0 +1,26 @@
"use strict";
module.exports = function(url, options) {
if (!options) {
// eslint-disable-next-line no-param-reassign
options = {};
} // eslint-disable-next-line no-underscore-dangle, no-param-reassign
url = url && url.__esModule ? url.default : url;
if (typeof url !== "string") {
return url;
} // If url is already wrapped in quotes, remove them
if (/^['"].*['"]$/.test(url)) {
// eslint-disable-next-line no-param-reassign
url = url.slice(1, -1);
}
if (options.hash) {
// eslint-disable-next-line no-param-reassign
url += options.hash;
} // Should url be wrapped?
// See https://drafts.csswg.org/css-values-3/#urls
if (/["'() \t\n]/.test(url) || options.needQuotes) {
return '"'.concat(url.replace(/"/g, '\\"').replace(/\n/g, "\\n"), '"');
}
return url;
};
//# sourceMappingURL=getUrl.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../../build/webpack/loaders/css-loader/src/runtime/getUrl.js"],"names":["module","exports","url","options","__esModule","default","test","slice","hash","needQuotes","concat","replace"],"mappings":"AAAAA;AAAAA,MAAM,CAACC,OAAO,GAAG,SAAUC,GAAG,EAAEC,OAAO,EAAE;IACvC,IAAI,CAACA,OAAO,EAAE;QACZ,6CAA6C;QAC7CA,OAAO,GAAG,EAAE;KACb,CAAC,mEAAmE;IAErED,GAAG,GAAGA,GAAG,IAAIA,GAAG,CAACE,UAAU,GAAGF,GAAG,CAACG,OAAO,GAAGH,GAAG;IAE/C,IAAI,OAAOA,GAAG,KAAK,QAAQ,EAAE;QAC3B,OAAOA,GAAG,CAAA;KACX,CAAC,mDAAmD;IAErD,IAAI,eAAeI,IAAI,CAACJ,GAAG,CAAC,EAAE;QAC5B,6CAA6C;QAC7CA,GAAG,GAAGA,GAAG,CAACK,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;KACvB;IAED,IAAIJ,OAAO,CAACK,IAAI,EAAE;QAChB,6CAA6C;QAC7CN,GAAG,IAAIC,OAAO,CAACK,IAAI;KACpB,CAAC,yBAAyB;IAC3B,kDAAkD;IAElD,IAAI,cAAcF,IAAI,CAACJ,GAAG,CAAC,IAAIC,OAAO,CAACM,UAAU,EAAE;QACjD,OAAO,GAAG,CAACC,MAAM,CAACR,GAAG,CAACS,OAAO,OAAO,KAAK,CAAC,CAACA,OAAO,QAAQ,KAAK,CAAC,EAAE,GAAG,CAAC,CAAA;KACvE;IAED,OAAOT,GAAG,CAAA;CACX"}

View File

@@ -0,0 +1,387 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.isDataUrl = exports.sort = exports.isUrlRequestable = exports.resolveRequests = exports.getExportCode = exports.getModuleCode = exports.getImportCode = exports.getPreRequester = exports.normalizeSourceMap = exports.getModulesPlugins = exports.shouldUseIcssPlugin = exports.shouldUseModulesPlugins = exports.shouldUseURLPlugin = exports.shouldUseImportPlugin = exports.getFilter = exports.requestify = exports.normalizeUrl = void 0;
var _url = require("url");
var _path = _interopRequireDefault(require("path"));
var _loaderUtils3 = require("next/dist/compiled/loader-utils3");
var _postcssModulesValues = _interopRequireDefault(require("next/dist/compiled/postcss-modules-values"));
var _postcssModulesLocalByDefault = _interopRequireDefault(require("next/dist/compiled/postcss-modules-local-by-default"));
var _postcssModulesExtractImports = _interopRequireDefault(require("next/dist/compiled/postcss-modules-extract-imports"));
var _postcssModulesScope = _interopRequireDefault(require("next/dist/compiled/postcss-modules-scope"));
var _camelcase = _interopRequireDefault(require("./camelcase"));
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
const whitespace = "[\\x20\\t\\r\\n\\f]";
const unescapeRegExp = new RegExp(`\\\\([\\da-f]{1,6}${whitespace}?|(${whitespace})|.)`, "ig");
const matchNativeWin32Path = /^[A-Z]:[/\\]|^\\\\/i;
function unescape(str) {
return str.replace(unescapeRegExp, (_, escaped, escapedWhitespace)=>{
const high = `0x${escaped}` - 0x10000;
/* eslint-disable line-comment-position */ // NaN means non-codepoint
// Workaround erroneous numeric interpretation of +"0x"
// eslint-disable-next-line no-self-compare
return high !== high || escapedWhitespace ? escaped : high < 0 ? String.fromCharCode(high + 0x10000) : // eslint-disable-next-line no-bitwise
String.fromCharCode(high >> 10 | 0xd800, high & 0x3ff | 0xdc00);
/* eslint-enable line-comment-position */ });
}
function normalizePath(file) {
return _path.default.sep === "\\" ? file.replace(/\\/g, "/") : file;
}
function fixedEncodeURIComponent(str) {
return str.replace(/[!'()*]/g, (c)=>`%${c.charCodeAt(0).toString(16)}`);
}
function normalizeUrl(url, isStringValue) {
let normalizedUrl = url;
if (isStringValue && /\\(\n|\r\n|\r|\f)/.test(normalizedUrl)) {
normalizedUrl = normalizedUrl.replace(/\\(\n|\r\n|\r|\f)/g, "");
}
if (matchNativeWin32Path.test(url)) {
try {
normalizedUrl = decodeURIComponent(normalizedUrl);
} catch (error) {
// Ignores invalid and broken URLs and try to resolve them as is
}
return normalizedUrl;
}
normalizedUrl = unescape(normalizedUrl);
if (isDataUrl(url)) {
return fixedEncodeURIComponent(normalizedUrl);
}
try {
normalizedUrl = decodeURI(normalizedUrl);
} catch (error) {
// Ignores invalid and broken URLs and try to resolve them as is
}
return normalizedUrl;
}
function requestify(url, rootContext) {
if (/^file:/i.test(url)) {
return (0, _url).fileURLToPath(url);
}
if (/^[a-z][a-z0-9+.-]*:/i.test(url)) {
return url;
}
return url.charAt(0) === "/" ? (0, _loaderUtils3).urlToRequest(url, rootContext) : (0, _loaderUtils3).urlToRequest(url);
}
function getFilter(filter, resourcePath) {
return (...args)=>{
if (typeof filter === "function") {
return filter(...args, resourcePath);
}
return true;
};
}
function shouldUseImportPlugin(options) {
if (options.modules.exportOnlyLocals) {
return false;
}
if (typeof options.import === "boolean") {
return options.import;
}
return true;
}
function shouldUseURLPlugin(options) {
if (options.modules.exportOnlyLocals) {
return false;
}
if (typeof options.url === "boolean") {
return options.url;
}
return true;
}
function shouldUseModulesPlugins(options) {
return options.modules.compileType === "module";
}
function shouldUseIcssPlugin(options) {
return options.icss === true || Boolean(options.modules);
}
function getModulesPlugins(options, loaderContext, meta) {
const { mode , getLocalIdent , localIdentName , localIdentContext , localIdentHashPrefix , localIdentRegExp , } = options.modules;
let plugins = [];
try {
plugins = [
_postcssModulesValues.default,
(0, _postcssModulesLocalByDefault).default({
mode
}),
(0, _postcssModulesExtractImports).default(),
(0, _postcssModulesScope).default({
generateScopedName (exportName) {
return getLocalIdent(loaderContext, localIdentName, exportName, {
context: localIdentContext,
hashPrefix: localIdentHashPrefix,
regExp: localIdentRegExp
}, meta);
},
exportGlobals: options.modules.exportGlobals
}),
];
} catch (error) {
loaderContext.emitError(error);
}
return plugins;
}
const IS_NATIVE_WIN32_PATH = /^[a-z]:[/\\]|^\\\\/i;
const ABSOLUTE_SCHEME = /^[a-z0-9+\-.]+:/i;
function getURLType(source) {
if (source[0] === "/") {
if (source[1] === "/") {
return "scheme-relative";
}
return "path-absolute";
}
if (IS_NATIVE_WIN32_PATH.test(source)) {
return "path-absolute";
}
return ABSOLUTE_SCHEME.test(source) ? "absolute" : "path-relative";
}
function normalizeSourceMap(map, resourcePath) {
let newMap = map;
// Some loader emit source map as string
// Strip any JSON XSSI avoidance prefix from the string (as documented in the source maps specification), and then parse the string as JSON.
if (typeof newMap === "string") {
newMap = JSON.parse(newMap);
}
delete newMap.file;
const { sourceRoot } = newMap;
delete newMap.sourceRoot;
if (newMap.sources) {
// Source maps should use forward slash because it is URLs (https://github.com/mozilla/source-map/issues/91)
// We should normalize path because previous loaders like `sass-loader` using backslash when generate source map
newMap.sources = newMap.sources.map((source)=>{
// Non-standard syntax from `postcss`
if (source.indexOf("<") === 0) {
return source;
}
const sourceType = getURLType(source);
// Do no touch `scheme-relative` and `absolute` URLs
if (sourceType === "path-relative" || sourceType === "path-absolute") {
const absoluteSource = sourceType === "path-relative" && sourceRoot ? _path.default.resolve(sourceRoot, normalizePath(source)) : normalizePath(source);
return _path.default.relative(_path.default.dirname(resourcePath), absoluteSource);
}
return source;
});
}
return newMap;
}
function getPreRequester({ loaders , loaderIndex }) {
const cache = Object.create(null);
return (number)=>{
if (cache[number]) {
return cache[number];
}
if (number === false) {
cache[number] = "";
} else {
const loadersRequest = loaders.slice(loaderIndex, loaderIndex + 1 + (typeof number !== "number" ? 0 : number)).map((x)=>x.request).join("!");
cache[number] = `-!${loadersRequest}!`;
}
return cache[number];
};
}
function getImportCode(imports, options) {
let code = "";
for (const item of imports){
const { importName , url , icss } = item;
if (options.esModule) {
if (icss && options.modules.namedExport) {
code += `import ${options.modules.exportOnlyLocals ? "" : `${importName}, `}* as ${importName}_NAMED___ from ${url};\n`;
} else {
code += `import ${importName} from ${url};\n`;
}
} else {
code += `var ${importName} = require(${url});\n`;
}
}
return code ? `// Imports\n${code}` : "";
}
function normalizeSourceMapForRuntime(map, loaderContext) {
const resultMap = map ? map.toJSON() : null;
if (resultMap) {
delete resultMap.file;
resultMap.sourceRoot = "";
resultMap.sources = resultMap.sources.map((source)=>{
// Non-standard syntax from `postcss`
if (source.indexOf("<") === 0) {
return source;
}
const sourceType = getURLType(source);
if (sourceType !== "path-relative") {
return source;
}
const resourceDirname = _path.default.dirname(loaderContext.resourcePath);
const absoluteSource = _path.default.resolve(resourceDirname, source);
const contextifyPath = normalizePath(_path.default.relative(loaderContext.rootContext, absoluteSource));
return `webpack://${contextifyPath}`;
});
}
return JSON.stringify(resultMap);
}
function getModuleCode(result, api, replacements, options, loaderContext) {
if (options.modules.exportOnlyLocals === true) {
return "";
}
const sourceMapValue = options.sourceMap ? `,${normalizeSourceMapForRuntime(result.map, loaderContext)}` : "";
let code = JSON.stringify(result.css);
let beforeCode = `var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(${options.sourceMap});\n`;
for (const item of api){
const { url , media , dedupe } = item;
beforeCode += url ? `___CSS_LOADER_EXPORT___.push([module.id, ${JSON.stringify(`@import url(${url});`)}${media ? `, ${JSON.stringify(media)}` : ""}]);\n` : `___CSS_LOADER_EXPORT___.i(${item.importName}${media ? `, ${JSON.stringify(media)}` : dedupe ? ', ""' : ""}${dedupe ? ", true" : ""});\n`;
}
for (const item1 of replacements){
const { replacementName , importName , localName } = item1;
if (localName) {
code = code.replace(new RegExp(replacementName, "g"), ()=>options.modules.namedExport ? `" + ${importName}_NAMED___[${JSON.stringify((0, _camelcase).default(localName))}] + "` : `" + ${importName}.locals[${JSON.stringify(localName)}] + "`);
} else {
const { hash , needQuotes } = item1;
const getUrlOptions = [].concat(hash ? [
`hash: ${JSON.stringify(hash)}`
] : []).concat(needQuotes ? "needQuotes: true" : []);
const preparedOptions = getUrlOptions.length > 0 ? `, { ${getUrlOptions.join(", ")} }` : "";
beforeCode += `var ${replacementName} = ___CSS_LOADER_GET_URL_IMPORT___(${importName}${preparedOptions});\n`;
code = code.replace(new RegExp(replacementName, "g"), ()=>`" + ${replacementName} + "`);
}
}
return `${beforeCode}// Module\n___CSS_LOADER_EXPORT___.push([module.id, ${code}, ""${sourceMapValue}]);\n`;
}
function dashesCamelCase(str) {
return str.replace(/-+(\w)/g, (match, firstLetter)=>firstLetter.toUpperCase());
}
function getExportCode(exports, replacements, options) {
let code = "// Exports\n";
let localsCode = "";
const addExportToLocalsCode = (name, value)=>{
if (options.modules.namedExport) {
localsCode += `export const ${(0, _camelcase).default(name)} = ${JSON.stringify(value)};\n`;
} else {
if (localsCode) {
localsCode += `,\n`;
}
localsCode += `\t${JSON.stringify(name)}: ${JSON.stringify(value)}`;
}
};
for (const { name: name1 , value: value1 } of exports){
switch(options.modules.exportLocalsConvention){
case "camelCase":
{
addExportToLocalsCode(name1, value1);
const modifiedName = (0, _camelcase).default(name1);
if (modifiedName !== name1) {
addExportToLocalsCode(modifiedName, value1);
}
break;
}
case "camelCaseOnly":
{
addExportToLocalsCode((0, _camelcase).default(name1), value1);
break;
}
case "dashes":
{
addExportToLocalsCode(name1, value1);
const modifiedName = dashesCamelCase(name1);
if (modifiedName !== name1) {
addExportToLocalsCode(modifiedName, value1);
}
break;
}
case "dashesOnly":
{
addExportToLocalsCode(dashesCamelCase(name1), value1);
break;
}
case "asIs":
default:
addExportToLocalsCode(name1, value1);
break;
}
}
for (const item of replacements){
const { replacementName , localName } = item;
if (localName) {
const { importName } = item;
localsCode = localsCode.replace(new RegExp(replacementName, "g"), ()=>{
if (options.modules.namedExport) {
return `" + ${importName}_NAMED___[${JSON.stringify((0, _camelcase).default(localName))}] + "`;
} else if (options.modules.exportOnlyLocals) {
return `" + ${importName}[${JSON.stringify(localName)}] + "`;
}
return `" + ${importName}.locals[${JSON.stringify(localName)}] + "`;
});
} else {
localsCode = localsCode.replace(new RegExp(replacementName, "g"), ()=>`" + ${replacementName} + "`);
}
}
if (options.modules.exportOnlyLocals) {
code += options.modules.namedExport ? localsCode : `${options.esModule ? "export default" : "module.exports ="} {\n${localsCode}\n};\n`;
return code;
}
if (localsCode) {
code += options.modules.namedExport ? localsCode : `___CSS_LOADER_EXPORT___.locals = {\n${localsCode}\n};\n`;
}
code += `${options.esModule ? "export default" : "module.exports ="} ___CSS_LOADER_EXPORT___;\n`;
return code;
}
async function resolveRequests(resolve, context, possibleRequests) {
return resolve(context, possibleRequests[0]).then((result)=>{
return result;
}).catch((error)=>{
const [, ...tailPossibleRequests] = possibleRequests;
if (tailPossibleRequests.length === 0) {
throw error;
}
return resolveRequests(resolve, context, tailPossibleRequests);
});
}
function isUrlRequestable(url) {
// Protocol-relative URLs
if (/^\/\//.test(url)) {
return false;
}
// `file:` protocol
if (/^file:/i.test(url)) {
return true;
}
// Absolute URLs
if (/^[a-z][a-z0-9+.-]*:/i.test(url)) {
return true;
}
// `#` URLs
if (/^#/.test(url)) {
return false;
}
return true;
}
function sort(a, b) {
return a.index - b.index;
}
function isDataUrl(url) {
if (/^data:/i.test(url)) {
return true;
}
return false;
}
exports.normalizeUrl = normalizeUrl;
exports.requestify = requestify;
exports.getFilter = getFilter;
exports.shouldUseImportPlugin = shouldUseImportPlugin;
exports.shouldUseURLPlugin = shouldUseURLPlugin;
exports.shouldUseModulesPlugins = shouldUseModulesPlugins;
exports.shouldUseIcssPlugin = shouldUseIcssPlugin;
exports.getModulesPlugins = getModulesPlugins;
exports.normalizeSourceMap = normalizeSourceMap;
exports.getPreRequester = getPreRequester;
exports.getImportCode = getImportCode;
exports.getModuleCode = getModuleCode;
exports.getExportCode = getExportCode;
exports.resolveRequests = resolveRequests;
exports.isUrlRequestable = isUrlRequestable;
exports.sort = sort;
exports.isDataUrl = isDataUrl;
//# sourceMappingURL=utils.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,3 @@
import { webpack } from 'next/dist/compiled/webpack/webpack';
declare const ErrorLoader: webpack.LoaderDefinitionFunction;
export default ErrorLoader;

View File

@@ -0,0 +1,28 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _chalk = _interopRequireDefault(require("next/dist/compiled/chalk"));
var _path = _interopRequireDefault(require("path"));
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
const ErrorLoader = function() {
var ref, ref1, ref2;
// @ts-ignore exists
const options = this.getOptions() || {};
const { reason ="An unknown error has occurred" } = options;
// @ts-expect-error
const resource = ((ref = this._module) == null ? void 0 : (ref1 = ref.issuer) == null ? void 0 : ref1.resource) ?? null;
const context = this.rootContext ?? ((ref2 = this._compiler) == null ? void 0 : ref2.context);
const issuer = resource ? context ? _path.default.relative(context, resource) : resource : null;
const err = new Error(reason + (issuer ? `\nLocation: ${_chalk.default.cyan(issuer)}` : ""));
this.emitError(err);
};
var _default = ErrorLoader;
exports.default = _default;
//# sourceMappingURL=error-loader.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../build/webpack/loaders/error-loader.ts"],"names":["ErrorLoader","options","getOptions","reason","resource","_module","issuer","context","rootContext","_compiler","path","relative","err","Error","chalk","cyan","emitError"],"mappings":"AAAA;;;;;AAAkB,IAAA,MAA0B,kCAA1B,0BAA0B,EAAA;AAC3B,IAAA,KAAM,kCAAN,MAAM,EAAA;;;;;;AAGvB,MAAMA,WAAW,GAAqC,WAAY;QAO/C,GAAY,QACO,IAAc;IAPlD,oBAAoB;IACpB,MAAMC,OAAO,GAAG,IAAI,CAACC,UAAU,EAAE,IAAK,EAAE,AAAQ;IAEhD,MAAM,EAAEC,MAAM,EAAG,+BAA+B,CAAA,EAAE,GAAGF,OAAO;IAE5D,mBAAmB;IACnB,MAAMG,QAAQ,GAAG,CAAA,CAAA,GAAY,GAAZ,IAAI,CAACC,OAAO,SAAQ,GAApB,KAAA,CAAoB,GAApB,QAAA,GAAY,CAAEC,MAAM,SAAA,GAApB,KAAA,CAAoB,QAAEF,QAAQ,AAAV,CAAA,IAAc,IAAI;IACvD,MAAMG,OAAO,GAAG,IAAI,CAACC,WAAW,IAAI,CAAA,CAAA,IAAc,GAAd,IAAI,CAACC,SAAS,SAAS,GAAvB,KAAA,CAAuB,GAAvB,IAAc,CAAEF,OAAO,CAAA;IAE3D,MAAMD,MAAM,GAAGF,QAAQ,GACnBG,OAAO,GACLG,KAAI,QAAA,CAACC,QAAQ,CAACJ,OAAO,EAAEH,QAAQ,CAAC,GAChCA,QAAQ,GACV,IAAI;IAER,MAAMQ,GAAG,GAAG,IAAIC,KAAK,CACnBV,MAAM,GAAG,CAACG,MAAM,GAAG,CAAC,YAAY,EAAEQ,MAAK,QAAA,CAACC,IAAI,CAACT,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAC7D;IACD,IAAI,CAACU,SAAS,CAACJ,GAAG,CAAC;CACpB;eAEcZ,WAAW"}

View File

@@ -0,0 +1,40 @@
import type { MiddlewareMatcher, RSCModuleType } from '../../analysis/get-page-static-info';
import { webpack } from 'next/dist/compiled/webpack/webpack';
/**
* A getter for module build info that casts to the type it should have.
* We also expose here types to make easier to use it.
*/
export declare function getModuleBuildInfo(webpackModule: webpack.Module): {
nextEdgeMiddleware?: EdgeMiddlewareMeta | undefined;
nextEdgeApiFunction?: EdgeMiddlewareMeta | undefined;
nextEdgeSSR?: EdgeSSRMeta | undefined;
nextUsedEnvVars?: Set<string> | undefined;
nextWasmMiddlewareBinding?: AssetBinding | undefined;
nextAssetMiddlewareBinding?: AssetBinding | undefined;
usingIndirectEval?: boolean | Set<string> | undefined;
route?: RouteMeta | undefined;
importLocByPath?: Map<string, any> | undefined;
rootDir?: string | undefined;
rsc?: RSCMeta | undefined;
};
export interface RSCMeta {
type?: RSCModuleType;
requests?: string[];
}
export interface RouteMeta {
page: string;
absolutePagePath: string;
}
export interface EdgeMiddlewareMeta {
page: string;
matchers?: MiddlewareMatcher[];
}
export interface EdgeSSRMeta {
isServerComponent: boolean;
isAppDir?: boolean;
page: string;
}
export interface AssetBinding {
filePath: string;
name: string;
}

View File

@@ -0,0 +1,10 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getModuleBuildInfo = getModuleBuildInfo;
function getModuleBuildInfo(webpackModule) {
return webpackModule.buildInfo;
}
//# sourceMappingURL=get-module-build-info.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../build/webpack/loaders/get-module-build-info.ts"],"names":["getModuleBuildInfo","webpackModule","buildInfo"],"mappings":"AAAA;;;;QAUgBA,kBAAkB,GAAlBA,kBAAkB;AAA3B,SAASA,kBAAkB,CAACC,aAA6B,EAAE;IAChE,OAAOA,aAAa,CAACC,SAAS,CAY7B;CACF"}

View File

@@ -0,0 +1,28 @@
import type webpack from 'webpack';
import type { ValueOf } from '../../../shared/lib/constants';
declare const FILE_TYPES: {
readonly layout: "layout";
readonly template: "template";
readonly error: "error";
readonly loading: "loading";
readonly head: "head";
readonly 'not-found': "not-found";
};
declare type ComponentModule = () => any;
declare type ModuleReference = [componentModule: ComponentModule, filePath: string];
export declare type ComponentsType = {
readonly [componentKey in ValueOf<typeof FILE_TYPES>]?: ModuleReference;
} & {
readonly page?: ModuleReference;
};
declare const nextAppLoader: webpack.LoaderDefinitionFunction<{
name: string;
pagePath: string;
appDir: string;
appPaths: string[] | null;
pageExtensions: string[];
rootDir?: string;
tsconfigPath?: string;
isDev?: boolean;
}>;
export default nextAppLoader;

View File

@@ -0,0 +1,241 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _chalk = _interopRequireDefault(require("next/dist/compiled/chalk"));
var _webpackConfig = require("../../webpack-config");
var _getModuleBuildInfo = require("./get-module-build-info");
var _path = require("path");
var _verifyRootLayout = require("../../../lib/verifyRootLayout");
var Log = _interopRequireWildcard(require("../../../build/output/log"));
var _constants = require("../../../lib/constants");
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 FILE_TYPES = {
layout: "layout",
template: "template",
error: "error",
loading: "loading",
head: "head",
"not-found": "not-found"
};
const GLOBAL_ERROR_FILE_TYPE = "global-error";
const PAGE_SEGMENT = "page$";
async function createTreeCodeFromPath({ pagePath , resolve , resolveParallelSegments }) {
const splittedPath = pagePath.split(/[\\/]/);
const appDirPrefix = splittedPath[0];
const pages = [];
let rootLayout;
let globalError;
async function createSubtreePropsFromSegmentPath(segments) {
const segmentPath = segments.join("/");
// Existing tree are the children of the current segment
const props = {};
// We need to resolve all parallel routes in this level.
const parallelSegments = [];
if (segments.length === 0) {
parallelSegments.push([
"children",
""
]);
} else {
parallelSegments.push(...resolveParallelSegments(segmentPath));
}
for (const [parallelKey, parallelSegment] of parallelSegments){
if (parallelSegment === PAGE_SEGMENT) {
const matchedPagePath = `${appDirPrefix}${segmentPath}/page`;
const resolvedPagePath = await resolve(matchedPagePath);
if (resolvedPagePath) pages.push(resolvedPagePath);
// Use '' for segment as it's the page. There can't be a segment called '' so this is the safest way to add it.
props[parallelKey] = `['', {}, {
page: [() => import(/* webpackMode: "eager" */ ${JSON.stringify(resolvedPagePath)}), ${JSON.stringify(resolvedPagePath)}]}]`;
continue;
}
const parallelSegmentPath = segmentPath + "/" + parallelSegment;
const subtree = await createSubtreePropsFromSegmentPath([
...segments,
parallelSegment,
]);
// `page` is not included here as it's added above.
const filePaths = await Promise.all(Object.values(FILE_TYPES).map(async (file)=>{
return [
file,
await resolve(`${appDirPrefix}${parallelSegmentPath}/${file}`),
];
}));
if (!rootLayout) {
var ref;
rootLayout = (ref = filePaths.find(([type, path])=>type === "layout" && !!path)) == null ? void 0 : ref[1];
}
if (!globalError) {
globalError = await resolve(`${appDirPrefix}${parallelSegmentPath}/${GLOBAL_ERROR_FILE_TYPE}`);
}
props[parallelKey] = `[
'${parallelSegment}',
${subtree},
{
${filePaths.filter(([, filePath])=>filePath !== undefined).map(([file, filePath])=>{
if (filePath === undefined) {
return "";
}
return `'${file}': [() => import(/* webpackMode: "eager" */ ${JSON.stringify(filePath)}), ${JSON.stringify(filePath)}],`;
}).join("\n")}
}
]`;
}
return `{
${Object.entries(props).map(([key, value])=>`${key}: ${value}`).join(",\n")}
}`;
}
const tree = await createSubtreePropsFromSegmentPath([]);
return [
`const tree = ${tree}.children;`,
pages,
rootLayout,
globalError
];
}
function createAbsolutePath(appDir, pathToTurnAbsolute) {
return pathToTurnAbsolute// Replace all POSIX path separators with the current OS path separator
.replace(/\//g, _path.sep).replace(/^private-next-app-dir/, appDir);
}
const nextAppLoader = async function nextAppLoader() {
const { name , appDir , appPaths , pagePath , pageExtensions , rootDir , tsconfigPath , isDev , } = this.getOptions() || {};
const buildInfo = (0, _getModuleBuildInfo).getModuleBuildInfo(this._module);
buildInfo.route = {
page: name.replace(/^app/, ""),
absolutePagePath: createAbsolutePath(appDir, pagePath)
};
const extensions = pageExtensions.map((extension)=>`.${extension}`);
const resolveOptions = {
..._webpackConfig.NODE_RESOLVE_OPTIONS,
extensions
};
const resolve = this.getResolve(resolveOptions);
const normalizedAppPaths = typeof appPaths === "string" ? [
appPaths
] : appPaths || [];
const resolveParallelSegments = (pathname)=>{
const matched = {};
for (const path of normalizedAppPaths){
if (path.startsWith(pathname + "/")) {
const rest = path.slice(pathname.length + 1).split("/");
let matchedSegment = rest[0];
// It is the actual page, mark it sepcially.
if (rest.length === 1 && matchedSegment === "page") {
matchedSegment = PAGE_SEGMENT;
}
const matchedKey = matchedSegment.startsWith("@") ? matchedSegment.slice(1) : "children";
matched[matchedKey] = matchedSegment;
}
}
return Object.entries(matched);
};
const resolver = async (pathname)=>{
try {
const resolved = await resolve(this.rootContext, pathname);
this.addDependency(resolved);
return resolved;
} catch (err) {
const absolutePath = createAbsolutePath(appDir, pathname);
for (const ext of extensions){
const absolutePathWithExtension = `${absolutePath}${ext}`;
this.addMissingDependency(absolutePathWithExtension);
}
if (err.message.includes("Can't resolve")) {
return undefined;
}
throw err;
}
};
const [treeCode, pages, rootLayout, globalError] = await createTreeCodeFromPath({
pagePath,
resolve: resolver,
resolveParallelSegments
});
if (!rootLayout) {
const errorMessage = `${_chalk.default.bold(pagePath.replace(`${_constants.APP_DIR_ALIAS}/`, ""))} doesn't have a root layout. To fix this error, make sure every page has a root layout.`;
if (!isDev) {
// If we're building and missing a root layout, exit the build
Log.error(errorMessage);
process.exit(1);
} else {
// In dev we'll try to create a root layout
const createdRootLayout = await (0, _verifyRootLayout).verifyRootLayout({
appDir: appDir,
dir: rootDir,
tsconfigPath: tsconfigPath,
pagePath,
pageExtensions
});
if (!createdRootLayout) {
throw new Error(errorMessage);
}
}
}
const result = `
export ${treeCode}
export const pages = ${JSON.stringify(pages)}
export { default as AppRouter } from 'next/dist/client/components/app-router'
export { default as LayoutRouter } from 'next/dist/client/components/layout-router'
export { default as RenderFromTemplateContext } from 'next/dist/client/components/render-from-template-context'
export { default as GlobalError } from ${JSON.stringify(globalError || "next/dist/client/components/error-boundary")}
export { staticGenerationAsyncStorage } from 'next/dist/client/components/static-generation-async-storage'
export { requestAsyncStorage } from 'next/dist/client/components/request-async-storage'
export * as serverHooks from 'next/dist/client/components/hooks-server-context'
export { renderToReadableStream } from 'next/dist/compiled/react-server-dom-webpack/server.browser'
export const __next_app_webpack_require__ = __webpack_require__
`;
return result;
};
var _default = nextAppLoader;
exports.default = _default;
//# sourceMappingURL=next-app-loader.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,6 @@
export declare type ClientPagesLoaderOptions = {
absolutePagePath: string;
page: string;
};
declare function nextClientPagesLoader(this: any): any;
export default nextClientPagesLoader;

View File

@@ -0,0 +1,33 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _stringifyRequest = require("../stringify-request");
// this parameter: https://www.typescriptlang.org/docs/handbook/functions.html#this-parameters
function nextClientPagesLoader() {
const pagesLoaderSpan = this.currentTraceSpan.traceChild("next-client-pages-loader");
return pagesLoaderSpan.traceFn(()=>{
const { absolutePagePath , page } = this.getOptions();
pagesLoaderSpan.setAttribute("absolutePagePath", absolutePagePath);
const stringifiedPageRequest = (0, _stringifyRequest).stringifyRequest(this, absolutePagePath);
const stringifiedPage = JSON.stringify(page);
return `
(window.__NEXT_P = window.__NEXT_P || []).push([
${stringifiedPage},
function () {
return require(${stringifiedPageRequest});
}
]);
if(module.hot) {
module.hot.dispose(function () {
window.__NEXT_P.push([${stringifiedPage}])
});
}
`;
});
}
var _default = nextClientPagesLoader;
exports.default = _default;
//# sourceMappingURL=next-client-pages-loader.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../build/webpack/loaders/next-client-pages-loader.ts"],"names":["nextClientPagesLoader","pagesLoaderSpan","currentTraceSpan","traceChild","traceFn","absolutePagePath","page","getOptions","setAttribute","stringifiedPageRequest","stringifyRequest","stringifiedPage","JSON","stringify"],"mappings":"AAAA;;;;;AAAiC,IAAA,iBAAsB,WAAtB,sBAAsB,CAAA;AAOvD,8FAA8F;AAC9F,SAASA,qBAAqB,GAAY;IACxC,MAAMC,eAAe,GAAG,IAAI,CAACC,gBAAgB,CAACC,UAAU,CACtD,0BAA0B,CAC3B;IAED,OAAOF,eAAe,CAACG,OAAO,CAAC,IAAM;QACnC,MAAM,EAAEC,gBAAgB,CAAA,EAAEC,IAAI,CAAA,EAAE,GAC9B,IAAI,CAACC,UAAU,EAAE,AAA4B;QAE/CN,eAAe,CAACO,YAAY,CAAC,kBAAkB,EAAEH,gBAAgB,CAAC;QAElE,MAAMI,sBAAsB,GAAGC,CAAAA,GAAAA,iBAAgB,AAAwB,CAAA,iBAAxB,CAAC,IAAI,EAAEL,gBAAgB,CAAC;QACvE,MAAMM,eAAe,GAAGC,IAAI,CAACC,SAAS,CAACP,IAAI,CAAC;QAE5C,OAAO,CAAC;;MAEN,EAAEK,eAAe,CAAC;;uBAED,EAAEF,sBAAsB,CAAC;;;;;8BAKlB,EAAEE,eAAe,CAAC;;;EAG9C,CAAC,CAAA;KACA,CAAC,CAAA;CACH;eAEcX,qBAAqB"}

View File

@@ -0,0 +1,6 @@
export declare type EdgeFunctionLoaderOptions = {
absolutePagePath: string;
page: string;
rootDir: string;
};
export default function middlewareLoader(this: any): string;

View File

@@ -0,0 +1,38 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = middlewareLoader;
var _getModuleBuildInfo = require("./get-module-build-info");
var _stringifyRequest = require("../stringify-request");
function middlewareLoader() {
const { absolutePagePath , page , rootDir } = this.getOptions();
const stringifiedPagePath = (0, _stringifyRequest).stringifyRequest(this, absolutePagePath);
const buildInfo = (0, _getModuleBuildInfo).getModuleBuildInfo(this._module);
buildInfo.nextEdgeApiFunction = {
page: page || "/"
};
buildInfo.rootDir = rootDir;
return `
import { adapter, enhanceGlobals } from 'next/dist/esm/server/web/adapter'
enhanceGlobals()
var mod = require(${stringifiedPagePath})
var handler = mod.middleware || mod.default;
if (typeof handler !== 'function') {
throw new Error('The Edge Function "pages${page}" must export a \`default\` function');
}
export default function (opts) {
return adapter({
...opts,
page: ${JSON.stringify(page)},
handler,
})
}
`;
}
//# sourceMappingURL=next-edge-function-loader.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../build/webpack/loaders/next-edge-function-loader.ts"],"names":["middlewareLoader","absolutePagePath","page","rootDir","getOptions","stringifiedPagePath","stringifyRequest","buildInfo","getModuleBuildInfo","_module","nextEdgeApiFunction","JSON","stringify"],"mappings":"AAAA;;;;kBASwBA,gBAAgB;AATL,IAAA,mBAAyB,WAAzB,yBAAyB,CAAA;AAC3B,IAAA,iBAAsB,WAAtB,sBAAsB,CAAA;AAQxC,SAASA,gBAAgB,GAAY;IAClD,MAAM,EAAEC,gBAAgB,CAAA,EAAEC,IAAI,CAAA,EAAEC,OAAO,CAAA,EAAE,GACvC,IAAI,CAACC,UAAU,EAAE;IACnB,MAAMC,mBAAmB,GAAGC,CAAAA,GAAAA,iBAAgB,AAAwB,CAAA,iBAAxB,CAAC,IAAI,EAAEL,gBAAgB,CAAC;IACpE,MAAMM,SAAS,GAAGC,CAAAA,GAAAA,mBAAkB,AAAc,CAAA,mBAAd,CAAC,IAAI,CAACC,OAAO,CAAC;IAClDF,SAAS,CAACG,mBAAmB,GAAG;QAC9BR,IAAI,EAAEA,IAAI,IAAI,GAAG;KAClB;IACDK,SAAS,CAACJ,OAAO,GAAGA,OAAO;IAE3B,OAAO,CAAC;;;;;0BAKgB,EAAEE,mBAAmB,CAAC;;;;mDAIG,EAAEH,IAAI,CAAC;;;;;;oBAMtC,EAAES,IAAI,CAACC,SAAS,CAACV,IAAI,CAAC,CAAC;;;;IAIvC,CAAC,CAAA;CACJ"}

View File

@@ -0,0 +1,17 @@
export declare type EdgeSSRLoaderQuery = {
absolute500Path: string;
absoluteAppPath: string;
absoluteDocumentPath: string;
absoluteErrorPath: string;
absolutePagePath: string;
buildId: string;
dev: boolean;
isServerComponent: boolean;
page: string;
stringifiedConfig: string;
appDirLoader?: string;
pagesType: 'app' | 'pages' | 'root';
sriEnabled: boolean;
hasFontLoaders: boolean;
};
export default function edgeSSRLoader(this: any): Promise<string>;

View File

@@ -0,0 +1,102 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = edgeSSRLoader;
var _getModuleBuildInfo = require("../get-module-build-info");
var _stringifyRequest = require("../../stringify-request");
async function edgeSSRLoader() {
const { dev , page , buildId , absolutePagePath , absoluteAppPath , absoluteDocumentPath , absolute500Path , absoluteErrorPath , isServerComponent , stringifiedConfig , appDirLoader: appDirLoaderBase64 , pagesType , sriEnabled , hasFontLoaders , } = this.getOptions();
const appDirLoader = Buffer.from(appDirLoaderBase64 || "", "base64").toString();
const isAppDir = pagesType === "app";
const buildInfo = (0, _getModuleBuildInfo).getModuleBuildInfo(this._module);
buildInfo.nextEdgeSSR = {
isServerComponent: isServerComponent === "true",
page: page,
isAppDir
};
buildInfo.route = {
page,
absolutePagePath
};
const stringifiedPagePath = (0, _stringifyRequest).stringifyRequest(this, absolutePagePath);
const stringifiedAppPath = (0, _stringifyRequest).stringifyRequest(this, swapDistFolderWithEsmDistFolder(absoluteAppPath));
const stringifiedErrorPath = (0, _stringifyRequest).stringifyRequest(this, swapDistFolderWithEsmDistFolder(absoluteErrorPath));
const stringifiedDocumentPath = (0, _stringifyRequest).stringifyRequest(this, swapDistFolderWithEsmDistFolder(absoluteDocumentPath));
const stringified500Path = absolute500Path ? (0, _stringifyRequest).stringifyRequest(this, absolute500Path) : null;
const pageModPath = `${appDirLoader}${stringifiedPagePath.substring(1, stringifiedPagePath.length - 1)}${isAppDir ? "?__edge_ssr_entry__" : ""}`;
const transformed = `
import { adapter, enhanceGlobals } from 'next/dist/esm/server/web/adapter'
import { getRender } from 'next/dist/esm/build/webpack/loaders/next-edge-ssr-loader/render'
enhanceGlobals()
const pageType = ${JSON.stringify(pagesType)}
${isAppDir ? `
import { renderToHTMLOrFlight as appRenderToHTML } from 'next/dist/esm/server/app-render'
import * as pageMod from ${JSON.stringify(pageModPath)}
const Document = null
const pagesRenderToHTML = null
const appMod = null
const errorMod = null
const error500Mod = null
` : `
import Document from ${stringifiedDocumentPath}
import { renderToHTML as pagesRenderToHTML } from 'next/dist/esm/server/render'
import * as pageMod from ${stringifiedPagePath}
import * as appMod from ${stringifiedAppPath}
import * as errorMod from ${stringifiedErrorPath}
${stringified500Path ? `import * as error500Mod from ${stringified500Path}` : `const error500Mod = null`}
const appRenderToHTML = null
`}
const buildManifest = self.__BUILD_MANIFEST
const reactLoadableManifest = self.__REACT_LOADABLE_MANIFEST
const rscManifest = self.__RSC_MANIFEST
const rscCssManifest = self.__RSC_CSS_MANIFEST
const subresourceIntegrityManifest = ${sriEnabled ? "self.__SUBRESOURCE_INTEGRITY_MANIFEST" : "undefined"}
const fontLoaderManifest = ${hasFontLoaders ? "self.__FONT_LOADER_MANIFEST" : "undefined"}
const render = getRender({
pageType,
dev: ${dev},
page: ${JSON.stringify(page)},
appMod,
pageMod,
errorMod,
error500Mod,
Document,
buildManifest,
appRenderToHTML,
pagesRenderToHTML,
reactLoadableManifest,
serverComponentManifest: ${isServerComponent} ? rscManifest : null,
serverCSSManifest: ${isServerComponent} ? rscCssManifest : null,
subresourceIntegrityManifest,
config: ${stringifiedConfig},
buildId: ${JSON.stringify(buildId)},
fontLoaderManifest,
})
export const ComponentMod = pageMod
export default function(opts) {
return adapter({
...opts,
handler: render
})
}`;
return transformed;
}
/*
For pages SSR'd at the edge, we bundle them with the ESM version of Next in order to
benefit from the better tree-shaking and thus, smaller bundle sizes.
The absolute paths for _app, _error and _document, used in this loader, link to the regular CJS modules.
They are generated in `createPagesMapping` where we don't have access to `isEdgeRuntime`,
so we have to do it here. It's not that bad because it keeps all references to ESM modules magic in this place.
*/ function swapDistFolderWithEsmDistFolder(path) {
return path.replace("next/dist/pages", "next/dist/esm/pages");
}
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../build/webpack/loaders/next-edge-ssr-loader/index.ts"],"names":["edgeSSRLoader","dev","page","buildId","absolutePagePath","absoluteAppPath","absoluteDocumentPath","absolute500Path","absoluteErrorPath","isServerComponent","stringifiedConfig","appDirLoader","appDirLoaderBase64","pagesType","sriEnabled","hasFontLoaders","getOptions","Buffer","from","toString","isAppDir","buildInfo","getModuleBuildInfo","_module","nextEdgeSSR","route","stringifiedPagePath","stringifyRequest","stringifiedAppPath","swapDistFolderWithEsmDistFolder","stringifiedErrorPath","stringifiedDocumentPath","stringified500Path","pageModPath","substring","length","transformed","JSON","stringify","path","replace"],"mappings":"AAAA;;;;kBAgC8BA,aAAa;AAhCR,IAAA,mBAA0B,WAA1B,0BAA0B,CAAA;AAC5B,IAAA,iBAAyB,WAAzB,yBAAyB,CAAA;AA+B3C,eAAeA,aAAa,GAAY;I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CAAA;CACnB;AAhJD;;;;;;;EAOE,CACF,SAASP,+BAA+B,CAACU,IAAY,EAAE;IACrD,OAAOA,IAAI,CAACC,OAAO,CAAC,iBAAiB,EAAE,qBAAqB,CAAC,CAAA;CAC9D"}

View File

@@ -0,0 +1,26 @@
import type { NextConfig } from '../../../../server/config-shared';
import type { DocumentType } from '../../../../shared/lib/utils';
import type { BuildManifest } from '../../../../server/get-page-files';
import type { ReactLoadableManifest } from '../../../../server/load-components';
import type { FontLoaderManifest } from '../../plugins/font-loader-manifest-plugin';
export declare function getRender({ dev, page, appMod, pageMod, errorMod, error500Mod, pagesType, Document, buildManifest, reactLoadableManifest, appRenderToHTML, pagesRenderToHTML, serverComponentManifest, subresourceIntegrityManifest, serverCSSManifest, config, buildId, fontLoaderManifest, }: {
pagesType: 'app' | 'pages' | 'root';
dev: boolean;
page: string;
appMod: any;
pageMod: any;
errorMod: any;
error500Mod: any;
appRenderToHTML: any;
pagesRenderToHTML: any;
Document: DocumentType;
buildManifest: BuildManifest;
reactLoadableManifest: ReactLoadableManifest;
subresourceIntegrityManifest?: Record<string, string>;
serverComponentManifest: any;
serverCSSManifest: any;
appServerMod: any;
config: NextConfig;
buildId: string;
fontLoaderManifest: FontLoaderManifest;
}): (request: Request) => Promise<Response>;

View File

@@ -0,0 +1,94 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getRender = getRender;
var _webServer = _interopRequireDefault(require("../../../../server/web-server"));
var _web = require("../../../../server/base-http/web");
var _constants = require("../../../../lib/constants");
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
function getRender({ dev , page , appMod , pageMod , errorMod , error500Mod , pagesType , Document , buildManifest , reactLoadableManifest , appRenderToHTML , pagesRenderToHTML , serverComponentManifest , subresourceIntegrityManifest , serverCSSManifest , config , buildId , fontLoaderManifest }) {
const isAppPath = pagesType === "app";
const baseLoadComponentResult = {
dev,
buildManifest,
reactLoadableManifest,
subresourceIntegrityManifest,
fontLoaderManifest,
Document,
App: appMod == null ? void 0 : appMod.default
};
const server = new _webServer.default({
dev,
conf: config,
minimalMode: true,
webServerConfig: {
page,
pagesType,
extendRenderOpts: {
buildId,
runtime: _constants.SERVER_RUNTIME.experimentalEdge,
supportsDynamicHTML: true,
disableOptimizedLoading: true,
serverComponentManifest,
serverCSSManifest
},
appRenderToHTML,
pagesRenderToHTML,
loadComponent: async (pathname)=>{
if (isAppPath) return null;
if (pathname === page) {
return {
...baseLoadComponentResult,
Component: pageMod.default,
pageConfig: pageMod.config || {},
getStaticProps: pageMod.getStaticProps,
getServerSideProps: pageMod.getServerSideProps,
getStaticPaths: pageMod.getStaticPaths,
ComponentMod: pageMod,
pathname
};
}
// If there is a custom 500 page, we need to handle it separately.
if (pathname === "/500" && error500Mod) {
return {
...baseLoadComponentResult,
Component: error500Mod.default,
pageConfig: error500Mod.config || {},
getStaticProps: error500Mod.getStaticProps,
getServerSideProps: error500Mod.getServerSideProps,
getStaticPaths: error500Mod.getStaticPaths,
ComponentMod: error500Mod,
pathname
};
}
if (pathname === "/_error") {
return {
...baseLoadComponentResult,
Component: errorMod.default,
pageConfig: errorMod.config || {},
getStaticProps: errorMod.getStaticProps,
getServerSideProps: errorMod.getServerSideProps,
getStaticPaths: errorMod.getStaticPaths,
ComponentMod: errorMod,
pathname
};
}
return null;
}
}
});
const requestHandler = server.getRequestHandler();
return async function render(request) {
const extendedReq = new _web.WebNextRequest(request);
const extendedRes = new _web.WebNextResponse();
requestHandler(extendedReq, extendedRes);
return await extendedRes.toResponse();
};
}
//# sourceMappingURL=render.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../build/webpack/loaders/next-edge-ssr-loader/render.ts"],"names":["getRender","dev","page","appMod","pageMod","errorMod","error500Mod","pagesType","Document","buildManifest","reactLoadableManifest","appRenderToHTML","pagesRenderToHTML","serverComponentManifest","subresourceIntegrityManifest","serverCSSManifest","config","buildId","fontLoaderManifest","isAppPath","baseLoadComponentResult","App","default","server","WebServer","conf","minimalMode","webServerConfig","extendRenderOpts","runtime","SERVER_RUNTIME","experimentalEdge","supportsDynamicHTML","disableOptimizedLoading","loadComponent","pathname","Component","pageConfig","getStaticProps","getServerSideProps","getStaticPaths","ComponentMod","requestHandler","getRequestHandler","render","request","extendedReq","WebNextRequest","extendedRes","WebNextResponse","toResponse"],"mappings":"AAAA;;;;QAcgBA,SAAS,GAATA,SAAS;AAPH,IAAA,UAA+B,kCAA/B,+BAA+B,EAAA;AAI9C,IAAA,IAAkC,WAAlC,kCAAkC,CAAA;AACV,IAAA,UAA2B,WAA3B,2BAA2B,CAAA;;;;;;AAEnD,SAASA,SAAS,CAAC,EACxBC,GAAG,CAAA,EACHC,IAAI,CAAA,EACJC,MAAM,CAAA,EACNC,OAAO,CAAA,EACPC,QAAQ,CAAA,EACRC,WAAW,CAAA,EACXC,SAAS,CAAA,EACTC,QAAQ,CAAA,EACRC,aAAa,CAAA,EACbC,qBAAqB,CAAA,EACrBC,eAAe,CAAA,EACfC,iBAAiB,CAAA,EACjBC,uBAAuB,CAAA,EACvBC,4BAA4B,CAAA,EAC5BC,iBAAiB,CAAA,EACjBC,MAAM,CAAA,EACNC,OAAO,CAAA,EACPC,kBAAkB,CAAA,EAqBnB,EAAE;IACD,MAAMC,SAAS,GAAGZ,SAAS,KAAK,KAAK;IACrC,MAAMa,uBAAuB,GAAG;QAC9BnB,GAAG;QACHQ,aAAa;QACbC,qBAAqB;QACrBI,4BAA4B;QAC5BI,kBAAkB;QAClBV,QAAQ;QACRa,GAAG,EAAElB,MAAM,QAAS,GAAfA,KAAAA,CAAe,GAAfA,MAAM,CAAEmB,OAAO;KACrB;IAED,MAAMC,MAAM,GAAG,IAAIC,UAAS,QAAA,CAAC;QAC3BvB,GAAG;QACHwB,IAAI,EAAET,MAAM;QACZU,WAAW,EAAE,IAAI;QACjBC,eAAe,EAAE;YACfzB,IAAI;YACJK,SAAS;YACTqB,gBAAgB,EAAE;gBAChBX,OAAO;gBACPY,OAAO,E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C,cAAc;wBACvCC,kBAAkB,EAAElC,QAAQ,CAACkC,kBAAkB;wBAC/CC,cAAc,EAAEnC,QAAQ,CAACmC,cAAc;wBACvCC,YAAY,EAAEpC,QAAQ;wBACtB8B,QAAQ;qBACT,CAAA;iBACF;gBAED,OAAO,IAAI,CAAA;aACZ;SACF;KACF,CAAC;IACF,MAAMO,cAAc,GAAGnB,MAAM,CAACoB,iBAAiB,EAAE;IAEjD,OAAO,eAAeC,MAAM,CAACC,OAAgB,EAAE;QAC7C,MAAMC,WAAW,GAAG,IAAIC,IAAc,eAAA,CAACF,OAAO,CAAC;QAC/C,MAAMG,WAAW,GAAG,IAAIC,IAAe,gBAAA,EAAE;QACzCP,cAAc,CAACI,WAAW,EAAEE,WAAW,CAAC;QACxC,OAAO,MAAMA,WAAW,CAACE,UAAU,EAAE,CAAA;KACtC,CAAA;CACF"}

View File

@@ -0,0 +1,8 @@
export declare type ClientComponentImports = string[];
export declare type CssImports = Record<string, string[]>;
export declare type NextFlightClientEntryLoaderOptions = {
modules: ClientComponentImports;
/** This is transmitted as a string to `getOptions` */
server: boolean | 'true' | 'false';
};
export default function transformSource(this: any): Promise<string>;

View File

@@ -0,0 +1,31 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = transformSource;
var _constants = require("../../../shared/lib/constants");
var _getModuleBuildInfo = require("./get-module-build-info");
var _utils = require("./utils");
async function transformSource() {
let { modules , server } = this.getOptions();
const isServer = server === "true";
if (!Array.isArray(modules)) {
modules = modules ? [
modules
] : [];
}
const requests = modules;
const code = requests// Filter out css files on the server
.filter((request)=>isServer ? !_utils.regexCSS.test(request) : true).map((request)=>_utils.regexCSS.test(request) ? `(() => import(/* webpackMode: "lazy" */ ${JSON.stringify(request)}))` : `import(/* webpackMode: "eager" */ ${JSON.stringify(request)})`).join(";\n");
const buildInfo = (0, _getModuleBuildInfo).getModuleBuildInfo(this._module);
const resolve = this.getResolve();
// Resolve to absolute resource url for flight manifest to collect and use to determine client components
const resolvedRequests = await Promise.all(requests.map(async (r)=>await resolve(this.rootContext, r)));
buildInfo.rsc = {
type: _constants.RSC_MODULE_TYPES.client,
requests: resolvedRequests
};
return code;
}
//# sourceMappingURL=next-flight-client-entry-loader.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../build/webpack/loaders/next-flight-client-entry-loader.ts"],"names":["transformSource","modules","server","getOptions","isServer","Array","isArray","requests","code","filter","request","regexCSS","test","map","JSON","stringify","join","buildInfo","getModuleBuildInfo","_module","resolve","getResolve","resolvedRequests","Promise","all","r","rootContext","rsc","type","RSC_MODULE_TYPES","client"],"mappings":"AAAA;;;;kBAa8BA,eAAe;AAbZ,IAAA,UAA+B,WAA/B,+BAA+B,CAAA;AAC7B,IAAA,mBAAyB,WAAzB,yBAAyB,CAAA;AACnC,IAAA,MAAS,WAAT,SAAS,CAAA;AAWnB,eAAeA,eAAe,GAA6B;IACxE,IAAI,EAAEC,OAAO,CAAA,EAAEC,MAAM,CAAA,EAAE,GACrB,IAAI,CAACC,UAAU,EAAE;IACnB,MAAMC,QAAQ,GAAGF,MAAM,KAAK,MAAM;IAElC,IAAI,CAACG,KAAK,CAACC,OAAO,CAACL,OAAO,CAAC,EAAE;QAC3BA,OAAO,GAAGA,OAAO,GAAG;YAACA,OAAO;SAAC,GAAG,EAAE;KACnC;IAED,MAAMM,QAAQ,GAAGN,OAAO,AAAY;IACpC,MAAMO,IAAI,GAAGD,QAAQ,AACnB,qCAAqC;KACpCE,MAAM,CAAC,CAACC,OAAO,GAAMN,QAAQ,GAAG,CAACO,MAAQ,SAAA,CAACC,IAAI,CAACF,OAAO,CAAC,GAAG,IAAI,AAAC,CAAC,CAChEG,GAAG,CAAC,CAACH,OAAO,GACXC,MAAQ,SAAA,CAACC,IAAI,CAACF,OAAO,CAAC,GAClB,CAAC,wCAAwC,EAAEI,IAAI,CAACC,SAAS,CAACL,OAAO,CAAC,CAAC,EAAE,CAAC,GACtE,CAAC,kCAAkC,EAAEI,IAAI,CAACC,SAAS,CAACL,OAAO,CAAC,CAAC,CAAC,CAAC,CACpE,CACAM,IAAI,CAAC,KAAK,CAAC;IAEd,MAAMC,SAAS,GAAGC,CAAAA,GAAAA,mBAAkB,AAAc,CAAA,mBAAd,CAAC,IAAI,CAACC,OAAO,CAAC;IAClD,MAAMC,OAAO,GAAG,IAAI,CAACC,UAAU,EAAE;IAEjC,yGAAyG;IACzG,MAAMC,gBAAgB,GAAG,MAAMC,OAAO,CAACC,GAAG,CACxCjB,QAAQ,CAACM,GAAG,CAAC,OAAOY,CAAC,GAAK,MAAML,OAAO,CAAC,IAAI,CAACM,WAAW,EAAED,CAAC,CAAC,CAAC,CAC9D;IAEDR,SAAS,CAACU,GAAG,GAAG;QACdC,IAAI,EAAEC,UAAgB,iBAAA,CAACC,MAAM;QAC7BvB,QAAQ,EAAEe,gBAAgB;KAC3B;IAED,OAAOd,IAAI,CAAA;CACZ"}

View File

@@ -0,0 +1,8 @@
/**
* For server-side CSS imports, we need to ignore the actual module content but
* still trigger the hot-reloading diff mechanism. So here we put the content
* inside a comment.
*/
export declare function pitch(this: any): void;
declare const NextServerCSSLoader: (this: any, content: string) => string;
export default NextServerCSSLoader;

View File

@@ -0,0 +1,35 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.pitch = pitch;
exports.default = void 0;
var _crypto = _interopRequireDefault(require("crypto"));
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
function pitch() {
if (process.env.NODE_ENV !== "production") {
const content = this.fs.readFileSync(this.resourcePath);
this.data.__checksum = _crypto.default.createHash("sha256").update(typeof content === "string" ? Buffer.from(content) : content).digest().toString("hex");
}
}
const NextServerCSSLoader = function(content) {
this.cacheable && this.cacheable();
// Only add the checksum during development.
if (process.env.NODE_ENV !== "production") {
const isCSSModule = this.resourcePath.match(/\.module\.(css|sass|scss)$/);
const checksum = _crypto.default.createHash("sha256").update(this.data.__checksum + (typeof content === "string" ? Buffer.from(content) : content)).digest().toString("hex").substring(0, 12);
if (isCSSModule) {
return content + "\nmodule.exports.__checksum = " + JSON.stringify(checksum);
}
return `export default ${JSON.stringify(checksum)}`;
}
return content;
};
var _default = NextServerCSSLoader;
exports.default = _default;
//# sourceMappingURL=next-flight-css-dev-loader.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../build/webpack/loaders/next-flight-css-dev-loader.ts"],"names":["pitch","process","env","NODE_ENV","content","fs","readFileSync","resourcePath","data","__checksum","crypto","createHash","update","Buffer","from","digest","toString","NextServerCSSLoader","cacheable","isCSSModule","match","checksum","substring","JSON","stringify"],"mappings":"AAMA;;;;QAEgBA,KAAK,GAALA,KAAK;;AAFF,IAAA,OAAQ,kCAAR,QAAQ,EAAA;;;;;;AAEpB,SAASA,KAAK,GAAY;IAC/B,IAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,EAAE;QACzC,MAAMC,OAAO,GAAG,IAAI,CAACC,EAAE,CAACC,YAAY,CAAC,IAAI,CAACC,YAAY,CAAC;QACvD,IAAI,CAACC,IAAI,CAACC,UAAU,GAAGC,OAAM,QAAA,CAC1BC,UAAU,CAAC,QAAQ,CAAC,CACpBC,MAAM,CAAC,OAAOR,OAAO,KAAK,QAAQ,GAAGS,MAAM,CAACC,IAAI,CAACV,OAAO,CAAC,GAAGA,OAAO,CAAC,CACpEW,MAAM,EAAE,CACRC,QAAQ,CAAC,KAAK,CAAC;KACnB;CACF;AAED,MAAMC,mBAAmB,GAAG,SAAqBb,OAAe,EAAE;IAChE,IAAI,CAACc,SAAS,IAAI,IAAI,CAACA,SAAS,EAAE;IAElC,4CAA4C;IAC5C,IAAIjB,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,EAAE;QACzC,MAAMgB,WAAW,GAAG,IAAI,CAACZ,YAAY,CAACa,KAAK,8BAA8B;QACzE,MAAMC,QAAQ,GAAGX,OAAM,QAAA,CACpBC,UAAU,CAAC,QAAQ,CAAC,CACpBC,MAAM,CACL,IAAI,CAACJ,IAAI,CAACC,UAAU,GAClB,CAAC,OAAOL,OAAO,KAAK,QAAQ,GAAGS,MAAM,CAACC,IAAI,CAACV,OAAO,CAAC,GAAGA,OAAO,CAAC,CACjE,CACAW,MAAM,EAAE,CACRC,QAAQ,CAAC,KAAK,CAAC,CACfM,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC;QAEnB,IAAIH,WAAW,EAAE;YACf,OACEf,OAAO,GAAG,gCAAgC,GAAGmB,IAAI,CAACC,SAAS,CAACH,QAAQ,CAAC,CACtE;SACF;QAED,OAAO,CAAC,eAAe,EAAEE,IAAI,CAACC,SAAS,CAACH,QAAQ,CAAC,CAAC,CAAC,CAAA;KACpD;IAED,OAAOjB,OAAO,CAAA;CACf;eAEca,mBAAmB"}

View File

@@ -0,0 +1 @@
export default function transformSource(this: any, source: string, sourceMap: any): Promise<any>;

View File

@@ -0,0 +1,34 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = transformSource;
var _constants = require("../../../../shared/lib/constants");
var _warnOnce = require("../../../../shared/lib/utils/warn-once");
var _getPageStaticInfo = require("../../../analysis/get-page-static-info");
var _getModuleBuildInfo = require("../get-module-build-info");
async function transformSource(source, sourceMap) {
var ref;
// Avoid buffer to be consumed
if (typeof source !== "string") {
throw new Error("Expected source to have been transformed to a string.");
}
const callback = this.async();
const buildInfo = (0, _getModuleBuildInfo).getModuleBuildInfo(this._module);
const rscType = (0, _getPageStaticInfo).getRSCModuleType(source);
// Assign the RSC meta information to buildInfo.
// Exclude next internal files which are not marked as client files
buildInfo.rsc = {
type: rscType
};
if (((ref = buildInfo.rsc) == null ? void 0 : ref.type) === _constants.RSC_MODULE_TYPES.client) {
return callback(null, source, sourceMap);
}
if (noopHeadPath === this.resourcePath) {
(0, _warnOnce).warnOnce(`Warning: You're using \`next/head\` inside app directory, please migrate to \`head.js\`. Checkout https://beta.nextjs.org/docs/api-reference/file-conventions/head for details.`);
}
return callback(null, source, sourceMap);
}
const noopHeadPath = require.resolve("next/dist/client/components/noop-head");
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../build/webpack/loaders/next-flight-loader/index.ts"],"names":["transformSource","source","sourceMap","buildInfo","Error","callback","async","getModuleBuildInfo","_module","rscType","getRSCModuleType","rsc","type","RSC_MODULE_TYPES","client","noopHeadPath","resourcePath","warnOnce","require","resolve"],"mappings":"AAAA;;;;kBAO8BA,eAAe;AAPZ,IAAA,UAAkC,WAAlC,kCAAkC,CAAA;AAC1C,IAAA,SAAwC,WAAxC,wCAAwC,CAAA;AAChC,IAAA,kBAAwC,WAAxC,wCAAwC,CAAA;AACtC,IAAA,mBAA0B,WAA1B,0BAA0B,CAAA;AAI9C,eAAeA,eAAe,CAE3CC,MAAc,EACdC,SAAc,EACd;QAcIC,GAAa;IAbjB,8BAA8B;IAC9B,IAAI,OAAOF,MAAM,KAAK,QAAQ,EAAE;QAC9B,MAAM,IAAIG,KAAK,CAAC,uDAAuD,CAAC,CAAA;KACzE;IAED,MAAMC,QAAQ,GAAG,IAAI,CAACC,KAAK,EAAE;IAC7B,MAAMH,SAAS,GAAGI,CAAAA,GAAAA,mBAAkB,AAAc,CAAA,mBAAd,CAAC,IAAI,CAACC,OAAO,CAAC;IAClD,MAAMC,OAAO,GAAGC,CAAAA,GAAAA,kBAAgB,AAAQ,CAAA,iBAAR,CAACT,MAAM,CAAC;IAExC,gDAAgD;IAChD,mEAAmE;IACnEE,SAAS,CAACQ,GAAG,GAAG;QAAEC,IAAI,EAAEH,OAAO;KAAE;IAEjC,IAAIN,CAAAA,CAAAA,GAAa,GAAbA,SAAS,CAACQ,GAAG,SAAM,GAAnBR,KAAAA,CAAmB,GAAnBA,GAAa,CAAES,IAAI,CAAA,KAAKC,UAAgB,iBAAA,CAACC,MAAM,EAAE;QACnD,OAAOT,QAAQ,CAAC,IAAI,EAAEJ,MAAM,EAAEC,SAAS,CAAC,CAAA;KACzC;IAED,IAAIa,YAAY,KAAK,IAAI,CAACC,YAAY,EAAE;QACtCC,CAAAA,GAAAA,SAAQ,AAEP,CAAA,SAFO,CACN,CAAC,+KAA+K,CAAC,CAClL;KACF;IACD,OAAOZ,QAAQ,CAAC,IAAI,EAAEJ,MAAM,EAAEC,SAAS,CAAC,CAAA;CACzC;AA9BD,MAAMa,YAAY,GAAGG,OAAO,CAACC,OAAO,CAAC,uCAAuC,CAAC"}

View File

@@ -0,0 +1,7 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
export declare function createProxy(moduleId: string): object;

View File

@@ -0,0 +1,99 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.createProxy = createProxy;
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/ // Modified from https://github.com/facebook/react/blob/main/packages/react-server-dom-webpack/src/ReactFlightWebpackNodeRegister.js
const MODULE_REFERENCE = Symbol.for("react.module.reference");
const PROMISE_PROTOTYPE = Promise.prototype;
const proxyHandlers = {
get: function(target, name, _receiver) {
switch(name){
// These names are read by the Flight runtime if you end up using the exports object.
case "$$typeof":
// These names are a little too common. We should probably have a way to
// have the Flight runtime extract the inner target instead.
return target.$$typeof;
case "filepath":
return target.filepath;
case "name":
return target.name;
case "async":
return target.async;
// We need to special case this because createElement reads it if we pass this
// reference.
case "defaultProps":
return undefined;
case "__esModule":
// Something is conditionally checking which export to use. We'll pretend to be
// an ESM compat module but then we'll check again on the client.
target.default = {
$$typeof: MODULE_REFERENCE,
filepath: target.filepath,
// This a placeholder value that tells the client to conditionally use the
// whole object or just the default export.
name: "",
async: target.async
};
return true;
case "then":
if (!target.async) {
// If this module is expected to return a Promise (such as an AsyncModule) then
// we should resolve that with a client reference that unwraps the Promise on
// the client.
const then = function then(resolve, _reject) {
const moduleReference = {
$$typeof: MODULE_REFERENCE,
filepath: target.filepath,
name: "*",
async: true
};
return Promise.resolve(resolve(new Proxy(moduleReference, proxyHandlers)));
};
// If this is not used as a Promise but is treated as a reference to a `.then`
// export then we should treat it as a reference to that name.
then.$$typeof = MODULE_REFERENCE;
then.filepath = target.filepath;
// then.name is conveniently already "then" which is the export name we need.
// This will break if it's minified though.
return then;
}
break;
default:
break;
}
let cachedReference = target[name];
if (!cachedReference) {
cachedReference = target[name] = {
$$typeof: MODULE_REFERENCE,
filepath: target.filepath,
name: name,
async: target.async
};
}
return cachedReference;
},
getPrototypeOf (_target) {
// Pretend to be a Promise in case anyone asks.
return PROMISE_PROTOTYPE;
},
set: function() {
throw new Error("Cannot assign to a client module from a server module.");
}
};
function createProxy(moduleId) {
const moduleReference = {
$$typeof: MODULE_REFERENCE,
filepath: moduleId,
name: "*",
async: false
};
return new Proxy(moduleReference, proxyHandlers);
}
//# sourceMappingURL=module-proxy.js.map

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