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

Experimental feature for allowing importing Typescript files outside of the root directory #22867

Merged
merged 7 commits into from
Mar 19, 2021

Conversation

shuding
Copy link
Member

@shuding shuding commented Mar 8, 2021

This PR attempts to provide an option to allow importing TS/TSX from outside of the current Next.js project root directory. Although this goes against the design decision that no source code should be imported from outside of root and might bring tons of issues, it will still be helpful in some monorepo use cases.

This PR assumes that the external files are following the same language syntax rules and under the same tooling versions as the source code inside your project root. And it's also not allowed to enable the baseUrl feature in the external directory (as the project should only have 1 import base URL).

module.exports = {
  experimental: {
    externalDir: true,
  },
}

X-ref: #9474, #15569, #19928, #20374.

@ijjk ijjk added the type: next label Mar 8, 2021
@ijjk
Copy link
Member

ijjk commented Mar 8, 2021

Stats from current PR

Default Server Mode (Decrease detected ✓)
General Overall increase ⚠️
vercel/next.js canary shuding/next.js feat-external-dir Change
buildDuration 13.4s 13.4s -38ms
nodeModulesSize 42.8 MB 42.8 MB ⚠️ +853 B
Page Load Tests Overall decrease ⚠️
vercel/next.js canary shuding/next.js feat-external-dir Change
/ failed reqs 0 0
/ total time (seconds) 2.398 2.478 ⚠️ +0.08
/ avg req/sec 1042.55 1008.95 ⚠️ -33.6
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.641 1.717 ⚠️ +0.08
/error-in-render avg req/sec 1523.9 1456.11 ⚠️ -67.79
Client Bundles (main, webpack, commons)
vercel/next.js canary shuding/next.js feat-external-dir Change
677f882d2ed8..a2e7.js gzip 13.4 kB 13.4 kB
framework.HASH.js gzip 39 kB 39 kB
main-HASH.js gzip 6.65 kB 6.65 kB
webpack-HASH.js gzip 751 B 751 B
Overall change 59.8 kB 59.8 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary shuding/next.js feat-external-dir Change
polyfills-HASH.js gzip 31.3 kB 31.3 kB
Overall change 31.3 kB 31.3 kB
Client Pages
vercel/next.js canary shuding/next.js feat-external-dir Change
_app-2a09aa2..4a98.js gzip 1.28 kB 1.28 kB
_error-8b758..aef6.js gzip 3.46 kB 3.46 kB
amp-e3e9bc99..932c.js gzip 536 B 536 B
hooks-5023ef..3670.js gzip 888 B 888 B
index-3a2b03..c677.js gzip 227 B 227 B
link-177412b..043e.js gzip 1.67 kB 1.67 kB
routerDirect..1a66.js gzip 303 B 303 B
withRouter-9..1b7d.js gzip 302 B 302 B
Overall change 8.66 kB 8.66 kB
Client Build Manifests
vercel/next.js canary shuding/next.js feat-external-dir Change
_buildManifest.js gzip 347 B 347 B
Overall change 347 B 347 B
Rendered Page Sizes
vercel/next.js canary shuding/next.js feat-external-dir Change
index.html gzip 615 B 615 B
link.html gzip 621 B 621 B
withRouter.html gzip 609 B 609 B
Overall change 1.84 kB 1.84 kB

Serverless Mode
General Overall increase ⚠️
vercel/next.js canary shuding/next.js feat-external-dir Change
buildDuration 16s 15.4s -549ms
nodeModulesSize 42.8 MB 42.8 MB ⚠️ +853 B
Client Bundles (main, webpack, commons)
vercel/next.js canary shuding/next.js feat-external-dir Change
677f882d2ed8..a2e7.js gzip 13.4 kB 13.4 kB
framework.HASH.js gzip 39 kB 39 kB
main-HASH.js gzip 6.65 kB 6.65 kB
webpack-HASH.js gzip 751 B 751 B
Overall change 59.8 kB 59.8 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary shuding/next.js feat-external-dir Change
polyfills-HASH.js gzip 31.3 kB 31.3 kB
Overall change 31.3 kB 31.3 kB
Client Pages
vercel/next.js canary shuding/next.js feat-external-dir Change
_app-2a09aa2..4a98.js gzip 1.28 kB 1.28 kB
_error-8b758..aef6.js gzip 3.46 kB 3.46 kB
amp-e3e9bc99..932c.js gzip 536 B 536 B
hooks-5023ef..3670.js gzip 888 B 888 B
index-3a2b03..c677.js gzip 227 B 227 B
link-177412b..043e.js gzip 1.67 kB 1.67 kB
routerDirect..1a66.js gzip 303 B 303 B
withRouter-9..1b7d.js gzip 302 B 302 B
Overall change 8.66 kB 8.66 kB
Client Build Manifests
vercel/next.js canary shuding/next.js feat-external-dir Change
_buildManifest.js gzip 347 B 347 B
Overall change 347 B 347 B
Serverless bundles
vercel/next.js canary shuding/next.js feat-external-dir Change
_error.js 1.02 MB 1.02 MB
404.html 2.67 kB 2.67 kB
500.html 2.65 kB 2.65 kB
amp.amp.html 10.5 kB 10.5 kB
amp.html 1.86 kB 1.86 kB
hooks.html 1.92 kB 1.92 kB
index.js 1.02 MB 1.02 MB
link.js 1.08 MB 1.08 MB
routerDirect.js 1.07 MB 1.07 MB
withRouter.js 1.07 MB 1.07 MB
Overall change 5.27 MB 5.27 MB

Webpack 5 Mode (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary shuding/next.js feat-external-dir Change
buildDuration 15.7s 15.7s ⚠️ +44ms
nodeModulesSize 42.8 MB 42.8 MB ⚠️ +853 B
Page Load Tests Overall increase ✓
vercel/next.js canary shuding/next.js feat-external-dir Change
/ failed reqs 0 0
/ total time (seconds) 2.403 2.404 0
/ avg req/sec 1040.19 1039.98 ⚠️ -0.21
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.615 1.579 -0.04
/error-in-render avg req/sec 1547.86 1582.82 +34.96
Client Bundles (main, webpack, commons)
vercel/next.js canary shuding/next.js feat-external-dir Change
597-2bc2376a..203d.js gzip 13.3 kB 13.3 kB
framework.HASH.js gzip 39.3 kB 39.3 kB
main-HASH.js gzip 6.59 kB 6.59 kB
webpack-HASH.js gzip 954 B 954 B
Overall change 60.2 kB 60.2 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary shuding/next.js feat-external-dir Change
polyfills-HASH.js gzip 31.1 kB 31.1 kB
Overall change 31.1 kB 31.1 kB
Client Pages
vercel/next.js canary shuding/next.js feat-external-dir Change
_app-aedc815..1421.js gzip 1.26 kB 1.26 kB
_error-71ec2..1a96.js gzip 3.38 kB 3.38 kB
amp-33a09cb0..6745.js gzip 536 B 536 B
hooks-4e968a..f870.js gzip 902 B 902 B
index-5c6845..f75c.js gzip 230 B 230 B
link-99f0c6c..b84a.js gzip 1.65 kB 1.65 kB
routerDirect..bb56.js gzip 306 B 306 B
withRouter-7..2133.js gzip 302 B 302 B
Overall change 8.57 kB 8.57 kB
Client Build Manifests
vercel/next.js canary shuding/next.js feat-external-dir Change
_buildManifest.js gzip 326 B 326 B
Overall change 326 B 326 B
Rendered Page Sizes
vercel/next.js canary shuding/next.js feat-external-dir Change
index.html gzip 586 B 586 B
link.html gzip 592 B 592 B
withRouter.html gzip 580 B 580 B
Overall change 1.76 kB 1.76 kB

Diffs

Diff for index.html
@@ -43,7 +43,7 @@
         "props": { "pageProps": {} },
         "page": "/",
         "query": {},
-        "buildId": "z5yCROqmtabiru6UUg5PW",
+        "buildId": "N7l92tQxFR2QNgcjNsGTR",
         "isFallback": false,
         "gip": true
       }
@@ -77,11 +77,11 @@
       async=""
     ></script>
     <script
-      src="/_next/static/z5yCROqmtabiru6UUg5PW/_buildManifest.js"
+      src="/_next/static/N7l92tQxFR2QNgcjNsGTR/_buildManifest.js"
       async=""
     ></script>
     <script
-      src="/_next/static/z5yCROqmtabiru6UUg5PW/_ssgManifest.js"
+      src="/_next/static/N7l92tQxFR2QNgcjNsGTR/_ssgManifest.js"
       async=""
     ></script>
   </body>
Diff for link.html
@@ -48,7 +48,7 @@
         "props": { "pageProps": {} },
         "page": "/link",
         "query": {},
-        "buildId": "z5yCROqmtabiru6UUg5PW",
+        "buildId": "N7l92tQxFR2QNgcjNsGTR",
         "isFallback": false,
         "gip": true
       }
@@ -82,11 +82,11 @@
       async=""
     ></script>
     <script
-      src="/_next/static/z5yCROqmtabiru6UUg5PW/_buildManifest.js"
+      src="/_next/static/N7l92tQxFR2QNgcjNsGTR/_buildManifest.js"
       async=""
     ></script>
     <script
-      src="/_next/static/z5yCROqmtabiru6UUg5PW/_ssgManifest.js"
+      src="/_next/static/N7l92tQxFR2QNgcjNsGTR/_ssgManifest.js"
       async=""
     ></script>
   </body>
Diff for withRouter.html
@@ -43,7 +43,7 @@
         "props": { "pageProps": {} },
         "page": "/withRouter",
         "query": {},
-        "buildId": "z5yCROqmtabiru6UUg5PW",
+        "buildId": "N7l92tQxFR2QNgcjNsGTR",
         "isFallback": false,
         "gip": true
       }
@@ -77,11 +77,11 @@
       async=""
     ></script>
     <script
-      src="/_next/static/z5yCROqmtabiru6UUg5PW/_buildManifest.js"
+      src="/_next/static/N7l92tQxFR2QNgcjNsGTR/_buildManifest.js"
       async=""
     ></script>
     <script
-      src="/_next/static/z5yCROqmtabiru6UUg5PW/_ssgManifest.js"
+      src="/_next/static/N7l92tQxFR2QNgcjNsGTR/_ssgManifest.js"
       async=""
     ></script>
   </body>
Commit: 0096d0b

@ijjk
Copy link
Member

ijjk commented Mar 8, 2021

Stats from current PR

Default Server Mode (Decrease detected ✓)
General Overall increase ⚠️
vercel/next.js canary shuding/next.js feat-external-dir Change
buildDuration 12.5s 12.5s -51ms
nodeModulesSize 42.8 MB 42.8 MB ⚠️ +698 B
Page Load Tests Overall decrease ⚠️
vercel/next.js canary shuding/next.js feat-external-dir Change
/ failed reqs 0 0
/ total time (seconds) 2.253 2.427 ⚠️ +0.17
/ avg req/sec 1109.42 1029.97 ⚠️ -79.45
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.501 1.522 ⚠️ +0.02
/error-in-render avg req/sec 1665.04 1642.07 ⚠️ -22.97
Client Bundles (main, webpack, commons)
vercel/next.js canary shuding/next.js feat-external-dir Change
677f882d2ed8..a2e7.js gzip 13.4 kB 13.4 kB
framework.HASH.js gzip 39 kB 39 kB
main-HASH.js gzip 6.65 kB 6.65 kB
webpack-HASH.js gzip 751 B 751 B
Overall change 59.8 kB 59.8 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary shuding/next.js feat-external-dir Change
polyfills-HASH.js gzip 31.3 kB 31.3 kB
Overall change 31.3 kB 31.3 kB
Client Pages
vercel/next.js canary shuding/next.js feat-external-dir Change
_app-2a09aa2..4a98.js gzip 1.28 kB 1.28 kB
_error-8b758..aef6.js gzip 3.46 kB 3.46 kB
amp-e3e9bc99..932c.js gzip 536 B 536 B
hooks-5023ef..3670.js gzip 888 B 888 B
index-3a2b03..c677.js gzip 227 B 227 B
link-177412b..043e.js gzip 1.67 kB 1.67 kB
routerDirect..1a66.js gzip 303 B 303 B
withRouter-9..1b7d.js gzip 302 B 302 B
Overall change 8.66 kB 8.66 kB
Client Build Manifests
vercel/next.js canary shuding/next.js feat-external-dir Change
_buildManifest.js gzip 347 B 347 B
Overall change 347 B 347 B
Rendered Page Sizes
vercel/next.js canary shuding/next.js feat-external-dir Change
index.html gzip 615 B 615 B
link.html gzip 621 B 621 B
withRouter.html gzip 609 B 609 B
Overall change 1.84 kB 1.84 kB

Serverless Mode
General Overall increase ⚠️
vercel/next.js canary shuding/next.js feat-external-dir Change
buildDuration 14.8s 14.9s ⚠️ +125ms
nodeModulesSize 42.8 MB 42.8 MB ⚠️ +698 B
Client Bundles (main, webpack, commons)
vercel/next.js canary shuding/next.js feat-external-dir Change
677f882d2ed8..a2e7.js gzip 13.4 kB 13.4 kB
framework.HASH.js gzip 39 kB 39 kB
main-HASH.js gzip 6.65 kB 6.65 kB
webpack-HASH.js gzip 751 B 751 B
Overall change 59.8 kB 59.8 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary shuding/next.js feat-external-dir Change
polyfills-HASH.js gzip 31.3 kB 31.3 kB
Overall change 31.3 kB 31.3 kB
Client Pages
vercel/next.js canary shuding/next.js feat-external-dir Change
_app-2a09aa2..4a98.js gzip 1.28 kB 1.28 kB
_error-8b758..aef6.js gzip 3.46 kB 3.46 kB
amp-e3e9bc99..932c.js gzip 536 B 536 B
hooks-5023ef..3670.js gzip 888 B 888 B
index-3a2b03..c677.js gzip 227 B 227 B
link-177412b..043e.js gzip 1.67 kB 1.67 kB
routerDirect..1a66.js gzip 303 B 303 B
withRouter-9..1b7d.js gzip 302 B 302 B
Overall change 8.66 kB 8.66 kB
Client Build Manifests
vercel/next.js canary shuding/next.js feat-external-dir Change
_buildManifest.js gzip 347 B 347 B
Overall change 347 B 347 B
Serverless bundles
vercel/next.js canary shuding/next.js feat-external-dir Change
_error.js 1.02 MB 1.02 MB
404.html 2.67 kB 2.67 kB
500.html 2.65 kB 2.65 kB
amp.amp.html 10.5 kB 10.5 kB
amp.html 1.86 kB 1.86 kB
hooks.html 1.92 kB 1.92 kB
index.js 1.02 MB 1.02 MB
link.js 1.08 MB 1.08 MB
routerDirect.js 1.07 MB 1.07 MB
withRouter.js 1.07 MB 1.07 MB
Overall change 5.27 MB 5.27 MB

Webpack 5 Mode (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary shuding/next.js feat-external-dir Change
buildDuration 15.1s 14.2s -951ms
nodeModulesSize 42.8 MB 42.8 MB ⚠️ +698 B
Page Load Tests Overall increase ✓
vercel/next.js canary shuding/next.js feat-external-dir Change
/ failed reqs 0 0
/ total time (seconds) 2.316 2.127 -0.19
/ avg req/sec 1079.57 1175.14 +95.57
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.566 1.631 ⚠️ +0.06
/error-in-render avg req/sec 1596.84 1532.96 ⚠️ -63.88
Client Bundles (main, webpack, commons)
vercel/next.js canary shuding/next.js feat-external-dir Change
597-2bc2376a..203d.js gzip 13.3 kB 13.3 kB
framework.HASH.js gzip 39.3 kB 39.3 kB
main-HASH.js gzip 6.59 kB 6.59 kB
webpack-HASH.js gzip 954 B 954 B
Overall change 60.2 kB 60.2 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary shuding/next.js feat-external-dir Change
polyfills-HASH.js gzip 31.1 kB 31.1 kB
Overall change 31.1 kB 31.1 kB
Client Pages
vercel/next.js canary shuding/next.js feat-external-dir Change
_app-aedc815..1421.js gzip 1.26 kB 1.26 kB
_error-71ec2..1a96.js gzip 3.38 kB 3.38 kB
amp-33a09cb0..6745.js gzip 536 B 536 B
hooks-4e968a..f870.js gzip 902 B 902 B
index-5c6845..f75c.js gzip 230 B 230 B
link-99f0c6c..b84a.js gzip 1.65 kB 1.65 kB
routerDirect..bb56.js gzip 306 B 306 B
withRouter-7..2133.js gzip 302 B 302 B
Overall change 8.57 kB 8.57 kB
Client Build Manifests
vercel/next.js canary shuding/next.js feat-external-dir Change
_buildManifest.js gzip 326 B 326 B
Overall change 326 B 326 B
Rendered Page Sizes
vercel/next.js canary shuding/next.js feat-external-dir Change
index.html gzip 586 B 586 B
link.html gzip 592 B 592 B
withRouter.html gzip 580 B 580 B
Overall change 1.76 kB 1.76 kB

Diffs

Diff for index.html
@@ -43,7 +43,7 @@
         "props": { "pageProps": {} },
         "page": "/",
         "query": {},
-        "buildId": "SIgv2mqzIr7yXeXKV-FtQ",
+        "buildId": "lCLzpbAQhXQzYoP4Bt-_T",
         "isFallback": false,
         "gip": true
       }
@@ -77,11 +77,11 @@
       async=""
     ></script>
     <script
-      src="/_next/static/SIgv2mqzIr7yXeXKV-FtQ/_buildManifest.js"
+      src="/_next/static/lCLzpbAQhXQzYoP4Bt-_T/_buildManifest.js"
       async=""
     ></script>
     <script
-      src="/_next/static/SIgv2mqzIr7yXeXKV-FtQ/_ssgManifest.js"
+      src="/_next/static/lCLzpbAQhXQzYoP4Bt-_T/_ssgManifest.js"
       async=""
     ></script>
   </body>
Diff for link.html
@@ -48,7 +48,7 @@
         "props": { "pageProps": {} },
         "page": "/link",
         "query": {},
-        "buildId": "SIgv2mqzIr7yXeXKV-FtQ",
+        "buildId": "lCLzpbAQhXQzYoP4Bt-_T",
         "isFallback": false,
         "gip": true
       }
@@ -82,11 +82,11 @@
       async=""
     ></script>
     <script
-      src="/_next/static/SIgv2mqzIr7yXeXKV-FtQ/_buildManifest.js"
+      src="/_next/static/lCLzpbAQhXQzYoP4Bt-_T/_buildManifest.js"
       async=""
     ></script>
     <script
-      src="/_next/static/SIgv2mqzIr7yXeXKV-FtQ/_ssgManifest.js"
+      src="/_next/static/lCLzpbAQhXQzYoP4Bt-_T/_ssgManifest.js"
       async=""
     ></script>
   </body>
Diff for withRouter.html
@@ -43,7 +43,7 @@
         "props": { "pageProps": {} },
         "page": "/withRouter",
         "query": {},
-        "buildId": "SIgv2mqzIr7yXeXKV-FtQ",
+        "buildId": "lCLzpbAQhXQzYoP4Bt-_T",
         "isFallback": false,
         "gip": true
       }
@@ -77,11 +77,11 @@
       async=""
     ></script>
     <script
-      src="/_next/static/SIgv2mqzIr7yXeXKV-FtQ/_buildManifest.js"
+      src="/_next/static/lCLzpbAQhXQzYoP4Bt-_T/_buildManifest.js"
       async=""
     ></script>
     <script
-      src="/_next/static/SIgv2mqzIr7yXeXKV-FtQ/_ssgManifest.js"
+      src="/_next/static/lCLzpbAQhXQzYoP4Bt-_T/_ssgManifest.js"
       async=""
     ></script>
   </body>
Commit: 7d13000

@matamatanot
Copy link
Contributor

matamatanot commented Mar 8, 2021

#15569 is another related PR. (Thanks for editing the main comment)

@shuding shuding marked this pull request as ready for review March 11, 2021 10:52
@ijjk
Copy link
Member

ijjk commented Mar 19, 2021

Stats from current PR

Default Server Mode (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary shuding/next.js feat-external-dir Change
buildDuration 11.6s 11.7s ⚠️ +52ms
nodeModulesSize 43.6 MB 43.6 MB ⚠️ +426 B
Page Load Tests Overall increase ✓
vercel/next.js canary shuding/next.js feat-external-dir Change
/ failed reqs 0 0
/ total time (seconds) 1.957 1.95 -0.01
/ avg req/sec 1277.64 1282.23 +4.59
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.196 1.184 -0.01
/error-in-render avg req/sec 2089.98 2110.85 +20.87
Client Bundles (main, webpack, commons)
vercel/next.js canary shuding/next.js feat-external-dir Change
677f882d2ed8..a2e7.js gzip 13.4 kB 13.4 kB
framework.HASH.js gzip 39 kB 39 kB
main-HASH.js gzip 7.14 kB 7.14 kB
webpack-HASH.js gzip 751 B 751 B
Overall change 60.3 kB 60.3 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary shuding/next.js feat-external-dir Change
polyfills-HASH.js gzip 31.3 kB 31.3 kB
Overall change 31.3 kB 31.3 kB
Client Pages
vercel/next.js canary shuding/next.js feat-external-dir Change
_app-fde3324..9dd1.js gzip 1.28 kB 1.28 kB
_error-af59f..582f.js gzip 3.46 kB 3.46 kB
amp-9716187d..0aa8.js gzip 536 B 536 B
hooks-107e90..74c7.js gzip 888 B 888 B
index-ac435c..ecf2.js gzip 227 B 227 B
link-e6cee42..49eb.js gzip 1.64 kB 1.64 kB
routerDirect..dc9d.js gzip 303 B 303 B
withRouter-6..0e02.js gzip 302 B 302 B
Overall change 8.64 kB 8.64 kB
Client Build Manifests
vercel/next.js canary shuding/next.js feat-external-dir Change
_buildManifest.js gzip 346 B 346 B
Overall change 346 B 346 B
Rendered Page Sizes
vercel/next.js canary shuding/next.js feat-external-dir Change
index.html gzip 613 B 613 B
link.html gzip 620 B 620 B
withRouter.html gzip 608 B 608 B
Overall change 1.84 kB 1.84 kB

Serverless Mode
General Overall increase ⚠️
vercel/next.js canary shuding/next.js feat-external-dir Change
buildDuration 13.3s 12.9s -397ms
nodeModulesSize 43.6 MB 43.6 MB ⚠️ +426 B
Client Bundles (main, webpack, commons)
vercel/next.js canary shuding/next.js feat-external-dir Change
677f882d2ed8..a2e7.js gzip 13.4 kB 13.4 kB
framework.HASH.js gzip 39 kB 39 kB
main-HASH.js gzip 7.14 kB 7.14 kB
webpack-HASH.js gzip 751 B 751 B
Overall change 60.3 kB 60.3 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary shuding/next.js feat-external-dir Change
polyfills-HASH.js gzip 31.3 kB 31.3 kB
Overall change 31.3 kB 31.3 kB
Client Pages
vercel/next.js canary shuding/next.js feat-external-dir Change
_app-fde3324..9dd1.js gzip 1.28 kB 1.28 kB
_error-af59f..582f.js gzip 3.46 kB 3.46 kB
amp-9716187d..0aa8.js gzip 536 B 536 B
hooks-107e90..74c7.js gzip 888 B 888 B
index-ac435c..ecf2.js gzip 227 B 227 B
link-e6cee42..49eb.js gzip 1.64 kB 1.64 kB
routerDirect..dc9d.js gzip 303 B 303 B
withRouter-6..0e02.js gzip 302 B 302 B
Overall change 8.64 kB 8.64 kB
Client Build Manifests
vercel/next.js canary shuding/next.js feat-external-dir Change
_buildManifest.js gzip 346 B 346 B
Overall change 346 B 346 B
Serverless bundles
vercel/next.js canary shuding/next.js feat-external-dir Change
_error.js 1.02 MB 1.02 MB
404.html 2.67 kB 2.67 kB
500.html 2.65 kB 2.65 kB
amp.amp.html 10.6 kB 10.6 kB
amp.html 1.86 kB 1.86 kB
hooks.html 1.92 kB 1.92 kB
index.js 1.02 MB 1.02 MB
link.js 1.08 MB 1.08 MB
routerDirect.js 1.07 MB 1.07 MB
withRouter.js 1.07 MB 1.07 MB
Overall change 5.27 MB 5.27 MB

Webpack 5 Mode (Decrease detected ✓)
General Overall increase ⚠️
vercel/next.js canary shuding/next.js feat-external-dir Change
buildDuration 13.4s 13.3s -90ms
nodeModulesSize 43.6 MB 43.6 MB ⚠️ +426 B
Page Load Tests Overall decrease ⚠️
vercel/next.js canary shuding/next.js feat-external-dir Change
/ failed reqs 0 0
/ total time (seconds) 1.972 1.94 -0.03
/ avg req/sec 1267.53 1288.82 +21.29
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.193 1.224 ⚠️ +0.03
/error-in-render avg req/sec 2096.1 2042.04 ⚠️ -54.06
Client Bundles (main, webpack, commons)
vercel/next.js canary shuding/next.js feat-external-dir Change
597-12fee761..569d.js gzip 13.3 kB 13.3 kB
framework.HASH.js gzip 39.3 kB 39.3 kB
main-HASH.js gzip 7.1 kB 7.1 kB
webpack-HASH.js gzip 993 B 993 B
Overall change 60.7 kB 60.7 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary shuding/next.js feat-external-dir Change
polyfills-HASH.js gzip 31.1 kB 31.1 kB
Overall change 31.1 kB 31.1 kB
Client Pages
vercel/next.js canary shuding/next.js feat-external-dir Change
_app-d0eb668..79ef.js gzip 1.28 kB 1.28 kB
_error-d12ff..6063.js gzip 3.4 kB 3.4 kB
amp-127483e4..9cd8.js gzip 560 B 560 B
hooks-75994b..62d3.js gzip 924 B 924 B
index-ac1ee6..819e.js gzip 243 B 243 B
link-1cd4709..71e5.js gzip 1.65 kB 1.65 kB
routerDirect..4d90.js gzip 333 B 333 B
withRouter-0..60b0.js gzip 329 B 329 B
Overall change 8.72 kB 8.72 kB
Client Build Manifests
vercel/next.js canary shuding/next.js feat-external-dir Change
_buildManifest.js gzip 324 B 324 B
Overall change 324 B 324 B
Rendered Page Sizes
vercel/next.js canary shuding/next.js feat-external-dir Change
index.html gzip 586 B 586 B
link.html gzip 593 B 593 B
withRouter.html gzip 581 B 581 B
Overall change 1.76 kB 1.76 kB

Diffs

Diff for index.html
@@ -43,7 +43,7 @@
         "props": { "pageProps": {} },
         "page": "/",
         "query": {},
-        "buildId": "KVt5TVdJwthCWLpNeleV5",
+        "buildId": "SrjrNrNAPNKnNvtyCOrqB",
         "isFallback": false,
         "gip": true
       }
@@ -77,11 +77,11 @@
       async=""
     ></script>
     <script
-      src="/_next/static/KVt5TVdJwthCWLpNeleV5/_buildManifest.js"
+      src="/_next/static/SrjrNrNAPNKnNvtyCOrqB/_buildManifest.js"
       async=""
     ></script>
     <script
-      src="/_next/static/KVt5TVdJwthCWLpNeleV5/_ssgManifest.js"
+      src="/_next/static/SrjrNrNAPNKnNvtyCOrqB/_ssgManifest.js"
       async=""
     ></script>
   </body>
Diff for link.html
@@ -48,7 +48,7 @@
         "props": { "pageProps": {} },
         "page": "/link",
         "query": {},
-        "buildId": "KVt5TVdJwthCWLpNeleV5",
+        "buildId": "SrjrNrNAPNKnNvtyCOrqB",
         "isFallback": false,
         "gip": true
       }
@@ -82,11 +82,11 @@
       async=""
     ></script>
     <script
-      src="/_next/static/KVt5TVdJwthCWLpNeleV5/_buildManifest.js"
+      src="/_next/static/SrjrNrNAPNKnNvtyCOrqB/_buildManifest.js"
       async=""
     ></script>
     <script
-      src="/_next/static/KVt5TVdJwthCWLpNeleV5/_ssgManifest.js"
+      src="/_next/static/SrjrNrNAPNKnNvtyCOrqB/_ssgManifest.js"
       async=""
     ></script>
   </body>
Diff for withRouter.html
@@ -43,7 +43,7 @@
         "props": { "pageProps": {} },
         "page": "/withRouter",
         "query": {},
-        "buildId": "KVt5TVdJwthCWLpNeleV5",
+        "buildId": "SrjrNrNAPNKnNvtyCOrqB",
         "isFallback": false,
         "gip": true
       }
@@ -77,11 +77,11 @@
       async=""
     ></script>
     <script
-      src="/_next/static/KVt5TVdJwthCWLpNeleV5/_buildManifest.js"
+      src="/_next/static/SrjrNrNAPNKnNvtyCOrqB/_buildManifest.js"
       async=""
     ></script>
     <script
-      src="/_next/static/KVt5TVdJwthCWLpNeleV5/_ssgManifest.js"
+      src="/_next/static/SrjrNrNAPNKnNvtyCOrqB/_ssgManifest.js"
       async=""
     ></script>
   </body>
Commit: 83ee858

@ijjk
Copy link
Member

ijjk commented Mar 19, 2021

Stats from current PR

Default Server Mode (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary shuding/next.js feat-external-dir Change
buildDuration 13.3s 12.9s -340ms
nodeModulesSize 43.6 MB 43.6 MB ⚠️ +426 B
Page Load Tests Overall increase ✓
vercel/next.js canary shuding/next.js feat-external-dir Change
/ failed reqs 0 0
/ total time (seconds) 2.31 2.392 ⚠️ +0.08
/ avg req/sec 1082.27 1045.03 ⚠️ -37.24
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.631 1.546 -0.08
/error-in-render avg req/sec 1533.24 1617.34 +84.1
Client Bundles (main, webpack, commons)
vercel/next.js canary shuding/next.js feat-external-dir Change
677f882d2ed8..a2e7.js gzip 13.4 kB 13.4 kB
framework.HASH.js gzip 39 kB 39 kB
main-HASH.js gzip 7.14 kB 7.14 kB
webpack-HASH.js gzip 751 B 751 B
Overall change 60.3 kB 60.3 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary shuding/next.js feat-external-dir Change
polyfills-HASH.js gzip 31.3 kB 31.3 kB
Overall change 31.3 kB 31.3 kB
Client Pages
vercel/next.js canary shuding/next.js feat-external-dir Change
_app-fde3324..9dd1.js gzip 1.28 kB 1.28 kB
_error-af59f..582f.js gzip 3.46 kB 3.46 kB
amp-9716187d..0aa8.js gzip 536 B 536 B
hooks-107e90..74c7.js gzip 888 B 888 B
index-ac435c..ecf2.js gzip 227 B 227 B
link-e6cee42..49eb.js gzip 1.64 kB 1.64 kB
routerDirect..dc9d.js gzip 303 B 303 B
withRouter-6..0e02.js gzip 302 B 302 B
Overall change 8.64 kB 8.64 kB
Client Build Manifests
vercel/next.js canary shuding/next.js feat-external-dir Change
_buildManifest.js gzip 346 B 346 B
Overall change 346 B 346 B
Rendered Page Sizes
vercel/next.js canary shuding/next.js feat-external-dir Change
index.html gzip 613 B 613 B
link.html gzip 620 B 620 B
withRouter.html gzip 608 B 608 B
Overall change 1.84 kB 1.84 kB

Serverless Mode
General Overall increase ⚠️
vercel/next.js canary shuding/next.js feat-external-dir Change
buildDuration 15s 14.6s -333ms
nodeModulesSize 43.6 MB 43.6 MB ⚠️ +426 B
Client Bundles (main, webpack, commons)
vercel/next.js canary shuding/next.js feat-external-dir Change
677f882d2ed8..a2e7.js gzip 13.4 kB 13.4 kB
framework.HASH.js gzip 39 kB 39 kB
main-HASH.js gzip 7.14 kB 7.14 kB
webpack-HASH.js gzip 751 B 751 B
Overall change 60.3 kB 60.3 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary shuding/next.js feat-external-dir Change
polyfills-HASH.js gzip 31.3 kB 31.3 kB
Overall change 31.3 kB 31.3 kB
Client Pages
vercel/next.js canary shuding/next.js feat-external-dir Change
_app-fde3324..9dd1.js gzip 1.28 kB 1.28 kB
_error-af59f..582f.js gzip 3.46 kB 3.46 kB
amp-9716187d..0aa8.js gzip 536 B 536 B
hooks-107e90..74c7.js gzip 888 B 888 B
index-ac435c..ecf2.js gzip 227 B 227 B
link-e6cee42..49eb.js gzip 1.64 kB 1.64 kB
routerDirect..dc9d.js gzip 303 B 303 B
withRouter-6..0e02.js gzip 302 B 302 B
Overall change 8.64 kB 8.64 kB
Client Build Manifests
vercel/next.js canary shuding/next.js feat-external-dir Change
_buildManifest.js gzip 346 B 346 B
Overall change 346 B 346 B
Serverless bundles
vercel/next.js canary shuding/next.js feat-external-dir Change
_error.js 1.02 MB 1.02 MB
404.html 2.67 kB 2.67 kB
500.html 2.65 kB 2.65 kB
amp.amp.html 10.6 kB 10.6 kB
amp.html 1.86 kB 1.86 kB
hooks.html 1.92 kB 1.92 kB
index.js 1.02 MB 1.02 MB
link.js 1.08 MB 1.08 MB
routerDirect.js 1.07 MB 1.07 MB
withRouter.js 1.07 MB 1.07 MB
Overall change 5.27 MB 5.27 MB

Webpack 5 Mode (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary shuding/next.js feat-external-dir Change
buildDuration 15.1s 15.4s ⚠️ +254ms
nodeModulesSize 43.6 MB 43.6 MB ⚠️ +426 B
Page Load Tests Overall increase ✓
vercel/next.js canary shuding/next.js feat-external-dir Change
/ failed reqs 0 0
/ total time (seconds) 2.397 2.333 -0.06
/ avg req/sec 1042.79 1071.46 +28.67
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.628 1.567 -0.06
/error-in-render avg req/sec 1535.19 1594.9 +59.71
Client Bundles (main, webpack, commons)
vercel/next.js canary shuding/next.js feat-external-dir Change
597-12fee761..569d.js gzip 13.3 kB 13.3 kB
framework.HASH.js gzip 39.3 kB 39.3 kB
main-HASH.js gzip 7.1 kB 7.1 kB
webpack-HASH.js gzip 993 B 993 B
Overall change 60.7 kB 60.7 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary shuding/next.js feat-external-dir Change
polyfills-HASH.js gzip 31.1 kB 31.1 kB
Overall change 31.1 kB 31.1 kB
Client Pages
vercel/next.js canary shuding/next.js feat-external-dir Change
_app-d0eb668..79ef.js gzip 1.28 kB 1.28 kB
_error-d12ff..6063.js gzip 3.4 kB 3.4 kB
amp-127483e4..9cd8.js gzip 560 B 560 B
hooks-75994b..62d3.js gzip 924 B 924 B
index-ac1ee6..819e.js gzip 243 B 243 B
link-1cd4709..71e5.js gzip 1.65 kB 1.65 kB
routerDirect..4d90.js gzip 333 B 333 B
withRouter-0..60b0.js gzip 329 B 329 B
Overall change 8.72 kB 8.72 kB
Client Build Manifests
vercel/next.js canary shuding/next.js feat-external-dir Change
_buildManifest.js gzip 324 B 324 B
Overall change 324 B 324 B
Rendered Page Sizes
vercel/next.js canary shuding/next.js feat-external-dir Change
index.html gzip 586 B 586 B
link.html gzip 593 B 593 B
withRouter.html gzip 581 B 581 B
Overall change 1.76 kB 1.76 kB

Diffs

Diff for index.html
@@ -43,7 +43,7 @@
         "props": { "pageProps": {} },
         "page": "/",
         "query": {},
-        "buildId": "ep70cI-5eQShunEETotNJ",
+        "buildId": "2HaXjmfO_d5YlZRJ7LXFv",
         "isFallback": false,
         "gip": true
       }
@@ -77,11 +77,11 @@
       async=""
     ></script>
     <script
-      src="/_next/static/ep70cI-5eQShunEETotNJ/_buildManifest.js"
+      src="/_next/static/2HaXjmfO_d5YlZRJ7LXFv/_buildManifest.js"
       async=""
     ></script>
     <script
-      src="/_next/static/ep70cI-5eQShunEETotNJ/_ssgManifest.js"
+      src="/_next/static/2HaXjmfO_d5YlZRJ7LXFv/_ssgManifest.js"
       async=""
     ></script>
   </body>
Diff for link.html
@@ -48,7 +48,7 @@
         "props": { "pageProps": {} },
         "page": "/link",
         "query": {},
-        "buildId": "ep70cI-5eQShunEETotNJ",
+        "buildId": "2HaXjmfO_d5YlZRJ7LXFv",
         "isFallback": false,
         "gip": true
       }
@@ -82,11 +82,11 @@
       async=""
     ></script>
     <script
-      src="/_next/static/ep70cI-5eQShunEETotNJ/_buildManifest.js"
+      src="/_next/static/2HaXjmfO_d5YlZRJ7LXFv/_buildManifest.js"
       async=""
     ></script>
     <script
-      src="/_next/static/ep70cI-5eQShunEETotNJ/_ssgManifest.js"
+      src="/_next/static/2HaXjmfO_d5YlZRJ7LXFv/_ssgManifest.js"
       async=""
     ></script>
   </body>
Diff for withRouter.html
@@ -43,7 +43,7 @@
         "props": { "pageProps": {} },
         "page": "/withRouter",
         "query": {},
-        "buildId": "ep70cI-5eQShunEETotNJ",
+        "buildId": "2HaXjmfO_d5YlZRJ7LXFv",
         "isFallback": false,
         "gip": true
       }
@@ -77,11 +77,11 @@
       async=""
     ></script>
     <script
-      src="/_next/static/ep70cI-5eQShunEETotNJ/_buildManifest.js"
+      src="/_next/static/2HaXjmfO_d5YlZRJ7LXFv/_buildManifest.js"
       async=""
     ></script>
     <script
-      src="/_next/static/ep70cI-5eQShunEETotNJ/_ssgManifest.js"
+      src="/_next/static/2HaXjmfO_d5YlZRJ7LXFv/_ssgManifest.js"
       async=""
     ></script>
   </body>
Commit: e4fb242

@ijjk
Copy link
Member

ijjk commented Mar 19, 2021

Stats from current PR

Default Server Mode (Decrease detected ✓)
General Overall increase ⚠️
vercel/next.js canary shuding/next.js feat-external-dir Change
buildDuration 13.1s 13.1s ⚠️ +17ms
nodeModulesSize 43.6 MB 43.6 MB ⚠️ +426 B
Page Load Tests Overall decrease ⚠️
vercel/next.js canary shuding/next.js feat-external-dir Change
/ failed reqs 0 0
/ total time (seconds) 2.299 2.387 ⚠️ +0.09
/ avg req/sec 1087.27 1047.22 ⚠️ -40.05
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.578 1.599 ⚠️ +0.02
/error-in-render avg req/sec 1584.59 1563.62 ⚠️ -20.97
Client Bundles (main, webpack, commons)
vercel/next.js canary shuding/next.js feat-external-dir Change
677f882d2ed8..a2e7.js gzip 13.4 kB 13.4 kB
framework.HASH.js gzip 39 kB 39 kB
main-HASH.js gzip 7.14 kB 7.14 kB
webpack-HASH.js gzip 751 B 751 B
Overall change 60.3 kB 60.3 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary shuding/next.js feat-external-dir Change
polyfills-HASH.js gzip 31.3 kB 31.3 kB
Overall change 31.3 kB 31.3 kB
Client Pages
vercel/next.js canary shuding/next.js feat-external-dir Change
_app-fde3324..9dd1.js gzip 1.28 kB 1.28 kB
_error-af59f..582f.js gzip 3.46 kB 3.46 kB
amp-9716187d..0aa8.js gzip 536 B 536 B
hooks-107e90..74c7.js gzip 888 B 888 B
index-ac435c..ecf2.js gzip 227 B 227 B
link-e6cee42..49eb.js gzip 1.64 kB 1.64 kB
routerDirect..dc9d.js gzip 303 B 303 B
withRouter-6..0e02.js gzip 302 B 302 B
Overall change 8.64 kB 8.64 kB
Client Build Manifests
vercel/next.js canary shuding/next.js feat-external-dir Change
_buildManifest.js gzip 346 B 346 B
Overall change 346 B 346 B
Rendered Page Sizes
vercel/next.js canary shuding/next.js feat-external-dir Change
index.html gzip 613 B 613 B
link.html gzip 622 B 622 B
withRouter.html gzip 609 B 609 B
Overall change 1.84 kB 1.84 kB

Serverless Mode
General Overall increase ⚠️
vercel/next.js canary shuding/next.js feat-external-dir Change
buildDuration 14.9s 14.7s -144ms
nodeModulesSize 43.6 MB 43.6 MB ⚠️ +426 B
Client Bundles (main, webpack, commons)
vercel/next.js canary shuding/next.js feat-external-dir Change
677f882d2ed8..a2e7.js gzip 13.4 kB 13.4 kB
framework.HASH.js gzip 39 kB 39 kB
main-HASH.js gzip 7.14 kB 7.14 kB
webpack-HASH.js gzip 751 B 751 B
Overall change 60.3 kB 60.3 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary shuding/next.js feat-external-dir Change
polyfills-HASH.js gzip 31.3 kB 31.3 kB
Overall change 31.3 kB 31.3 kB
Client Pages
vercel/next.js canary shuding/next.js feat-external-dir Change
_app-fde3324..9dd1.js gzip 1.28 kB 1.28 kB
_error-af59f..582f.js gzip 3.46 kB 3.46 kB
amp-9716187d..0aa8.js gzip 536 B 536 B
hooks-107e90..74c7.js gzip 888 B 888 B
index-ac435c..ecf2.js gzip 227 B 227 B
link-e6cee42..49eb.js gzip 1.64 kB 1.64 kB
routerDirect..dc9d.js gzip 303 B 303 B
withRouter-6..0e02.js gzip 302 B 302 B
Overall change 8.64 kB 8.64 kB
Client Build Manifests
vercel/next.js canary shuding/next.js feat-external-dir Change
_buildManifest.js gzip 346 B 346 B
Overall change 346 B 346 B
Serverless bundles
vercel/next.js canary shuding/next.js feat-external-dir Change
_error.js 1.02 MB 1.02 MB
404.html 2.67 kB 2.67 kB
500.html 2.65 kB 2.65 kB
amp.amp.html 10.6 kB 10.6 kB
amp.html 1.86 kB 1.86 kB
hooks.html 1.92 kB 1.92 kB
index.js 1.02 MB 1.02 MB
link.js 1.08 MB 1.08 MB
routerDirect.js 1.07 MB 1.07 MB
withRouter.js 1.07 MB 1.07 MB
Overall change 5.27 MB 5.27 MB

Webpack 5 Mode (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary shuding/next.js feat-external-dir Change
buildDuration 15.3s 15.4s ⚠️ +69ms
nodeModulesSize 43.6 MB 43.6 MB ⚠️ +426 B
Page Load Tests Overall increase ✓
vercel/next.js canary shuding/next.js feat-external-dir Change
/ failed reqs 0 0
/ total time (seconds) 2.254 2.226 -0.03
/ avg req/sec 1109.28 1123.18 +13.9
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.576 1.557 -0.02
/error-in-render avg req/sec 1586.05 1605.68 +19.63
Client Bundles (main, webpack, commons)
vercel/next.js canary shuding/next.js feat-external-dir Change
597-12fee761..569d.js gzip 13.3 kB 13.3 kB
framework.HASH.js gzip 39.3 kB 39.3 kB
main-HASH.js gzip 7.1 kB 7.1 kB
webpack-HASH.js gzip 993 B 993 B
Overall change 60.7 kB 60.7 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary shuding/next.js feat-external-dir Change
polyfills-HASH.js gzip 31.1 kB 31.1 kB
Overall change 31.1 kB 31.1 kB
Client Pages
vercel/next.js canary shuding/next.js feat-external-dir Change
_app-d0eb668..79ef.js gzip 1.28 kB 1.28 kB
_error-d12ff..6063.js gzip 3.4 kB 3.4 kB
amp-127483e4..9cd8.js gzip 560 B 560 B
hooks-75994b..62d3.js gzip 924 B 924 B
index-ac1ee6..819e.js gzip 243 B 243 B
link-1cd4709..71e5.js gzip 1.65 kB 1.65 kB
routerDirect..4d90.js gzip 333 B 333 B
withRouter-0..60b0.js gzip 329 B 329 B
Overall change 8.72 kB 8.72 kB
Client Build Manifests
vercel/next.js canary shuding/next.js feat-external-dir Change
_buildManifest.js gzip 324 B 324 B
Overall change 324 B 324 B
Rendered Page Sizes
vercel/next.js canary shuding/next.js feat-external-dir Change
index.html gzip 586 B 586 B
link.html gzip 593 B 593 B
withRouter.html gzip 580 B 580 B
Overall change 1.76 kB 1.76 kB

Diffs

Diff for index.html
@@ -43,7 +43,7 @@
         "props": { "pageProps": {} },
         "page": "/",
         "query": {},
-        "buildId": "l7ikcdoqFOu0IRpvirqf6",
+        "buildId": "4eGc8NYWHKWXSOVdidRKG",
         "isFallback": false,
         "gip": true
       }
@@ -77,11 +77,11 @@
       async=""
     ></script>
     <script
-      src="/_next/static/l7ikcdoqFOu0IRpvirqf6/_buildManifest.js"
+      src="/_next/static/4eGc8NYWHKWXSOVdidRKG/_buildManifest.js"
       async=""
     ></script>
     <script
-      src="/_next/static/l7ikcdoqFOu0IRpvirqf6/_ssgManifest.js"
+      src="/_next/static/4eGc8NYWHKWXSOVdidRKG/_ssgManifest.js"
       async=""
     ></script>
   </body>
Diff for link.html
@@ -48,7 +48,7 @@
         "props": { "pageProps": {} },
         "page": "/link",
         "query": {},
-        "buildId": "l7ikcdoqFOu0IRpvirqf6",
+        "buildId": "4eGc8NYWHKWXSOVdidRKG",
         "isFallback": false,
         "gip": true
       }
@@ -82,11 +82,11 @@
       async=""
     ></script>
     <script
-      src="/_next/static/l7ikcdoqFOu0IRpvirqf6/_buildManifest.js"
+      src="/_next/static/4eGc8NYWHKWXSOVdidRKG/_buildManifest.js"
       async=""
     ></script>
     <script
-      src="/_next/static/l7ikcdoqFOu0IRpvirqf6/_ssgManifest.js"
+      src="/_next/static/4eGc8NYWHKWXSOVdidRKG/_ssgManifest.js"
       async=""
     ></script>
   </body>
Diff for withRouter.html
@@ -43,7 +43,7 @@
         "props": { "pageProps": {} },
         "page": "/withRouter",
         "query": {},
-        "buildId": "l7ikcdoqFOu0IRpvirqf6",
+        "buildId": "4eGc8NYWHKWXSOVdidRKG",
         "isFallback": false,
         "gip": true
       }
@@ -77,11 +77,11 @@
       async=""
     ></script>
     <script
-      src="/_next/static/l7ikcdoqFOu0IRpvirqf6/_buildManifest.js"
+      src="/_next/static/4eGc8NYWHKWXSOVdidRKG/_buildManifest.js"
       async=""
     ></script>
     <script
-      src="/_next/static/l7ikcdoqFOu0IRpvirqf6/_ssgManifest.js"
+      src="/_next/static/4eGc8NYWHKWXSOVdidRKG/_ssgManifest.js"
       async=""
     ></script>
   </body>
Commit: 3064eb3

@kodiakhq kodiakhq bot merged commit 32c435d into vercel:canary Mar 19, 2021
@shuding shuding deleted the feat-external-dir branch March 19, 2021 17:17
@cliffordfajardo
Copy link

cliffordfajardo commented Apr 10, 2021

This is awesome, I know this is experimental 😅 . Wanted to note that this worked wonderfully for me out of the box with a nextjs app inside a mono repo that looked like this:

mobile/
shared/
web-app/
   |_next.config.js  (was able to import modules from /shared)

@Izhaki
Copy link

Izhaki commented Apr 16, 2021

Although already merged. A few comments:

Should be aliases based?

The code in this PR:

          ...(config.experimental.externalDir
            ? // Allowing importing TS/TSX files from outside of the root dir.
              {}
            : { include: [dir, ...babelIncludeRegexes] }),

NextJS already has a built-in support for aliases. I think rather than allowing anything to be transpiled, this feature should simply add the aliases directories.

CSS and SCSS too please

We have a mono-repo with siblings app and core and we import in app a component from core that imports a .scss file.

next-transpile-modules didn't work for us (not even latests of yesterday), so we had to modify it's own (very hacky) code to get this to work.

See how
/**
 * Based on https://github.com/martpie/next-transpile-modules/blob/a37eeaeea882d28c8bbe6d0b7d38aa7982efd013/src/next-transpile-modules.js
 */

/**
 * Check if two regexes are equal
 * Stolen from https://stackoverflow.com/questions/10776600/testing-for-equality-of-regular-expressions
 *
 * @param {RegExp} x
 * @param {RegExp} y
 * @returns {boolean}
 */
const regexEqual = (x, y) => {
  return (
    x instanceof RegExp &&
    y instanceof RegExp &&
    x.source === y.source &&
    x.global === y.global &&
    x.ignoreCase === y.ignoreCase &&
    x.multiline === y.multiline
  );
};

const createWebpackMatcher = (aliases = {}) => (filePath) =>
  Object.values(aliases).some((aliasDestination) => filePath.startsWith(aliasDestination));

function enableAliasesCompilationForStyles(config, aliases) {
  const nextCssLoaders = config.module.rules.find((rule) => typeof rule.oneOf === 'object');

  if (nextCssLoaders) {
    const matcher = createWebpackMatcher(aliases);

    const nextCssLoader = nextCssLoaders.oneOf.find(
      (rule) => rule.sideEffects === false && regexEqual(rule.test, /\.module\.css$/)
    );

    const nextSassLoader = nextCssLoaders.oneOf.find(
      (rule) => rule.sideEffects === false && regexEqual(rule.test, /\.module\.(scss|sass)$/)
    );

    if (nextCssLoader) {
      nextCssLoader.issuer.or = nextCssLoader.issuer.and
        ? nextCssLoader.issuer.and.concat(matcher)
        : matcher;
      delete nextCssLoader.issuer.not;
      delete nextCssLoader.issuer.and;
    } else {
      // eslint-disable-next-line no-console
      console.warn('withAliases - could not find default CSS rule, CSS imports may not work');
    }

    if (nextSassLoader) {
      nextSassLoader.issuer.or = nextSassLoader.issuer.and
        ? nextSassLoader.issuer.and.concat(matcher)
        : matcher;
      delete nextSassLoader.issuer.not;
      delete nextSassLoader.issuer.and;
    } else {
      // eslint-disable-next-line no-console
      console.warn('withAliases - could not find default SASS rule, SASS imports may not work');
    }
  }
}

function addAliasesToWebpack(config, aliases) {
  config.resolve.alias = {
    ...config.resolve.alias,
    ...aliases,
  };
}

const withAliasesInitializer = (aliases) => {
  const withAliases = (nextConfig = {}) => {
    return {
      ...nextConfig,
      webpack(config, options) {
        addAliasesToWebpack(config, aliases);
        enableAliasesCompilationForStyles(config, aliases);

        // Overload the Webpack config if it was already overloaded
        if (typeof nextConfig.webpack === 'function') {
          return nextConfig.webpack(config, options);
        }

        return config;
      },
    };
  };

  return withAliases;
};

module.exports = withAliasesInitializer;

@shuding @timneutkens Gonna leave discussion here before raising an issue.

flybayer pushed a commit to blitz-js/next.js that referenced this pull request Apr 29, 2021
…of the root directory (vercel#22867)

This PR attempts to provide an option to allow importing TS/TSX from outside of the current Next.js project root directory. Although this goes against the design decision that no source code should be imported from outside of root and [might bring tons of issues](vercel#19928 (comment)), it will still be helpful in some monorepo use cases.

This PR assumes that the external files are following the same language syntax rules and under the same tooling versions as the source code inside your project root. And it's also not allowed to enable the `baseUrl` feature in the external directory (as the project should only have 1 import base URL).

X-ref: vercel#9474, vercel#15569, vercel#19928, vercel#20374.
@schickling
Copy link
Contributor

@timneutkens @shuding does this also work for ESM JS files/packages (i.e. not TS files) in node_modules? (e.g. newer package releases by @sindresorhus which are mostly ESM-only)

@timneutkens
Copy link
Member

@schickling this only supports .ts, otherwise all JS in node_modules would have to be parsed/compiled which would lead to significantly slower build/dev times.

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

7 participants