Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: add warning helper for removed experimental option #44213

Merged
merged 8 commits into from Jan 3, 2023

Conversation

SukkaW
Copy link
Contributor

@SukkaW SukkaW commented Dec 21, 2022

Continues #44202, implements #44202 (comment).

cc @styfle

Bug

  • Related issues linked using fixes #number
  • Integration tests added
  • Errors have a helpful link attached, see contributing.md

Feature

  • Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
  • Related issues linked using fixes #number
  • e2e tests added
  • Documentation added
  • Telemetry added. In case of a feature if it's used or not.
  • Errors have a helpful link attached, see contributing.md

Documentation / Examples

  • Make sure the linting passes by running pnpm build && pnpm lint
  • The "examples guidelines" are followed from our contributing doc

config: NextConfig,
key: keyof NextConfigComplete,
configFileName: string,
isCompilerFeature: false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the isCompilerFeature is too specific. Instead, we should be able to reference any part of the config.

Perhaps we could use a dot syntax like key: 'compiler.relay'

Copy link
Contributor Author

@SukkaW SukkaW Dec 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 335c35a (#44213). But there will be no strict type check for oldKey and newKey.

@SukkaW SukkaW requested a review from styfle December 22, 2022 06:50
@SukkaW SukkaW force-pushed the load-config-deprecation-helper branch from 335c35a to e6bc1a0 Compare December 22, 2022 14:45
@ijjk
Copy link
Member

ijjk commented Dec 22, 2022

Stats from current PR

Default Build
General Overall increase ⚠️
vercel/next.js canary SukkaW/next.js load-config-deprecation-helper Change
buildDuration 36.5s 37.9s ⚠️ +1.4s
buildDurationCached 10.5s 10.6s ⚠️ +133ms
nodeModulesSize 95 MB 95 MB
nextStartRea..uration (ms) 279ms 290ms ⚠️ +11ms
Client Bundles (main, webpack)
vercel/next.js canary SukkaW/next.js load-config-deprecation-helper Change
152-HASH.js gzip 64.5 kB 64.5 kB
53.HASH.js gzip 182 B 182 B
main-app-HASH.js gzip 205 B 205 B
main-HASH.js gzip 79.2 kB 79.2 kB
webpack-HASH.js gzip 1.7 kB 1.7 kB
Overall change 146 kB 146 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary SukkaW/next.js load-config-deprecation-helper Change
polyfills-HASH.js gzip 31 kB 31 kB
Overall change 31 kB 31 kB
Client Pages
vercel/next.js canary SukkaW/next.js load-config-deprecation-helper Change
_app-HASH.js gzip 192 B 192 B
_error-HASH.js gzip 179 B 179 B
amp-HASH.js gzip 484 B 484 B
css-HASH.js gzip 804 B 804 B
dynamic-HASH.js gzip 2.29 kB 2.29 kB
edge-ssr-HASH.js gzip 255 B 255 B
head-HASH.js gzip 827 B 827 B
hooks-HASH.js gzip 848 B 848 B
image-HASH.js gzip 4.3 kB 4.3 kB
index-HASH.js gzip 252 B 252 B
link-HASH.js gzip 2.69 kB 2.69 kB
routerDirect..HASH.js gzip 782 B 782 B
script-HASH.js gzip 857 B 857 B
withRouter-HASH.js gzip 781 B 781 B
85e02e95b279..7e3.css gzip 107 B 107 B
Overall change 15.6 kB 15.6 kB
Client Build Manifests
vercel/next.js canary SukkaW/next.js load-config-deprecation-helper Change
_buildManifest.js gzip 481 B 481 B
Overall change 481 B 481 B
Rendered Page Sizes
vercel/next.js canary SukkaW/next.js load-config-deprecation-helper Change
index.html gzip 489 B 489 B
link.html gzip 504 B 504 B
withRouter.html gzip 485 B 485 B
Overall change 1.48 kB 1.48 kB
Edge SSR bundle Size
vercel/next.js canary SukkaW/next.js load-config-deprecation-helper Change
edge-ssr.js gzip 110 kB 110 kB
page.js gzip 98.4 kB 98.4 kB
Overall change 209 kB 209 kB
Middleware size
vercel/next.js canary SukkaW/next.js load-config-deprecation-helper Change
middleware-b..fest.js gzip 585 B 585 B
middleware-r..fest.js gzip 145 B 145 B
middleware.js gzip 27 kB 27 kB
edge-runtime..pack.js gzip 1.83 kB 1.83 kB
Overall change 29.6 kB 29.6 kB

Diffs

Diff for page.js
@@ -8618,16 +8618,16 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
       /***/
     },
 
-    /***/ 199: /***/ (
+    /***/ 1036: /***/ (
       __unused_webpack_module,
       __unused_webpack_exports,
       __webpack_require__
     ) => {
       Promise.resolve(/* import() eager */).then(
-        __webpack_require__.bind(__webpack_require__, 2973)
+        __webpack_require__.bind(__webpack_require__, 1210)
       );
       Promise.resolve(/* import() eager */).then(
-        __webpack_require__.bind(__webpack_require__, 1210)
+        __webpack_require__.bind(__webpack_require__, 2973)
       );
       Promise.resolve(/* import() eager */).then(
         __webpack_require__.bind(__webpack_require__, 6448)
Diff for middleware-b..-manifest.js
@@ -9,7 +9,7 @@ self.__BUILD_MANIFEST = {
   rootMainFiles: [
     "static/chunks/webpack-c452a3e31b73f504.js",
     "static/chunks/152-4025b906f33b8271.js",
-    "static/chunks/main-app-ec4ed0640c5bbc2a.js"
+    "static/chunks/main-app-c9a0aaff35eafcb5.js"
   ],
   pages: {
     "/": [
Diff for main-app-HASH.js
@@ -1,16 +1,16 @@
 (self["webpackChunk_N_E"] = self["webpackChunk_N_E"] || []).push([
   [744],
   {
-    /***/ 9421: /***/ function(
+    /***/ 9915: /***/ function(
       __unused_webpack_module,
       __unused_webpack_exports,
       __webpack_require__
     ) {
       Promise.resolve(/* import() eager */).then(
-        __webpack_require__.t.bind(__webpack_require__, 1161, 23)
+        __webpack_require__.t.bind(__webpack_require__, 429, 23)
       );
       Promise.resolve(/* import() eager */).then(
-        __webpack_require__.t.bind(__webpack_require__, 429, 23)
+        __webpack_require__.t.bind(__webpack_require__, 1161, 23)
       );
       Promise.resolve(/* import() eager */).then(
         __webpack_require__.t.bind(__webpack_require__, 8138, 23)
@@ -28,7 +28,7 @@
       return __webpack_require__((__webpack_require__.s = moduleId));
     };
     /******/ __webpack_require__.O(0, [152], function() {
-      return __webpack_exec__(7070), __webpack_exec__(9421);
+      return __webpack_exec__(7070), __webpack_exec__(9915);
     });
     /******/ var __webpack_exports__ = __webpack_require__.O();
     /******/ _N_E = __webpack_exports__;
Commit: fc6b678


let current = config
const newKeys = newKey.split('.')
while (newKeys.length > 1) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of while and newKeys.shift(), could you use for (const key of newKeys)?

Copy link
Contributor Author

@SukkaW SukkaW Dec 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@styfle I was considering using for, but it can't stop before the last key.

Take compiler.relay (['compiler', 'relay']) as an example. We will need to stop at ['relay'], as only compiler requires current.compiler ||= {}. The last key relay requires current.relay = config.experimental.relay instead of current.relay ||= {}.

That's why I use while (.length > 1) here.

Copy link
Member

@styfle styfle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Could you write a couple unit tests to ensure this is working as expected?

@SukkaW SukkaW requested a review from huozhi as a code owner December 23, 2022 02:45
@SukkaW
Copy link
Contributor Author

SukkaW commented Dec 23, 2022

@styfle Sure! I just add the unit test in 672dfc7 (#44213).

@SukkaW SukkaW requested a review from styfle December 23, 2022 02:46
@SukkaW SukkaW force-pushed the load-config-deprecation-helper branch from c6fd310 to 672dfc7 Compare December 23, 2022 02:47
warnOptionHasBeenMovedOutOfExperimental(
result,
'allowMiddlewareResponseBody',
'allowMiddlewareResponseBody',
Copy link
Member

@styfle styfle Dec 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not seeing an option for allowMiddlewareResponseBody.

Where is that used?

Copy link
Contributor Author

@SukkaW SukkaW Dec 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, my bad. allowMiddlewareResponseBody was removed in #44224. I must have missed it when rebasing my PR.
Fixed in 7e9482f (#44213).

@SukkaW SukkaW requested a review from styfle December 24, 2022 05:34
Copy link
Member

@ijjk ijjk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks for the PR!

@ijjk ijjk merged commit c728575 into vercel:canary Jan 3, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 3, 2023
@SukkaW SukkaW deleted the load-config-deprecation-helper branch October 24, 2023 08:34
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants