Initial commit
This commit is contained in:
commit
78f8d225ee
21173 changed files with 2907774 additions and 0 deletions
34
node_modules/next/dist/build/webpack/loaders/lightningcss-loader/src/codegen.d.ts
generated
vendored
Normal file
34
node_modules/next/dist/build/webpack/loaders/lightningcss-loader/src/codegen.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
import type { LoaderContext } from 'next/dist/compiled/webpack/webpack';
|
||||
export interface CssImport {
|
||||
icss?: boolean;
|
||||
importName: string;
|
||||
url: string;
|
||||
type?: 'url' | string;
|
||||
index?: number;
|
||||
}
|
||||
export interface CssExport {
|
||||
name: string;
|
||||
value: string;
|
||||
}
|
||||
export interface ApiParam {
|
||||
url?: string;
|
||||
importName?: string;
|
||||
layer?: string;
|
||||
supports?: string;
|
||||
media?: string;
|
||||
dedupe?: boolean;
|
||||
index?: number;
|
||||
}
|
||||
export interface ApiReplacement {
|
||||
replacementName: string;
|
||||
localName?: string;
|
||||
importName: string;
|
||||
needQuotes?: boolean;
|
||||
hash?: string;
|
||||
}
|
||||
export declare function getImportCode(imports: CssImport[], options: any): string;
|
||||
export declare function getModuleCode(result: {
|
||||
map: any;
|
||||
css: any;
|
||||
}, api: ApiParam[], replacements: ApiReplacement[], options: any, loaderContext: LoaderContext<any>): string;
|
||||
export declare function getExportCode(exports: CssExport[], replacements: ApiReplacement[], options: any): string;
|
||||
156
node_modules/next/dist/build/webpack/loaders/lightningcss-loader/src/codegen.js
generated
vendored
Normal file
156
node_modules/next/dist/build/webpack/loaders/lightningcss-loader/src/codegen.js
generated
vendored
Normal file
|
|
@ -0,0 +1,156 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
0 && (module.exports = {
|
||||
getExportCode: null,
|
||||
getImportCode: null,
|
||||
getModuleCode: null
|
||||
});
|
||||
function _export(target, all) {
|
||||
for(var name in all)Object.defineProperty(target, name, {
|
||||
enumerable: true,
|
||||
get: all[name]
|
||||
});
|
||||
}
|
||||
_export(exports, {
|
||||
getExportCode: function() {
|
||||
return getExportCode;
|
||||
},
|
||||
getImportCode: function() {
|
||||
return getImportCode;
|
||||
},
|
||||
getModuleCode: function() {
|
||||
return getModuleCode;
|
||||
}
|
||||
});
|
||||
const _camelcase = /*#__PURE__*/ _interop_require_default(require("../../css-loader/src/camelcase"));
|
||||
const _utils = require("../../css-loader/src/utils");
|
||||
function _interop_require_default(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
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 getModuleCode(result, api, replacements, options, loaderContext) {
|
||||
if (options.modules.exportOnlyLocals === true) {
|
||||
return '';
|
||||
}
|
||||
const sourceMapValue = options.sourceMap ? `,${(0, _utils.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 item of replacements){
|
||||
const { replacementName, importName, localName } = item;
|
||||
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 } = item;
|
||||
const getUrlOptions = [
|
||||
...hash ? [
|
||||
`hash: ${JSON.stringify(hash)}`
|
||||
] : [],
|
||||
...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 getExportCode(exports1, 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, value } of exports1){
|
||||
switch(options.modules.exportLocalsConvention){
|
||||
case 'camelCase':
|
||||
{
|
||||
addExportToLocalsCode(name, value);
|
||||
const modifiedName = (0, _camelcase.default)(name);
|
||||
if (modifiedName !== name) {
|
||||
addExportToLocalsCode(modifiedName, value);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'camelCaseOnly':
|
||||
{
|
||||
addExportToLocalsCode((0, _camelcase.default)(name), value);
|
||||
break;
|
||||
}
|
||||
case 'dashes':
|
||||
{
|
||||
addExportToLocalsCode(name, value);
|
||||
const modifiedName = (0, _utils.dashesCamelCase)(name);
|
||||
if (modifiedName !== name) {
|
||||
addExportToLocalsCode(modifiedName, value);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'dashesOnly':
|
||||
{
|
||||
addExportToLocalsCode((0, _utils.dashesCamelCase)(name), value);
|
||||
break;
|
||||
}
|
||||
case 'asIs':
|
||||
default:
|
||||
addExportToLocalsCode(name, value);
|
||||
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;
|
||||
}
|
||||
|
||||
//# sourceMappingURL=codegen.js.map
|
||||
1
node_modules/next/dist/build/webpack/loaders/lightningcss-loader/src/codegen.js.map
generated
vendored
Normal file
1
node_modules/next/dist/build/webpack/loaders/lightningcss-loader/src/codegen.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
3
node_modules/next/dist/build/webpack/loaders/lightningcss-loader/src/index.d.ts
generated
vendored
Normal file
3
node_modules/next/dist/build/webpack/loaders/lightningcss-loader/src/index.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
import { LightningCssLoader } from './loader';
|
||||
export { LightningCssMinifyPlugin } from './minify';
|
||||
export default LightningCssLoader;
|
||||
27
node_modules/next/dist/build/webpack/loaders/lightningcss-loader/src/index.js
generated
vendored
Normal file
27
node_modules/next/dist/build/webpack/loaders/lightningcss-loader/src/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
0 && (module.exports = {
|
||||
LightningCssMinifyPlugin: null,
|
||||
default: null
|
||||
});
|
||||
function _export(target, all) {
|
||||
for(var name in all)Object.defineProperty(target, name, {
|
||||
enumerable: true,
|
||||
get: all[name]
|
||||
});
|
||||
}
|
||||
_export(exports, {
|
||||
LightningCssMinifyPlugin: function() {
|
||||
return _minify.LightningCssMinifyPlugin;
|
||||
},
|
||||
default: function() {
|
||||
return _default;
|
||||
}
|
||||
});
|
||||
const _loader = require("./loader");
|
||||
const _minify = require("./minify");
|
||||
const _default = _loader.LightningCssLoader;
|
||||
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
node_modules/next/dist/build/webpack/loaders/lightningcss-loader/src/index.js.map
generated
vendored
Normal file
1
node_modules/next/dist/build/webpack/loaders/lightningcss-loader/src/index.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"sources":["../../../../../../src/build/webpack/loaders/lightningcss-loader/src/index.ts"],"sourcesContent":["import { LightningCssLoader } from './loader'\n\nexport { LightningCssMinifyPlugin } from './minify'\nexport default LightningCssLoader\n"],"names":["LightningCssMinifyPlugin","LightningCssLoader"],"mappings":";;;;;;;;;;;;;;;IAESA,wBAAwB;eAAxBA,gCAAwB;;IACjC,OAAiC;eAAjC;;;wBAHmC;wBAEM;MACzC,WAAeC,0BAAkB"}
|
||||
4
node_modules/next/dist/build/webpack/loaders/lightningcss-loader/src/interface.d.ts
generated
vendored
Normal file
4
node_modules/next/dist/build/webpack/loaders/lightningcss-loader/src/interface.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
export declare enum ECacheKey {
|
||||
loader = "loader",
|
||||
minify = "minify"
|
||||
}
|
||||
17
node_modules/next/dist/build/webpack/loaders/lightningcss-loader/src/interface.js
generated
vendored
Normal file
17
node_modules/next/dist/build/webpack/loaders/lightningcss-loader/src/interface.js
generated
vendored
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "ECacheKey", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return ECacheKey;
|
||||
}
|
||||
});
|
||||
var ECacheKey = /*#__PURE__*/ function(ECacheKey) {
|
||||
ECacheKey["loader"] = "loader";
|
||||
ECacheKey["minify"] = "minify";
|
||||
return ECacheKey;
|
||||
}({});
|
||||
|
||||
//# sourceMappingURL=interface.js.map
|
||||
1
node_modules/next/dist/build/webpack/loaders/lightningcss-loader/src/interface.js.map
generated
vendored
Normal file
1
node_modules/next/dist/build/webpack/loaders/lightningcss-loader/src/interface.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"sources":["../../../../../../src/build/webpack/loaders/lightningcss-loader/src/interface.ts"],"sourcesContent":["export enum ECacheKey {\n loader = 'loader',\n minify = 'minify',\n}\n"],"names":["ECacheKey"],"mappings":";;;;+BAAYA;;;eAAAA;;;AAAL,IAAA,AAAKA,mCAAAA;;;WAAAA"}
|
||||
3
node_modules/next/dist/build/webpack/loaders/lightningcss-loader/src/loader.d.ts
generated
vendored
Normal file
3
node_modules/next/dist/build/webpack/loaders/lightningcss-loader/src/loader.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
import type { LoaderContext } from 'webpack';
|
||||
export declare function LightningCssLoader(this: LoaderContext<any>, source: string, prevMap?: Record<string, any>): Promise<void>;
|
||||
export declare const raw = true;
|
||||
424
node_modules/next/dist/build/webpack/loaders/lightningcss-loader/src/loader.js
generated
vendored
Normal file
424
node_modules/next/dist/build/webpack/loaders/lightningcss-loader/src/loader.js
generated
vendored
Normal file
|
|
@ -0,0 +1,424 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
0 && (module.exports = {
|
||||
LightningCssLoader: null,
|
||||
raw: null
|
||||
});
|
||||
function _export(target, all) {
|
||||
for(var name in all)Object.defineProperty(target, name, {
|
||||
enumerable: true,
|
||||
get: all[name]
|
||||
});
|
||||
}
|
||||
_export(exports, {
|
||||
LightningCssLoader: function() {
|
||||
return LightningCssLoader;
|
||||
},
|
||||
raw: function() {
|
||||
return raw;
|
||||
}
|
||||
});
|
||||
const _utils = require("./utils");
|
||||
const _codegen = require("./codegen");
|
||||
const _utils1 = require("../../css-loader/src/utils");
|
||||
const _stringifyrequest = require("../../../stringify-request");
|
||||
const _interface = require("./interface");
|
||||
const encoder = new TextEncoder();
|
||||
function createUrlAndImportVisitor(visitorOptions, apis, imports, replacements, replacedUrls, replacedImportUrls) {
|
||||
const importUrlToNameMap = new Map();
|
||||
let hasUrlImportHelper = false;
|
||||
const urlToNameMap = new Map();
|
||||
const urlToReplacementMap = new Map();
|
||||
let urlIndex = -1;
|
||||
let importUrlIndex = -1;
|
||||
function handleUrl(u) {
|
||||
let url = u.url;
|
||||
const needKeep = visitorOptions.urlFilter(url);
|
||||
if (!needKeep) {
|
||||
return u;
|
||||
}
|
||||
if ((0, _utils1.isDataUrl)(url)) {
|
||||
return u;
|
||||
}
|
||||
urlIndex++;
|
||||
replacedUrls.set(urlIndex, url);
|
||||
url = `__NEXT_LIGHTNINGCSS_LOADER_URL_REPLACE_${urlIndex}__`;
|
||||
const [, query, hashOrQuery] = url.split(/(\?)?#/, 3);
|
||||
const queryParts = url.split('!');
|
||||
let prefix;
|
||||
if (queryParts.length > 1) {
|
||||
url = queryParts.pop();
|
||||
prefix = queryParts.join('!');
|
||||
}
|
||||
let hash = query ? '?' : '';
|
||||
hash += hashOrQuery ? `#${hashOrQuery}` : '';
|
||||
if (!hasUrlImportHelper) {
|
||||
imports.push({
|
||||
type: 'get_url_import',
|
||||
importName: '___CSS_LOADER_GET_URL_IMPORT___',
|
||||
url: JSON.stringify(require.resolve('../../css-loader/src/runtime/getUrl.js')),
|
||||
index: -1
|
||||
});
|
||||
hasUrlImportHelper = true;
|
||||
}
|
||||
const newUrl = prefix ? `${prefix}!${url}` : url;
|
||||
let importName = urlToNameMap.get(newUrl);
|
||||
if (!importName) {
|
||||
importName = `___CSS_LOADER_URL_IMPORT_${urlToNameMap.size}___`;
|
||||
urlToNameMap.set(newUrl, importName);
|
||||
imports.push({
|
||||
type: 'url',
|
||||
importName,
|
||||
url: JSON.stringify(newUrl),
|
||||
index: urlIndex
|
||||
});
|
||||
}
|
||||
// This should be true for string-urls in image-set
|
||||
const needQuotes = false;
|
||||
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);
|
||||
replacements.push({
|
||||
replacementName,
|
||||
importName,
|
||||
hash,
|
||||
needQuotes
|
||||
});
|
||||
}
|
||||
return {
|
||||
loc: u.loc,
|
||||
url: replacementName
|
||||
};
|
||||
}
|
||||
return {
|
||||
Rule: {
|
||||
import (node) {
|
||||
if (visitorOptions.importFilter) {
|
||||
const needKeep = visitorOptions.importFilter(node.value.url, node.value.media);
|
||||
if (!needKeep) {
|
||||
return node;
|
||||
}
|
||||
}
|
||||
let url = node.value.url;
|
||||
importUrlIndex++;
|
||||
replacedImportUrls.set(importUrlIndex, url);
|
||||
url = `__NEXT_LIGHTNINGCSS_LOADER_IMPORT_URL_REPLACE_${importUrlIndex}__`;
|
||||
// TODO: Use identical logic as valueParser.stringify()
|
||||
const media = node.value.media.mediaQueries.length ? JSON.stringify(node.value.media.mediaQueries) : undefined;
|
||||
const isRequestable = (0, _utils1.isUrlRequestable)(url);
|
||||
let prefix;
|
||||
if (isRequestable) {
|
||||
const queryParts = url.split('!');
|
||||
if (queryParts.length > 1) {
|
||||
url = queryParts.pop();
|
||||
prefix = queryParts.join('!');
|
||||
}
|
||||
}
|
||||
if (!isRequestable) {
|
||||
apis.push({
|
||||
url,
|
||||
media
|
||||
});
|
||||
// Bug of lightningcss
|
||||
return {
|
||||
type: 'ignored',
|
||||
value: ''
|
||||
};
|
||||
}
|
||||
const newUrl = prefix ? `${prefix}!${url}` : url;
|
||||
let importName = importUrlToNameMap.get(newUrl);
|
||||
if (!importName) {
|
||||
importName = `___CSS_LOADER_AT_RULE_IMPORT_${importUrlToNameMap.size}___`;
|
||||
importUrlToNameMap.set(newUrl, importName);
|
||||
const importUrl = visitorOptions.urlHandler(newUrl);
|
||||
imports.push({
|
||||
type: 'rule_import',
|
||||
importName,
|
||||
url: importUrl
|
||||
});
|
||||
}
|
||||
apis.push({
|
||||
importName,
|
||||
media
|
||||
});
|
||||
// Bug of lightningcss
|
||||
return {
|
||||
type: 'ignored',
|
||||
value: ''
|
||||
};
|
||||
}
|
||||
},
|
||||
Url (node) {
|
||||
return handleUrl(node);
|
||||
}
|
||||
};
|
||||
}
|
||||
function createIcssVisitor({ apis, imports, replacements, replacedUrls, urlHandler }) {
|
||||
let index = -1;
|
||||
let replacementIndex = -1;
|
||||
return {
|
||||
Declaration: {
|
||||
composes (node) {
|
||||
if (node.property === 'unparsed') {
|
||||
return;
|
||||
}
|
||||
const specifier = node.value.from;
|
||||
if ((specifier == null ? void 0 : specifier.type) !== 'file') {
|
||||
return;
|
||||
}
|
||||
let url = specifier.value;
|
||||
if (!url) {
|
||||
return;
|
||||
}
|
||||
index++;
|
||||
replacedUrls.set(index, url);
|
||||
url = `__NEXT_LIGHTNINGCSS_LOADER_ICSS_URL_REPLACE_${index}__`;
|
||||
const importName = `___CSS_LOADER_ICSS_IMPORT_${imports.length}___`;
|
||||
imports.push({
|
||||
type: 'icss_import',
|
||||
importName,
|
||||
icss: true,
|
||||
url: urlHandler(url),
|
||||
index
|
||||
});
|
||||
apis.push({
|
||||
importName,
|
||||
dedupe: true,
|
||||
index
|
||||
});
|
||||
const newNames = [];
|
||||
for (const localName of node.value.names){
|
||||
replacementIndex++;
|
||||
const replacementName = `___CSS_LOADER_ICSS_IMPORT_${index}_REPLACEMENT_${replacementIndex}___`;
|
||||
replacements.push({
|
||||
replacementName,
|
||||
importName,
|
||||
localName
|
||||
});
|
||||
newNames.push(replacementName);
|
||||
}
|
||||
return {
|
||||
property: 'composes',
|
||||
value: {
|
||||
loc: node.value.loc,
|
||||
names: newNames,
|
||||
from: specifier
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
const LOADER_NAME = `lightningcss-loader`;
|
||||
async function LightningCssLoader(source, prevMap) {
|
||||
var _options_modules;
|
||||
const done = this.async();
|
||||
const options = this.getOptions();
|
||||
const { implementation, targets: userTargets, ...opts } = options;
|
||||
options.modules ??= {};
|
||||
if (implementation && typeof implementation.transformCss !== 'function') {
|
||||
done(Object.defineProperty(new TypeError(`[${LOADER_NAME}]: options.implementation.transformCss must be an 'lightningcss' transform function. Received ${typeof implementation.transformCss}`), "__NEXT_ERROR_CODE", {
|
||||
value: "E560",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
}));
|
||||
return;
|
||||
}
|
||||
if (options.postcss) {
|
||||
var _postcssWithPlugins_plugins;
|
||||
const { postcssWithPlugins } = await options.postcss();
|
||||
if ((postcssWithPlugins == null ? void 0 : (_postcssWithPlugins_plugins = postcssWithPlugins.plugins) == null ? void 0 : _postcssWithPlugins_plugins.length) > 0) {
|
||||
throw Object.defineProperty(new Error(`[${LOADER_NAME}]: experimental.useLightningcss does not work with postcss plugins. Please remove 'useLightningcss: true' from your configuration.`), "__NEXT_ERROR_CODE", {
|
||||
value: "E519",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
}
|
||||
const exports1 = [];
|
||||
const imports = [];
|
||||
const icssImports = [];
|
||||
const apis = [];
|
||||
const replacements = [];
|
||||
if (((_options_modules = options.modules) == null ? void 0 : _options_modules.exportOnlyLocals) !== true) {
|
||||
imports.unshift({
|
||||
type: 'api_import',
|
||||
importName: '___CSS_LOADER_API_IMPORT___',
|
||||
url: (0, _stringifyrequest.stringifyRequest)(this, require.resolve('../../css-loader/src/runtime/api'))
|
||||
});
|
||||
}
|
||||
const { loadBindings } = require('next/dist/build/swc');
|
||||
const transform = (implementation == null ? void 0 : implementation.transformCss) ?? (await loadBindings()).css.lightning.transform;
|
||||
const replacedUrls = new Map();
|
||||
const icssReplacedUrls = new Map();
|
||||
const replacedImportUrls = new Map();
|
||||
const urlImportVisitor = createUrlAndImportVisitor({
|
||||
urlHandler: (url)=>(0, _stringifyrequest.stringifyRequest)(this, (0, _utils1.getPreRequester)(this)(options.importLoaders ?? 0) + url),
|
||||
urlFilter: (0, _utils1.getFilter)(options.url, this.resourcePath),
|
||||
importFilter: (0, _utils1.getFilter)(options.import, this.resourcePath),
|
||||
context: this.context
|
||||
}, apis, imports, replacements, replacedUrls, replacedImportUrls);
|
||||
const icssVisitor = createIcssVisitor({
|
||||
apis,
|
||||
imports: icssImports,
|
||||
replacements,
|
||||
replacedUrls: icssReplacedUrls,
|
||||
urlHandler: (url)=>(0, _stringifyrequest.stringifyRequest)(this, (0, _utils1.getPreRequester)(this)(options.importLoaders) + url)
|
||||
});
|
||||
// This works by returned visitors are not conflicting.
|
||||
// naive workaround for composeVisitors, as we do not directly depends on lightningcss's npm pkg
|
||||
// but next-swc provides bindings
|
||||
const visitor = {
|
||||
...urlImportVisitor,
|
||||
...icssVisitor
|
||||
};
|
||||
try {
|
||||
const { code, map, exports: moduleExports } = transform({
|
||||
...opts,
|
||||
visitor,
|
||||
cssModules: options.modules ? {
|
||||
pattern: process.env.__NEXT_TEST_MODE ? '[name]__[local]' : '[name]__[hash]__[local]'
|
||||
} : undefined,
|
||||
filename: this.resourcePath,
|
||||
code: encoder.encode(source),
|
||||
sourceMap: this.sourceMap,
|
||||
targets: (0, _utils.getTargets)({
|
||||
targets: userTargets,
|
||||
key: _interface.ECacheKey.loader
|
||||
}),
|
||||
inputSourceMap: this.sourceMap && prevMap ? JSON.stringify(prevMap) : undefined,
|
||||
include: 1
|
||||
});
|
||||
let cssCodeAsString = code.toString();
|
||||
if (moduleExports) {
|
||||
for(const name in moduleExports){
|
||||
if (Object.prototype.hasOwnProperty.call(moduleExports, name)) {
|
||||
const v = moduleExports[name];
|
||||
let value = v.name;
|
||||
for (const compose of v.composes){
|
||||
value += ` ${compose.name}`;
|
||||
}
|
||||
exports1.push({
|
||||
name,
|
||||
value
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
if (replacedUrls.size !== 0) {
|
||||
const urlResolver = this.getResolve({
|
||||
conditionNames: [
|
||||
'asset'
|
||||
],
|
||||
mainFields: [
|
||||
'asset'
|
||||
],
|
||||
mainFiles: [],
|
||||
extensions: []
|
||||
});
|
||||
for (const [index, url] of replacedUrls.entries()){
|
||||
const [pathname] = url.split(/(\?)?#/, 3);
|
||||
const request = (0, _utils1.requestify)(pathname, this.rootContext);
|
||||
const resolvedUrl = await (0, _utils1.resolveRequests)(urlResolver, this.context, [
|
||||
...new Set([
|
||||
request,
|
||||
url
|
||||
])
|
||||
]);
|
||||
for (const importItem of imports){
|
||||
importItem.url = importItem.url.replace(`__NEXT_LIGHTNINGCSS_LOADER_URL_REPLACE_${index}__`, resolvedUrl ?? url);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (replacedImportUrls.size !== 0) {
|
||||
const importResolver = this.getResolve({
|
||||
conditionNames: [
|
||||
'style'
|
||||
],
|
||||
extensions: [
|
||||
'.css'
|
||||
],
|
||||
mainFields: [
|
||||
'css',
|
||||
'style',
|
||||
'main',
|
||||
'...'
|
||||
],
|
||||
mainFiles: [
|
||||
'index',
|
||||
'...'
|
||||
],
|
||||
restrictions: [
|
||||
/\.css$/i
|
||||
]
|
||||
});
|
||||
for (const [index, url] of replacedImportUrls.entries()){
|
||||
const [pathname] = url.split(/(\?)?#/, 3);
|
||||
const request = (0, _utils1.requestify)(pathname, this.rootContext);
|
||||
const resolvedUrl = await (0, _utils1.resolveRequests)(importResolver, this.context, [
|
||||
...new Set([
|
||||
request,
|
||||
url
|
||||
])
|
||||
]);
|
||||
for (const importItem of imports){
|
||||
importItem.url = importItem.url.replace(`__NEXT_LIGHTNINGCSS_LOADER_IMPORT_URL_REPLACE_${index}__`, resolvedUrl ?? url);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (icssReplacedUrls.size !== 0) {
|
||||
const icssResolver = this.getResolve({
|
||||
conditionNames: [
|
||||
'style'
|
||||
],
|
||||
extensions: [],
|
||||
mainFields: [
|
||||
'css',
|
||||
'style',
|
||||
'main',
|
||||
'...'
|
||||
],
|
||||
mainFiles: [
|
||||
'index',
|
||||
'...'
|
||||
]
|
||||
});
|
||||
for (const [index, url] of icssReplacedUrls.entries()){
|
||||
const [pathname] = url.split(/(\?)?#/, 3);
|
||||
const request = (0, _utils1.requestify)(pathname, this.rootContext);
|
||||
const resolvedUrl = await (0, _utils1.resolveRequests)(icssResolver, this.context, [
|
||||
...new Set([
|
||||
url,
|
||||
request
|
||||
])
|
||||
]);
|
||||
for (const importItem of icssImports){
|
||||
importItem.url = importItem.url.replace(`__NEXT_LIGHTNINGCSS_LOADER_ICSS_URL_REPLACE_${index}__`, resolvedUrl ?? url);
|
||||
}
|
||||
}
|
||||
}
|
||||
imports.push(...icssImports);
|
||||
const importCode = (0, _codegen.getImportCode)(imports, options);
|
||||
const moduleCode = (0, _codegen.getModuleCode)({
|
||||
css: cssCodeAsString,
|
||||
map
|
||||
}, apis, replacements, options, this);
|
||||
const exportCode = (0, _codegen.getExportCode)(exports1, replacements, options);
|
||||
const esCode = `${importCode}${moduleCode}${exportCode}`;
|
||||
done(null, esCode, map && JSON.parse(map.toString()));
|
||||
} catch (error) {
|
||||
console.error('lightningcss-loader error', error);
|
||||
done(error);
|
||||
}
|
||||
}
|
||||
const raw = true;
|
||||
|
||||
//# sourceMappingURL=loader.js.map
|
||||
1
node_modules/next/dist/build/webpack/loaders/lightningcss-loader/src/loader.js.map
generated
vendored
Normal file
1
node_modules/next/dist/build/webpack/loaders/lightningcss-loader/src/loader.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
8
node_modules/next/dist/build/webpack/loaders/lightningcss-loader/src/minify.d.ts
generated
vendored
Normal file
8
node_modules/next/dist/build/webpack/loaders/lightningcss-loader/src/minify.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
import type { Compiler } from 'webpack';
|
||||
export declare class LightningCssMinifyPlugin {
|
||||
private readonly options;
|
||||
private transform;
|
||||
constructor(opts?: any);
|
||||
apply(compiler: Compiler): void;
|
||||
private transformAssets;
|
||||
}
|
||||
94
node_modules/next/dist/build/webpack/loaders/lightningcss-loader/src/minify.js
generated
vendored
Normal file
94
node_modules/next/dist/build/webpack/loaders/lightningcss-loader/src/minify.js
generated
vendored
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
// @ts-ignore
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "LightningCssMinifyPlugin", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return LightningCssMinifyPlugin;
|
||||
}
|
||||
});
|
||||
const _webpack = require("next/dist/compiled/webpack/webpack");
|
||||
const _webpacksources3 = require("next/dist/compiled/webpack-sources3");
|
||||
const _interface = require("./interface");
|
||||
const _utils = require("./utils");
|
||||
const _buffer = require("buffer");
|
||||
const PLUGIN_NAME = 'lightning-css-minify';
|
||||
const CSS_FILE_REG = /\.css(?:\?.*)?$/i;
|
||||
class LightningCssMinifyPlugin {
|
||||
constructor(opts = {}){
|
||||
const { implementation, ...otherOpts } = opts;
|
||||
if (implementation && typeof implementation.transformCss !== 'function') {
|
||||
throw Object.defineProperty(new TypeError(`[LightningCssMinifyPlugin]: implementation.transformCss must be an 'lightningcss' transform function. Received ${typeof implementation.transformCss}`), "__NEXT_ERROR_CODE", {
|
||||
value: "E561",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
this.transform = implementation == null ? void 0 : implementation.transformCss;
|
||||
this.options = otherOpts;
|
||||
}
|
||||
apply(compiler) {
|
||||
const meta = JSON.stringify({
|
||||
name: '@next/lightningcss-loader',
|
||||
version: '0.0.0',
|
||||
options: this.options
|
||||
});
|
||||
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation)=>{
|
||||
compilation.hooks.chunkHash.tap(PLUGIN_NAME, (_, hash)=>hash.update(meta));
|
||||
compilation.hooks.processAssets.tapPromise({
|
||||
name: PLUGIN_NAME,
|
||||
stage: _webpack.webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE,
|
||||
additionalAssets: true
|
||||
}, async ()=>await this.transformAssets(compilation));
|
||||
compilation.hooks.statsPrinter.tap(PLUGIN_NAME, (statsPrinter)=>{
|
||||
statsPrinter.hooks.print.for('asset.info.minimized')// @ts-ignore
|
||||
.tap(PLUGIN_NAME, (minimized, { green, formatFlag })=>{
|
||||
// @ts-ignore
|
||||
return minimized ? green(formatFlag('minimized')) : undefined;
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
async transformAssets(compilation) {
|
||||
const { options: { devtool } } = compilation.compiler;
|
||||
if (!this.transform) {
|
||||
const { loadBindings } = require('next/dist/build/swc');
|
||||
this.transform = (await loadBindings()).css.lightning.transform;
|
||||
}
|
||||
const sourcemap = this.options.sourceMap === undefined ? devtool && devtool.includes('source-map') : this.options.sourceMap;
|
||||
const { include, exclude, test: testRegExp, targets: userTargets, ...transformOptions } = this.options;
|
||||
const assets = compilation.getAssets().filter((asset)=>// Filter out already minimized
|
||||
!asset.info.minimized && // Filter out by file type
|
||||
(testRegExp || CSS_FILE_REG).test(asset.name) && _webpack.ModuleFilenameHelpers.matchObject({
|
||||
include,
|
||||
exclude
|
||||
}, asset.name));
|
||||
await Promise.all(assets.map(async (asset)=>{
|
||||
const { source, map } = asset.source.sourceAndMap();
|
||||
const sourceAsString = source.toString();
|
||||
const code = typeof source === 'string' ? _buffer.Buffer.from(source) : source;
|
||||
const targets = (0, _utils.getTargets)({
|
||||
targets: userTargets,
|
||||
key: _interface.ECacheKey.minify
|
||||
});
|
||||
const result = await this.transform({
|
||||
filename: asset.name,
|
||||
code,
|
||||
minify: true,
|
||||
sourceMap: sourcemap,
|
||||
targets,
|
||||
...transformOptions
|
||||
});
|
||||
const codeString = result.code.toString();
|
||||
compilation.updateAsset(asset.name, // @ts-ignore
|
||||
sourcemap ? new _webpacksources3.SourceMapSource(codeString, asset.name, JSON.parse(result.map.toString()), sourceAsString, map, true) : new _webpacksources3.RawSource(codeString), {
|
||||
...asset.info,
|
||||
minimized: true
|
||||
});
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=minify.js.map
|
||||
1
node_modules/next/dist/build/webpack/loaders/lightningcss-loader/src/minify.js.map
generated
vendored
Normal file
1
node_modules/next/dist/build/webpack/loaders/lightningcss-loader/src/minify.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
4
node_modules/next/dist/build/webpack/loaders/lightningcss-loader/src/utils.d.ts
generated
vendored
Normal file
4
node_modules/next/dist/build/webpack/loaders/lightningcss-loader/src/utils.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
export declare const getTargets: (opts: {
|
||||
targets?: string[];
|
||||
key: any;
|
||||
}) => any;
|
||||
58
node_modules/next/dist/build/webpack/loaders/lightningcss-loader/src/utils.js
generated
vendored
Normal file
58
node_modules/next/dist/build/webpack/loaders/lightningcss-loader/src/utils.js
generated
vendored
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "getTargets", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return getTargets;
|
||||
}
|
||||
});
|
||||
let targetsCache = {};
|
||||
/**
|
||||
* Convert a version number to a single 24-bit number
|
||||
*
|
||||
* https://github.com/lumeland/lume/blob/4cc75599006df423a14befc06d3ed8493c645b09/plugins/lightningcss.ts#L160
|
||||
*/ function version(major, minor = 0, patch = 0) {
|
||||
return major << 16 | minor << 8 | patch;
|
||||
}
|
||||
function parseVersion(v) {
|
||||
return v.split('.').reduce((acc, val)=>{
|
||||
if (!acc) {
|
||||
return null;
|
||||
}
|
||||
const parsed = parseInt(val, 10);
|
||||
if (isNaN(parsed)) {
|
||||
return null;
|
||||
}
|
||||
acc.push(parsed);
|
||||
return acc;
|
||||
}, []);
|
||||
}
|
||||
function browserslistToTargets(targets) {
|
||||
return targets.reduce((acc, value)=>{
|
||||
const [name, v] = value.split(' ');
|
||||
const parsedVersion = parseVersion(v);
|
||||
if (!parsedVersion) {
|
||||
return acc;
|
||||
}
|
||||
const versionDigit = version(parsedVersion[0], parsedVersion[1], parsedVersion[2]);
|
||||
if (name === 'and_qq' || name === 'and_uc' || name === 'baidu' || name === 'bb' || name === 'kaios' || name === 'op_mini') {
|
||||
return acc;
|
||||
}
|
||||
if (acc[name] == null || versionDigit < acc[name]) {
|
||||
acc[name] = versionDigit;
|
||||
}
|
||||
return acc;
|
||||
}, {});
|
||||
}
|
||||
const getTargets = (opts)=>{
|
||||
const cache = targetsCache[opts.key];
|
||||
if (cache) {
|
||||
return cache;
|
||||
}
|
||||
const result = browserslistToTargets(opts.targets ?? []);
|
||||
return targetsCache[opts.key] = result;
|
||||
};
|
||||
|
||||
//# sourceMappingURL=utils.js.map
|
||||
1
node_modules/next/dist/build/webpack/loaders/lightningcss-loader/src/utils.js.map
generated
vendored
Normal file
1
node_modules/next/dist/build/webpack/loaders/lightningcss-loader/src/utils.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"sources":["../../../../../../src/build/webpack/loaders/lightningcss-loader/src/utils.ts"],"sourcesContent":["let targetsCache: Record<string, any> = {}\n\n/**\n * Convert a version number to a single 24-bit number\n *\n * https://github.com/lumeland/lume/blob/4cc75599006df423a14befc06d3ed8493c645b09/plugins/lightningcss.ts#L160\n */\nfunction version(major: number, minor = 0, patch = 0): number {\n return (major << 16) | (minor << 8) | patch\n}\n\nfunction parseVersion(v: string) {\n return v.split('.').reduce(\n (acc, val) => {\n if (!acc) {\n return null\n }\n\n const parsed = parseInt(val, 10)\n if (isNaN(parsed)) {\n return null\n }\n acc.push(parsed)\n return acc\n },\n [] as Array<number> | null\n )\n}\n\nfunction browserslistToTargets(targets: Array<string>) {\n return targets.reduce(\n (acc, value) => {\n const [name, v] = value.split(' ')\n const parsedVersion = parseVersion(v)\n\n if (!parsedVersion) {\n return acc\n }\n const versionDigit = version(\n parsedVersion[0],\n parsedVersion[1],\n parsedVersion[2]\n )\n\n if (\n name === 'and_qq' ||\n name === 'and_uc' ||\n name === 'baidu' ||\n name === 'bb' ||\n name === 'kaios' ||\n name === 'op_mini'\n ) {\n return acc\n }\n\n if (acc[name] == null || versionDigit < acc[name]) {\n acc[name] = versionDigit\n }\n\n return acc\n },\n {} as Record<string, number>\n )\n}\n\nexport const getTargets = (opts: { targets?: string[]; key: any }) => {\n const cache = targetsCache[opts.key]\n if (cache) {\n return cache\n }\n\n const result = browserslistToTargets(opts.targets ?? [])\n return (targetsCache[opts.key] = result)\n}\n"],"names":["getTargets","targetsCache","version","major","minor","patch","parseVersion","v","split","reduce","acc","val","parsed","parseInt","isNaN","push","browserslistToTargets","targets","value","name","parsedVersion","versionDigit","opts","cache","key","result"],"mappings":";;;;+BAiEaA;;;eAAAA;;;AAjEb,IAAIC,eAAoC,CAAC;AAEzC;;;;CAIC,GACD,SAASC,QAAQC,KAAa,EAAEC,QAAQ,CAAC,EAAEC,QAAQ,CAAC;IAClD,OAAO,AAACF,SAAS,KAAOC,SAAS,IAAKC;AACxC;AAEA,SAASC,aAAaC,CAAS;IAC7B,OAAOA,EAAEC,KAAK,CAAC,KAAKC,MAAM,CACxB,CAACC,KAAKC;QACJ,IAAI,CAACD,KAAK;YACR,OAAO;QACT;QAEA,MAAME,SAASC,SAASF,KAAK;QAC7B,IAAIG,MAAMF,SAAS;YACjB,OAAO;QACT;QACAF,IAAIK,IAAI,CAACH;QACT,OAAOF;IACT,GACA,EAAE;AAEN;AAEA,SAASM,sBAAsBC,OAAsB;IACnD,OAAOA,QAAQR,MAAM,CACnB,CAACC,KAAKQ;QACJ,MAAM,CAACC,MAAMZ,EAAE,GAAGW,MAAMV,KAAK,CAAC;QAC9B,MAAMY,gBAAgBd,aAAaC;QAEnC,IAAI,CAACa,eAAe;YAClB,OAAOV;QACT;QACA,MAAMW,eAAenB,QACnBkB,aAAa,CAAC,EAAE,EAChBA,aAAa,CAAC,EAAE,EAChBA,aAAa,CAAC,EAAE;QAGlB,IACED,SAAS,YACTA,SAAS,YACTA,SAAS,WACTA,SAAS,QACTA,SAAS,WACTA,SAAS,WACT;YACA,OAAOT;QACT;QAEA,IAAIA,GAAG,CAACS,KAAK,IAAI,QAAQE,eAAeX,GAAG,CAACS,KAAK,EAAE;YACjDT,GAAG,CAACS,KAAK,GAAGE;QACd;QAEA,OAAOX;IACT,GACA,CAAC;AAEL;AAEO,MAAMV,aAAa,CAACsB;IACzB,MAAMC,QAAQtB,YAAY,CAACqB,KAAKE,GAAG,CAAC;IACpC,IAAID,OAAO;QACT,OAAOA;IACT;IAEA,MAAME,SAAST,sBAAsBM,KAAKL,OAAO,IAAI,EAAE;IACvD,OAAQhB,YAAY,CAACqB,KAAKE,GAAG,CAAC,GAAGC;AACnC"}
|
||||
Loading…
Add table
Add a link
Reference in a new issue