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

enhance: upgrade local ts #674

Merged
merged 10 commits into from
Apr 5, 2021
Merged

enhance: upgrade local ts #674

merged 10 commits into from
Apr 5, 2021

Conversation

huozhi
Copy link
Member

@huozhi huozhi commented Mar 23, 2021

Fixes #606

  • bump ts-loader version
  • bump built-in ts version
  • override incremental option to false

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! Looks like CI is failing though.

@huozhi huozhi marked this pull request as draft March 24, 2021 02:20
@huozhi
Copy link
Member Author

huozhi commented Mar 24, 2021

The inproper ts version in test directory lead to test failures

@styfle @guybedford, if I want to upgrade the ts lib assets generated in test/integration/node_modules/typescript/, (introduced #252) what's the proper coommand I should run? I tried ./dist/ncc/cli.js build src/typescript.js -o test/integration/node_modules/typescript/ -m but it emits unexpected assets

@guybedford
Copy link
Contributor

@huozhi that sounds right to me, but TypeScript is a very complex build for ncc already - just updating TypeScript is a job unto itself. Is it working?

@huozhi huozhi marked this pull request as ready for review March 24, 2021 16:26
@huozhi huozhi requested a review from styfle March 24, 2021 16:26
yarn.lock Outdated Show resolved Hide resolved
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.

I'm not sure if a symlink for test/integration/node_modules/typescript/index.js is correct here. What do you think @guybedford ?

@guybedford
Copy link
Contributor

@styfle the symlink approach seems fine to me actually. Note we should be sure to thoroughly test the TypeScript upgrade here manually before releasing, and it is a major release to upgrade TypeScript.

@styfle
Copy link
Member

styfle commented Mar 24, 2021

@guybedford All the CI tests are passing. Any other TS tests you have in mind?

@styfle styfle changed the title disable ts incremental option fix: disable ts incremental option Mar 24, 2021
@styfle styfle changed the title fix: disable ts incremental option fix: disable TS incremental option Mar 24, 2021
@guybedford
Copy link
Contributor

@styfle we may be missing test coverage of the bundled typescript version. That is, we should add a test that does a similar symlink trick, but to ./dist/typescript instead. Because otherwise node_modules/typescript will always be used as a local TypeScript always takes precedence so does in these tests as well.

Copy link
Member Author

@huozhi huozhi left a comment

Choose a reason for hiding this comment

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

this ts upgration is truly a big gap (from 3.2.2 to 3.9.9).
one idea is to only upgrade to 3.4 to support incremental option, the gap is small.
another option is to change purpose of this PR to "upgrade local provided ts" and release later.

which one do you prefer?

yarn.lock Outdated Show resolved Hide resolved
@codecov-io
Copy link

codecov-io commented Mar 28, 2021

Codecov Report

Merging #674 (9678c2b) into master (630d44e) will decrease coverage by 1.51%.
The diff coverage is 77.93%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #674      +/-   ##
==========================================
- Coverage   74.93%   73.41%   -1.52%     
==========================================
  Files          13       13              
  Lines         399      474      +75     
==========================================
+ Hits          299      348      +49     
- Misses        100      126      +26     
Impacted Files Coverage Δ
src/@@notfound.js 0.00% <0.00%> (ø)
src/typescript.js 80.00% <75.00%> (+2.22%) ⬆️
src/index.js 79.32% <76.98%> (-4.61%) ⬇️
src/cli.js 62.85% <91.66%> (+0.50%) ⬆️
src/loaders/empty-loader.js 100.00% <100.00%> (ø)
src/loaders/relocate-loader.js 100.00% <100.00%> (ø)
src/utils/get-package-base.js 0.00% <0.00%> (-37.50%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 57bdfc5...9678c2b. Read the comment docs.

@styfle
Copy link
Member

styfle commented Mar 30, 2021

Looks good! Just missing this: #674 (comment)

Also in regard to the TS version, we bundle TS so its not going to use any version besides the one defined in devDependencies (3.6.5 in your PR or rather the version in the lock file)

@huozhi
Copy link
Member Author

huozhi commented Apr 1, 2021

I'm kinda unclear about the approach of testing ./dist/typescript.js with symlink, would you mind clarifying it a bit more specific? I can work on that then. Thanks

@guybedford
Copy link
Contributor

@huozhi perhaps a symlink is the wrong direction actually - instead we just want to not load the local test/node_modules/typescript by ensuring that TypeScript cannot be located.

One way to do this would be to construct a tmp folder at the system root - /tmp/s9d8f0s9d8/test.ts and then execute that ts file. Because there is no node_modules containing typescript from such a path, this will force ncc to use its local inbuilt typescript version and thus test that.

Alternatively, simply running ncc from a difference cwd could also do this:

cd /
ncc run /path/to/ncc/test/unit/ts-ext/test.ts

Tests like the above might be possible to construct with the test/cli.js file (https://github.com/vercel/ncc/blob/master/test/cli.js) by adding a cwd option support to that test system.

So that's two possible ways to test this, basically if ncc finds a node_modules/typescript in cwd, it uses it, and notes that it is in the console. And because ncc/node_modules and ncc/test/node_modules both have local typescript versions, we are never testing the case where it isn't found. If you can think of another way apart from my above two suggestions to catch this other case feel free to try something else too and just let me know if I can clarify further at all.

@huozhi huozhi changed the title fix: disable TS incremental option enhance: upgrade local ts Apr 2, 2021
@huozhi huozhi requested a review from styfle April 2, 2021 10:58
@huozhi
Copy link
Member Author

huozhi commented Apr 2, 2021

I use the TYPESCRIPT_LOOKUP_PATH env as override option for tests. If the folder is invalid ncc can fallback to built-in ts lib. hope it's sth you're expecting.

Copy link
Contributor

@guybedford guybedford 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, thanks for your work on this!

test/index.test.js Outdated Show resolved Hide resolved
Co-authored-by: Steven <steven@ceriously.com>
@styfle styfle enabled auto-merge (squash) April 5, 2021 13:27
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.

Great work, thanks! 🎉

@styfle styfle added the automerge Automatically merge PR once checks pass label Apr 5, 2021
@styfle styfle merged commit 6f4714d into vercel:master Apr 5, 2021
@huozhi huozhi deleted the disable-incremental branch April 5, 2021 14:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Automatically merge PR once checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fails to compile when tsconfig has incremental: true
4 participants