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

Fix implied formats, file watching, new source file creating during edits #50098

Merged
merged 16 commits into from
Aug 1, 2022

Conversation

sheetalkamat
Copy link
Member

@sheetalkamat sheetalkamat commented Jul 29, 2022

This change includes:

  1. When program is created, we track package.json per file that affect its implied format
  2. We watch those files to invalidate resolutions of that file
  3. If oldSourceFile.impliedNodeFormat is not same as new one, we need to create new file, so we pass that information to host
  4. Document registry handles implied node format as part of its key to get the file and release it
  5. Package.json files are being watched so we know when to clear the package json info cache.
  6. Fixed issue with module resolution cache not passed around in watch mode
  7. If implied file format is determined by package.json persence/absence and file is module, its reported with --explainFiles

Fixes #50086

…e to invalidate package json entries instead of clearing them out everytime program is created
@sheetalkamat
Copy link
Member Author

@typescript-bot pack this

@sheetalkamat sheetalkamat marked this pull request as ready for review July 30, 2022 04:54
@typescript-bot
Copy link
Collaborator

typescript-bot commented Jul 30, 2022

Heya @sheetalkamat, I've started to run the tarball bundle task on this PR at 73f56b2. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jul 30, 2022

Hey @sheetalkamat, I've packed this into an installable tgz. You can install it for testing by referencing it in your package.json like so:

{
    "devDependencies": {
        "typescript": "https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/130808/artifacts?artifactName=tgz&fileId=0F60CBFC416351EB284A80B475F3B3683C765BFED326AB1F53DC657615AB3D2202&fileName=/typescript-4.8.0-insiders.20220730.tgz"
    }
}

and then running npm install.


There is also a playground for this build and an npm module you can use via "typescript": "npm:@typescript-deploys/pr-build@4.8.0-pr-50098-2".;

src/compiler/moduleNameResolver.ts Outdated Show resolved Hide resolved
/*details*/ undefined,
Diagnostics.File_redirects_to_file_0,
toFileName(file.redirectInfo.redirectTarget, fileNameConvertor)
));
}
if (isExternalOrCommonJsModule(file)) {
switch (file.impliedNodeFormat) {
case ModuleKind.ESNext:
Copy link
Member

Choose a reason for hiding this comment

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

Should both of these have a branch for when the file extension sets the format, for .cts, .cjs, .mjs and .mts files?

Copy link
Member Author

@sheetalkamat sheetalkamat Aug 1, 2022

Choose a reason for hiding this comment

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

@DanielRosenwasser and myself discussed offline before this change and decided try this with only spitting this out when package.json determines the context.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Milestone Bug PRs that fix a bug with a specific milestone
Projects
None yet
Development

Successfully merging this pull request may close these issues.

nodenext doesn't pick up on addition of type field to package.json
3 participants