Use consistent postcss version for all transforms (#28529)
Co-authored-by: JJ Kasper <jj@jjsweb.site>
This commit is contained in:
parent
c9efbe1818
commit
9a56fdba82
66 changed files with 2651 additions and 369 deletions
|
@ -34,6 +34,7 @@
|
|||
"lint-staged": "lint-staged",
|
||||
"next-with-deps": "./scripts/next-with-deps.sh",
|
||||
"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",
|
||||
"debug": "node --inspect packages/next/dist/bin/next"
|
||||
},
|
||||
|
|
1
packages/next/build/cssnano-simple.js
Normal file
1
packages/next/build/cssnano-simple.js
Normal file
|
@ -0,0 +1 @@
|
|||
module.exports = require('cssnano-simple')(require('postcss'))
|
|
@ -11,6 +11,69 @@ import {
|
|||
getLocalModuleImportError,
|
||||
} from './messages'
|
||||
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
|
||||
export const regexLikeCss = /\.(css|scss|sass)(\.webpack\[javascript\/auto\])?$/
|
||||
|
|
|
@ -3,10 +3,11 @@ import { webpack } from 'next/dist/compiled/webpack/webpack'
|
|||
import { ConfigurationContext } from '../../../utils'
|
||||
import { getClientStyleLoader } from './client'
|
||||
import { cssFileResolve } from './file-resolve'
|
||||
import postcss from 'postcss'
|
||||
|
||||
export function getGlobalCssLoader(
|
||||
ctx: ConfigurationContext,
|
||||
postCssPlugins: readonly AcceptedPlugin[],
|
||||
postCssPlugins: AcceptedPlugin[],
|
||||
preProcessors: readonly webpack.RuleSetUseItem[] = []
|
||||
): webpack.RuleSetUseItem[] {
|
||||
const loaders: webpack.RuleSetUseItem[] = []
|
||||
|
@ -24,7 +25,7 @@ export function getGlobalCssLoader(
|
|||
|
||||
// Resolve CSS `@import`s and `url()`s
|
||||
loaders.push({
|
||||
loader: require.resolve('next/dist/compiled/css-loader'),
|
||||
loader: require.resolve('../../../../loaders/css-loader/src'),
|
||||
options: {
|
||||
importLoaders: 1 + preProcessors.length,
|
||||
// Next.js controls CSS Modules eligibility:
|
||||
|
@ -37,9 +38,9 @@ export function getGlobalCssLoader(
|
|||
|
||||
// Compile CSS
|
||||
loaders.push({
|
||||
loader: require.resolve('next/dist/compiled/postcss-loader'),
|
||||
loader: require.resolve('../../../../loaders/postcss-loader/src'),
|
||||
options: {
|
||||
postcssOptions: { plugins: postCssPlugins, config: false },
|
||||
postcss: postcss(postCssPlugins),
|
||||
},
|
||||
})
|
||||
|
||||
|
|
|
@ -4,10 +4,11 @@ import { ConfigurationContext } from '../../../utils'
|
|||
import { getClientStyleLoader } from './client'
|
||||
import { cssFileResolve } from './file-resolve'
|
||||
import { getCssModuleLocalIdent } from './getCssModuleLocalIdent'
|
||||
import postcss from 'postcss'
|
||||
|
||||
export function getCssModuleLoader(
|
||||
ctx: ConfigurationContext,
|
||||
postCssPlugins: readonly AcceptedPlugin[],
|
||||
postCssPlugins: AcceptedPlugin[],
|
||||
preProcessors: readonly webpack.RuleSetUseItem[] = []
|
||||
): webpack.RuleSetUseItem[] {
|
||||
const loaders: webpack.RuleSetUseItem[] = []
|
||||
|
@ -25,7 +26,7 @@ export function getCssModuleLoader(
|
|||
|
||||
// Resolve CSS `@import`s and `url()`s
|
||||
loaders.push({
|
||||
loader: require.resolve('next/dist/compiled/css-loader'),
|
||||
loader: require.resolve('../../../../loaders/css-loader/src'),
|
||||
options: {
|
||||
importLoaders: 1 + preProcessors.length,
|
||||
// Use CJS mode for backwards compatibility:
|
||||
|
@ -53,9 +54,9 @@ export function getCssModuleLoader(
|
|||
|
||||
// Compile CSS
|
||||
loaders.push({
|
||||
loader: require.resolve('next/dist/compiled/postcss-loader'),
|
||||
loader: require.resolve('../../../../loaders/postcss-loader/src'),
|
||||
options: {
|
||||
postcssOptions: { plugins: postCssPlugins, config: false },
|
||||
postcss: postcss(postCssPlugins),
|
||||
},
|
||||
})
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { webpack } from 'next/dist/compiled/webpack/webpack'
|
||||
import { getPostCssPlugins } from './plugins'
|
||||
import postcss from 'postcss'
|
||||
|
||||
export async function __overrideCssConfiguration(
|
||||
rootDirectory: string,
|
||||
|
@ -15,6 +16,12 @@ export async function __overrideCssConfiguration(
|
|||
typeof rule.options.postcssOptions === 'object'
|
||||
) {
|
||||
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)) {
|
||||
rule.oneOf.forEach(patch)
|
||||
} else if (Array.isArray(rule.use)) {
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
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
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
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
|
||||
}
|
||||
}
|
115
packages/next/build/webpack/loaders/css-loader/src/camelcase.js
Normal file
115
packages/next/build/webpack/loaders/css-loader/src/camelcase.js
Normal file
|
@ -0,0 +1,115 @@
|
|||
/*
|
||||
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
|
193
packages/next/build/webpack/loaders/css-loader/src/index.js
Normal file
193
packages/next/build/webpack/loaders/css-loader/src/index.js
Normal file
|
@ -0,0 +1,193 @@
|
|||
/*
|
||||
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}`)
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
import importParser from './postcss-import-parser'
|
||||
import icssParser from './postcss-icss-parser'
|
||||
import urlParser from './postcss-url-parser'
|
||||
|
||||
export { importParser, icssParser, urlParser }
|
|
@ -0,0 +1,114 @@
|
|||
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
|
|
@ -0,0 +1,243 @@
|
|||
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
|
|
@ -0,0 +1,433 @@
|
|||
import valueParser from 'next/dist/compiled/postcss-value-parser'
|
||||
|
||||
import {
|
||||
resolveRequests,
|
||||
normalizeUrl,
|
||||
requestify,
|
||||
isUrlRequestable,
|
||||
isDataUrl,
|
||||
WEBPACK_IGNORE_COMMENT_REGEXP,
|
||||
} from '../utils'
|
||||
|
||||
const isUrlFunc = /url/i
|
||||
const isImageSetFunc = /^(?:-webkit-)?image-set$/i
|
||||
const needParseDeclaration = /(?:url|(?:-webkit-)?image-set)\(/i
|
||||
|
||||
function getNodeFromUrlFunc(node) {
|
||||
return node.nodes && node.nodes[0]
|
||||
}
|
||||
|
||||
function getWebpackIgnoreCommentValue(index, nodes, inBetween) {
|
||||
if (index === 0 && typeof inBetween !== 'undefined') {
|
||||
return inBetween
|
||||
}
|
||||
|
||||
let prevValueNode = nodes[index - 1]
|
||||
|
||||
if (!prevValueNode) {
|
||||
// eslint-disable-next-line consistent-return
|
||||
return
|
||||
}
|
||||
|
||||
if (prevValueNode.type === 'space') {
|
||||
if (!nodes[index - 2]) {
|
||||
// eslint-disable-next-line consistent-return
|
||||
return
|
||||
}
|
||||
|
||||
prevValueNode = nodes[index - 2]
|
||||
}
|
||||
|
||||
if (prevValueNode.type !== 'comment') {
|
||||
// eslint-disable-next-line consistent-return
|
||||
return
|
||||
}
|
||||
|
||||
const matched = prevValueNode.value.match(WEBPACK_IGNORE_COMMENT_REGEXP)
|
||||
|
||||
return matched && matched[2] === 'true'
|
||||
}
|
||||
|
||||
function shouldHandleURL(url, declaration, result, isSupportDataURLInNewURL) {
|
||||
if (url.length === 0) {
|
||||
result.warn(`Unable to find uri in '${declaration.toString()}'`, {
|
||||
node: declaration,
|
||||
})
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
if (isDataUrl(url) && isSupportDataURLInNewURL) {
|
||||
try {
|
||||
decodeURIComponent(url)
|
||||
} catch (ignoreError) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
if (!isUrlRequestable(url)) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
function parseDeclaration(declaration, key, result, isSupportDataURLInNewURL) {
|
||||
if (!needParseDeclaration.test(declaration[key])) {
|
||||
return
|
||||
}
|
||||
|
||||
const parsed = valueParser(
|
||||
declaration.raws && declaration.raws.value && declaration.raws.value.raw
|
||||
? declaration.raws.value.raw
|
||||
: declaration[key]
|
||||
)
|
||||
|
||||
let inBetween
|
||||
|
||||
if (declaration.raws && declaration.raws.between) {
|
||||
const lastCommentIndex = declaration.raws.between.lastIndexOf('/*')
|
||||
|
||||
const matched = declaration.raws.between
|
||||
.slice(lastCommentIndex)
|
||||
.match(WEBPACK_IGNORE_COMMENT_REGEXP)
|
||||
|
||||
if (matched) {
|
||||
inBetween = matched[2] === 'true'
|
||||
}
|
||||
}
|
||||
|
||||
let isIgnoreOnDeclaration = false
|
||||
|
||||
const prevNode = declaration.prev()
|
||||
|
||||
if (prevNode && prevNode.type === 'comment') {
|
||||
const matched = prevNode.text.match(WEBPACK_IGNORE_COMMENT_REGEXP)
|
||||
|
||||
if (matched) {
|
||||
isIgnoreOnDeclaration = matched[2] === 'true'
|
||||
}
|
||||
}
|
||||
|
||||
let needIgnore
|
||||
|
||||
const parsedURLs = []
|
||||
|
||||
parsed.walk((valueNode, index, valueNodes) => {
|
||||
if (valueNode.type !== 'function') {
|
||||
return
|
||||
}
|
||||
|
||||
if (isUrlFunc.test(valueNode.value)) {
|
||||
needIgnore = getWebpackIgnoreCommentValue(index, valueNodes, inBetween)
|
||||
|
||||
if (
|
||||
(isIgnoreOnDeclaration && typeof needIgnore === 'undefined') ||
|
||||
needIgnore
|
||||
) {
|
||||
if (needIgnore) {
|
||||
// eslint-disable-next-line no-undefined
|
||||
needIgnore = undefined
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
const { nodes } = valueNode
|
||||
const isStringValue = nodes.length !== 0 && nodes[0].type === 'string'
|
||||
let url = isStringValue ? nodes[0].value : valueParser.stringify(nodes)
|
||||
url = normalizeUrl(url, isStringValue)
|
||||
|
||||
// Do not traverse inside `url`
|
||||
if (
|
||||
!shouldHandleURL(url, declaration, result, isSupportDataURLInNewURL)
|
||||
) {
|
||||
// eslint-disable-next-line consistent-return
|
||||
return false
|
||||
}
|
||||
|
||||
const queryParts = url.split('!')
|
||||
let prefix
|
||||
|
||||
if (queryParts.length > 1) {
|
||||
url = queryParts.pop()
|
||||
prefix = queryParts.join('!')
|
||||
}
|
||||
|
||||
parsedURLs.push({
|
||||
declaration,
|
||||
parsed,
|
||||
node: getNodeFromUrlFunc(valueNode),
|
||||
prefix,
|
||||
url,
|
||||
needQuotes: false,
|
||||
})
|
||||
|
||||
// eslint-disable-next-line consistent-return
|
||||
return false
|
||||
} else if (isImageSetFunc.test(valueNode.value)) {
|
||||
for (const [innerIndex, nNode] of valueNode.nodes.entries()) {
|
||||
const { type, value } = nNode
|
||||
|
||||
if (type === 'function' && isUrlFunc.test(value)) {
|
||||
needIgnore = getWebpackIgnoreCommentValue(innerIndex, valueNode.nodes)
|
||||
|
||||
if (
|
||||
(isIgnoreOnDeclaration && typeof needIgnore === 'undefined') ||
|
||||
needIgnore
|
||||
) {
|
||||
if (needIgnore) {
|
||||
// eslint-disable-next-line no-undefined
|
||||
needIgnore = undefined
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-continue
|
||||
continue
|
||||
}
|
||||
|
||||
const { nodes } = nNode
|
||||
const isStringValue = nodes.length !== 0 && nodes[0].type === 'string'
|
||||
let url = isStringValue
|
||||
? nodes[0].value
|
||||
: valueParser.stringify(nodes)
|
||||
url = normalizeUrl(url, isStringValue)
|
||||
|
||||
// Do not traverse inside `url`
|
||||
if (
|
||||
!shouldHandleURL(url, declaration, result, isSupportDataURLInNewURL)
|
||||
) {
|
||||
// eslint-disable-next-line consistent-return
|
||||
return false
|
||||
}
|
||||
|
||||
const queryParts = url.split('!')
|
||||
let prefix
|
||||
|
||||
if (queryParts.length > 1) {
|
||||
url = queryParts.pop()
|
||||
prefix = queryParts.join('!')
|
||||
}
|
||||
|
||||
parsedURLs.push({
|
||||
declaration,
|
||||
parsed,
|
||||
node: getNodeFromUrlFunc(nNode),
|
||||
prefix,
|
||||
url,
|
||||
needQuotes: false,
|
||||
})
|
||||
} else if (type === 'string') {
|
||||
needIgnore = getWebpackIgnoreCommentValue(innerIndex, valueNode.nodes)
|
||||
|
||||
if (
|
||||
(isIgnoreOnDeclaration && typeof needIgnore === 'undefined') ||
|
||||
needIgnore
|
||||
) {
|
||||
if (needIgnore) {
|
||||
// eslint-disable-next-line no-undefined
|
||||
needIgnore = undefined
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-continue
|
||||
continue
|
||||
}
|
||||
|
||||
let url = normalizeUrl(value, true)
|
||||
|
||||
// Do not traverse inside `url`
|
||||
if (
|
||||
!shouldHandleURL(url, declaration, result, isSupportDataURLInNewURL)
|
||||
) {
|
||||
// eslint-disable-next-line consistent-return
|
||||
return false
|
||||
}
|
||||
|
||||
const queryParts = url.split('!')
|
||||
let prefix
|
||||
|
||||
if (queryParts.length > 1) {
|
||||
url = queryParts.pop()
|
||||
prefix = queryParts.join('!')
|
||||
}
|
||||
|
||||
parsedURLs.push({
|
||||
declaration,
|
||||
parsed,
|
||||
node: nNode,
|
||||
prefix,
|
||||
url,
|
||||
needQuotes: true,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Do not traverse inside `image-set`
|
||||
// eslint-disable-next-line consistent-return
|
||||
return false
|
||||
}
|
||||
})
|
||||
|
||||
// eslint-disable-next-line consistent-return
|
||||
return parsedURLs
|
||||
}
|
||||
|
||||
const plugin = (options = {}) => {
|
||||
return {
|
||||
postcssPlugin: 'postcss-url-parser',
|
||||
prepare(result) {
|
||||
const parsedDeclarations = []
|
||||
|
||||
return {
|
||||
Declaration(declaration) {
|
||||
const { isSupportDataURLInNewURL } = options
|
||||
const parsedURL = parseDeclaration(
|
||||
declaration,
|
||||
'value',
|
||||
result,
|
||||
isSupportDataURLInNewURL
|
||||
)
|
||||
|
||||
if (!parsedURL) {
|
||||
return
|
||||
}
|
||||
|
||||
parsedDeclarations.push(...parsedURL)
|
||||
},
|
||||
async OnceExit() {
|
||||
if (parsedDeclarations.length === 0) {
|
||||
return
|
||||
}
|
||||
|
||||
const resolvedDeclarations = await Promise.all(
|
||||
parsedDeclarations.map(async (parsedDeclaration) => {
|
||||
const { url } = parsedDeclaration
|
||||
|
||||
if (options.filter) {
|
||||
const needKeep = await options.filter(url)
|
||||
|
||||
if (!needKeep) {
|
||||
// eslint-disable-next-line consistent-return
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if (isDataUrl(url)) {
|
||||
// eslint-disable-next-line consistent-return
|
||||
return parsedDeclaration
|
||||
}
|
||||
|
||||
const splittedUrl = url.split(/(\?)?#/)
|
||||
const [pathname, query, hashOrQuery] = splittedUrl
|
||||
|
||||
let hash = query ? '?' : ''
|
||||
hash += hashOrQuery ? `#${hashOrQuery}` : ''
|
||||
|
||||
const { needToResolveURL, rootContext } = options
|
||||
const request = requestify(
|
||||
pathname,
|
||||
rootContext,
|
||||
needToResolveURL
|
||||
)
|
||||
|
||||
if (!needToResolveURL) {
|
||||
// eslint-disable-next-line consistent-return
|
||||
return { ...parsedDeclaration, url: request, hash }
|
||||
}
|
||||
|
||||
const { resolver, context } = options
|
||||
const resolvedUrl = await resolveRequests(resolver, context, [
|
||||
...new Set([request, url]),
|
||||
])
|
||||
|
||||
if (!resolvedUrl) {
|
||||
// eslint-disable-next-line consistent-return
|
||||
return
|
||||
}
|
||||
|
||||
// eslint-disable-next-line consistent-return
|
||||
return { ...parsedDeclaration, url: resolvedUrl, hash }
|
||||
})
|
||||
)
|
||||
|
||||
const urlToNameMap = new Map()
|
||||
const urlToReplacementMap = new Map()
|
||||
|
||||
let hasUrlImportHelper = false
|
||||
|
||||
for (
|
||||
let index = 0;
|
||||
index <= resolvedDeclarations.length - 1;
|
||||
index++
|
||||
) {
|
||||
const item = resolvedDeclarations[index]
|
||||
|
||||
if (!item) {
|
||||
// eslint-disable-next-line no-continue
|
||||
continue
|
||||
}
|
||||
|
||||
if (!hasUrlImportHelper) {
|
||||
options.imports.push({
|
||||
type: 'get_url_import',
|
||||
importName: '___CSS_LOADER_GET_URL_IMPORT___',
|
||||
url: options.urlHandler(
|
||||
require.resolve('../runtime/getUrl.js')
|
||||
),
|
||||
index: -1,
|
||||
})
|
||||
|
||||
hasUrlImportHelper = true
|
||||
}
|
||||
|
||||
const { url, prefix } = item
|
||||
const newUrl = prefix ? `${prefix}!${url}` : url
|
||||
let importName = urlToNameMap.get(newUrl)
|
||||
|
||||
if (!importName) {
|
||||
importName = `___CSS_LOADER_URL_IMPORT_${urlToNameMap.size}___`
|
||||
urlToNameMap.set(newUrl, importName)
|
||||
|
||||
options.imports.push({
|
||||
type: 'url',
|
||||
importName,
|
||||
url: options.needToResolveURL
|
||||
? options.urlHandler(newUrl)
|
||||
: JSON.stringify(newUrl),
|
||||
index,
|
||||
})
|
||||
}
|
||||
|
||||
const { hash, needQuotes } = item
|
||||
const replacementKey = JSON.stringify({ newUrl, hash, needQuotes })
|
||||
let replacementName = urlToReplacementMap.get(replacementKey)
|
||||
|
||||
if (!replacementName) {
|
||||
replacementName = `___CSS_LOADER_URL_REPLACEMENT_${urlToReplacementMap.size}___`
|
||||
urlToReplacementMap.set(replacementKey, replacementName)
|
||||
|
||||
options.replacements.push({
|
||||
replacementName,
|
||||
importName,
|
||||
hash,
|
||||
needQuotes,
|
||||
})
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
item.node.type = 'word'
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
item.node.value = replacementName
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
item.declaration.value = item.parsed.toString()
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
plugin.postcss = true
|
||||
|
||||
export default plugin
|
|
@ -0,0 +1,95 @@
|
|||
/*
|
||||
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} */`
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
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
|
||||
}
|
649
packages/next/build/webpack/loaders/css-loader/src/utils.js
Normal file
649
packages/next/build/webpack/loaders/css-loader/src/utils.js
Normal file
|
@ -0,0 +1,649 @@
|
|||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
import { fileURLToPath } from 'url'
|
||||
import path from 'path'
|
||||
|
||||
import { urlToRequest } from 'next/dist/compiled/loader-utils'
|
||||
import modulesValues from 'next/dist/compiled/postcss-modules-values'
|
||||
import localByDefault from 'next/dist/compiled/postcss-modules-local-by-default'
|
||||
import extractImports from 'next/dist/compiled/postcss-modules-extract-imports'
|
||||
import modulesScope from 'next/dist/compiled/postcss-modules-scope'
|
||||
import camelCase from './camelcase'
|
||||
|
||||
const whitespace = '[\\x20\\t\\r\\n\\f]'
|
||||
const unescapeRegExp = new RegExp(
|
||||
`\\\\([\\da-f]{1,6}${whitespace}?|(${whitespace})|.)`,
|
||||
'ig'
|
||||
)
|
||||
const matchNativeWin32Path = /^[A-Z]:[/\\]|^\\\\/i
|
||||
|
||||
function unescape(str) {
|
||||
return str.replace(unescapeRegExp, (_, escaped, escapedWhitespace) => {
|
||||
const high = `0x${escaped}` - 0x10000
|
||||
|
||||
/* eslint-disable line-comment-position */
|
||||
// NaN means non-codepoint
|
||||
// Workaround erroneous numeric interpretation of +"0x"
|
||||
// eslint-disable-next-line no-self-compare
|
||||
return high !== high || escapedWhitespace
|
||||
? escaped
|
||||
: high < 0
|
||||
? // BMP codepoint
|
||||
String.fromCharCode(high + 0x10000)
|
||||
: // Supplemental Plane codepoint (surrogate pair)
|
||||
// eslint-disable-next-line no-bitwise
|
||||
String.fromCharCode((high >> 10) | 0xd800, (high & 0x3ff) | 0xdc00)
|
||||
/* eslint-enable line-comment-position */
|
||||
})
|
||||
}
|
||||
|
||||
function normalizePath(file) {
|
||||
return path.sep === '\\' ? file.replace(/\\/g, '/') : file
|
||||
}
|
||||
|
||||
function normalizeUrl(url, isStringValue) {
|
||||
let normalizedUrl = url
|
||||
|
||||
if (isStringValue && /\\(\n|\r\n|\r|\f)/.test(normalizedUrl)) {
|
||||
normalizedUrl = normalizedUrl.replace(/\\(\n|\r\n|\r|\f)/g, '')
|
||||
}
|
||||
|
||||
if (matchNativeWin32Path.test(url)) {
|
||||
return decodeURIComponent(normalizedUrl)
|
||||
}
|
||||
|
||||
return decodeURIComponent(unescape(normalizedUrl))
|
||||
}
|
||||
|
||||
function requestify(url, rootContext) {
|
||||
if (/^file:/i.test(url)) {
|
||||
return fileURLToPath(url)
|
||||
}
|
||||
|
||||
return url.charAt(0) === '/'
|
||||
? urlToRequest(url, rootContext)
|
||||
: urlToRequest(url)
|
||||
}
|
||||
|
||||
function getFilter(filter, resourcePath) {
|
||||
return (...args) => {
|
||||
if (typeof filter === 'function') {
|
||||
return filter(...args, resourcePath)
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
const moduleRegExp = /\.module\.\w+$/i
|
||||
|
||||
function getModulesOptions(rawOptions, loaderContext) {
|
||||
const { resourcePath } = loaderContext
|
||||
|
||||
if (typeof rawOptions.modules === 'undefined') {
|
||||
const isModules = moduleRegExp.test(resourcePath)
|
||||
|
||||
if (!isModules) {
|
||||
return false
|
||||
}
|
||||
} else if (
|
||||
typeof rawOptions.modules === 'boolean' &&
|
||||
rawOptions.modules === false
|
||||
) {
|
||||
return false
|
||||
}
|
||||
|
||||
let modulesOptions = {
|
||||
compileType: rawOptions.icss ? 'icss' : 'module',
|
||||
auto: true,
|
||||
mode: 'local',
|
||||
exportGlobals: false,
|
||||
localIdentName: '[hash:base64]',
|
||||
localIdentContext: loaderContext.rootContext,
|
||||
localIdentHashPrefix: '',
|
||||
// eslint-disable-next-line no-undefined
|
||||
localIdentRegExp: undefined,
|
||||
namedExport: false,
|
||||
exportLocalsConvention: 'asIs',
|
||||
exportOnlyLocals: false,
|
||||
}
|
||||
|
||||
if (
|
||||
typeof rawOptions.modules === 'boolean' ||
|
||||
typeof rawOptions.modules === 'string'
|
||||
) {
|
||||
modulesOptions.mode =
|
||||
typeof rawOptions.modules === 'string' ? rawOptions.modules : 'local'
|
||||
} else {
|
||||
if (rawOptions.modules) {
|
||||
if (typeof rawOptions.modules.auto === 'boolean') {
|
||||
const isModules =
|
||||
rawOptions.modules.auto && moduleRegExp.test(resourcePath)
|
||||
|
||||
if (!isModules) {
|
||||
return false
|
||||
}
|
||||
} else if (rawOptions.modules.auto instanceof RegExp) {
|
||||
const isModules = rawOptions.modules.auto.test(resourcePath)
|
||||
|
||||
if (!isModules) {
|
||||
return false
|
||||
}
|
||||
} else if (typeof rawOptions.modules.auto === 'function') {
|
||||
const isModule = rawOptions.modules.auto(resourcePath)
|
||||
|
||||
if (!isModule) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
rawOptions.modules.namedExport === true &&
|
||||
typeof rawOptions.modules.exportLocalsConvention === 'undefined'
|
||||
) {
|
||||
modulesOptions.exportLocalsConvention = 'camelCaseOnly'
|
||||
}
|
||||
}
|
||||
|
||||
modulesOptions = { ...modulesOptions, ...(rawOptions.modules || {}) }
|
||||
}
|
||||
|
||||
if (typeof modulesOptions.mode === 'function') {
|
||||
modulesOptions.mode = modulesOptions.mode(loaderContext.resourcePath)
|
||||
}
|
||||
|
||||
if (modulesOptions.namedExport === true) {
|
||||
if (rawOptions.esModule === false) {
|
||||
throw new Error(
|
||||
'The "modules.namedExport" option requires the "esModules" option to be enabled'
|
||||
)
|
||||
}
|
||||
|
||||
if (modulesOptions.exportLocalsConvention !== 'camelCaseOnly') {
|
||||
throw new Error(
|
||||
'The "modules.namedExport" option requires the "modules.exportLocalsConvention" option to be "camelCaseOnly"'
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
return modulesOptions
|
||||
}
|
||||
|
||||
function normalizeOptions(rawOptions, loaderContext) {
|
||||
if (rawOptions.icss) {
|
||||
loaderContext.emitWarning(
|
||||
new Error(
|
||||
'The "icss" option is deprecated, use "modules.compileType: "icss"" instead'
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
const modulesOptions = getModulesOptions(rawOptions, loaderContext)
|
||||
|
||||
return {
|
||||
url: typeof rawOptions.url === 'undefined' ? true : rawOptions.url,
|
||||
import: typeof rawOptions.import === 'undefined' ? true : rawOptions.import,
|
||||
modules: modulesOptions,
|
||||
// TODO remove in the next major release
|
||||
icss: typeof rawOptions.icss === 'undefined' ? false : rawOptions.icss,
|
||||
sourceMap:
|
||||
typeof rawOptions.sourceMap === 'boolean'
|
||||
? rawOptions.sourceMap
|
||||
: loaderContext.sourceMap,
|
||||
importLoaders:
|
||||
typeof rawOptions.importLoaders === 'string'
|
||||
? parseInt(rawOptions.importLoaders, 10)
|
||||
: rawOptions.importLoaders,
|
||||
esModule:
|
||||
typeof rawOptions.esModule === 'undefined' ? true : rawOptions.esModule,
|
||||
}
|
||||
}
|
||||
|
||||
function shouldUseImportPlugin(options) {
|
||||
if (options.modules.exportOnlyLocals) {
|
||||
return false
|
||||
}
|
||||
|
||||
if (typeof options.import === 'boolean') {
|
||||
return options.import
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
function shouldUseURLPlugin(options) {
|
||||
if (options.modules.exportOnlyLocals) {
|
||||
return false
|
||||
}
|
||||
|
||||
if (typeof options.url === 'boolean') {
|
||||
return options.url
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
function shouldUseModulesPlugins(options) {
|
||||
return options.modules.compileType === 'module'
|
||||
}
|
||||
|
||||
function shouldUseIcssPlugin(options) {
|
||||
return options.icss === true || Boolean(options.modules)
|
||||
}
|
||||
|
||||
function getModulesPlugins(options, loaderContext) {
|
||||
const {
|
||||
mode,
|
||||
getLocalIdent,
|
||||
localIdentName,
|
||||
localIdentContext,
|
||||
localIdentHashPrefix,
|
||||
localIdentRegExp,
|
||||
} = options.modules
|
||||
|
||||
let plugins = []
|
||||
|
||||
try {
|
||||
plugins = [
|
||||
modulesValues,
|
||||
localByDefault({ mode }),
|
||||
extractImports(),
|
||||
modulesScope({
|
||||
generateScopedName(exportName) {
|
||||
return getLocalIdent(loaderContext, localIdentName, exportName, {
|
||||
context: localIdentContext,
|
||||
hashPrefix: localIdentHashPrefix,
|
||||
regExp: localIdentRegExp,
|
||||
})
|
||||
},
|
||||
exportGlobals: options.modules.exportGlobals,
|
||||
}),
|
||||
]
|
||||
} catch (error) {
|
||||
loaderContext.emitError(error)
|
||||
}
|
||||
|
||||
return plugins
|
||||
}
|
||||
|
||||
const IS_NATIVE_WIN32_PATH = /^[a-z]:[/\\]|^\\\\/i
|
||||
const ABSOLUTE_SCHEME = /^[a-z0-9+\-.]+:/i
|
||||
|
||||
function getURLType(source) {
|
||||
if (source[0] === '/') {
|
||||
if (source[1] === '/') {
|
||||
return 'scheme-relative'
|
||||
}
|
||||
|
||||
return 'path-absolute'
|
||||
}
|
||||
|
||||
if (IS_NATIVE_WIN32_PATH.test(source)) {
|
||||
return 'path-absolute'
|
||||
}
|
||||
|
||||
return ABSOLUTE_SCHEME.test(source) ? 'absolute' : 'path-relative'
|
||||
}
|
||||
|
||||
function normalizeSourceMap(map, resourcePath) {
|
||||
let newMap = map
|
||||
|
||||
// Some loader emit source map as string
|
||||
// Strip any JSON XSSI avoidance prefix from the string (as documented in the source maps specification), and then parse the string as JSON.
|
||||
if (typeof newMap === 'string') {
|
||||
newMap = JSON.parse(newMap)
|
||||
}
|
||||
|
||||
delete newMap.file
|
||||
|
||||
const { sourceRoot } = newMap
|
||||
|
||||
delete newMap.sourceRoot
|
||||
|
||||
if (newMap.sources) {
|
||||
// Source maps should use forward slash because it is URLs (https://github.com/mozilla/source-map/issues/91)
|
||||
// We should normalize path because previous loaders like `sass-loader` using backslash when generate source map
|
||||
newMap.sources = newMap.sources.map((source) => {
|
||||
// Non-standard syntax from `postcss`
|
||||
if (source.indexOf('<') === 0) {
|
||||
return source
|
||||
}
|
||||
|
||||
const sourceType = getURLType(source)
|
||||
|
||||
// Do no touch `scheme-relative` and `absolute` URLs
|
||||
if (sourceType === 'path-relative' || sourceType === 'path-absolute') {
|
||||
const absoluteSource =
|
||||
sourceType === 'path-relative' && sourceRoot
|
||||
? path.resolve(sourceRoot, normalizePath(source))
|
||||
: normalizePath(source)
|
||||
|
||||
return path.relative(path.dirname(resourcePath), absoluteSource)
|
||||
}
|
||||
|
||||
return source
|
||||
})
|
||||
}
|
||||
|
||||
return newMap
|
||||
}
|
||||
|
||||
function getPreRequester({ loaders, loaderIndex }) {
|
||||
const cache = Object.create(null)
|
||||
|
||||
return (number) => {
|
||||
if (cache[number]) {
|
||||
return cache[number]
|
||||
}
|
||||
|
||||
if (number === false) {
|
||||
cache[number] = ''
|
||||
} else {
|
||||
const loadersRequest = loaders
|
||||
.slice(
|
||||
loaderIndex,
|
||||
loaderIndex + 1 + (typeof number !== 'number' ? 0 : number)
|
||||
)
|
||||
.map((x) => x.request)
|
||||
.join('!')
|
||||
|
||||
cache[number] = `-!${loadersRequest}!`
|
||||
}
|
||||
|
||||
return cache[number]
|
||||
}
|
||||
}
|
||||
|
||||
function getImportCode(imports, options) {
|
||||
let code = ''
|
||||
|
||||
for (const item of imports) {
|
||||
const { importName, url, icss } = item
|
||||
|
||||
if (options.esModule) {
|
||||
if (icss && options.modules.namedExport) {
|
||||
code += `import ${
|
||||
options.modules.exportOnlyLocals ? '' : `${importName}, `
|
||||
}* as ${importName}_NAMED___ from ${url};\n`
|
||||
} else {
|
||||
code += `import ${importName} from ${url};\n`
|
||||
}
|
||||
} else {
|
||||
code += `var ${importName} = require(${url});\n`
|
||||
}
|
||||
}
|
||||
|
||||
return code ? `// Imports\n${code}` : ''
|
||||
}
|
||||
|
||||
function normalizeSourceMapForRuntime(map, loaderContext) {
|
||||
const resultMap = map ? map.toJSON() : null
|
||||
|
||||
if (resultMap) {
|
||||
delete resultMap.file
|
||||
|
||||
resultMap.sourceRoot = ''
|
||||
|
||||
resultMap.sources = resultMap.sources.map((source) => {
|
||||
// Non-standard syntax from `postcss`
|
||||
if (source.indexOf('<') === 0) {
|
||||
return source
|
||||
}
|
||||
|
||||
const sourceType = getURLType(source)
|
||||
|
||||
if (sourceType !== 'path-relative') {
|
||||
return source
|
||||
}
|
||||
|
||||
const resourceDirname = path.dirname(loaderContext.resourcePath)
|
||||
const absoluteSource = path.resolve(resourceDirname, source)
|
||||
const contextifyPath = normalizePath(
|
||||
path.relative(loaderContext.rootContext, absoluteSource)
|
||||
)
|
||||
|
||||
return `webpack://${contextifyPath}`
|
||||
})
|
||||
}
|
||||
|
||||
return JSON.stringify(resultMap)
|
||||
}
|
||||
|
||||
function getModuleCode(result, api, replacements, options, loaderContext) {
|
||||
if (options.modules.exportOnlyLocals === true) {
|
||||
return ''
|
||||
}
|
||||
|
||||
const sourceMapValue = options.sourceMap
|
||||
? `,${normalizeSourceMapForRuntime(result.map, loaderContext)}`
|
||||
: ''
|
||||
|
||||
let code = JSON.stringify(result.css)
|
||||
let beforeCode = `var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(${options.sourceMap});\n`
|
||||
|
||||
for (const item of api) {
|
||||
const { url, media, dedupe } = item
|
||||
|
||||
beforeCode += url
|
||||
? `___CSS_LOADER_EXPORT___.push([module.id, ${JSON.stringify(
|
||||
`@import url(${url});`
|
||||
)}${media ? `, ${JSON.stringify(media)}` : ''}]);\n`
|
||||
: `___CSS_LOADER_EXPORT___.i(${item.importName}${
|
||||
media ? `, ${JSON.stringify(media)}` : dedupe ? ', ""' : ''
|
||||
}${dedupe ? ', true' : ''});\n`
|
||||
}
|
||||
|
||||
for (const item of replacements) {
|
||||
const { replacementName, importName, localName } = item
|
||||
|
||||
if (localName) {
|
||||
code = code.replace(new RegExp(replacementName, 'g'), () =>
|
||||
options.modules.namedExport
|
||||
? `" + ${importName}_NAMED___[${JSON.stringify(
|
||||
camelCase(localName)
|
||||
)}] + "`
|
||||
: `" + ${importName}.locals[${JSON.stringify(localName)}] + "`
|
||||
)
|
||||
} else {
|
||||
const { hash, needQuotes } = item
|
||||
const getUrlOptions = []
|
||||
.concat(hash ? [`hash: ${JSON.stringify(hash)}`] : [])
|
||||
.concat(needQuotes ? 'needQuotes: true' : [])
|
||||
const preparedOptions =
|
||||
getUrlOptions.length > 0 ? `, { ${getUrlOptions.join(', ')} }` : ''
|
||||
|
||||
beforeCode += `var ${replacementName} = ___CSS_LOADER_GET_URL_IMPORT___(${importName}${preparedOptions});\n`
|
||||
code = code.replace(
|
||||
new RegExp(replacementName, 'g'),
|
||||
() => `" + ${replacementName} + "`
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
return `${beforeCode}// Module\n___CSS_LOADER_EXPORT___.push([module.id, ${code}, ""${sourceMapValue}]);\n`
|
||||
}
|
||||
|
||||
function dashesCamelCase(str) {
|
||||
return str.replace(/-+(\w)/g, (match, firstLetter) =>
|
||||
firstLetter.toUpperCase()
|
||||
)
|
||||
}
|
||||
|
||||
function getExportCode(exports, replacements, options) {
|
||||
let code = '// Exports\n'
|
||||
let localsCode = ''
|
||||
|
||||
const addExportToLocalsCode = (name, value) => {
|
||||
if (options.modules.namedExport) {
|
||||
localsCode += `export const ${camelCase(name)} = ${JSON.stringify(
|
||||
value
|
||||
)};\n`
|
||||
} else {
|
||||
if (localsCode) {
|
||||
localsCode += `,\n`
|
||||
}
|
||||
|
||||
localsCode += `\t${JSON.stringify(name)}: ${JSON.stringify(value)}`
|
||||
}
|
||||
}
|
||||
|
||||
for (const { name, value } of exports) {
|
||||
switch (options.modules.exportLocalsConvention) {
|
||||
case 'camelCase': {
|
||||
addExportToLocalsCode(name, value)
|
||||
|
||||
const modifiedName = camelCase(name)
|
||||
|
||||
if (modifiedName !== name) {
|
||||
addExportToLocalsCode(modifiedName, value)
|
||||
}
|
||||
break
|
||||
}
|
||||
case 'camelCaseOnly': {
|
||||
addExportToLocalsCode(camelCase(name), value)
|
||||
break
|
||||
}
|
||||
case 'dashes': {
|
||||
addExportToLocalsCode(name, value)
|
||||
|
||||
const modifiedName = dashesCamelCase(name)
|
||||
|
||||
if (modifiedName !== name) {
|
||||
addExportToLocalsCode(modifiedName, value)
|
||||
}
|
||||
break
|
||||
}
|
||||
case 'dashesOnly': {
|
||||
addExportToLocalsCode(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(
|
||||
camelCase(localName)
|
||||
)}] + "`
|
||||
} else if (options.modules.exportOnlyLocals) {
|
||||
return `" + ${importName}[${JSON.stringify(localName)}] + "`
|
||||
}
|
||||
|
||||
return `" + ${importName}.locals[${JSON.stringify(localName)}] + "`
|
||||
})
|
||||
} else {
|
||||
localsCode = localsCode.replace(
|
||||
new RegExp(replacementName, 'g'),
|
||||
() => `" + ${replacementName} + "`
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
if (options.modules.exportOnlyLocals) {
|
||||
code += options.modules.namedExport
|
||||
? localsCode
|
||||
: `${
|
||||
options.esModule ? 'export default' : 'module.exports ='
|
||||
} {\n${localsCode}\n};\n`
|
||||
|
||||
return code
|
||||
}
|
||||
|
||||
if (localsCode) {
|
||||
code += options.modules.namedExport
|
||||
? localsCode
|
||||
: `___CSS_LOADER_EXPORT___.locals = {\n${localsCode}\n};\n`
|
||||
}
|
||||
|
||||
code += `${
|
||||
options.esModule ? 'export default' : 'module.exports ='
|
||||
} ___CSS_LOADER_EXPORT___;\n`
|
||||
|
||||
return code
|
||||
}
|
||||
|
||||
async function resolveRequests(resolve, context, possibleRequests) {
|
||||
return resolve(context, possibleRequests[0])
|
||||
.then((result) => {
|
||||
return result
|
||||
})
|
||||
.catch((error) => {
|
||||
const [, ...tailPossibleRequests] = possibleRequests
|
||||
|
||||
if (tailPossibleRequests.length === 0) {
|
||||
throw error
|
||||
}
|
||||
|
||||
return resolveRequests(resolve, context, tailPossibleRequests)
|
||||
})
|
||||
}
|
||||
|
||||
function isUrlRequestable(url) {
|
||||
// Protocol-relative URLs
|
||||
if (/^\/\//.test(url)) {
|
||||
return false
|
||||
}
|
||||
|
||||
// `file:` protocol
|
||||
if (/^file:/i.test(url)) {
|
||||
return true
|
||||
}
|
||||
|
||||
// Absolute URLs
|
||||
if (/^[a-z][a-z0-9+.-]*:/i.test(url) && !matchNativeWin32Path.test(url)) {
|
||||
return false
|
||||
}
|
||||
|
||||
// `#` URLs
|
||||
if (/^#/.test(url)) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
function sort(a, b) {
|
||||
return a.index - b.index
|
||||
}
|
||||
|
||||
function isDataUrl(url) {
|
||||
if (/^data:/i.test(url)) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
export {
|
||||
isDataUrl,
|
||||
normalizeOptions,
|
||||
shouldUseModulesPlugins,
|
||||
shouldUseImportPlugin,
|
||||
shouldUseURLPlugin,
|
||||
shouldUseIcssPlugin,
|
||||
normalizeUrl,
|
||||
requestify,
|
||||
getFilter,
|
||||
getModulesOptions,
|
||||
getModulesPlugins,
|
||||
normalizeSourceMap,
|
||||
getPreRequester,
|
||||
getImportCode,
|
||||
getModuleCode,
|
||||
getExportCode,
|
||||
resolveRequests,
|
||||
isUrlRequestable,
|
||||
sort,
|
||||
}
|
|
@ -1,79 +1,31 @@
|
|||
import loaderUtils from 'next/dist/compiled/loader-utils'
|
||||
import path from 'path'
|
||||
import { validate } from 'next/dist/compiled/schema-utils3'
|
||||
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 = () => {}
|
||||
|
||||
loaderApi.pitch = function loader(request) {
|
||||
const options = loaderUtils.getOptions(this)
|
||||
const loaderSpan = this.currentTraceSpan.traceChild('next-style-loader')
|
||||
|
||||
validate(schema, options, {
|
||||
name: 'Style Loader',
|
||||
baseDataPath: 'options',
|
||||
})
|
||||
return loaderSpan.traceFn(() => {
|
||||
const options = loaderUtils.getOptions(this)
|
||||
|
||||
const insert =
|
||||
typeof options.insert === 'undefined'
|
||||
? '"head"'
|
||||
: typeof options.insert === 'string'
|
||||
? JSON.stringify(options.insert)
|
||||
: options.insert.toString()
|
||||
const injectType = options.injectType || 'styleTag'
|
||||
const esModule =
|
||||
typeof options.esModule !== 'undefined' ? options.esModule : false
|
||||
const insert =
|
||||
typeof options.insert === 'undefined'
|
||||
? '"head"'
|
||||
: typeof options.insert === 'string'
|
||||
? JSON.stringify(options.insert)
|
||||
: options.insert.toString()
|
||||
const injectType = options.injectType || 'styleTag'
|
||||
const esModule =
|
||||
typeof options.esModule !== 'undefined' ? options.esModule : false
|
||||
|
||||
delete options.esModule
|
||||
delete options.esModule
|
||||
|
||||
switch (injectType) {
|
||||
case 'linkTag': {
|
||||
const hmrCode = this.hot
|
||||
? `
|
||||
switch (injectType) {
|
||||
case 'linkTag': {
|
||||
const hmrCode = this.hot
|
||||
? `
|
||||
if (module.hot) {
|
||||
module.hot.accept(
|
||||
${loaderUtils.stringifyRequest(this, `!!${request}`)},
|
||||
|
@ -97,29 +49,29 @@ if (module.hot) {
|
|||
update();
|
||||
});
|
||||
}`
|
||||
: ''
|
||||
: ''
|
||||
|
||||
return `${
|
||||
esModule
|
||||
? `import api from ${loaderUtils.stringifyRequest(
|
||||
this,
|
||||
`!${path.join(__dirname, 'runtime/injectStylesIntoLinkTag.js')}`
|
||||
)};
|
||||
return `${
|
||||
esModule
|
||||
? `import api from ${loaderUtils.stringifyRequest(
|
||||
this,
|
||||
`!${path.join(__dirname, 'runtime/injectStylesIntoLinkTag.js')}`
|
||||
)};
|
||||
import content from ${loaderUtils.stringifyRequest(
|
||||
this,
|
||||
`!!${request}`
|
||||
)};`
|
||||
: `var api = require(${loaderUtils.stringifyRequest(
|
||||
this,
|
||||
`!${path.join(__dirname, 'runtime/injectStylesIntoLinkTag.js')}`
|
||||
)});
|
||||
: `var api = require(${loaderUtils.stringifyRequest(
|
||||
this,
|
||||
`!${path.join(__dirname, 'runtime/injectStylesIntoLinkTag.js')}`
|
||||
)});
|
||||
var content = require(${loaderUtils.stringifyRequest(
|
||||
this,
|
||||
`!!${request}`
|
||||
)});
|
||||
|
||||
content = content.__esModule ? content.default : content;`
|
||||
}
|
||||
}
|
||||
|
||||
var options = ${JSON.stringify(options)};
|
||||
|
||||
|
@ -130,14 +82,14 @@ var update = api(content, options);
|
|||
${hmrCode}
|
||||
|
||||
${esModule ? 'export default {}' : ''}`
|
||||
}
|
||||
}
|
||||
|
||||
case 'lazyStyleTag':
|
||||
case 'lazySingletonStyleTag': {
|
||||
const isSingleton = injectType === 'lazySingletonStyleTag'
|
||||
case 'lazyStyleTag':
|
||||
case 'lazySingletonStyleTag': {
|
||||
const isSingleton = injectType === 'lazySingletonStyleTag'
|
||||
|
||||
const hmrCode = this.hot
|
||||
? `
|
||||
const hmrCode = this.hot
|
||||
? `
|
||||
if (module.hot) {
|
||||
if (!content.locals || module.hot.invalidate) {
|
||||
var isEqualLocals = ${isEqualLocals.toString()};
|
||||
|
@ -188,22 +140,28 @@ if (module.hot) {
|
|||
}
|
||||
});
|
||||
}`
|
||||
: ''
|
||||
: ''
|
||||
|
||||
return `${
|
||||
esModule
|
||||
? `import api from ${loaderUtils.stringifyRequest(
|
||||
this,
|
||||
`!${path.join(__dirname, 'runtime/injectStylesIntoStyleTag.js')}`
|
||||
)};
|
||||
return `${
|
||||
esModule
|
||||
? `import api from ${loaderUtils.stringifyRequest(
|
||||
this,
|
||||
`!${path.join(
|
||||
__dirname,
|
||||
'runtime/injectStylesIntoStyleTag.js'
|
||||
)}`
|
||||
)};
|
||||
import content from ${loaderUtils.stringifyRequest(
|
||||
this,
|
||||
`!!${request}`
|
||||
)};`
|
||||
: `var api = require(${loaderUtils.stringifyRequest(
|
||||
this,
|
||||
`!${path.join(__dirname, 'runtime/injectStylesIntoStyleTag.js')}`
|
||||
)});
|
||||
: `var api = require(${loaderUtils.stringifyRequest(
|
||||
this,
|
||||
`!${path.join(
|
||||
__dirname,
|
||||
'runtime/injectStylesIntoStyleTag.js'
|
||||
)}`
|
||||
)});
|
||||
var content = require(${loaderUtils.stringifyRequest(
|
||||
this,
|
||||
`!!${request}`
|
||||
|
@ -214,7 +172,7 @@ if (module.hot) {
|
|||
if (typeof content === 'string') {
|
||||
content = [[module.id, content, '']];
|
||||
}`
|
||||
}
|
||||
}
|
||||
|
||||
var refs = 0;
|
||||
var update;
|
||||
|
@ -243,15 +201,15 @@ exported.unuse = function() {
|
|||
${hmrCode}
|
||||
|
||||
${esModule ? 'export default' : 'module.exports ='} exported;`
|
||||
}
|
||||
}
|
||||
|
||||
case 'styleTag':
|
||||
case 'singletonStyleTag':
|
||||
default: {
|
||||
const isSingleton = injectType === 'singletonStyleTag'
|
||||
case 'styleTag':
|
||||
case 'singletonStyleTag':
|
||||
default: {
|
||||
const isSingleton = injectType === 'singletonStyleTag'
|
||||
|
||||
const hmrCode = this.hot
|
||||
? `
|
||||
const hmrCode = this.hot
|
||||
? `
|
||||
if (module.hot) {
|
||||
if (!content.locals || module.hot.invalidate) {
|
||||
var isEqualLocals = ${isEqualLocals.toString()};
|
||||
|
@ -300,22 +258,28 @@ if (module.hot) {
|
|||
update();
|
||||
});
|
||||
}`
|
||||
: ''
|
||||
: ''
|
||||
|
||||
return `${
|
||||
esModule
|
||||
? `import api from ${loaderUtils.stringifyRequest(
|
||||
this,
|
||||
`!${path.join(__dirname, 'runtime/injectStylesIntoStyleTag.js')}`
|
||||
)};
|
||||
return `${
|
||||
esModule
|
||||
? `import api from ${loaderUtils.stringifyRequest(
|
||||
this,
|
||||
`!${path.join(
|
||||
__dirname,
|
||||
'runtime/injectStylesIntoStyleTag.js'
|
||||
)}`
|
||||
)};
|
||||
import content from ${loaderUtils.stringifyRequest(
|
||||
this,
|
||||
`!!${request}`
|
||||
)};`
|
||||
: `var api = require(${loaderUtils.stringifyRequest(
|
||||
this,
|
||||
`!${path.join(__dirname, 'runtime/injectStylesIntoStyleTag.js')}`
|
||||
)});
|
||||
: `var api = require(${loaderUtils.stringifyRequest(
|
||||
this,
|
||||
`!${path.join(
|
||||
__dirname,
|
||||
'runtime/injectStylesIntoStyleTag.js'
|
||||
)}`
|
||||
)});
|
||||
var content = require(${loaderUtils.stringifyRequest(
|
||||
this,
|
||||
`!!${request}`
|
||||
|
@ -326,7 +290,7 @@ if (module.hot) {
|
|||
if (typeof content === 'string') {
|
||||
content = [[module.id, content, '']];
|
||||
}`
|
||||
}
|
||||
}
|
||||
|
||||
var options = ${JSON.stringify(options)};
|
||||
|
||||
|
@ -338,8 +302,9 @@ var update = api(content, options);
|
|||
${hmrCode}
|
||||
|
||||
${esModule ? 'export default' : 'module.exports ='} content.locals || {};`
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = loaderApi
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
/**
|
||||
* **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
|
|
@ -0,0 +1,32 @@
|
|||
/**
|
||||
* **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
|
136
packages/next/build/webpack/loaders/postcss-loader/src/index.js
Normal file
136
packages/next/build/webpack/loaders/postcss-loader/src/index.js
Normal file
|
@ -0,0 +1,136 @@
|
|||
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)
|
||||
}
|
||||
)
|
||||
}
|
|
@ -0,0 +1,88 @@
|
|||
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 }
|
|
@ -1 +0,0 @@
|
|||
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)}();
|
File diff suppressed because one or more lines are too long
|
@ -1 +0,0 @@
|
|||
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)}();
|
|
@ -1 +0,0 @@
|
|||
{"name":"css-loader","main":"cjs.js","author":"Tobias Koppers @sokra","license":"MIT"}
|
1
packages/next/compiled/icss-utils/index.js
Normal file
1
packages/next/compiled/icss-utils/index.js
Normal file
|
@ -0,0 +1 @@
|
|||
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)})();
|
1
packages/next/compiled/icss-utils/package.json
Normal file
1
packages/next/compiled/icss-utils/package.json
Normal file
|
@ -0,0 +1 @@
|
|||
{"name":"icss-utils","main":"index.js","author":"Glen Maddern","license":"ISC"}
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1 +0,0 @@
|
|||
{"name":"postcss-loader","main":"cjs.js","author":"Andrey Sitnik <andrey@sitnik.ru>","license":"MIT"}
|
|
@ -0,0 +1,5 @@
|
|||
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.
|
|
@ -0,0 +1 @@
|
|||
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)})();
|
|
@ -0,0 +1 @@
|
|||
{"name":"postcss-modules-extract-imports","main":"index.js","author":"Glen Maddern","license":"ISC"}
|
|
@ -0,0 +1,20 @@
|
|||
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.
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1 @@
|
|||
{"name":"postcss-modules-local-by-default","main":"index.js","author":"Mark Dalgleish","license":"MIT"}
|
7
packages/next/compiled/postcss-modules-scope/LICENSE
Normal file
7
packages/next/compiled/postcss-modules-scope/LICENSE
Normal file
|
@ -0,0 +1,7 @@
|
|||
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.
|
1
packages/next/compiled/postcss-modules-scope/index.js
Normal file
1
packages/next/compiled/postcss-modules-scope/index.js
Normal file
File diff suppressed because one or more lines are too long
|
@ -0,0 +1 @@
|
|||
{"name":"postcss-modules-scope","main":"index.js","author":"Glen Maddern","license":"ISC"}
|
7
packages/next/compiled/postcss-modules-values/LICENSE
Normal file
7
packages/next/compiled/postcss-modules-values/LICENSE
Normal file
|
@ -0,0 +1,7 @@
|
|||
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.
|
1
packages/next/compiled/postcss-modules-values/index.js
Normal file
1
packages/next/compiled/postcss-modules-values/index.js
Normal file
|
@ -0,0 +1 @@
|
|||
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)})();
|
|
@ -0,0 +1 @@
|
|||
{"name":"postcss-modules-values","main":"index.js","author":"Glen Maddern","license":"ISC"}
|
File diff suppressed because one or more lines are too long
20
packages/next/compiled/postcss-safe-parser/LICENSE
Normal file
20
packages/next/compiled/postcss-safe-parser/LICENSE
Normal file
|
@ -0,0 +1,20 @@
|
|||
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.
|
1
packages/next/compiled/postcss-safe-parser/package.json
Normal file
1
packages/next/compiled/postcss-safe-parser/package.json
Normal file
|
@ -0,0 +1 @@
|
|||
{"name":"postcss-safe-parser","main":"safe-parse.js","author":"Andrey Sitnik <andrey@sitnik.ru>","license":"MIT"}
|
1
packages/next/compiled/postcss-safe-parser/safe-parse.js
Normal file
1
packages/next/compiled/postcss-safe-parser/safe-parse.js
Normal file
File diff suppressed because one or more lines are too long
22
packages/next/compiled/postcss-value-parser/LICENSE
Normal file
22
packages/next/compiled/postcss-value-parser/LICENSE
Normal file
|
@ -0,0 +1,22 @@
|
|||
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.
|
1
packages/next/compiled/postcss-value-parser/index.js
Normal file
1
packages/next/compiled/postcss-value-parser/index.js
Normal file
File diff suppressed because one or more lines are too long
1
packages/next/compiled/postcss-value-parser/package.json
Normal file
1
packages/next/compiled/postcss-value-parser/package.json
Normal file
|
@ -0,0 +1 @@
|
|||
{"name":"postcss-value-parser","main":"index.js","author":"Bogdan Chadkin <trysound@yandex.ru>","license":"MIT"}
|
File diff suppressed because one or more lines are too long
|
@ -206,7 +206,6 @@
|
|||
"content-type": "1.0.4",
|
||||
"cookie": "0.4.1",
|
||||
"cross-spawn": "6.0.5",
|
||||
"css-loader": "4.3.0",
|
||||
"debug": "4.1.1",
|
||||
"devalue": "2.0.1",
|
||||
"escape-string-regexp": "2.0.0",
|
||||
|
@ -217,6 +216,7 @@
|
|||
"glob": "7.1.7",
|
||||
"gzip-size": "5.1.1",
|
||||
"http-proxy": "1.18.1",
|
||||
"icss-utils": "5.1.0",
|
||||
"ignore-loader": "0.1.2",
|
||||
"is-docker": "2.0.0",
|
||||
"is-wsl": "2.2.0",
|
||||
|
@ -231,9 +231,14 @@
|
|||
"ora": "4.0.4",
|
||||
"path-to-regexp": "6.1.0",
|
||||
"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-safe-parser": "6.0.0",
|
||||
"postcss-scss": "3.0.5",
|
||||
"postcss-value-parser": "4.1.0",
|
||||
"recast": "0.18.5",
|
||||
"resolve-url-loader": "3.1.2",
|
||||
"sass-loader": "10.0.5",
|
||||
|
|
|
@ -45,7 +45,10 @@ const externals = {
|
|||
|
||||
chalk: 'chalk',
|
||||
'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
|
||||
'node-libs-browser': 'node-libs-browser',
|
||||
|
@ -250,21 +253,6 @@ export async function ncc_cross_spawn(task, opts) {
|
|||
.target('compiled/cross-spawn')
|
||||
}
|
||||
// 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'
|
||||
export async function ncc_debug(task, opts) {
|
||||
await task
|
||||
|
@ -454,18 +442,13 @@ export async function ncc_postcss_flexbugs_fixes(task, opts) {
|
|||
.target('compiled/postcss-flexbugs-fixes')
|
||||
}
|
||||
// eslint-disable-next-line camelcase
|
||||
externals['postcss-loader'] = 'next/dist/compiled/postcss-loader'
|
||||
export async function ncc_postcss_loader(task, opts) {
|
||||
export async function ncc_postcss_safe_parser(task, opts) {
|
||||
await task
|
||||
.source(opts.src || relative(__dirname, require.resolve('postcss-loader')))
|
||||
.ncc({
|
||||
packageName: 'postcss-loader',
|
||||
externals: {
|
||||
...externals,
|
||||
'schema-utils': 'next/dist/compiled/schema-utils3',
|
||||
},
|
||||
})
|
||||
.target('compiled/postcss-loader')
|
||||
.source(
|
||||
opts.src || relative(__dirname, require.resolve('postcss-safe-parser'))
|
||||
)
|
||||
.ncc({ packageName: 'postcss-safe-parser', externals })
|
||||
.target('compiled/postcss-safe-parser')
|
||||
}
|
||||
// eslint-disable-next-line camelcase
|
||||
externals['postcss-preset-env'] = 'next/dist/compiled/postcss-preset-env'
|
||||
|
@ -485,7 +468,6 @@ export async function ncc_postcss_scss(task, opts) {
|
|||
.ncc({
|
||||
packageName: 'postcss-scss',
|
||||
externals: {
|
||||
postcss: 'postcss',
|
||||
'postcss/lib/parser': 'postcss/lib/parser',
|
||||
...externals,
|
||||
},
|
||||
|
@ -493,6 +475,105 @@ export async function ncc_postcss_scss(task, opts) {
|
|||
.target('compiled/postcss-scss')
|
||||
}
|
||||
// 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'
|
||||
export async function ncc_recast(task, opts) {
|
||||
await task
|
||||
|
@ -786,7 +867,6 @@ export async function ncc(task, opts) {
|
|||
'ncc_content_type',
|
||||
'ncc_cookie',
|
||||
'ncc_cross_spawn',
|
||||
'ncc_css_loader',
|
||||
'ncc_debug',
|
||||
'ncc_devalue',
|
||||
'ncc_escape_string_regexp',
|
||||
|
@ -809,10 +889,16 @@ export async function ncc(task, opts) {
|
|||
'ncc_nanoid',
|
||||
'ncc_neo_async',
|
||||
'ncc_ora',
|
||||
'ncc_postcss_safe_parser',
|
||||
'ncc_postcss_flexbugs_fixes',
|
||||
'ncc_postcss_loader',
|
||||
'ncc_postcss_preset_env',
|
||||
'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_resolve_url_loader',
|
||||
'ncc_sass_loader',
|
||||
|
|
|
@ -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)
|
||||
|
||||
> 1 | button {}
|
||||
| ^"
|
||||
| ^"
|
||||
`)
|
||||
|
||||
await cleanup()
|
||||
|
|
|
@ -36,7 +36,7 @@ describe('AMP Fragment Styles', () => {
|
|||
await validateAMP(html)
|
||||
const $ = cheerio.load(html)
|
||||
const styles = $('style[amp-custom]').text()
|
||||
expect(styles).toMatch(/background:(.*|)#ff69b4/)
|
||||
expect(styles).toMatch(/background:(.*|)hotpink/)
|
||||
expect(styles).toMatch(/font-size:(.*|)16\.4px/)
|
||||
})
|
||||
})
|
||||
|
|
|
@ -232,7 +232,7 @@ describe('AMP Usage', () => {
|
|||
const html = await renderViaHTTP(appPort, '/styled?amp=1')
|
||||
const $ = cheerio.load(html)
|
||||
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', () => {
|
|||
})
|
||||
})
|
||||
|
||||
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', () => {
|
||||
const appDir = join(fixturesDir, 'custom-configuration-arr')
|
||||
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
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)
|
||||
})
|
||||
})
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
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
|
|
@ -1,3 +0,0 @@
|
|||
export default function Home() {
|
||||
return <div />
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
/* 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() {
|
|||
|
||||
it('should render styles during SSR (AMP)', async () => {
|
||||
const html = await renderViaHTTP(appPort, '/amp')
|
||||
expect(html).toMatch(/color:.*?#0ff/)
|
||||
expect(html).toMatch(/color:.*?cyan/)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
146
yarn.lock
146
yarn.lock
|
@ -7856,24 +7856,6 @@ css-loader@1.0.0:
|
|||
postcss-value-parser "^3.3.0"
|
||||
source-list-map "^2.0.0"
|
||||
|
||||
css-loader@4.3.0:
|
||||
version "4.3.0"
|
||||
resolved "https://registry.yarnpkg.com/css-loader/-/css-loader-4.3.0.tgz#c888af64b2a5b2e85462c72c0f4a85c7e2e0821e"
|
||||
integrity sha512-rdezjCjScIrsL8BSYszgT4s476IcNKt6yX69t0pHjJVnPUTDpn4WfIpDQTN3wCJvUvfsz/mFjuGOekf3PY3NUg==
|
||||
dependencies:
|
||||
camelcase "^6.0.0"
|
||||
cssesc "^3.0.0"
|
||||
icss-utils "^4.1.1"
|
||||
loader-utils "^2.0.0"
|
||||
postcss "^7.0.32"
|
||||
postcss-modules-extract-imports "^2.0.0"
|
||||
postcss-modules-local-by-default "^3.0.3"
|
||||
postcss-modules-scope "^2.2.0"
|
||||
postcss-modules-values "^3.0.0"
|
||||
postcss-value-parser "^4.1.0"
|
||||
schema-utils "^2.7.1"
|
||||
semver "^7.3.2"
|
||||
|
||||
css-prefers-color-scheme@^3.1.1:
|
||||
version "3.1.1"
|
||||
resolved "https://registry.yarnpkg.com/css-prefers-color-scheme/-/css-prefers-color-scheme-3.1.1.tgz#6f830a2714199d4f0d0d0bb8a27916ed65cff1f4"
|
||||
|
@ -10924,24 +10906,17 @@ icss-replace-symbols@^1.1.0:
|
|||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/icss-replace-symbols/-/icss-replace-symbols-1.1.0.tgz#06ea6f83679a7749e386cfe1fe812ae5db223ded"
|
||||
|
||||
icss-utils@5.1.0, icss-utils@^5.0.0:
|
||||
version "5.1.0"
|
||||
resolved "https://registry.yarnpkg.com/icss-utils/-/icss-utils-5.1.0.tgz#c6be6858abd013d768e98366ae47e25d5887b1ae"
|
||||
integrity sha512-soFhflCVWLfRNOPU3iv5Z9VUdT44xFRbzjLsEzSr5AQmgqPMTHdU3PMT1Cf1ssx8fLNJDA1juftYl+PUcv3MqA==
|
||||
|
||||
icss-utils@^2.1.0:
|
||||
version "2.1.0"
|
||||
resolved "https://registry.yarnpkg.com/icss-utils/-/icss-utils-2.1.0.tgz#83f0a0ec378bf3246178b6c2ad9136f135b1c962"
|
||||
dependencies:
|
||||
postcss "^6.0.1"
|
||||
|
||||
icss-utils@^4.0.0, icss-utils@^4.1.1:
|
||||
version "4.1.1"
|
||||
resolved "https://registry.yarnpkg.com/icss-utils/-/icss-utils-4.1.1.tgz#21170b53789ee27447c2f47dd683081403f9a467"
|
||||
integrity sha512-4aFq7wvWyMHKgxsH8QQtGpvbASCf+eM3wPRLI6R+MgAnTCZ6STYsRvttLvRWK0Nfif5piF394St3HeJDaljGPA==
|
||||
dependencies:
|
||||
postcss "^7.0.14"
|
||||
|
||||
icss-utils@^5.0.0:
|
||||
version "5.1.0"
|
||||
resolved "https://registry.yarnpkg.com/icss-utils/-/icss-utils-5.1.0.tgz#c6be6858abd013d768e98366ae47e25d5887b1ae"
|
||||
integrity sha512-soFhflCVWLfRNOPU3iv5Z9VUdT44xFRbzjLsEzSr5AQmgqPMTHdU3PMT1Cf1ssx8fLNJDA1juftYl+PUcv3MqA==
|
||||
|
||||
idb@3.0.2:
|
||||
version "3.0.2"
|
||||
resolved "https://registry.yarnpkg.com/idb/-/idb-3.0.2.tgz#c8e9122d5ddd40f13b60ae665e4862f8b13fa384"
|
||||
|
@ -15586,17 +15561,6 @@ postcss-loader@3.0.0:
|
|||
postcss-load-config "^2.0.0"
|
||||
schema-utils "^1.0.0"
|
||||
|
||||
postcss-loader@4.3.0:
|
||||
version "4.3.0"
|
||||
resolved "https://registry.yarnpkg.com/postcss-loader/-/postcss-loader-4.3.0.tgz#2c4de9657cd4f07af5ab42bd60a673004da1b8cc"
|
||||
integrity sha512-M/dSoIiNDOo8Rk0mUqoj4kpGq91gcxCfb9PoyZVdZ76/AuhxylHDYZblNE8o+EQ9AMSASeMFEKxZf5aU6wlx1Q==
|
||||
dependencies:
|
||||
cosmiconfig "^7.0.0"
|
||||
klona "^2.0.4"
|
||||
loader-utils "^2.0.0"
|
||||
schema-utils "^3.0.0"
|
||||
semver "^7.3.4"
|
||||
|
||||
postcss-logical@^3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/postcss-logical/-/postcss-logical-3.0.0.tgz#2495d0f8b82e9f262725f75f9401b34e7b45d5b5"
|
||||
|
@ -15665,42 +15629,18 @@ postcss-minify-selectors@^4.0.2:
|
|||
postcss "^7.0.0"
|
||||
postcss-selector-parser "^3.0.0"
|
||||
|
||||
postcss-modules-extract-imports@3.0.0, postcss-modules-extract-imports@^3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/postcss-modules-extract-imports/-/postcss-modules-extract-imports-3.0.0.tgz#cda1f047c0ae80c97dbe28c3e76a43b88025741d"
|
||||
integrity sha512-bdHleFnP3kZ4NYDhuGlVK+CMrQ/pqUm8bx/oGL93K6gVwiclvX5x0n76fYMKuIGKzlABOy13zsvqjb0f92TEXw==
|
||||
|
||||
postcss-modules-extract-imports@^1.2.0:
|
||||
version "1.2.1"
|
||||
resolved "https://registry.yarnpkg.com/postcss-modules-extract-imports/-/postcss-modules-extract-imports-1.2.1.tgz#dc87e34148ec7eab5f791f7cd5849833375b741a"
|
||||
dependencies:
|
||||
postcss "^6.0.1"
|
||||
|
||||
postcss-modules-extract-imports@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/postcss-modules-extract-imports/-/postcss-modules-extract-imports-2.0.0.tgz#818719a1ae1da325f9832446b01136eeb493cd7e"
|
||||
integrity sha512-LaYLDNS4SG8Q5WAWqIJgdHPJrDDr/Lv775rMBFUbgjTz6j34lUznACHcdRWroPvXANP2Vj7yNK57vp9eFqzLWQ==
|
||||
dependencies:
|
||||
postcss "^7.0.5"
|
||||
|
||||
postcss-modules-extract-imports@^3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/postcss-modules-extract-imports/-/postcss-modules-extract-imports-3.0.0.tgz#cda1f047c0ae80c97dbe28c3e76a43b88025741d"
|
||||
integrity sha512-bdHleFnP3kZ4NYDhuGlVK+CMrQ/pqUm8bx/oGL93K6gVwiclvX5x0n76fYMKuIGKzlABOy13zsvqjb0f92TEXw==
|
||||
|
||||
postcss-modules-local-by-default@^1.2.0:
|
||||
version "1.2.0"
|
||||
resolved "https://registry.yarnpkg.com/postcss-modules-local-by-default/-/postcss-modules-local-by-default-1.2.0.tgz#f7d80c398c5a393fa7964466bd19500a7d61c069"
|
||||
dependencies:
|
||||
css-selector-tokenizer "^0.7.0"
|
||||
postcss "^6.0.1"
|
||||
|
||||
postcss-modules-local-by-default@^3.0.3:
|
||||
version "3.0.3"
|
||||
resolved "https://registry.yarnpkg.com/postcss-modules-local-by-default/-/postcss-modules-local-by-default-3.0.3.tgz#bb14e0cc78279d504dbdcbfd7e0ca28993ffbbb0"
|
||||
integrity sha512-e3xDq+LotiGesympRlKNgaJ0PCzoUIdpH0dj47iWAui/kyTgh3CiAr1qP54uodmJhl6p9rN6BoNcdEDVJx9RDw==
|
||||
dependencies:
|
||||
icss-utils "^4.1.1"
|
||||
postcss "^7.0.32"
|
||||
postcss-selector-parser "^6.0.2"
|
||||
postcss-value-parser "^4.1.0"
|
||||
|
||||
postcss-modules-local-by-default@^4.0.0:
|
||||
postcss-modules-local-by-default@4.0.0, postcss-modules-local-by-default@^4.0.0:
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/postcss-modules-local-by-default/-/postcss-modules-local-by-default-4.0.0.tgz#ebbb54fae1598eecfdf691a02b3ff3b390a5a51c"
|
||||
integrity sha512-sT7ihtmGSF9yhm6ggikHdV0hlziDTX7oFoXtuVWeDd3hHObNkcHRo9V3yg7vCAY7cONyxJC/XXCmmiHHcvX7bQ==
|
||||
|
@ -15709,6 +15649,20 @@ postcss-modules-local-by-default@^4.0.0:
|
|||
postcss-selector-parser "^6.0.2"
|
||||
postcss-value-parser "^4.1.0"
|
||||
|
||||
postcss-modules-local-by-default@^1.2.0:
|
||||
version "1.2.0"
|
||||
resolved "https://registry.yarnpkg.com/postcss-modules-local-by-default/-/postcss-modules-local-by-default-1.2.0.tgz#f7d80c398c5a393fa7964466bd19500a7d61c069"
|
||||
dependencies:
|
||||
css-selector-tokenizer "^0.7.0"
|
||||
postcss "^6.0.1"
|
||||
|
||||
postcss-modules-scope@3.0.0, postcss-modules-scope@^3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/postcss-modules-scope/-/postcss-modules-scope-3.0.0.tgz#9ef3151456d3bbfa120ca44898dfca6f2fa01f06"
|
||||
integrity sha512-hncihwFA2yPath8oZ15PZqvWGkWf+XUfQgUGamS4LqoP1anQLOsOJw0vr7J7IwLpoY9fatA2qiGUGmuZL0Iqlg==
|
||||
dependencies:
|
||||
postcss-selector-parser "^6.0.4"
|
||||
|
||||
postcss-modules-scope@^1.1.0:
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/postcss-modules-scope/-/postcss-modules-scope-1.1.0.tgz#d6ea64994c79f97b62a72b426fbe6056a194bb90"
|
||||
|
@ -15716,20 +15670,12 @@ postcss-modules-scope@^1.1.0:
|
|||
css-selector-tokenizer "^0.7.0"
|
||||
postcss "^6.0.1"
|
||||
|
||||
postcss-modules-scope@^2.2.0:
|
||||
version "2.2.0"
|
||||
resolved "https://registry.yarnpkg.com/postcss-modules-scope/-/postcss-modules-scope-2.2.0.tgz#385cae013cc7743f5a7d7602d1073a89eaae62ee"
|
||||
integrity sha512-YyEgsTMRpNd+HmyC7H/mh3y+MeFWevy7V1evVhJWewmMbjDHIbZbOXICC2y+m1xI1UVfIT1HMW/O04Hxyu9oXQ==
|
||||
postcss-modules-values@4.0.0, postcss-modules-values@^4.0.0:
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/postcss-modules-values/-/postcss-modules-values-4.0.0.tgz#d7c5e7e68c3bb3c9b27cbf48ca0bb3ffb4602c9c"
|
||||
integrity sha512-RDxHkAiEGI78gS2ofyvCsu7iycRv7oqw5xMWn9iMoR0N/7mf9D50ecQqUo5BZ9Zh2vH4bCUR/ktCqbB9m8vJjQ==
|
||||
dependencies:
|
||||
postcss "^7.0.6"
|
||||
postcss-selector-parser "^6.0.0"
|
||||
|
||||
postcss-modules-scope@^3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/postcss-modules-scope/-/postcss-modules-scope-3.0.0.tgz#9ef3151456d3bbfa120ca44898dfca6f2fa01f06"
|
||||
integrity sha512-hncihwFA2yPath8oZ15PZqvWGkWf+XUfQgUGamS4LqoP1anQLOsOJw0vr7J7IwLpoY9fatA2qiGUGmuZL0Iqlg==
|
||||
dependencies:
|
||||
postcss-selector-parser "^6.0.4"
|
||||
icss-utils "^5.0.0"
|
||||
|
||||
postcss-modules-values@^1.3.0:
|
||||
version "1.3.0"
|
||||
|
@ -15738,21 +15684,6 @@ postcss-modules-values@^1.3.0:
|
|||
icss-replace-symbols "^1.1.0"
|
||||
postcss "^6.0.1"
|
||||
|
||||
postcss-modules-values@^3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/postcss-modules-values/-/postcss-modules-values-3.0.0.tgz#5b5000d6ebae29b4255301b4a3a54574423e7f10"
|
||||
integrity sha512-1//E5jCBrZ9DmRX+zCtmQtRSV6PV42Ix7Bzj9GbwJceduuf7IqP8MgeTXuRDHOWj2m0VzZD5+roFWDuU8RQjcg==
|
||||
dependencies:
|
||||
icss-utils "^4.0.0"
|
||||
postcss "^7.0.6"
|
||||
|
||||
postcss-modules-values@^4.0.0:
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/postcss-modules-values/-/postcss-modules-values-4.0.0.tgz#d7c5e7e68c3bb3c9b27cbf48ca0bb3ffb4602c9c"
|
||||
integrity sha512-RDxHkAiEGI78gS2ofyvCsu7iycRv7oqw5xMWn9iMoR0N/7mf9D50ecQqUo5BZ9Zh2vH4bCUR/ktCqbB9m8vJjQ==
|
||||
dependencies:
|
||||
icss-utils "^5.0.0"
|
||||
|
||||
postcss-modules@^4.0.0:
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/postcss-modules/-/postcss-modules-4.0.0.tgz#2bc7f276ab88f3f1b0fadf6cbd7772d43b5f3b9b"
|
||||
|
@ -15965,6 +15896,11 @@ postcss-safe-parser@4.0.2:
|
|||
dependencies:
|
||||
postcss "^7.0.26"
|
||||
|
||||
postcss-safe-parser@6.0.0:
|
||||
version "6.0.0"
|
||||
resolved "https://registry.yarnpkg.com/postcss-safe-parser/-/postcss-safe-parser-6.0.0.tgz#bb4c29894171a94bc5c996b9a30317ef402adaa1"
|
||||
integrity sha512-FARHN8pwH+WiS2OPCxJI8FuRJpTVnn6ZNFiqAM2aeW2LwTHWWmWgIyKC6cUo0L8aeKiF/14MNvnpls6R2PBeMQ==
|
||||
|
||||
postcss-scss@3.0.5:
|
||||
version "3.0.5"
|
||||
resolved "https://registry.yarnpkg.com/postcss-scss/-/postcss-scss-3.0.5.tgz#bd484faf05890e48a6f5e097acb3d104cc7b9ac7"
|
||||
|
@ -16042,15 +15978,15 @@ postcss-unique-selectors@^4.0.1:
|
|||
postcss "^7.0.0"
|
||||
uniqs "^2.0.0"
|
||||
|
||||
postcss-value-parser@^3.0.0, postcss-value-parser@^3.3.0, postcss-value-parser@^3.3.1:
|
||||
version "3.3.1"
|
||||
resolved "https://registry.yarnpkg.com/postcss-value-parser/-/postcss-value-parser-3.3.1.tgz#9ff822547e2893213cf1c30efa51ac5fd1ba8281"
|
||||
|
||||
postcss-value-parser@^4.0.2, postcss-value-parser@^4.1.0:
|
||||
postcss-value-parser@4.1.0, postcss-value-parser@^4.0.2, postcss-value-parser@^4.1.0:
|
||||
version "4.1.0"
|
||||
resolved "https://registry.yarnpkg.com/postcss-value-parser/-/postcss-value-parser-4.1.0.tgz#443f6a20ced6481a2bda4fa8532a6e55d789a2cb"
|
||||
integrity sha512-97DXOFbQJhk71ne5/Mt6cOu6yxsSfM0QGQyl0L25Gca4yGWEGJaig7l7gbCX623VqTBNGLRLaVUCnNkcedlRSQ==
|
||||
|
||||
postcss-value-parser@^3.0.0, postcss-value-parser@^3.3.0, postcss-value-parser@^3.3.1:
|
||||
version "3.3.1"
|
||||
resolved "https://registry.yarnpkg.com/postcss-value-parser/-/postcss-value-parser-3.3.1.tgz#9ff822547e2893213cf1c30efa51ac5fd1ba8281"
|
||||
|
||||
postcss-values-parser@^2.0.0, postcss-values-parser@^2.0.1:
|
||||
version "2.0.1"
|
||||
resolved "https://registry.yarnpkg.com/postcss-values-parser/-/postcss-values-parser-2.0.1.tgz#da8b472d901da1e205b47bdc98637b9e9e550e5f"
|
||||
|
@ -17621,7 +17557,7 @@ scheduler@^0.20.2:
|
|||
loose-envify "^1.1.0"
|
||||
object-assign "^4.1.1"
|
||||
|
||||
schema-utils@2.7.1, schema-utils@^2.6.5, schema-utils@^2.7.1:
|
||||
schema-utils@2.7.1, schema-utils@^2.6.5:
|
||||
version "2.7.1"
|
||||
resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-2.7.1.tgz#1ca4f32d1b24c590c203b8e7a50bf0ea4cd394d7"
|
||||
integrity sha512-SHiNtMOUGWBQJwzISiVYKu82GiV4QYGePp3odlY1tuKO7gPtphAT5R/py0fA6xtbgLL/RvtJZnU9b8s0F1q0Xg==
|
||||
|
|
Loading…
Reference in a new issue