Skip to content

Commit

Permalink
Update to postcss-loader 4.0.2.
Browse files Browse the repository at this point in the history
- postcss-loader 4.0 improves compatibility with webpack 5.
- the 4.0.2 release notes also mention improved PostCSS 8 compatibility (see issue #17242)
- postcss-loader by default now detects external PostCss configs and merges them with loader options,
so I have disabled this to preserve Next’s current behaviour. For example, Next accepts JSON configs with comments,
but css-loader fails to load them.
- passing an `ident` field to the postcss-loader options triggers a schema validation error, so when patching
 the loader configuration, I try to detect the `postcssOptions` field instead.
  • Loading branch information
ludofischer committed Sep 30, 2020
1 parent f06c589 commit 0397292
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ export function getGlobalCssLoader(
loaders.push({
loader: require.resolve('next/dist/compiled/postcss-loader'),
options: {
ident: '__nextjs_postcss',
plugins: postCssPlugins,
postcssOptions: { plugins: postCssPlugins, config: false },
sourceMap: true,
},
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ export function getCssModuleLoader(
loaders.push({
loader: require.resolve('next/dist/compiled/postcss-loader'),
options: {
ident: '__nextjs_postcss',
plugins: postCssPlugins,
postcssOptions: { plugins: postCssPlugins, config: false },
sourceMap: true,
},
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ export async function __overrideCssConfiguration(
if (
rule.options &&
typeof rule.options === 'object' &&
rule.options['ident'] === '__nextjs_postcss'
typeof rule.options.postcssOptions === 'object'
) {
rule.options.plugins = postCssPlugins
rule.options.postcssOptions.plugins = postCssPlugins
} else if (Array.isArray(rule.oneOf)) {
rule.oneOf.forEach(patch)
} else if (Array.isArray(rule.use)) {
Expand Down
34 changes: 17 additions & 17 deletions packages/next/compiled/postcss-loader/LICENSE
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
License (MIT)
Copyright JS Foundation and other contributors

Copyright 2017 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:

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 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.
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 change: 1 addition & 0 deletions packages/next/compiled/postcss-loader/cjs.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion packages/next/compiled/postcss-loader/index.js

This file was deleted.

2 changes: 1 addition & 1 deletion packages/next/compiled/postcss-loader/package.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"name":"postcss-loader","main":"index.js","author":"Andrey Sitnik <andrey@sitnik.ru>","license":"MIT"}
{"name":"postcss-loader","main":"cjs.js","author":"Andrey Sitnik <andrey@sitnik.ru>","license":"MIT"}
2 changes: 1 addition & 1 deletion packages/next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@
"ora": "4.0.4",
"path-to-regexp": "6.1.0",
"postcss-flexbugs-fixes": "4.2.1",
"postcss-loader": "3.0.0",
"postcss-loader": "4.0.2",
"postcss-preset-env": "6.7.0",
"raw-body": "2.4.1",
"recast": "0.18.5",
Expand Down
29 changes: 28 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5723,6 +5723,17 @@ cosmiconfig@^6.0.0:
path-type "^4.0.0"
yaml "^1.7.2"

cosmiconfig@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-7.0.0.tgz#ef9b44d773959cae63ddecd122de23853b60f8d3"
integrity sha512-pondGvTuVYDk++upghXJabWzL6Kxu6f26ljFw64Swq9v6sQPUL3EUlVDV56diOjpCayKihL6hVe8exIACU4XcA==
dependencies:
"@types/parse-json" "^4.0.0"
import-fresh "^3.2.1"
parse-json "^5.0.0"
path-type "^4.0.0"
yaml "^1.10.0"

coveralls@3.0.3:
version "3.0.3"
resolved "https://registry.yarnpkg.com/coveralls/-/coveralls-3.0.3.tgz#83b1c64aea1c6afa69beaf50b55ac1bc4d13e2b8"
Expand Down Expand Up @@ -8609,7 +8620,7 @@ import-fresh@^2.0.0:
caller-path "^2.0.0"
resolve-from "^3.0.0"

import-fresh@^3.0.0, import-fresh@^3.1.0:
import-fresh@^3.0.0, import-fresh@^3.1.0, import-fresh@^3.2.1:
version "3.2.1"
resolved "https://registry.yarnpkg.com/import-fresh/-/import-fresh-3.2.1.tgz#633ff618506e793af5ac91bf48b72677e15cbe66"
dependencies:
Expand Down Expand Up @@ -12873,6 +12884,17 @@ postcss-loader@3.0.0:
postcss-load-config "^2.0.0"
schema-utils "^1.0.0"

postcss-loader@4.0.2:
version "4.0.2"
resolved "https://registry.yarnpkg.com/postcss-loader/-/postcss-loader-4.0.2.tgz#b9e55a6126ee67bb7b94bbfcbf1aa24c69f11229"
integrity sha512-u7Qoa6GSPIeg9/hHbNnXspzuD5jjCIWKgk1fJ/gGJPS0uaj6Whk2zjXhDAiHZyYSrDmIzUQk7GgwRF22eRIQGQ==
dependencies:
cosmiconfig "^7.0.0"
klona "^2.0.3"
loader-utils "^2.0.0"
schema-utils "^2.7.1"
semver "^7.3.2"

postcss-logical@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/postcss-logical/-/postcss-logical-3.0.0.tgz#2495d0f8b82e9f262725f75f9401b34e7b45d5b5"
Expand Down Expand Up @@ -17140,6 +17162,11 @@ yallist@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72"

yaml@^1.10.0:
version "1.10.0"
resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.10.0.tgz#3b593add944876077d4d683fee01081bd9fff31e"
integrity sha512-yr2icI4glYaNG+KWONODapy2/jDdMSDnrONSjblABjD9B4Z5LgiircSt8m8sRZFNi08kG9Sm0uSHtEmP3zaEGg==

yaml@^1.7.2:
version "1.9.2"
resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.9.2.tgz#f0cfa865f003ab707663e4f04b3956957ea564ed"
Expand Down

0 comments on commit 0397292

Please sign in to comment.