Unverified Commit 9a56fdba authored by Tim Neutkens's avatar Tim Neutkens Committed by GitHub

Use consistent postcss version for all transforms (#28529)

Co-authored-by: 's avatarJJ Kasper <jj@jjsweb.site>
parent c9efbe18
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
"lint-staged": "lint-staged", "lint-staged": "lint-staged",
"next-with-deps": "./scripts/next-with-deps.sh", "next-with-deps": "./scripts/next-with-deps.sh",
"next": "node --trace-deprecation --enable-source-maps packages/next/dist/bin/next", "next": "node --trace-deprecation --enable-source-maps packages/next/dist/bin/next",
"next-no-sourcemaps": "node --trace-deprecation packages/next/dist/bin/next",
"clean-trace-jaeger": "rm -rf test/integration/basic/.next && TRACE_TARGET=JAEGER node --trace-deprecation --enable-source-maps packages/next/dist/bin/next build test/integration/basic", "clean-trace-jaeger": "rm -rf test/integration/basic/.next && TRACE_TARGET=JAEGER node --trace-deprecation --enable-source-maps packages/next/dist/bin/next build test/integration/basic",
"debug": "node --inspect packages/next/dist/bin/next" "debug": "node --inspect packages/next/dist/bin/next"
}, },
......
module.exports = require('cssnano-simple')(require('postcss'))
...@@ -11,6 +11,69 @@ import { ...@@ -11,6 +11,69 @@ import {
getLocalModuleImportError, getLocalModuleImportError,
} from './messages' } from './messages'
import { getPostCssPlugins } from './plugins' import { getPostCssPlugins } from './plugins'
import postcss from 'postcss'
// @ts-ignore backwards compat
postcss.plugin = function postcssPlugin(name, initializer) {
function creator(...args: any) {
let transformer = initializer(...args)
transformer.postcssPlugin = name
// transformer.postcssVersion = new Processor().version
return transformer
}
let cache: any
Object.defineProperty(creator, 'postcss', {
get() {
if (!cache) cache = creator()
return cache
},
})
creator.process = function (css: any, processOpts: any, pluginOpts: any) {
return postcss([creator(pluginOpts)]).process(css, processOpts)
}
return creator
}
// @ts-ignore backwards compat
postcss.vendor = {
/**
* Returns the vendor prefix extracted from an input string.
*
* @param {string} prop String with or without vendor prefix.
*
* @return {string} vendor prefix or empty string
*
* @example
* postcss.vendor.prefix('-moz-tab-size') //=> '-moz-'
* postcss.vendor.prefix('tab-size') //=> ''
*/
prefix: function prefix(prop: any) {
const match = prop.match(/^(-\w+-)/)
if (match) {
return match[0]
}
return ''
},
/**
* Returns the input string stripped of its vendor prefix.
*
* @param {string} prop String with or without vendor prefix.
*
* @return {string} String name without vendor prefixes.
*
* @example
* postcss.vendor.unprefixed('-moz-tab-size') //=> 'tab-size'
*/
unprefixed: function unprefixed(prop: any) {
return prop.replace(/^-\w+-/, '')
},
}
// RegExps for all Style Sheet variants // RegExps for all Style Sheet variants
export const regexLikeCss = /\.(css|scss|sass)(\.webpack\[javascript\/auto\])?$/ export const regexLikeCss = /\.(css|scss|sass)(\.webpack\[javascript\/auto\])?$/
......
...@@ -3,10 +3,11 @@ import { webpack } from 'next/dist/compiled/webpack/webpack' ...@@ -3,10 +3,11 @@ import { webpack } from 'next/dist/compiled/webpack/webpack'
import { ConfigurationContext } from '../../../utils' import { ConfigurationContext } from '../../../utils'
import { getClientStyleLoader } from './client' import { getClientStyleLoader } from './client'
import { cssFileResolve } from './file-resolve' import { cssFileResolve } from './file-resolve'
import postcss from 'postcss'
export function getGlobalCssLoader( export function getGlobalCssLoader(
ctx: ConfigurationContext, ctx: ConfigurationContext,
postCssPlugins: readonly AcceptedPlugin[], postCssPlugins: AcceptedPlugin[],
preProcessors: readonly webpack.RuleSetUseItem[] = [] preProcessors: readonly webpack.RuleSetUseItem[] = []
): webpack.RuleSetUseItem[] { ): webpack.RuleSetUseItem[] {
const loaders: webpack.RuleSetUseItem[] = [] const loaders: webpack.RuleSetUseItem[] = []
...@@ -24,7 +25,7 @@ export function getGlobalCssLoader( ...@@ -24,7 +25,7 @@ export function getGlobalCssLoader(
// Resolve CSS `@import`s and `url()`s // Resolve CSS `@import`s and `url()`s
loaders.push({ loaders.push({
loader: require.resolve('next/dist/compiled/css-loader'), loader: require.resolve('../../../../loaders/css-loader/src'),
options: { options: {
importLoaders: 1 + preProcessors.length, importLoaders: 1 + preProcessors.length,
// Next.js controls CSS Modules eligibility: // Next.js controls CSS Modules eligibility:
...@@ -37,9 +38,9 @@ export function getGlobalCssLoader( ...@@ -37,9 +38,9 @@ export function getGlobalCssLoader(
// Compile CSS // Compile CSS
loaders.push({ loaders.push({
loader: require.resolve('next/dist/compiled/postcss-loader'), loader: require.resolve('../../../../loaders/postcss-loader/src'),
options: { options: {
postcssOptions: { plugins: postCssPlugins, config: false }, postcss: postcss(postCssPlugins),
}, },
}) })
......
...@@ -4,10 +4,11 @@ import { ConfigurationContext } from '../../../utils' ...@@ -4,10 +4,11 @@ import { ConfigurationContext } from '../../../utils'
import { getClientStyleLoader } from './client' import { getClientStyleLoader } from './client'
import { cssFileResolve } from './file-resolve' import { cssFileResolve } from './file-resolve'
import { getCssModuleLocalIdent } from './getCssModuleLocalIdent' import { getCssModuleLocalIdent } from './getCssModuleLocalIdent'
import postcss from 'postcss'
export function getCssModuleLoader( export function getCssModuleLoader(
ctx: ConfigurationContext, ctx: ConfigurationContext,
postCssPlugins: readonly AcceptedPlugin[], postCssPlugins: AcceptedPlugin[],
preProcessors: readonly webpack.RuleSetUseItem[] = [] preProcessors: readonly webpack.RuleSetUseItem[] = []
): webpack.RuleSetUseItem[] { ): webpack.RuleSetUseItem[] {
const loaders: webpack.RuleSetUseItem[] = [] const loaders: webpack.RuleSetUseItem[] = []
...@@ -25,7 +26,7 @@ export function getCssModuleLoader( ...@@ -25,7 +26,7 @@ export function getCssModuleLoader(
// Resolve CSS `@import`s and `url()`s // Resolve CSS `@import`s and `url()`s
loaders.push({ loaders.push({
loader: require.resolve('next/dist/compiled/css-loader'), loader: require.resolve('../../../../loaders/css-loader/src'),
options: { options: {
importLoaders: 1 + preProcessors.length, importLoaders: 1 + preProcessors.length,
// Use CJS mode for backwards compatibility: // Use CJS mode for backwards compatibility:
...@@ -53,9 +54,9 @@ export function getCssModuleLoader( ...@@ -53,9 +54,9 @@ export function getCssModuleLoader(
// Compile CSS // Compile CSS
loaders.push({ loaders.push({
loader: require.resolve('next/dist/compiled/postcss-loader'), loader: require.resolve('../../../../loaders/postcss-loader/src'),
options: { options: {
postcssOptions: { plugins: postCssPlugins, config: false }, postcss: postcss(postCssPlugins),
}, },
}) })
......
import { webpack } from 'next/dist/compiled/webpack/webpack' import { webpack } from 'next/dist/compiled/webpack/webpack'
import { getPostCssPlugins } from './plugins' import { getPostCssPlugins } from './plugins'
import postcss from 'postcss'
export async function __overrideCssConfiguration( export async function __overrideCssConfiguration(
rootDirectory: string, rootDirectory: string,
...@@ -15,6 +16,12 @@ export async function __overrideCssConfiguration( ...@@ -15,6 +16,12 @@ export async function __overrideCssConfiguration(
typeof rule.options.postcssOptions === 'object' typeof rule.options.postcssOptions === 'object'
) { ) {
rule.options.postcssOptions.plugins = postCssPlugins rule.options.postcssOptions.plugins = postCssPlugins
} else if (
rule.options &&
typeof rule.options === 'object' &&
typeof rule.options.postcss !== 'undefined'
) {
rule.options.postcss = postcss(postCssPlugins)
} else if (Array.isArray(rule.oneOf)) { } else if (Array.isArray(rule.oneOf)) {
rule.oneOf.forEach(patch) rule.oneOf.forEach(patch)
} else if (Array.isArray(rule.use)) { } else if (Array.isArray(rule.use)) {
......
export default 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
}
}
export default class Warning extends Error {
constructor(warning) {
super(warning)
const { text, line, column } = warning
this.name = 'Warning'
// Based on https://github.com/postcss/postcss/blob/master/lib/warning.es6#L74
// We don't need `plugin` properties.
this.message = `${this.name}\n\n`
if (typeof line !== 'undefined') {
this.message += `(${line}:${column}) `
}
this.message += `${text}`
// 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
}
}
/*
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)
}
export default camelCase
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
import { getOptions, stringifyRequest } from 'next/dist/compiled/loader-utils'
import postcss from 'postcss'
import CssSyntaxError from './CssSyntaxError'
import Warning from './Warning'
import { icssParser, importParser, urlParser } from './plugins'
import {
normalizeOptions,
shouldUseModulesPlugins,
shouldUseImportPlugin,
shouldUseURLPlugin,
shouldUseIcssPlugin,
getPreRequester,
getExportCode,
getFilter,
getImportCode,
getModuleCode,
getModulesPlugins,
normalizeSourceMap,
sort,
} from './utils'
export default async function loader(content, map, meta) {
const rawOptions = getOptions(this)
const plugins = []
const callback = this.async()
let options
try {
options = normalizeOptions(rawOptions, this)
} catch (error) {
callback(error)
return
}
const replacements = []
const exports = []
if (shouldUseModulesPlugins(options)) {
plugins.push(...getModulesPlugins(options, this))
}
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) =>
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) => 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) =>
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
}
}
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 (error) {
if (error.file) {
this.addDependency(error.file)
}
callback(
error.name === 'CssSyntaxError' ? new CssSyntaxError(error) : error
)
return
}
for (const warning of result.warnings()) {
this.emitWarning(new Warning(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: 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)
callback(null, `${importCode}${moduleCode}${exportCode}`)
}
import importParser from './postcss-import-parser'
import icssParser from './postcss-icss-parser'
import urlParser from './postcss-url-parser'
export { importParser, icssParser, urlParser }
import {
extractICSS,
replaceValueSymbols,
replaceSymbols,
} from 'next/dist/compiled/icss-utils'
import { normalizeUrl, resolveRequests, requestify } from '../utils'
const plugin = (options = {}) => {
return {
postcssPlugin: 'postcss-icss-parser',
async OnceExit(root) {
const importReplacements = Object.create(null)
const { icssImports, icssExports } = 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) {
// eslint-disable-next-line no-continue
continue
}
let normalizedUrl = url
let prefix = ''
const queryParts = normalizedUrl.split('!')
if (queryParts.length > 1) {
normalizedUrl = queryParts.pop()
prefix = queryParts.join('!')
}
const request = requestify(
normalizeUrl(normalizedUrl, true),
options.rootContext
)
const doResolve = async () => {
const { resolver, context } = options
const resolvedUrl = await 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) {
// eslint-disable-next-line no-continue
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) {
replaceSymbols(root, importReplacements)
}
for (const name of Object.keys(icssExports)) {
const value = replaceValueSymbols(icssExports[name], importReplacements)
options.exports.push({ name, value })
}
},
}
}
plugin.postcss = true
export default plugin
import valueParser from 'next/dist/compiled/postcss-value-parser'
import {
normalizeUrl,
resolveRequests,
isUrlRequestable,
requestify,
WEBPACK_IGNORE_COMMENT_REGEXP,
} from '../utils'
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(WEBPACK_IGNORE_COMMENT_REGEXP)
if (matched && matched[2] === 'true') {
return
}
}
const prevNode = atRule.prev()
if (prevNode && prevNode.type === 'comment') {
const matched = prevNode.text.match(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 } = valueParser(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
: valueParser.stringify(paramsNodes[0].nodes)
}
url = normalizeUrl(url, isStringValue)
const isRequestable = 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 = valueParser.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 = requestify(url, options.rootContext)
const { resolver, context } = options
const resolvedUrl = await 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) {
// eslint-disable-next-line no-continue
continue
}
const { url, isRequestable, media } = resolvedAtRule
if (!isRequestable) {
options.api.push({ url, media, index })
// eslint-disable-next-line no-continue
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
export default plugin
/*
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) {
const list = []
// return the list of modules as css string
list.toString = function toString() {
return this.map((item) => {
const content = cssWithMappingToString(item, useSourceMap)
if (item[2]) {
return `@media ${item[2]} {${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, '']]
}
const alreadyImportedModules = {}
if (dedupe) {
for (let i = 0; i < this.length; i++) {
// eslint-disable-next-line prefer-destructuring
const id = this[i][0]
if (id != null) {
alreadyImportedModules[id] = true
}
}
}
for (let i = 0; i < modules.length; i++) {
const item = [].concat(modules[i])
if (dedupe && alreadyImportedModules[item[0]]) {
// eslint-disable-next-line no-continue
continue
}
if (mediaQuery) {
if (!item[2]) {
item[2] = mediaQuery
} else {
item[2] = `${mediaQuery} and ${item[2]}`
}
}
list.push(item)
}
}
return list
}
function cssWithMappingToString(item, useSourceMap) {
const content = item[1] || ''
// eslint-disable-next-line prefer-destructuring
const cssMapping = item[3]
if (!cssMapping) {
return content
}
if (useSourceMap && typeof btoa === 'function') {
const sourceMapping = toComment(cssMapping)
const sourceURLs = cssMapping.sources.map(
(source) => `/*# sourceURL=${cssMapping.sourceRoot || ''}${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
const base64 = btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap))))
const data = `sourceMappingURL=data:application/json;charset=utf-8;base64,${base64}`
return `/*# ${data} */`
}
module.exports = (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 `"${url.replace(/"/g, '\\"').replace(/\n/g, '\\n')}"`
}
return url
}
This diff is collapsed.
import loaderUtils from 'next/dist/compiled/loader-utils' import loaderUtils from 'next/dist/compiled/loader-utils'
import path from 'path' import path from 'path'
import { validate } from 'next/dist/compiled/schema-utils3'
import isEqualLocals from './runtime/isEqualLocals' import isEqualLocals from './runtime/isEqualLocals'
const schema = {
type: 'object',
properties: {
injectType: {
description:
'Allows to setup how styles will be injected into DOM (https://github.com/webpack-contrib/style-loader#injecttype).',
enum: [
'styleTag',
'singletonStyleTag',
'lazyStyleTag',
'lazySingletonStyleTag',
'linkTag',
],
},
attributes: {
description:
'Adds custom attributes to tag (https://github.com/webpack-contrib/style-loader#attributes).',
type: 'object',
},
insert: {
description:
'Inserts `<style>`/`<link>` at the given position (https://github.com/webpack-contrib/style-loader#insert).',
anyOf: [
{
type: 'string',
},
{
instanceof: 'Function',
},
],
},
base: {
description:
'Sets module ID base for DLLPlugin (https://github.com/webpack-contrib/style-loader#base).',
type: 'number',
},
esModule: {
description:
'Use the ES modules syntax (https://github.com/webpack-contrib/css-loader#esmodule).',
type: 'boolean',
},
},
additionalProperties: false,
}
const loaderApi = () => {} const loaderApi = () => {}
loaderApi.pitch = function loader(request) { loaderApi.pitch = function loader(request) {
const options = loaderUtils.getOptions(this) const loaderSpan = this.currentTraceSpan.traceChild('next-style-loader')
validate(schema, options, { return loaderSpan.traceFn(() => {
name: 'Style Loader', const options = loaderUtils.getOptions(this)
baseDataPath: 'options',
}) const insert =
typeof options.insert === 'undefined'
const insert = ? '"head"'
typeof options.insert === 'undefined' : typeof options.insert === 'string'
? '"head"' ? JSON.stringify(options.insert)
: typeof options.insert === 'string' : options.insert.toString()
? JSON.stringify(options.insert) const injectType = options.injectType || 'styleTag'
: options.insert.toString() const esModule =
const injectType = options.injectType || 'styleTag' typeof options.esModule !== 'undefined' ? options.esModule : false
const esModule =
typeof options.esModule !== 'undefined' ? options.esModule : false delete options.esModule
delete options.esModule switch (injectType) {
case 'linkTag': {
switch (injectType) { const hmrCode = this.hot
case 'linkTag': { ? `
const hmrCode = this.hot
? `
if (module.hot) { if (module.hot) {
module.hot.accept( module.hot.accept(
${loaderUtils.stringifyRequest(this, `!!${request}`)}, ${loaderUtils.stringifyRequest(this, `!!${request}`)},
...@@ -97,29 +49,29 @@ if (module.hot) { ...@@ -97,29 +49,29 @@ if (module.hot) {
update(); update();
}); });
}` }`
: '' : ''
return `${ return `${
esModule esModule
? `import api from ${loaderUtils.stringifyRequest( ? `import api from ${loaderUtils.stringifyRequest(
this, this,
`!${path.join(__dirname, 'runtime/injectStylesIntoLinkTag.js')}` `!${path.join(__dirname, 'runtime/injectStylesIntoLinkTag.js')}`
)}; )};
import content from ${loaderUtils.stringifyRequest( import content from ${loaderUtils.stringifyRequest(
this, this,
`!!${request}` `!!${request}`
)};` )};`
: `var api = require(${loaderUtils.stringifyRequest( : `var api = require(${loaderUtils.stringifyRequest(
this, this,
`!${path.join(__dirname, 'runtime/injectStylesIntoLinkTag.js')}` `!${path.join(__dirname, 'runtime/injectStylesIntoLinkTag.js')}`
)}); )});
var content = require(${loaderUtils.stringifyRequest( var content = require(${loaderUtils.stringifyRequest(
this, this,
`!!${request}` `!!${request}`
)}); )});
content = content.__esModule ? content.default : content;` content = content.__esModule ? content.default : content;`
} }
var options = ${JSON.stringify(options)}; var options = ${JSON.stringify(options)};
...@@ -130,14 +82,14 @@ var update = api(content, options); ...@@ -130,14 +82,14 @@ var update = api(content, options);
${hmrCode} ${hmrCode}
${esModule ? 'export default {}' : ''}` ${esModule ? 'export default {}' : ''}`
} }
case 'lazyStyleTag': case 'lazyStyleTag':
case 'lazySingletonStyleTag': { case 'lazySingletonStyleTag': {
const isSingleton = injectType === 'lazySingletonStyleTag' const isSingleton = injectType === 'lazySingletonStyleTag'
const hmrCode = this.hot const hmrCode = this.hot
? ` ? `
if (module.hot) { if (module.hot) {
if (!content.locals || module.hot.invalidate) { if (!content.locals || module.hot.invalidate) {
var isEqualLocals = ${isEqualLocals.toString()}; var isEqualLocals = ${isEqualLocals.toString()};
...@@ -188,22 +140,28 @@ if (module.hot) { ...@@ -188,22 +140,28 @@ if (module.hot) {
} }
}); });
}` }`
: '' : ''
return `${ return `${
esModule esModule
? `import api from ${loaderUtils.stringifyRequest( ? `import api from ${loaderUtils.stringifyRequest(
this, this,
`!${path.join(__dirname, 'runtime/injectStylesIntoStyleTag.js')}` `!${path.join(
)}; __dirname,
'runtime/injectStylesIntoStyleTag.js'
)}`
)};
import content from ${loaderUtils.stringifyRequest( import content from ${loaderUtils.stringifyRequest(
this, this,
`!!${request}` `!!${request}`
)};` )};`
: `var api = require(${loaderUtils.stringifyRequest( : `var api = require(${loaderUtils.stringifyRequest(
this, this,
`!${path.join(__dirname, 'runtime/injectStylesIntoStyleTag.js')}` `!${path.join(
)}); __dirname,
'runtime/injectStylesIntoStyleTag.js'
)}`
)});
var content = require(${loaderUtils.stringifyRequest( var content = require(${loaderUtils.stringifyRequest(
this, this,
`!!${request}` `!!${request}`
...@@ -214,7 +172,7 @@ if (module.hot) { ...@@ -214,7 +172,7 @@ if (module.hot) {
if (typeof content === 'string') { if (typeof content === 'string') {
content = [[module.id, content, '']]; content = [[module.id, content, '']];
}` }`
} }
var refs = 0; var refs = 0;
var update; var update;
...@@ -243,15 +201,15 @@ exported.unuse = function() { ...@@ -243,15 +201,15 @@ exported.unuse = function() {
${hmrCode} ${hmrCode}
${esModule ? 'export default' : 'module.exports ='} exported;` ${esModule ? 'export default' : 'module.exports ='} exported;`
} }
case 'styleTag': case 'styleTag':
case 'singletonStyleTag': case 'singletonStyleTag':
default: { default: {
const isSingleton = injectType === 'singletonStyleTag' const isSingleton = injectType === 'singletonStyleTag'
const hmrCode = this.hot const hmrCode = this.hot
? ` ? `
if (module.hot) { if (module.hot) {
if (!content.locals || module.hot.invalidate) { if (!content.locals || module.hot.invalidate) {
var isEqualLocals = ${isEqualLocals.toString()}; var isEqualLocals = ${isEqualLocals.toString()};
...@@ -300,22 +258,28 @@ if (module.hot) { ...@@ -300,22 +258,28 @@ if (module.hot) {
update(); update();
}); });
}` }`
: '' : ''
return `${ return `${
esModule esModule
? `import api from ${loaderUtils.stringifyRequest( ? `import api from ${loaderUtils.stringifyRequest(
this, this,
`!${path.join(__dirname, 'runtime/injectStylesIntoStyleTag.js')}` `!${path.join(
)}; __dirname,
'runtime/injectStylesIntoStyleTag.js'
)}`
)};
import content from ${loaderUtils.stringifyRequest( import content from ${loaderUtils.stringifyRequest(
this, this,
`!!${request}` `!!${request}`
)};` )};`
: `var api = require(${loaderUtils.stringifyRequest( : `var api = require(${loaderUtils.stringifyRequest(
this, this,
`!${path.join(__dirname, 'runtime/injectStylesIntoStyleTag.js')}` `!${path.join(
)}); __dirname,
'runtime/injectStylesIntoStyleTag.js'
)}`
)});
var content = require(${loaderUtils.stringifyRequest( var content = require(${loaderUtils.stringifyRequest(
this, this,
`!!${request}` `!!${request}`
...@@ -326,7 +290,7 @@ if (module.hot) { ...@@ -326,7 +290,7 @@ if (module.hot) {
if (typeof content === 'string') { if (typeof content === 'string') {
content = [[module.id, content, '']]; content = [[module.id, content, '']];
}` }`
} }
var options = ${JSON.stringify(options)}; var options = ${JSON.stringify(options)};
...@@ -338,8 +302,9 @@ var update = api(content, options); ...@@ -338,8 +302,9 @@ var update = api(content, options);
${hmrCode} ${hmrCode}
${esModule ? 'export default' : 'module.exports ='} content.locals || {};` ${esModule ? 'export default' : 'module.exports ='} content.locals || {};`
}
} }
} })
} }
module.exports = loaderApi module.exports = loaderApi
/**
* **PostCSS Syntax Error**
*
* Loader wrapper for postcss syntax errors
*
* @class SyntaxError
* @extends Error
*
* @param {Object} err CssSyntaxError
*/
class SyntaxError extends Error {
constructor(error) {
super(error)
const { line, column, reason, plugin, file } = error
this.name = 'SyntaxError'
this.message = `${this.name}\n\n`
if (typeof line !== 'undefined') {
this.message += `(${line}:${column}) `
}
this.message += plugin ? `${plugin}: ` : ''
this.message += file ? `${file} ` : '<css input> '
this.message += `${reason}`
const code = error.showSourceCode()
if (code) {
this.message += `\n\n${code}\n`
}
this.stack = false
}
}
module.exports = SyntaxError
/**
* **PostCSS Plugin Warning**
*
* Loader wrapper for postcss plugin warnings (`root.messages`)
*
* @class Warning
* @extends Error
*
* @param {Object} warning PostCSS Warning
*/
class Warning extends Error {
constructor(warning) {
super(warning)
const { text, line, column, plugin } = warning
this.name = 'Warning'
this.message = `${this.name}\n\n`
if (typeof line !== 'undefined') {
this.message += `(${line}:${column}) `
}
this.message += plugin ? `${plugin}: ` : ''
this.message += `${text}`
this.stack = false
}
}
module.exports = Warning
import Warning from './Warning'
import SyntaxError from './Error'
import { normalizeSourceMap, normalizeSourceMapAfterPostcss } from './utils'
import { getOptions } from 'next/dist/compiled/loader-utils'
/**
* **PostCSS Loader**
*
* Loads && processes CSS with [PostCSS](https://github.com/postcss/postcss)
*
* @method loader
*
* @param {String} content Source
* @param {Object} sourceMap Source Map
* @param {Object} meta Meta
*
* @return {callback} callback Result
*/
export default async function loader(content, sourceMap, meta) {
const loaderSpan = this.currentTraceSpan.traceChild('postcss-loader')
const callback = this.async()
loaderSpan
.traceAsyncFn(async () => {
const options = getOptions(this)
const file = this.resourcePath
const useSourceMap =
typeof options.sourceMap !== 'undefined'
? options.sourceMap
: this.sourceMap
const processOptions = {
from: file,
to: file,
}
if (useSourceMap) {
processOptions.map = {
inline: false,
annotation: false,
...processOptions.map,
}
}
if (sourceMap && processOptions.map) {
processOptions.map.prev = loaderSpan
.traceChild('normalize-source-map')
.traceFn(() => normalizeSourceMap(sourceMap, this.context))
}
let root
// Reuse PostCSS AST from other loaders
if (meta && meta.ast && meta.ast.type === 'postcss') {
;({ root } = meta.ast)
}
let result
try {
result = await loaderSpan
.traceChild('postcss-process')
.traceAsyncFn(() =>
options.postcss.process(root || content, processOptions)
)
} catch (error) {
if (error.file) {
this.addDependency(error.file)
}
if (error.name === 'CssSyntaxError') {
throw new SyntaxError(error)
}
throw error
}
for (const warning of result.warnings()) {
this.emitWarning(new Warning(warning))
}
for (const message of result.messages) {
// eslint-disable-next-line default-case
switch (message.type) {
case 'dependency':
this.addDependency(message.file)
break
case 'build-dependency':
this.addBuildDependency(message.file)
break
case 'missing-dependency':
this.addMissingDependency(message.file)
break
case 'context-dependency':
this.addContextDependency(message.file)
break
case 'dir-dependency':
this.addContextDependency(message.dir)
break
case 'asset':
if (message.content && message.file) {
this.emitFile(
message.file,
message.content,
message.sourceMap,
message.info
)
}
}
}
// eslint-disable-next-line no-undefined
let map = result.map ? result.map.toJSON() : undefined
if (map && useSourceMap) {
map = normalizeSourceMapAfterPostcss(map, this.context)
}
const ast = {
type: 'postcss',
version: result.processor.version,
root: result.root,
}
return [result.css, map, { ast }]
})
.then(
([css, map, { ast }]) => {
callback?.(null, css, map, { ast })
},
(err) => {
callback?.(err)
}
)
}
import path from 'path'
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, resourceContext) {
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) {
newMap.sources = newMap.sources.map((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.resolve(sourceRoot, path.normalize(source))
: path.normalize(source)
return path.relative(resourceContext, absoluteSource)
}
return source
})
}
return newMap
}
function normalizeSourceMapAfterPostcss(map, resourceContext) {
const newMap = map
// result.map.file is an optional property that provides the output filename.
// Since we don't know the final filename in the webpack build chain yet, it makes no sense to have it.
// eslint-disable-next-line no-param-reassign
delete newMap.file
// eslint-disable-next-line no-param-reassign
newMap.sourceRoot = ''
// eslint-disable-next-line no-param-reassign
newMap.sources = newMap.sources.map((source) => {
if (source.indexOf('<') === 0) {
return source
}
const sourceType = getURLType(source)
// Do no touch `scheme-relative`, `path-absolute` and `absolute` types
if (sourceType === 'path-relative') {
return path.resolve(resourceContext, source)
}
return source
})
return newMap
}
export { normalizeSourceMap, normalizeSourceMapAfterPostcss }
module.exports=function(){"use strict";var n={762:function(n){n.exports=function(n){var t=[];t.toString=function toString(){return this.map(function(t){var r=cssWithMappingToString(t,n);if(t[2]){return"@media ".concat(t[2]," {").concat(r,"}")}return r}).join("")};t.i=function(n,r,o){if(typeof n==="string"){n=[[null,n,""]]}var e={};if(o){for(var a=0;a<this.length;a++){var c=this[a][0];if(c!=null){e[c]=true}}}for(var i=0;i<n.length;i++){var u=[].concat(n[i]);if(o&&e[u[0]]){continue}if(r){if(!u[2]){u[2]=r}else{u[2]="".concat(r," and ").concat(u[2])}}t.push(u)}};return t};function cssWithMappingToString(n,t){var r=n[1]||"";var o=n[3];if(!o){return r}if(t&&typeof btoa==="function"){var e=toComment(o);var a=o.sources.map(function(n){return"/*# sourceURL=".concat(o.sourceRoot||"").concat(n," */")});return[r].concat(a).concat([e]).join("\n")}return[r].join("\n")}function toComment(n){var t=btoa(unescape(encodeURIComponent(JSON.stringify(n))));var r="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(t);return"/*# ".concat(r," */")}}};var t={};function __nccwpck_require__(r){if(t[r]){return t[r].exports}var o=t[r]={exports:{}};var e=true;try{n[r](o,o.exports,__nccwpck_require__);e=false}finally{if(e)delete t[r]}return o.exports}__nccwpck_require__.ab=__dirname+"/";return __nccwpck_require__(762)}();
\ No newline at end of file
This diff is collapsed.
module.exports=function(){"use strict";var e={91:function(e){e.exports=function(e,r){if(!r){r={}}e=e&&e.__esModule?e.default:e;if(typeof e!=="string"){return e}if(/^['"].*['"]$/.test(e)){e=e.slice(1,-1)}if(r.hash){e+=r.hash}if(/["'() \t\n]/.test(e)||r.needQuotes){return'"'.concat(e.replace(/"/g,'\\"').replace(/\n/g,"\\n"),'"')}return e}}};var r={};function __nccwpck_require__(t){if(r[t]){return r[t].exports}var _=r[t]={exports:{}};var n=true;try{e[t](_,_.exports,__nccwpck_require__);n=false}finally{if(n)delete r[t]}return _.exports}__nccwpck_require__.ab=__dirname+"/";return __nccwpck_require__(91)}();
\ No newline at end of file
{"name":"css-loader","main":"cjs.js","author":"Tobias Koppers @sokra","license":"MIT"}
module.exports=(()=>{var e={723:e=>{const t=(e,t,r="rule")=>{return Object.keys(e).map(s=>{const o=e[s];const c=Object.keys(o).map(e=>t.decl({prop:e,value:o[e],raws:{before:"\n "}}));const a=c.length>0;const n=r==="rule"?t.rule({selector:`:import('${s}')`,raws:{after:a?"\n":""}}):t.atRule({name:"icss-import",params:`'${s}'`,raws:{after:a?"\n":""}});if(a){n.append(c)}return n})};const r=(e,t,r="rule")=>{const s=Object.keys(e).map(r=>t.decl({prop:r,value:e[r],raws:{before:"\n "}}));if(s.length===0){return[]}const o=r==="rule"?t.rule({selector:`:export`,raws:{after:"\n"}}):t.atRule({name:"icss-export",raws:{after:"\n"}});o.append(s);return[o]};const s=(e,s,o,c)=>[...t(e,o,c),...r(s,o,c)];e.exports=s},32:e=>{const t=/^:import\(("[^"]*"|'[^']*'|[^"']+)\)$/;const r=/^("[^"]*"|'[^']*'|[^"']+)$/;const s=e=>{const t={};e.walkDecls(e=>{const r=e.raws.before?e.raws.before.trim():"";t[r+e.prop]=e.value});return t};const o=(e,o=true,c="auto")=>{const a={};const n={};function addImports(e,t){const r=t.replace(/'|"/g,"");a[r]=Object.assign(a[r]||{},s(e));if(o){e.remove()}}function addExports(e){Object.assign(n,s(e));if(o){e.remove()}}e.each(e=>{if(e.type==="rule"&&c!=="at-rule"){if(e.selector.slice(0,7)===":import"){const r=t.exec(e.selector);if(r){addImports(e,r[1])}}if(e.selector===":export"){addExports(e)}}if(e.type==="atrule"&&c!=="rule"){if(e.name==="icss-import"){const t=r.exec(e.params);if(t){addImports(e,t[1])}}if(e.name==="icss-export"){addExports(e)}}});return{icssImports:a,icssExports:n}};e.exports=o},630:(e,t,r)=>{const s=r(46);const o=r(951);const c=r(32);const a=r(723);e.exports={replaceValueSymbols:s,replaceSymbols:o,extractICSS:c,createICSSRules:a}},951:(e,t,r)=>{const s=r(46);const o=(e,t)=>{e.walk(e=>{if(e.type==="decl"&&e.value){e.value=s(e.value.toString(),t)}else if(e.type==="rule"&&e.selector){e.selector=s(e.selector.toString(),t)}else if(e.type==="atrule"&&e.params){e.params=s(e.params.toString(),t)}})};e.exports=o},46:e=>{const t=/[$]?[\w-]+/g;const r=(e,r)=>{let s;while(s=t.exec(e)){const o=r[s[0]];if(o){e=e.slice(0,s.index)+o+e.slice(t.lastIndex);t.lastIndex-=s[0].length-o.length}}return e};e.exports=r}};var t={};function __nccwpck_require__(r){if(t[r]){return t[r].exports}var s=t[r]={exports:{}};var o=true;try{e[r](s,s.exports,__nccwpck_require__);o=false}finally{if(o)delete t[r]}return s.exports}__nccwpck_require__.ab=__dirname+"/";return __nccwpck_require__(630)})();
\ No newline at end of file
{"name":"icss-utils","main":"index.js","author":"Glen Maddern","license":"ISC"}
This source diff could not be displayed because it is too large. You can view the blob instead.
{"name":"postcss-loader","main":"cjs.js","author":"Andrey Sitnik <andrey@sitnik.ru>","license":"MIT"}
Copyright 2015 Glen Maddern
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
module.exports=(()=>{var e={513:(e,r,t)=>{const o=t(32);const n=/^(.+?)\s+from\s+(?:"([^"]+)"|'([^']+)'|(global))$/;const s=/^:import\((?:"([^"]+)"|'([^']+)')\)/;const c=1;function addImportToGraph(e,r,t,o){const n=r+"_"+"siblings";const s=r+"_"+e;if(o[s]!==c){if(!Array.isArray(o[n])){o[n]=[]}const r=o[n];if(Array.isArray(t[e])){t[e]=t[e].concat(r)}else{t[e]=r.slice()}o[s]=c;r.push(e)}}e.exports=((e={})=>{let r=0;const t=typeof e.createImportedName!=="function"?e=>`i__imported_${e.replace(/\W/g,"_")}_${r++}`:e.createImportedName;const c=e.failOnWrongOrder;return{postcssPlugin:"postcss-modules-extract-imports",prepare(){const e={};const r={};const a={};const i={};const p={};return{Once(l,f){l.walkRules(t=>{const o=s.exec(t.selector);if(o){const[,n,s]=o;const c=n||s;addImportToGraph(c,"root",e,r);a[c]=t}});l.walkDecls(/^composes$/,o=>{const s=o.value.match(n);if(!s){return}let c;let[,a,l,f,u]=s;if(u){c=a.split(/\s+/).map(e=>`global(${e})`)}else{const n=l||f;let s=o.parent;let u="";while(s.type!=="root"){u=s.parent.index(s)+"_"+u;s=s.parent}const{selector:_}=o.parent;const d=`_${u}${_}`;addImportToGraph(n,d,e,r);i[n]=o;p[n]=p[n]||{};c=a.split(/\s+/).map(e=>{if(!p[n][e]){p[n][e]=t(e,n)}return p[n][e]})}o.value=c.join(" ")});const u=o(e,c);if(u instanceof Error){const e=u.nodes.find(e=>i.hasOwnProperty(e));const r=i[e];throw r.error("Failed to resolve order of composed modules "+u.nodes.map(e=>"`"+e+"`").join(", ")+".",{plugin:"postcss-modules-extract-imports",word:"composes"})}let _;u.forEach(e=>{const r=p[e];let t=a[e];if(!t&&r){t=f.rule({selector:`:import("${e}")`,raws:{after:"\n"}});if(_){l.insertAfter(_,t)}else{l.prepend(t)}}_=t;if(!r){return}Object.keys(r).forEach(e=>{t.append(f.decl({value:e,prop:r[e],raws:{before:"\n "}}))})})}}}}});e.exports.postcss=true},32:e=>{const r=2;const t=1;function createError(e,r){const t=new Error("Nondeterministic import's order");const o=r[e];const n=o.find(t=>r[t].indexOf(e)>-1);t.nodes=[e,n];return t}function walkGraph(e,o,n,s,c){if(n[e]===r){return}if(n[e]===t){if(c){return createError(e,o)}return}n[e]=t;const a=o[e];const i=a.length;for(let e=0;e<i;++e){const r=walkGraph(a[e],o,n,s,c);if(r instanceof Error){return r}}n[e]=r;s.push(e)}function topologicalSort(e,r){const t=[];const o={};const n=Object.keys(e);const s=n.length;for(let c=0;c<s;++c){const s=walkGraph(n[c],e,o,t,r);if(s instanceof Error){return s}}return t}e.exports=topologicalSort}};var r={};function __nccwpck_require__(t){if(r[t]){return r[t].exports}var o=r[t]={exports:{}};var n=true;try{e[t](o,o.exports,__nccwpck_require__);n=false}finally{if(n)delete r[t]}return o.exports}__nccwpck_require__.ab=__dirname+"/";return __nccwpck_require__(513)})();
\ No newline at end of file
{"name":"postcss-modules-extract-imports","main":"index.js","author":"Glen Maddern","license":"ISC"}
The MIT License (MIT)
Copyright 2015 Mark Dalgleish <mark.john.dalgleish@gmail.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.
{"name":"postcss-modules-local-by-default","main":"index.js","author":"Mark Dalgleish","license":"MIT"}
ISC License (ISC)
Copyright (c) 2015, Glen Maddern
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
This diff is collapsed.
{"name":"postcss-modules-scope","main":"index.js","author":"Glen Maddern","license":"ISC"}
ISC License (ISC)
Copyright (c) 2015, Glen Maddern
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
\ No newline at end of file
module.exports=(()=>{"use strict";var e={171:(e,r,s)=>{const t=s(892);const n=/^(.+?|\([\s\S]+?\))\s+from\s+("[^"]*"|'[^']*'|[\w-]+)$/;const o=/(?:\s+|^)([\w-]+):?(.*?)$/;const p=/^([\w-]+)(?:\s+as\s+([\w-]+))?/;e.exports=(e=>{let r=0;const s=e&&e.createImportedName||(e=>`i__const_${e.replace(/\W/g,"_")}_${r++}`);return{postcssPlugin:"postcss-modules-values",prepare(e){const r=[];const a={};return{Once(c,l){c.walkAtRules(/value/i,c=>{const l=c.params.match(n);if(l){let[,e,t]=l;if(a[t]){t=a[t]}const n=e.replace(/^\(\s*([\s\S]+)\s*\)$/,"$1").split(/\s*,\s*/).map(e=>{const r=p.exec(e);if(r){const[,e,t=e]=r;const n=s(t);a[t]=n;return{theirName:e,importedName:n}}else{throw new Error(`@import statement "${e}" is invalid!`)}});r.push({path:t,imports:n});c.remove();return}if(c.params.indexOf("@value")!==-1){e.warn("Invalid value definition: "+c.params)}let[,u,i]=`${c.params}${c.raws.between}`.match(o);const _=i.replace(/\/\*((?!\*\/).*?)\*\//g,"");if(_.length===0){e.warn("Invalid value definition: "+c.params);c.remove();return}let f=/^\s+$/.test(_);if(!f){i=i.trim()}a[u]=t.replaceValueSymbols(i,a);c.remove()});if(!Object.keys(a).length){return}t.replaceSymbols(c,a);const u=Object.keys(a).map(e=>l.decl({value:a[e],prop:e,raws:{before:"\n "}}));if(u.length>0){const e=l.rule({selector:":export",raws:{after:"\n"}});e.append(u);c.prepend(e)}r.reverse().forEach(({path:e,imports:r})=>{const s=l.rule({selector:`:import(${e})`,raws:{after:"\n"}});r.forEach(({theirName:e,importedName:r})=>{s.append({value:e,prop:r,raws:{before:"\n "}})});c.prepend(s)})}}}}});e.exports.postcss=true},892:e=>{e.exports=require("next/dist/compiled/icss-utils")}};var r={};function __nccwpck_require__(s){if(r[s]){return r[s].exports}var t=r[s]={exports:{}};var n=true;try{e[s](t,t.exports,__nccwpck_require__);n=false}finally{if(n)delete r[s]}return t.exports}__nccwpck_require__.ab=__dirname+"/";return __nccwpck_require__(171)})();
\ No newline at end of file
{"name":"postcss-modules-values","main":"index.js","author":"Glen Maddern","license":"ISC"}
The MIT License (MIT)
Copyright 2013 Andrey Sitnik <andrey@sitnik.ru>
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.
{"name":"postcss-safe-parser","main":"safe-parse.js","author":"Andrey Sitnik <andrey@sitnik.ru>","license":"MIT"}
This diff is collapsed.
Copyright (c) Bogdan Chadkin <trysound@yandex.ru>
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.
module.exports=(()=>{var r={285:(r,f,A)=>{var C=A(920);var y=A(987);var d=A(952);function ValueParser(r){if(this instanceof ValueParser){this.nodes=C(r);return this}return new ValueParser(r)}ValueParser.prototype.toString=function(){return Array.isArray(this.nodes)?d(this.nodes):""};ValueParser.prototype.walk=function(r,f){y(this.nodes,r,f);return this};ValueParser.unit=A(148);ValueParser.walk=y;ValueParser.stringify=d;r.exports=ValueParser},920:r=>{var f="(".charCodeAt(0);var A=")".charCodeAt(0);var C="'".charCodeAt(0);var y='"'.charCodeAt(0);var d="\\".charCodeAt(0);var _="/".charCodeAt(0);var g=",".charCodeAt(0);var I=":".charCodeAt(0);var V="*".charCodeAt(0);var N="u".charCodeAt(0);var E="U".charCodeAt(0);var S="+".charCodeAt(0);var U=/^[a-f0-9?-]+$/i;r.exports=function(r){var $=[];var j=r;var z,B,D,F,G,H,J,K;var L=0;var M=j.charCodeAt(L);var T=j.length;var W=[{nodes:$}];var X=0;var Y;var Z="";var q="";var R="";while(L<T){if(M<=32){z=L;do{z+=1;M=j.charCodeAt(z)}while(M<=32);F=j.slice(L,z);D=$[$.length-1];if(M===A&&X){R=F}else if(D&&D.type==="div"){D.after=F}else if(M===g||M===I||M===_&&j.charCodeAt(z+1)!==V&&(!Y||Y&&Y.type==="function"&&Y.value!=="calc")){q=F}else{$.push({type:"space",sourceIndex:L,value:F})}L=z}else if(M===C||M===y){z=L;B=M===C?"'":'"';F={type:"string",sourceIndex:L,quote:B};do{G=false;z=j.indexOf(B,z+1);if(~z){H=z;while(j.charCodeAt(H-1)===d){H-=1;G=!G}}else{j+=B;z=j.length-1;F.unclosed=true}}while(G);F.value=j.slice(L+1,z);$.push(F);L=z+1;M=j.charCodeAt(L)}else if(M===_&&j.charCodeAt(L+1)===V){F={type:"comment",sourceIndex:L};z=j.indexOf("*/",L);if(z===-1){F.unclosed=true;z=j.length}F.value=j.slice(L+2,z);$.push(F);L=z+2;M=j.charCodeAt(L)}else if((M===_||M===V)&&Y&&Y.type==="function"&&Y.value==="calc"){F=j[L];$.push({type:"word",sourceIndex:L-q.length,value:F});L+=1;M=j.charCodeAt(L)}else if(M===_||M===g||M===I){F=j[L];$.push({type:"div",sourceIndex:L-q.length,value:F,before:q,after:""});q="";L+=1;M=j.charCodeAt(L)}else if(f===M){z=L;do{z+=1;M=j.charCodeAt(z)}while(M<=32);K=L;F={type:"function",sourceIndex:L-Z.length,value:Z,before:j.slice(K+1,z)};L=z;if(Z==="url"&&M!==C&&M!==y){z-=1;do{G=false;z=j.indexOf(")",z+1);if(~z){H=z;while(j.charCodeAt(H-1)===d){H-=1;G=!G}}else{j+=")";z=j.length-1;F.unclosed=true}}while(G);J=z;do{J-=1;M=j.charCodeAt(J)}while(M<=32);if(K<J){if(L!==J+1){F.nodes=[{type:"word",sourceIndex:L,value:j.slice(L,J+1)}]}else{F.nodes=[]}if(F.unclosed&&J+1!==z){F.after="";F.nodes.push({type:"space",sourceIndex:J+1,value:j.slice(J+1,z)})}else{F.after=j.slice(J+1,z)}}else{F.after="";F.nodes=[]}L=z+1;M=j.charCodeAt(L);$.push(F)}else{X+=1;F.after="";$.push(F);W.push(F);$=F.nodes=[];Y=F}Z=""}else if(A===M&&X){L+=1;M=j.charCodeAt(L);Y.after=R;R="";X-=1;W.pop();Y=W[X];$=Y.nodes}else{z=L;do{if(M===d){z+=1}z+=1;M=j.charCodeAt(z)}while(z<T&&!(M<=32||M===C||M===y||M===g||M===I||M===_||M===f||M===V&&Y&&Y.type==="function"&&Y.value==="calc"||M===_&&Y.type==="function"&&Y.value==="calc"||M===A&&X));F=j.slice(L,z);if(f===M){Z=F}else if((N===F.charCodeAt(0)||E===F.charCodeAt(0))&&S===F.charCodeAt(1)&&U.test(F.slice(2))){$.push({type:"unicode-range",sourceIndex:L,value:F})}else{$.push({type:"word",sourceIndex:L,value:F})}L=z}}for(L=W.length-1;L;L-=1){W[L].unclosed=true}return W[0].nodes}},952:r=>{function stringifyNode(r,f){var A=r.type;var C=r.value;var y;var d;if(f&&(d=f(r))!==undefined){return d}else if(A==="word"||A==="space"){return C}else if(A==="string"){y=r.quote||"";return y+C+(r.unclosed?"":y)}else if(A==="comment"){return"/*"+C+(r.unclosed?"":"*/")}else if(A==="div"){return(r.before||"")+C+(r.after||"")}else if(Array.isArray(r.nodes)){y=stringify(r.nodes,f);if(A!=="function"){return y}return C+"("+(r.before||"")+y+(r.after||"")+(r.unclosed?"":")")}return C}function stringify(r,f){var A,C;if(Array.isArray(r)){A="";for(C=r.length-1;~C;C-=1){A=stringifyNode(r[C],f)+A}return A}return stringifyNode(r,f)}r.exports=stringify},148:r=>{var f="-".charCodeAt(0);var A="+".charCodeAt(0);var C=".".charCodeAt(0);var y="e".charCodeAt(0);var d="E".charCodeAt(0);function likeNumber(r){var y=r.charCodeAt(0);var d;if(y===A||y===f){d=r.charCodeAt(1);if(d>=48&&d<=57){return true}var _=r.charCodeAt(2);if(d===C&&_>=48&&_<=57){return true}return false}if(y===C){d=r.charCodeAt(1);if(d>=48&&d<=57){return true}return false}if(y>=48&&y<=57){return true}return false}r.exports=function(r){var _=0;var g=r.length;var I;var V;var N;if(g===0||!likeNumber(r)){return false}I=r.charCodeAt(_);if(I===A||I===f){_++}while(_<g){I=r.charCodeAt(_);if(I<48||I>57){break}_+=1}I=r.charCodeAt(_);V=r.charCodeAt(_+1);if(I===C&&V>=48&&V<=57){_+=2;while(_<g){I=r.charCodeAt(_);if(I<48||I>57){break}_+=1}}I=r.charCodeAt(_);V=r.charCodeAt(_+1);N=r.charCodeAt(_+2);if((I===y||I===d)&&(V>=48&&V<=57||(V===A||V===f)&&N>=48&&N<=57)){_+=V===A||V===f?3:2;while(_<g){I=r.charCodeAt(_);if(I<48||I>57){break}_+=1}}return{number:r.slice(0,_),unit:r.slice(_)}}},987:r=>{r.exports=function walk(r,f,A){var C,y,d,_;for(C=0,y=r.length;C<y;C+=1){d=r[C];if(!A){_=f(d,C,r)}if(_!==false&&d.type==="function"&&Array.isArray(d.nodes)){walk(d.nodes,f,A)}if(A){f(d,C,r)}}}}};var f={};function __nccwpck_require__(A){if(f[A]){return f[A].exports}var C=f[A]={exports:{}};var y=true;try{r[A](C,C.exports,__nccwpck_require__);y=false}finally{if(y)delete f[A]}return C.exports}__nccwpck_require__.ab=__dirname+"/";return __nccwpck_require__(285)})();
\ No newline at end of file
{"name":"postcss-value-parser","main":"index.js","author":"Bogdan Chadkin <trysound@yandex.ru>","license":"MIT"}
...@@ -206,7 +206,6 @@ ...@@ -206,7 +206,6 @@
"content-type": "1.0.4", "content-type": "1.0.4",
"cookie": "0.4.1", "cookie": "0.4.1",
"cross-spawn": "6.0.5", "cross-spawn": "6.0.5",
"css-loader": "4.3.0",
"debug": "4.1.1", "debug": "4.1.1",
"devalue": "2.0.1", "devalue": "2.0.1",
"escape-string-regexp": "2.0.0", "escape-string-regexp": "2.0.0",
...@@ -217,6 +216,7 @@ ...@@ -217,6 +216,7 @@
"glob": "7.1.7", "glob": "7.1.7",
"gzip-size": "5.1.1", "gzip-size": "5.1.1",
"http-proxy": "1.18.1", "http-proxy": "1.18.1",
"icss-utils": "5.1.0",
"ignore-loader": "0.1.2", "ignore-loader": "0.1.2",
"is-docker": "2.0.0", "is-docker": "2.0.0",
"is-wsl": "2.2.0", "is-wsl": "2.2.0",
...@@ -231,9 +231,14 @@ ...@@ -231,9 +231,14 @@
"ora": "4.0.4", "ora": "4.0.4",
"path-to-regexp": "6.1.0", "path-to-regexp": "6.1.0",
"postcss-flexbugs-fixes": "5.0.2", "postcss-flexbugs-fixes": "5.0.2",
"postcss-loader": "4.3.0", "postcss-modules-extract-imports": "3.0.0",
"postcss-modules-local-by-default": "4.0.0",
"postcss-modules-scope": "3.0.0",
"postcss-modules-values": "4.0.0",
"postcss-preset-env": "6.7.0", "postcss-preset-env": "6.7.0",
"postcss-safe-parser": "6.0.0",
"postcss-scss": "3.0.5", "postcss-scss": "3.0.5",
"postcss-value-parser": "4.1.0",
"recast": "0.18.5", "recast": "0.18.5",
"resolve-url-loader": "3.1.2", "resolve-url-loader": "3.1.2",
"sass-loader": "10.0.5", "sass-loader": "10.0.5",
......
...@@ -45,7 +45,10 @@ const externals = { ...@@ -45,7 +45,10 @@ const externals = {
chalk: 'chalk', chalk: 'chalk',
'node-fetch': 'node-fetch', 'node-fetch': 'node-fetch',
// postcss: 'postcss', postcss: 'postcss',
// Ensure latest version is used
'postcss-safe-parser': 'next/dist/compiled/postcss-safe-parser',
'cssnano-simple': 'next/dist/build/cssnano-simple',
// webpack // webpack
'node-libs-browser': 'node-libs-browser', 'node-libs-browser': 'node-libs-browser',
...@@ -250,21 +253,6 @@ export async function ncc_cross_spawn(task, opts) { ...@@ -250,21 +253,6 @@ export async function ncc_cross_spawn(task, opts) {
.target('compiled/cross-spawn') .target('compiled/cross-spawn')
} }
// eslint-disable-next-line camelcase // eslint-disable-next-line camelcase
externals['css-loader'] = 'next/dist/compiled/css-loader'
export async function ncc_css_loader(task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('css-loader')))
.ncc({
packageName: 'css-loader',
externals: {
...externals,
'schema-utils': 'next/dist/compiled/schema-utils',
},
target: 'es5',
})
.target('compiled/css-loader')
}
// eslint-disable-next-line camelcase
externals['debug'] = 'next/dist/compiled/debug' externals['debug'] = 'next/dist/compiled/debug'
export async function ncc_debug(task, opts) { export async function ncc_debug(task, opts) {
await task await task
...@@ -454,18 +442,13 @@ export async function ncc_postcss_flexbugs_fixes(task, opts) { ...@@ -454,18 +442,13 @@ export async function ncc_postcss_flexbugs_fixes(task, opts) {
.target('compiled/postcss-flexbugs-fixes') .target('compiled/postcss-flexbugs-fixes')
} }
// eslint-disable-next-line camelcase // eslint-disable-next-line camelcase
externals['postcss-loader'] = 'next/dist/compiled/postcss-loader' export async function ncc_postcss_safe_parser(task, opts) {
export async function ncc_postcss_loader(task, opts) {
await task await task
.source(opts.src || relative(__dirname, require.resolve('postcss-loader'))) .source(
.ncc({ opts.src || relative(__dirname, require.resolve('postcss-safe-parser'))
packageName: 'postcss-loader', )
externals: { .ncc({ packageName: 'postcss-safe-parser', externals })
...externals, .target('compiled/postcss-safe-parser')
'schema-utils': 'next/dist/compiled/schema-utils3',
},
})
.target('compiled/postcss-loader')
} }
// eslint-disable-next-line camelcase // eslint-disable-next-line camelcase
externals['postcss-preset-env'] = 'next/dist/compiled/postcss-preset-env' externals['postcss-preset-env'] = 'next/dist/compiled/postcss-preset-env'
...@@ -485,7 +468,6 @@ export async function ncc_postcss_scss(task, opts) { ...@@ -485,7 +468,6 @@ export async function ncc_postcss_scss(task, opts) {
.ncc({ .ncc({
packageName: 'postcss-scss', packageName: 'postcss-scss',
externals: { externals: {
postcss: 'postcss',
'postcss/lib/parser': 'postcss/lib/parser', 'postcss/lib/parser': 'postcss/lib/parser',
...externals, ...externals,
}, },
...@@ -493,6 +475,105 @@ export async function ncc_postcss_scss(task, opts) { ...@@ -493,6 +475,105 @@ export async function ncc_postcss_scss(task, opts) {
.target('compiled/postcss-scss') .target('compiled/postcss-scss')
} }
// eslint-disable-next-line camelcase // eslint-disable-next-line camelcase
externals['postcss-modules-extract-imports'] =
'next/dist/compiled/postcss-modules-extract-imports'
export async function ncc_postcss_modules_extract_imports(task, opts) {
await task
.source(
opts.src ||
relative(__dirname, require.resolve('postcss-modules-extract-imports'))
)
.ncc({
packageName: 'postcss-modules-extract-imports',
externals: {
'postcss/lib/parser': 'postcss/lib/parser',
...externals,
},
})
.target('compiled/postcss-modules-extract-imports')
}
// eslint-disable-next-line camelcase
externals['postcss-modules-local-by-default'] =
'next/dist/compiled/postcss-modules-local-by-default'
export async function ncc_postcss_modules_local_by_default(task, opts) {
await task
.source(
opts.src ||
relative(__dirname, require.resolve('postcss-modules-local-by-default'))
)
.ncc({
packageName: 'postcss-modules-local-by-default',
externals: {
'postcss/lib/parser': 'postcss/lib/parser',
...externals,
},
})
.target('compiled/postcss-modules-local-by-default')
}
// eslint-disable-next-line camelcase
externals['postcss-modules-scope'] = 'next/dist/compiled/postcss-modules-scope'
export async function ncc_postcss_modules_scope(task, opts) {
await task
.source(
opts.src || relative(__dirname, require.resolve('postcss-modules-scope'))
)
.ncc({
packageName: 'postcss-modules-scope',
externals: {
'postcss/lib/parser': 'postcss/lib/parser',
...externals,
},
})
.target('compiled/postcss-modules-scope')
}
// eslint-disable-next-line camelcase
externals['postcss-modules-values'] =
'next/dist/compiled/postcss-modules-values'
export async function ncc_postcss_modules_values(task, opts) {
await task
.source(
opts.src || relative(__dirname, require.resolve('postcss-modules-values'))
)
.ncc({
packageName: 'postcss-modules-values',
externals: {
'postcss/lib/parser': 'postcss/lib/parser',
...externals,
},
})
.target('compiled/postcss-modules-values')
}
// eslint-disable-next-line camelcase
externals['postcss-value-parser'] = 'next/dist/compiled/postcss-value-parser'
export async function ncc_postcss_value_parser(task, opts) {
await task
.source(
opts.src || relative(__dirname, require.resolve('postcss-value-parser'))
)
.ncc({
packageName: 'postcss-value-parser',
externals: {
'postcss/lib/parser': 'postcss/lib/parser',
...externals,
},
})
.target('compiled/postcss-value-parser')
}
// eslint-disable-next-line camelcase
externals['icss-utils'] = 'next/dist/compiled/icss-utils'
export async function ncc_icss_utils(task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('icss-utils')))
.ncc({
packageName: 'icss-utils',
externals: {
'postcss/lib/parser': 'postcss/lib/parser',
...externals,
},
})
.target('compiled/icss-utils')
}
// eslint-disable-next-line camelcase
externals['recast'] = 'next/dist/compiled/recast' externals['recast'] = 'next/dist/compiled/recast'
export async function ncc_recast(task, opts) { export async function ncc_recast(task, opts) {
await task await task
...@@ -786,7 +867,6 @@ export async function ncc(task, opts) { ...@@ -786,7 +867,6 @@ export async function ncc(task, opts) {
'ncc_content_type', 'ncc_content_type',
'ncc_cookie', 'ncc_cookie',
'ncc_cross_spawn', 'ncc_cross_spawn',
'ncc_css_loader',
'ncc_debug', 'ncc_debug',
'ncc_devalue', 'ncc_devalue',
'ncc_escape_string_regexp', 'ncc_escape_string_regexp',
...@@ -809,10 +889,16 @@ export async function ncc(task, opts) { ...@@ -809,10 +889,16 @@ export async function ncc(task, opts) {
'ncc_nanoid', 'ncc_nanoid',
'ncc_neo_async', 'ncc_neo_async',
'ncc_ora', 'ncc_ora',
'ncc_postcss_safe_parser',
'ncc_postcss_flexbugs_fixes', 'ncc_postcss_flexbugs_fixes',
'ncc_postcss_loader',
'ncc_postcss_preset_env', 'ncc_postcss_preset_env',
'ncc_postcss_scss', 'ncc_postcss_scss',
'ncc_postcss_modules_extract_imports',
'ncc_postcss_modules_local_by_default',
'ncc_postcss_modules_scope',
'ncc_postcss_modules_values',
'ncc_postcss_value_parser',
'ncc_icss_utils',
'ncc_recast', 'ncc_recast',
'ncc_resolve_url_loader', 'ncc_resolve_url_loader',
'ncc_sass_loader', 'ncc_sass_loader',
......
...@@ -859,7 +859,7 @@ test('css syntax errors', async () => { ...@@ -859,7 +859,7 @@ test('css syntax errors', async () => {
Syntax error: Selector \\"button\\" is not pure (pure selectors must contain at least one local class or id) Syntax error: Selector \\"button\\" is not pure (pure selectors must contain at least one local class or id)
> 1 | button {} > 1 | button {}
| ^" | ^"
`) `)
await cleanup() await cleanup()
......
...@@ -36,7 +36,7 @@ describe('AMP Fragment Styles', () => { ...@@ -36,7 +36,7 @@ describe('AMP Fragment Styles', () => {
await validateAMP(html) await validateAMP(html)
const $ = cheerio.load(html) const $ = cheerio.load(html)
const styles = $('style[amp-custom]').text() const styles = $('style[amp-custom]').text()
expect(styles).toMatch(/background:(.*|)#ff69b4/) expect(styles).toMatch(/background:(.*|)hotpink/)
expect(styles).toMatch(/font-size:(.*|)16\.4px/) expect(styles).toMatch(/font-size:(.*|)16\.4px/)
}) })
}) })
...@@ -232,7 +232,7 @@ describe('AMP Usage', () => { ...@@ -232,7 +232,7 @@ describe('AMP Usage', () => {
const html = await renderViaHTTP(appPort, '/styled?amp=1') const html = await renderViaHTTP(appPort, '/styled?amp=1')
const $ = cheerio.load(html) const $ = cheerio.load(html)
expect($('style[amp-custom]').first().text()).toMatch( expect($('style[amp-custom]').first().text()).toMatch(
/div.jsx-\d+{color:red}span.jsx-\d+{color:#00f}body{background-color:green}/ /div.jsx-\d+{color:red}span.jsx-\d+{color:blue}body{background-color:green}/
) )
}) })
......
...@@ -108,39 +108,6 @@ describe('Legacy Next-CSS Customization', () => { ...@@ -108,39 +108,6 @@ describe('Legacy Next-CSS Customization', () => {
}) })
}) })
describe('Custom CSS Customization via Webpack', () => {
const appDir = join(fixturesDir, 'custom-configuration-webpack')
beforeAll(async () => {
await remove(join(appDir, '.next'))
})
it('should compile successfully', async () => {
const { code, stdout, stderr } = await nextBuild(appDir, [], {
stdout: true,
stderr: true,
})
expect(code).toBe(0)
expect(stdout).toMatch(/Compiled successfully/)
expect(stderr).not.toMatch(
/Built-in CSS support is being disabled due to custom CSS configuration being detected/
)
})
it(`should've compiled and prefixed`, async () => {
const cssFolder = join(appDir, '.next/static/css')
const files = await readdir(cssFolder)
const cssFiles = files.filter((f) => /\.css$/.test(f))
expect(cssFiles.length).toBe(1)
const cssContent = await readFile(join(cssFolder, cssFiles[0]), 'utf8')
expect(cssContent.replace(/\/\*.*?\*\//g, '').trim()).toMatchInlineSnapshot(
`"@media (480px <= width < 768px){::placeholder{color:green}}.video{max-width:400px;max-height:300px}"`
)
})
})
describe('CSS Customization Array', () => { describe('CSS Customization Array', () => {
const appDir = join(fixturesDir, 'custom-configuration-arr') const appDir = join(fixturesDir, 'custom-configuration-arr')
......
module.exports = {
onDemandEntries: {
maxInactiveAge: 1000 * 60 * 60,
},
webpack(config) {
modifyLoaderConfig(
config.module.rules,
[/(?<!\.module)\.css$/, /\.module\.css$/],
(rule) => {
if (!Array.isArray(rule.use)) return
rule.use.forEach((u) => {
if (u.options.postcssOptions) {
u.options.postcssOptions.plugins = [
require('postcss-short-size')({
// Add a prefix to test that configuration is passed
prefix: 'xyz',
}),
]
}
})
}
)
return config
},
future: { strictPostcssConfiguration: true },
}
function modifyLoaderConfig(rules, regexes, cb) {
rules.forEach((rule) => {
if (rule.oneOf) return modifyLoaderConfig(rule.oneOf, regexes, cb)
regexes.forEach((regex) => {
if (rule.test && rule.test.toString() === regex.toString()) cb(rule)
})
})
}
import React from 'react'
import App from 'next/app'
import '../styles/global.css'
class MyApp extends App {
render() {
const { Component, pageProps } = this.props
return <Component {...pageProps} />
}
}
export default MyApp
/* this should pass through untransformed */
@media (480px <= width < 768px) {
::placeholder {
color: green;
}
}
/* this should be transformed to width/height */
.video {
-xyz-max-size: 400px 300px;
}
...@@ -43,7 +43,7 @@ function runTests() { ...@@ -43,7 +43,7 @@ function runTests() {
it('should render styles during SSR (AMP)', async () => { it('should render styles during SSR (AMP)', async () => {
const html = await renderViaHTTP(appPort, '/amp') const html = await renderViaHTTP(appPort, '/amp')
expect(html).toMatch(/color:.*?#0ff/) expect(html).toMatch(/color:.*?cyan/)
}) })
} }
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment