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

improves baseUrl resolution in typescript monorepos #13542

Merged

Conversation

jeantil
Copy link
Contributor

@jeantil jeantil commented May 29, 2020

Typescript configuration can inherit from files above cwd in the
filesystem. If a baseUrl was declared in such a file, it would not be
picked up by the webpack config. This would force users to use the
next-transpile-module and duplicate configuration with unintuitive path
relations (see #13197 for a detailed analysis)

If baseUrl is resolved it should be used instead of dir as the root
include for babel-resolve-loader.

An even nicer DX would auto detect the presence of a paths section in
the typescript config and automatically include
tsconfig-paths-webpack-plugin

fixes #13197
fixes #13616
fixes partially #9474

jeantil added a commit to jeantil/next-9-ts-aliases-workspaces that referenced this pull request May 29, 2020
if vercel/next.js#13542 is merged, most of the
yarn workspace + typescript config will be picked up automatically,
removing the need for next-transpile-modules
@jeantil
Copy link
Contributor Author

jeantil commented May 29, 2020

Without this PR, if resolvedBaseUrl is above dir in the filesystem, files in there will not be automatically picked up by next-babel-loader which forces endusers to configure next-transpile-module manually.
Depending on the setup this may not be trivial as it is not obvious what the actual resolved path will be.
you can see an example repo config and how to configure it without this at jeantil/next-9-ts-aliases-workspaces@ad0b342 and how this commit simplifies it in jeantil/next-9-ts-aliases-workspaces@ed7a52a

Copy link
Member

@timneutkens timneutkens left a comment

Choose a reason for hiding this comment

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

Looks great! This will also support extends. Can you add tests to test/integration. I'd probably copy typescript-paths into a new directory as this is slightly different and needs nesting of folders

@jeantil jeantil force-pushed the fix-monorepo-ts-baseUrl-resolution branch 2 times, most recently from cee85ce to ca4ff81 Compare May 29, 2020 15:24
@jeantil
Copy link
Contributor Author

jeantil commented May 29, 2020

@timneutkens I have added the integration test under test/integration/typescript-workspaces-paths/ and rebased on canary

@jeantil jeantil requested a review from timneutkens May 29, 2020 15:26
packages/next/build/webpack-config.ts Outdated Show resolved Hide resolved
packages/next/build/webpack-config.ts Outdated Show resolved Hide resolved
Copy link
Member

@Timer Timer left a comment

Choose a reason for hiding this comment

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

This only adds support for it in tsconfig.json, right? What about jsconfig.json? 🙏

@jeantil
Copy link
Contributor Author

jeantil commented May 30, 2020

This only adds support for it in tsconfig.json, right? What about jsconfig.json?

I have looked around a bit but I have failed to find a source or a even an example showing that jsconfig.json supports the extends clause ... without the extends clause there is no need for the additional path processing done by the typescript compiler.

I was also unable to identify the reference implementation to process jsconfig.json. Should I also process it with tsc ?

Note that this change will support jsconfig.json which set a baseUrl to a parent of dir (which was not the case before this change)

@jeantil jeantil force-pushed the fix-monorepo-ts-baseUrl-resolution branch from ca4ff81 to 8cc91ec Compare May 30, 2020 09:15
jeantil added a commit to jeantil/next-9-ts-aliases-workspaces that referenced this pull request May 30, 2020
if vercel/next.js#13542 is merged, most of the
yarn workspace + typescript config will be picked up automatically,
removing the need for next-transpile-modules
@timneutkens
Copy link
Member

jsconfig.json is fine as-is 👍 It doesn't support extends afaik

@jeantil
Copy link
Contributor Author

jeantil commented Jun 2, 2020

I think I have addressed all the requested changes but I'm not used to github's review flow so I'm not sure if I should do something more. Please let me know if there is more I can do about this PR.

@ijjk
Copy link
Member

ijjk commented Jun 2, 2020

Stats from current PR

Default Server Mode (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
buildDuration 12.6s 12.8s ⚠️ +195ms
nodeModulesSize 65.3 MB 65.3 MB ⚠️ +889 B
Page Load Tests Overall increase ✓
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
/ failed reqs 0 0
/ total time (seconds) 2.23 2.271 ⚠️ +0.04
/ avg req/sec 1121.32 1100.92 -20.4
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.409 1.365 -0.04
/error-in-render avg req/sec 1774.09 1831.94 ⚠️ +57.85
Client Bundles (main, webpack, commons)
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
main-HASH.js gzip 6.59 kB 6.59 kB
webpack-HASH.js gzip 746 B 746 B
de003c3a9d30..6c2a.js gzip 10.5 kB 10.5 kB
framework.HASH.js gzip 39.1 kB 39.1 kB
Overall change 57 kB 57 kB
Client Bundles (main, webpack, commons) Modern
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
main-HASH.module.js gzip 5.67 kB 5.67 kB
webpack-HASH..dule.js gzip 746 B 746 B
de003c3a9d30..dule.js gzip 6.93 kB 6.93 kB
framework.HA..dule.js gzip 39.1 kB 39.1 kB
Overall change 52.5 kB 52.5 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
polyfills-HASH.js gzip 26.3 kB 26.3 kB
Overall change 26.3 kB 26.3 kB
Client Pages
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
_app.js gzip 1.26 kB 1.26 kB
_error.js gzip 3.25 kB 3.25 kB
hooks.js gzip 881 B 881 B
index.js gzip 222 B 222 B
link.js gzip 2.05 kB 2.05 kB
routerDirect.js gzip 279 B 279 B
withRouter.js gzip 278 B 278 B
Overall change 8.21 kB 8.21 kB
Client Pages Modern
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
_app.module.js gzip 604 B 604 B
_error.module.js gzip 2.04 kB 2.04 kB
hooks.module.js gzip 383 B 383 B
index.module.js gzip 223 B 223 B
link.module.js gzip 1.51 kB 1.51 kB
routerDirect..dule.js gzip 281 B 281 B
withRouter.m..dule.js gzip 278 B 278 B
Overall change 5.32 kB 5.32 kB
Client Build Manifests
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
_buildManifest.js gzip 61 B 61 B
_buildManife..dule.js gzip 61 B 61 B
Overall change 122 B 122 B
Rendered Page Sizes
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
index.html gzip 926 B 926 B
link.html gzip 935 B 935 B
withRouter.html gzip 924 B 924 B
Overall change 2.79 kB 2.79 kB

Serverless Mode
General Overall increase ⚠️
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
buildDuration 13.7s 13.4s -241ms
nodeModulesSize 65.3 MB 65.3 MB ⚠️ +889 B
Client Bundles (main, webpack, commons)
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
main-HASH.js gzip 6.59 kB 6.59 kB
webpack-HASH.js gzip 746 B 746 B
de003c3a9d30..6c2a.js gzip 10.5 kB 10.5 kB
framework.HASH.js gzip 39.1 kB 39.1 kB
Overall change 57 kB 57 kB
Client Bundles (main, webpack, commons) Modern
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
main-HASH.module.js gzip 5.67 kB 5.67 kB
webpack-HASH..dule.js gzip 746 B 746 B
de003c3a9d30..dule.js gzip 6.93 kB 6.93 kB
framework.HA..dule.js gzip 39.1 kB 39.1 kB
Overall change 52.5 kB 52.5 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
polyfills-HASH.js gzip 26.3 kB 26.3 kB
Overall change 26.3 kB 26.3 kB
Client Pages
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
_app.js gzip 1.26 kB 1.26 kB
_error.js gzip 3.25 kB 3.25 kB
hooks.js gzip 881 B 881 B
index.js gzip 222 B 222 B
link.js gzip 2.05 kB 2.05 kB
routerDirect.js gzip 279 B 279 B
withRouter.js gzip 278 B 278 B
Overall change 8.21 kB 8.21 kB
Client Pages Modern
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
_app.module.js gzip 604 B 604 B
_error.module.js gzip 2.04 kB 2.04 kB
hooks.module.js gzip 383 B 383 B
index.module.js gzip 223 B 223 B
link.module.js gzip 1.51 kB 1.51 kB
routerDirect..dule.js gzip 281 B 281 B
withRouter.m..dule.js gzip 278 B 278 B
Overall change 5.32 kB 5.32 kB
Client Build Manifests
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
_buildManifest.js gzip 61 B 61 B
_buildManife..dule.js gzip 61 B 61 B
Overall change 122 B 122 B
Serverless bundles
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
_error.js 878 kB 878 kB
404.html 4.18 kB 4.18 kB
hooks.html 3.81 kB 3.81 kB
index.js 879 kB 879 kB
link.js 916 kB 916 kB
routerDirect.js 909 kB 909 kB
withRouter.js 909 kB 909 kB
Overall change 4.5 MB 4.5 MB

@jeantil jeantil force-pushed the fix-monorepo-ts-baseUrl-resolution branch from 9280efe to 7d6713d Compare June 3, 2020 09:13
@ijjk
Copy link
Member

ijjk commented Jun 3, 2020

Stats from current PR

Default Server Mode (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
buildDuration 14s 14.1s ⚠️ +27ms
nodeModulesSize 66 MB 66 MB ⚠️ +912 B
Page Load Tests Overall increase ✓
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
/ failed reqs 0 0
/ total time (seconds) 2.485 2.542 ⚠️ +0.06
/ avg req/sec 1006.2 983.4 -22.8
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.743 1.684 -0.06
/error-in-render avg req/sec 1434.26 1484.79 ⚠️ +50.53
Client Bundles (main, webpack, commons)
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
main-HASH.js gzip 6.59 kB 6.59 kB
webpack-HASH.js gzip 746 B 746 B
de003c3a9d30..6c2a.js gzip 10.5 kB 10.5 kB
framework.HASH.js gzip 39.1 kB 39.1 kB
Overall change 57 kB 57 kB
Client Bundles (main, webpack, commons) Modern
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
main-HASH.module.js gzip 5.67 kB 5.67 kB
webpack-HASH..dule.js gzip 746 B 746 B
de003c3a9d30..dule.js gzip 6.93 kB 6.93 kB
framework.HA..dule.js gzip 39.1 kB 39.1 kB
Overall change 52.5 kB 52.5 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
polyfills-HASH.js gzip 26.3 kB 26.3 kB
Overall change 26.3 kB 26.3 kB
Client Pages
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
_app.js gzip 1.26 kB 1.26 kB
_error.js gzip 3.25 kB 3.25 kB
hooks.js gzip 881 B 881 B
index.js gzip 222 B 222 B
link.js gzip 2.05 kB 2.05 kB
routerDirect.js gzip 279 B 279 B
withRouter.js gzip 278 B 278 B
Overall change 8.21 kB 8.21 kB
Client Pages Modern
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
_app.module.js gzip 604 B 604 B
_error.module.js gzip 2.04 kB 2.04 kB
hooks.module.js gzip 383 B 383 B
index.module.js gzip 223 B 223 B
link.module.js gzip 1.51 kB 1.51 kB
routerDirect..dule.js gzip 281 B 281 B
withRouter.m..dule.js gzip 278 B 278 B
Overall change 5.32 kB 5.32 kB
Client Build Manifests
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
_buildManifest.js gzip 61 B 61 B
_buildManife..dule.js gzip 61 B 61 B
Overall change 122 B 122 B
Rendered Page Sizes
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
index.html gzip 924 B 924 B
link.html gzip 934 B 934 B
withRouter.html gzip 922 B 922 B
Overall change 2.78 kB 2.78 kB

Serverless Mode
General Overall increase ⚠️
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
buildDuration 15.3s 15.4s ⚠️ +114ms
nodeModulesSize 66 MB 66 MB ⚠️ +912 B
Client Bundles (main, webpack, commons)
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
main-HASH.js gzip 6.59 kB 6.59 kB
webpack-HASH.js gzip 746 B 746 B
de003c3a9d30..6c2a.js gzip 10.5 kB 10.5 kB
framework.HASH.js gzip 39.1 kB 39.1 kB
Overall change 57 kB 57 kB
Client Bundles (main, webpack, commons) Modern
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
main-HASH.module.js gzip 5.67 kB 5.67 kB
webpack-HASH..dule.js gzip 746 B 746 B
de003c3a9d30..dule.js gzip 6.93 kB 6.93 kB
framework.HA..dule.js gzip 39.1 kB 39.1 kB
Overall change 52.5 kB 52.5 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
polyfills-HASH.js gzip 26.3 kB 26.3 kB
Overall change 26.3 kB 26.3 kB
Client Pages
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
_app.js gzip 1.26 kB 1.26 kB
_error.js gzip 3.25 kB 3.25 kB
hooks.js gzip 881 B 881 B
index.js gzip 222 B 222 B
link.js gzip 2.05 kB 2.05 kB
routerDirect.js gzip 279 B 279 B
withRouter.js gzip 278 B 278 B
Overall change 8.21 kB 8.21 kB
Client Pages Modern
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
_app.module.js gzip 604 B 604 B
_error.module.js gzip 2.04 kB 2.04 kB
hooks.module.js gzip 383 B 383 B
index.module.js gzip 223 B 223 B
link.module.js gzip 1.51 kB 1.51 kB
routerDirect..dule.js gzip 281 B 281 B
withRouter.m..dule.js gzip 278 B 278 B
Overall change 5.32 kB 5.32 kB
Client Build Manifests
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
_buildManifest.js gzip 61 B 61 B
_buildManife..dule.js gzip 61 B 61 B
Overall change 122 B 122 B
Serverless bundles
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
_error.js 878 kB 878 kB
404.html 4.18 kB 4.18 kB
hooks.html 3.81 kB 3.81 kB
index.js 879 kB 879 kB
link.js 916 kB 916 kB
routerDirect.js 909 kB 909 kB
withRouter.js 909 kB 909 kB
Overall change 4.5 MB 4.5 MB

@jeantil
Copy link
Contributor Author

jeantil commented Jun 8, 2020

hello @Timer, @timneutkens, I think I have addressed the requested changes, I have rebased against the latest canary. Feel free to ping me if there are any more concerns about this.

thanks

@jeantil jeantil force-pushed the fix-monorepo-ts-baseUrl-resolution branch from 7d6713d to d5500e5 Compare June 8, 2020 09:25
@ijjk ijjk added the type: next label Jun 8, 2020
@jeantil jeantil force-pushed the fix-monorepo-ts-baseUrl-resolution branch 2 times, most recently from 04e364a to 194c75b Compare July 17, 2020 10:46
@desmap
Copy link

desmap commented Jul 18, 2020

fwiw, I'd be already happy to just have extends working to get all of the basic config out of the monorepo's packages' single tsconfigs. Even if stuff like baseUrl is still overwritten by Next, just having extends would be already nice.

@jeantil jeantil force-pushed the fix-monorepo-ts-baseUrl-resolution branch from 194c75b to 6e199f9 Compare July 20, 2020 13:10
@ijjk
Copy link
Member

ijjk commented Jul 20, 2020

Stats from current PR

Default Server Mode (Decrease detected ✓)
General Overall increase ⚠️
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
buildDuration 12.9s 12.7s -188ms
nodeModulesSize 66.5 MB 66.5 MB ⚠️ +688 B
Page Load Tests Overall decrease ⚠️
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
/ failed reqs 0 0
/ total time (seconds) 2.051 2.04 -0.01
/ avg req/sec 1218.71 1225.67 +6.96
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.256 1.269 ⚠️ +0.01
/error-in-render avg req/sec 1990.54 1970.61 ⚠️ -19.93
Client Bundles (main, webpack, commons)
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
677f882d2ed8..db49.js gzip 9.7 kB 9.7 kB
framework.HASH.js gzip 39.1 kB 39.1 kB
main-35b59ab..f28f.js gzip 6.72 kB 6.72 kB
polyfills-05..1236.js gzip 30.8 kB 30.8 kB
webpack-488d..c0e7.js gzip 751 B 751 B
Overall change 87.1 kB 87.1 kB
Client Bundles (main, webpack, commons) Modern
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
677f882d2ed8..dule.js gzip 6.1 kB 6.1 kB
framework.HA..dule.js gzip 39.1 kB 39.1 kB
main-0e6fc45..dule.js gzip 5.79 kB 5.79 kB
polyfills-05..dule.js gzip 30.8 kB 30.8 kB
webpack-4f62..dule.js gzip 751 B 751 B
Overall change 82.6 kB 82.6 kB
Client Pages
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
_app-8f5f611..1f7b.js gzip 1.28 kB 1.28 kB
_error-8e69b..8695.js gzip 3.41 kB 3.41 kB
hooks-f7f3d0..7465.js gzip 887 B 887 B
index-08fb3f..c0e9.js gzip 227 B 227 B
link-ddd176e..5566.js gzip 1.29 kB 1.29 kB
routerDirect..8aa1.js gzip 284 B 284 B
withRouter-f..e777.js gzip 284 B 284 B
Overall change 7.66 kB 7.66 kB
Client Pages Modern
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
_app-669dbe5..dule.js gzip 626 B 626 B
_error-663e6..dule.js gzip 2.24 kB 2.24 kB
hooks-805c40..dule.js gzip 387 B 387 B
index-6ba5a4..dule.js gzip 226 B 226 B
link-69bc264..dule.js gzip 1.25 kB 1.25 kB
routerDirect..dule.js gzip 284 B 284 B
withRouter-d..dule.js gzip 282 B 282 B
Overall change 5.29 kB 5.29 kB
Client Build Manifests
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
_buildManifest.js gzip 275 B 275 B
_buildManife..dule.js gzip 281 B 281 B
Overall change 556 B 556 B
Rendered Page Sizes
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
index.html gzip 948 B 948 B
link.html gzip 955 B 955 B
withRouter.html gzip 941 B 941 B
Overall change 2.84 kB 2.84 kB

Serverless Mode
General Overall increase ⚠️
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
buildDuration 14.5s 13.6s -914ms
nodeModulesSize 66.5 MB 66.5 MB ⚠️ +688 B
Client Bundles (main, webpack, commons)
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
677f882d2ed8..db49.js gzip 9.7 kB 9.7 kB
framework.HASH.js gzip 39.1 kB 39.1 kB
main-35b59ab..f28f.js gzip 6.72 kB 6.72 kB
polyfills-05..1236.js gzip 30.8 kB 30.8 kB
webpack-488d..c0e7.js gzip 751 B 751 B
Overall change 87.1 kB 87.1 kB
Client Bundles (main, webpack, commons) Modern
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
677f882d2ed8..dule.js gzip 6.1 kB 6.1 kB
framework.HA..dule.js gzip 39.1 kB 39.1 kB
main-0e6fc45..dule.js gzip 5.79 kB 5.79 kB
polyfills-05..dule.js gzip 30.8 kB 30.8 kB
webpack-4f62..dule.js gzip 751 B 751 B
Overall change 82.6 kB 82.6 kB
Client Pages
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
_app-8f5f611..1f7b.js gzip 1.28 kB 1.28 kB
_error-8e69b..8695.js gzip 3.41 kB 3.41 kB
hooks-f7f3d0..7465.js gzip 887 B 887 B
index-08fb3f..c0e9.js gzip 227 B 227 B
link-ddd176e..5566.js gzip 1.29 kB 1.29 kB
routerDirect..8aa1.js gzip 284 B 284 B
withRouter-f..e777.js gzip 284 B 284 B
Overall change 7.66 kB 7.66 kB
Client Pages Modern
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
_app-669dbe5..dule.js gzip 626 B 626 B
_error-663e6..dule.js gzip 2.24 kB 2.24 kB
hooks-805c40..dule.js gzip 387 B 387 B
index-6ba5a4..dule.js gzip 226 B 226 B
link-69bc264..dule.js gzip 1.25 kB 1.25 kB
routerDirect..dule.js gzip 284 B 284 B
withRouter-d..dule.js gzip 282 B 282 B
Overall change 5.29 kB 5.29 kB
Client Build Manifests
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
_buildManifest.js gzip 275 B 275 B
_buildManife..dule.js gzip 281 B 281 B
Overall change 556 B 556 B
Serverless bundles
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
_error.js 881 kB 881 kB
404.html 4.18 kB 4.18 kB
hooks.html 3.82 kB 3.82 kB
index.js 882 kB 882 kB
link.js 923 kB 923 kB
routerDirect.js 917 kB 917 kB
withRouter.js 917 kB 917 kB
Overall change 4.53 MB 4.53 MB
Commit: 6e199f9

@jeantil jeantil force-pushed the fix-monorepo-ts-baseUrl-resolution branch from 6e199f9 to 2258885 Compare July 20, 2020 13:47
Typescript configuration can inherit from files above cwd in the
filesystem. If a baseUrl was declared in such a file, it would not be
picked up by the webpack config. This would force users to use the
next-transpile-module and duplicate configuration with unintuitive path
relations (see vercel#13197 for a detailed analysis)

If baseUrl is resolved it should be used instead of dir as the root
include for babel-resolve-loader.
@jeantil jeantil force-pushed the fix-monorepo-ts-baseUrl-resolution branch from 2258885 to 37d3a4a Compare July 20, 2020 13:53
@ijjk
Copy link
Member

ijjk commented Jul 20, 2020

Stats from current PR

Default Server Mode (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
buildDuration 13s 12.7s -264ms
nodeModulesSize 66.5 MB 66.5 MB ⚠️ +688 B
Page Load Tests Overall increase ✓
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
/ failed reqs 0 0
/ total time (seconds) 2.034 2.025 -0.01
/ avg req/sec 1228.9 1234.33 +5.43
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.324 1.262 -0.06
/error-in-render avg req/sec 1887.81 1981.49 +93.68
Client Bundles (main, webpack, commons)
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
677f882d2ed8..db49.js gzip 9.7 kB 9.7 kB
framework.HASH.js gzip 39.1 kB 39.1 kB
main-35b59ab..f28f.js gzip 6.72 kB 6.72 kB
polyfills-05..1236.js gzip 30.8 kB 30.8 kB
webpack-488d..c0e7.js gzip 751 B 751 B
Overall change 87.1 kB 87.1 kB
Client Bundles (main, webpack, commons) Modern
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
677f882d2ed8..dule.js gzip 6.1 kB 6.1 kB
framework.HA..dule.js gzip 39.1 kB 39.1 kB
main-0e6fc45..dule.js gzip 5.79 kB 5.79 kB
polyfills-05..dule.js gzip 30.8 kB 30.8 kB
webpack-4f62..dule.js gzip 751 B 751 B
Overall change 82.6 kB 82.6 kB
Client Pages
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
_app-8f5f611..1f7b.js gzip 1.28 kB 1.28 kB
_error-8e69b..8695.js gzip 3.41 kB 3.41 kB
hooks-f7f3d0..7465.js gzip 887 B 887 B
index-08fb3f..c0e9.js gzip 227 B 227 B
link-ddd176e..5566.js gzip 1.29 kB 1.29 kB
routerDirect..8aa1.js gzip 284 B 284 B
withRouter-f..e777.js gzip 284 B 284 B
Overall change 7.66 kB 7.66 kB
Client Pages Modern
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
_app-669dbe5..dule.js gzip 626 B 626 B
_error-663e6..dule.js gzip 2.24 kB 2.24 kB
hooks-805c40..dule.js gzip 387 B 387 B
index-6ba5a4..dule.js gzip 226 B 226 B
link-69bc264..dule.js gzip 1.25 kB 1.25 kB
routerDirect..dule.js gzip 284 B 284 B
withRouter-d..dule.js gzip 282 B 282 B
Overall change 5.29 kB 5.29 kB
Client Build Manifests
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
_buildManifest.js gzip 275 B 275 B
_buildManife..dule.js gzip 281 B 281 B
Overall change 556 B 556 B
Rendered Page Sizes
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
index.html gzip 948 B 948 B
link.html gzip 955 B 955 B
withRouter.html gzip 941 B 941 B
Overall change 2.84 kB 2.84 kB

Serverless Mode
General Overall increase ⚠️
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
buildDuration 13.9s 14.2s ⚠️ +247ms
nodeModulesSize 66.5 MB 66.5 MB ⚠️ +688 B
Client Bundles (main, webpack, commons)
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
677f882d2ed8..db49.js gzip 9.7 kB 9.7 kB
framework.HASH.js gzip 39.1 kB 39.1 kB
main-35b59ab..f28f.js gzip 6.72 kB 6.72 kB
polyfills-05..1236.js gzip 30.8 kB 30.8 kB
webpack-488d..c0e7.js gzip 751 B 751 B
Overall change 87.1 kB 87.1 kB
Client Bundles (main, webpack, commons) Modern
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
677f882d2ed8..dule.js gzip 6.1 kB 6.1 kB
framework.HA..dule.js gzip 39.1 kB 39.1 kB
main-0e6fc45..dule.js gzip 5.79 kB 5.79 kB
polyfills-05..dule.js gzip 30.8 kB 30.8 kB
webpack-4f62..dule.js gzip 751 B 751 B
Overall change 82.6 kB 82.6 kB
Client Pages
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
_app-8f5f611..1f7b.js gzip 1.28 kB 1.28 kB
_error-8e69b..8695.js gzip 3.41 kB 3.41 kB
hooks-f7f3d0..7465.js gzip 887 B 887 B
index-08fb3f..c0e9.js gzip 227 B 227 B
link-ddd176e..5566.js gzip 1.29 kB 1.29 kB
routerDirect..8aa1.js gzip 284 B 284 B
withRouter-f..e777.js gzip 284 B 284 B
Overall change 7.66 kB 7.66 kB
Client Pages Modern
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
_app-669dbe5..dule.js gzip 626 B 626 B
_error-663e6..dule.js gzip 2.24 kB 2.24 kB
hooks-805c40..dule.js gzip 387 B 387 B
index-6ba5a4..dule.js gzip 226 B 226 B
link-69bc264..dule.js gzip 1.25 kB 1.25 kB
routerDirect..dule.js gzip 284 B 284 B
withRouter-d..dule.js gzip 282 B 282 B
Overall change 5.29 kB 5.29 kB
Client Build Manifests
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
_buildManifest.js gzip 275 B 275 B
_buildManife..dule.js gzip 281 B 281 B
Overall change 556 B 556 B
Serverless bundles
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
_error.js 881 kB 881 kB
404.html 4.18 kB 4.18 kB
hooks.html 3.82 kB 3.82 kB
index.js 882 kB 882 kB
link.js 923 kB 923 kB
routerDirect.js 917 kB 917 kB
withRouter.js 917 kB 917 kB
Overall change 4.53 MB 4.53 MB
Commit: 2258885

@ijjk
Copy link
Member

ijjk commented Jul 20, 2020

Stats from current PR

Default Server Mode (Decrease detected ✓)
General Overall increase ⚠️
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
buildDuration 10.6s 10.6s ⚠️ +25ms
nodeModulesSize 66.5 MB 66.5 MB ⚠️ +688 B
Page Load Tests Overall decrease ⚠️
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
/ failed reqs 0 0
/ total time (seconds) 1.749 1.781 ⚠️ +0.03
/ avg req/sec 1429.53 1404.08 ⚠️ -25.45
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.042 1.034 -0.01
/error-in-render avg req/sec 2399.06 2418.47 +19.41
Client Bundles (main, webpack, commons)
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
677f882d2ed8..db49.js gzip 9.7 kB 9.7 kB
framework.HASH.js gzip 39.1 kB 39.1 kB
main-35b59ab..f28f.js gzip 6.72 kB 6.72 kB
polyfills-05..1236.js gzip 30.8 kB 30.8 kB
webpack-488d..c0e7.js gzip 751 B 751 B
Overall change 87.1 kB 87.1 kB
Client Bundles (main, webpack, commons) Modern
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
677f882d2ed8..dule.js gzip 6.1 kB 6.1 kB
framework.HA..dule.js gzip 39.1 kB 39.1 kB
main-0e6fc45..dule.js gzip 5.79 kB 5.79 kB
polyfills-05..dule.js gzip 30.8 kB 30.8 kB
webpack-4f62..dule.js gzip 751 B 751 B
Overall change 82.6 kB 82.6 kB
Client Pages
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
_app-8f5f611..1f7b.js gzip 1.28 kB 1.28 kB
_error-8e69b..8695.js gzip 3.41 kB 3.41 kB
hooks-f7f3d0..7465.js gzip 887 B 887 B
index-08fb3f..c0e9.js gzip 227 B 227 B
link-ddd176e..5566.js gzip 1.29 kB 1.29 kB
routerDirect..8aa1.js gzip 284 B 284 B
withRouter-f..e777.js gzip 284 B 284 B
Overall change 7.66 kB 7.66 kB
Client Pages Modern
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
_app-669dbe5..dule.js gzip 626 B 626 B
_error-663e6..dule.js gzip 2.24 kB 2.24 kB
hooks-805c40..dule.js gzip 387 B 387 B
index-6ba5a4..dule.js gzip 226 B 226 B
link-69bc264..dule.js gzip 1.25 kB 1.25 kB
routerDirect..dule.js gzip 284 B 284 B
withRouter-d..dule.js gzip 282 B 282 B
Overall change 5.29 kB 5.29 kB
Client Build Manifests
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
_buildManifest.js gzip 275 B 275 B
_buildManife..dule.js gzip 281 B 281 B
Overall change 556 B 556 B
Rendered Page Sizes
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
index.html gzip 948 B 948 B
link.html gzip 955 B 955 B
withRouter.html gzip 941 B 941 B
Overall change 2.84 kB 2.84 kB

Serverless Mode
General Overall increase ⚠️
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
buildDuration 11.7s 12.9s ⚠️ +1.3s
nodeModulesSize 66.5 MB 66.5 MB ⚠️ +688 B
Client Bundles (main, webpack, commons)
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
677f882d2ed8..db49.js gzip 9.7 kB 9.7 kB
framework.HASH.js gzip 39.1 kB 39.1 kB
main-35b59ab..f28f.js gzip 6.72 kB 6.72 kB
polyfills-05..1236.js gzip 30.8 kB 30.8 kB
webpack-488d..c0e7.js gzip 751 B 751 B
Overall change 87.1 kB 87.1 kB
Client Bundles (main, webpack, commons) Modern
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
677f882d2ed8..dule.js gzip 6.1 kB 6.1 kB
framework.HA..dule.js gzip 39.1 kB 39.1 kB
main-0e6fc45..dule.js gzip 5.79 kB 5.79 kB
polyfills-05..dule.js gzip 30.8 kB 30.8 kB
webpack-4f62..dule.js gzip 751 B 751 B
Overall change 82.6 kB 82.6 kB
Client Pages
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
_app-8f5f611..1f7b.js gzip 1.28 kB 1.28 kB
_error-8e69b..8695.js gzip 3.41 kB 3.41 kB
hooks-f7f3d0..7465.js gzip 887 B 887 B
index-08fb3f..c0e9.js gzip 227 B 227 B
link-ddd176e..5566.js gzip 1.29 kB 1.29 kB
routerDirect..8aa1.js gzip 284 B 284 B
withRouter-f..e777.js gzip 284 B 284 B
Overall change 7.66 kB 7.66 kB
Client Pages Modern
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
_app-669dbe5..dule.js gzip 626 B 626 B
_error-663e6..dule.js gzip 2.24 kB 2.24 kB
hooks-805c40..dule.js gzip 387 B 387 B
index-6ba5a4..dule.js gzip 226 B 226 B
link-69bc264..dule.js gzip 1.25 kB 1.25 kB
routerDirect..dule.js gzip 284 B 284 B
withRouter-d..dule.js gzip 282 B 282 B
Overall change 5.29 kB 5.29 kB
Client Build Manifests
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
_buildManifest.js gzip 275 B 275 B
_buildManife..dule.js gzip 281 B 281 B
Overall change 556 B 556 B
Serverless bundles
vercel/next.js canary jeantil/next.js fix-monorepo-ts-baseUrl-resolution Change
_error.js 881 kB 881 kB
404.html 4.18 kB 4.18 kB
hooks.html 3.82 kB 3.82 kB
index.js 882 kB 882 kB
link.js 923 kB 923 kB
routerDirect.js 917 kB 917 kB
withRouter.js 917 kB 917 kB
Overall change 4.53 MB 4.53 MB
Commit: 37d3a4a

@Timer
Copy link
Member

Timer commented Jul 30, 2020

This was just fixed in 9.5.1, please upgrade!

@hdngr
Copy link

hdngr commented Aug 5, 2020

Is there a place with a simple example implementation of this?

@belgattitude
Copy link
Contributor

belgattitude commented Aug 14, 2020

Made a quick example workspace project,

To see the changes needed from next-transpile-modules, have a look to belgattitude/next-transpile-ts-workspace#5

Huge thanks @jeantil

@jeantil
Copy link
Contributor Author

jeantil commented Aug 24, 2020

@hdngr have you looked at the integration test added by the PR ? https://github.com/vercel/next.js/tree/canary/test/integration/typescript-workspaces-paths
it is very similar to @belgattitude's example.

Both correctly resolve typescript source files through tsconfig including using paths and extending typescript configs. They still require some kind of configuration to transpile the typescript files, that won't be necessary anymore if #15569 is merged.

@theprobugmaker
Copy link

theprobugmaker commented Aug 25, 2020

@jeantil I noticed that extending works only for compilerOptions but if I have a similar exclude config in a root tsconfig.json Next.js will still put it back and ignore the root config. Is that intentional or a bug?

@jeantil
Copy link
Contributor Author

jeantil commented Aug 25, 2020

I noticed that too, it's completely unrelated to the changes in this PR,
The entry point for this specific issue should be around

export async function writeConfigurationDefaults(

since it the setting added is exactly the same as the one in my base tsconfig, I didn't spend any time to see why it failed to detect the extended setting...

@jeantil jeantil deleted the fix-monorepo-ts-baseUrl-resolution branch August 25, 2020 19:08
@desmap
Copy link

desmap commented Aug 29, 2020

@jeantil is there a way to get Next to recompile on change of above-cwd files within baseUrl?

@iam-yan
Copy link

iam-yan commented Feb 2, 2021

@hdngr have you looked at the integration test added by the PR ? https://github.com/vercel/next.js/tree/canary/test/integration/typescript-workspaces-paths
it is very similar to @belgattitude's example.

Both correctly resolve typescript source files through tsconfig including using paths and extending typescript configs. They still require some kind of configuration to transpile the typescript files, that won't be necessary anymore if #15569 is merged.

Hi @jeantil, I've tried the approach and have some questions:

Thanks.

@jeantil
Copy link
Contributor Author

jeantil commented Feb 2, 2021

hi @juuyan

Sorry I can't really help, I investigated and proposed patch to solve the issues I was encountering at the time (9 months ago).
They may have been fixed by other means than my patchs in next10 but I haven't been able to upgrade to next.js 10 yet.

I think it is safe to say that the goal of #15569 has not been achieved by other means unless the integration test hasn't been updated after the root issue was fixed. easiest way to test is to clone next.js, run the current integration test then remove the paths mapping section and re run the test :)

@iam-yan
Copy link

iam-yan commented Feb 2, 2021

@jeantil
I see. Thanks for your quick response. : )

@vercel vercel locked as resolved and limited conversation to collaborators Jan 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet