Skip to content

Use project references to fix build #335

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

Merged
merged 5 commits into from
Jun 16, 2021
Merged

Conversation

raoulmillais
Copy link
Contributor

@raoulmillais raoulmillais commented Jun 16, 2021

  • Create a root tsconfig to enable compiling everything from the root
  • Extract a minimal tsconfig.base.json to share settings amongst projects
  • Reference depedencies in project tsconfigs so tsc knows how to compile them if there are changes / no build outputs yet
  • Fix typescript include paths for extension
  • Correct usage of rootDir and baseUrl everywhere
  • Remove superfluous tsconfig from SmoldotProvider directory
  • Fix ConnectionManager imports in burnr
  • Remove no-longer-needed postinstall script from smoldot-test-utils
  • Use tsc -b everywhere to get incremental builds
  • Upgrade typescript to latest and typescript eslint packages to latest stable

This fixes #292

* Fix include paths for extension
* Correct usage of rootDir and baseUrl
* Remove superfluous tsconfig from SmoldotProvider directory
* Fix ConnectionManager imports in burnr
* Use `tsc -b` everywhere to get incremental builds
@raoulmillais raoulmillais requested a review from wirednkod June 16, 2021 11:55
Copy link
Contributor

@wirednkod wirednkod left a comment

Choose a reason for hiding this comment

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

I added same comment more than one times in separate files just to point the issue where it repeats.

"clean": "rm -rf dist",
"dev": "yarn run clean && tsc --noEmit & parcel ./public/index.html",
"clean": "rm -rf dist tsconfig.tsbuildinfo",
"dev": "yarn run clean && tsc -b & parcel ./public/index.html",
Copy link
Contributor

Choose a reason for hiding this comment

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

Why remove the noEmit? tsc is typechecking while parcel takes care of compiling the code. Afaiu this change will typecheck, build and then parcel will compile the code to show it for dev.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You can't use -b and --noEmit together. I decided it would be preferable to have incremental building and detection of changes in dependencies than suppressing the build output

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here is the justification from the typescript team on why noEmit wont build dependent references with --noEmit - microsoft/TypeScript#40431

Copy link
Contributor

@wirednkod wirednkod Jun 16, 2021

Choose a reason for hiding this comment

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

I agree with the above. noEmit is used for not emitting compiler output files like JavaScript source code, source-maps or declarations based on doc: https://www.typescriptlang.org/tsconfig#noEmit allowing other tools to do the compiling. All I am saying is that so far we were using parcel to compile our project while keep tsc (with --noEmit) just for typechecking. By replacing --noEmit with -b we now use tsc to typecheck and compile, and then parcel to compile again.

Copy link
Contributor Author

@raoulmillais raoulmillais Jun 16, 2021

Choose a reason for hiding this comment

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

The point is a user cannot just clone then cd into burnr and run yarn dev if we use --noEmit ... I think that is surprising. By using -b instead of --noEmit its true that the compile is slightly slower than using --noEmit but its "bulletproof" .. it will always do what you expect no matter the state of the other projects (it will compile them if needed)

Copy link
Contributor Author

@raoulmillais raoulmillais Jun 16, 2021

Choose a reason for hiding this comment

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

Also if you make changes to @substrate/connect (and don't recompile it) then cd into one of the demos and then run yarn dev in the demo you will not have the changes in @substrate/connect since typescript with --noEmit won't check the dependency for changes - it will use the stale build output from @substrate/connect. That's also surprising

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Regarding the slowdown by doing a full compile instead of using --noEmit.. that is probably only a concern for the first hit. -b does incremental compilation so after the first build it will have build caches and so is able to optimise the build time depending on what has changed

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure I follow. I just replicated the steps you mentioned (after changing the -b to --noEmit ofc) and I was able to yarn dev from inside burnr dir.

"clean": "rm -rf dist",
"dev": "yarn run clean && tsc --noEmit & parcel ./public/index.html",
"clean": "rm -rf dist tsconfig.tsbuildinfo",
"dev": "yarn run clean && tsc -b & parcel ./public/index.html",
Copy link
Contributor

Choose a reason for hiding this comment

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

by removing -noEmit then "tsc" command also compiles the code instead of just typechecking. We are using parcel for that

Copy link
Contributor Author

@raoulmillais raoulmillais Jun 16, 2021

Choose a reason for hiding this comment

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

See above .. we can't detect changes in dependent projects (and therefore typecheck properly) with noEmit

"typecheck": "tsc --noEmit",
"typecheck:watch": "tsc --noEmit --watch",
"clean": "rm -rf dist/ tsconfig.tsbuildinfo && mkdir -p dist/assets",
"typecheck": "tsc -b",
Copy link
Contributor

Choose a reason for hiding this comment

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

by removing -noEmit then "typecheck" command also compiles the code instead of just typechecking. We are using parcel for that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As above

@raoulmillais raoulmillais requested a review from wirednkod June 16, 2021 12:47
@raoulmillais raoulmillais merged commit 1122b5a into master Jun 16, 2021
@raoulmillais raoulmillais deleted the rm-ts-project-references branch June 16, 2021 13:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Setup typescript project references
2 participants