GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — `moduleResolution: node12` support by weswigham · Pull Request #45884 · microsoft/TypeScript

Conversation

@weswigham

@weswigham Wesley Wigham (weswigham) commented Sep 15, 2021

Copy link
Copy Markdown
Member

This PR is mostly just to pack up everything together for reviews over at weswigham#68 (if you're pinged as a reviewer here, go there to just review this most recent stage of development). It's also a viable PR to squash and merge to get everything merged all at once, once reviews and CI are in~

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

maxmilton, robpalme, styfle, Zertz, paulmelero, marvinhagemeister, mathiasbynens, redstrike, kolyasapphire, cyntler, and 16 more reacted with heart emoji AviVahl, styfle, danmarshall, evankennedy, dnalborczyk, carloschulo, robpalme, kripod, Jack-Works, paulmelero, and 15 more reacted with rocket emoji
All reactions
  • ❤️ 26 reactions
  • 🚀 25 reactions
Wesley Wigham (weswigham) added 12 commits July 12, 2021 15:17
@weswigham
Initial support for module: node12
c416aa9
@weswigham
Add allowJs and declaration emit enabled tests
34812f0
@weswigham
Fix typos
b447ed7
@weswigham
cts, mts, cjs, mjs, etc extension support
9b83a2e
@weswigham
Merge branch 'main' into module-node
44675c9
@weswigham
Merge branch 'module-node' into mjscjs-support
55d0728
@weswigham
Fix watch of files whose intepretation changes due to a package.json …
e6a386c
…update
@weswigham
Merge branch 'main' into module-node
fd2190f
@weswigham
Merge branch 'module-node' into mjscjs-support
13e76d7
@weswigham
Minor PR feedback
b12315f
@weswigham
Adjust error message
15e1904
@weswigham
Initial import/export/self-name support
093002c
@weswigham
Wesley Wigham (weswigham) requested review from Daniel Rosenwasser (DanielRosenwasser), Andrew Branch (andrewbranch), Ron Buckton (rbuckton) and Nathan Shively-Sanders (sandersn) September 15, 2021 02:24
@typescript-bot TypeScript Bot (typescript-bot) assigned Wesley Wigham (weswigham) Sep 15, 2021
@typescript-bot TypeScript Bot (typescript-bot) added Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Sep 15, 2021
@weswigham
Wesley Wigham (weswigham) force-pushed the imports-exports-selfs branch from cea73a2 to 093002c Compare September 15, 2021 02:27
Wesley Wigham (weswigham) added 4 commits September 14, 2021 19:32
@weswigham
Merge branch 'main' into module-node
4ab3f7e
@weswigham
Merge branch 'module-node' into mjscjs-support
a092fd3
@weswigham
Accept new error codes
5bf44ac
@weswigham
Merge branch 'mjscjs-support' into imports-exports-selfs
859abb6
@weswigham

Wesley Wigham (weswigham) commented Sep 15, 2021

Copy link
Copy Markdown
Member Author

TypeScript Bot (@typescript-bot) pack this

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@typescript-bot

TypeScript Bot (typescript-bot) commented Sep 15, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Heya Wesley Wigham (@weswigham), I've started to run the tarball bundle task on this PR at 859abb6. You can monitor the build here.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@typescript-bot

TypeScript Bot (typescript-bot) commented Sep 15, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Hey Wesley Wigham (@weswigham), 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/110514/artifacts?artifactName=tgz&fileId=A65D5A5264B9F1A3596294CAC5C757AD0A232C44FB117FB455A4D75D5A2F703C02&fileName=/typescript-4.5.0-insiders.20210915.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/[email protected]".;

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Wesley Wigham (weswigham) and others added 2 commits September 15, 2021 14:34
@weswigham
TypesVersions support in export/import map conditions
c21cb48
@weswigham
Fix import suggestion and autoimport default extensions under new res…
9294633
…olution modes
This was referenced Sep 24, 2021
Add flag to not transpile dynamic import() when module is CommonJS #43329
Closed
Support ".mjs" input files #27957
Closed
Support .mjs output #18442
Closed
Support for NodeJS 12.7+ package exports #33079
Closed
cts, mts, cjs, mjs, etc extension support #45774
Closed
Initial import/export/self-name support weswigham/TypeScript#68
Closed
cts, mts, cjs, mjs, etc extension support weswigham/TypeScript#67
Closed
Initial support for module: node12 #44501
Closed
Cannot find module or its corresponding type declaration when "main" has cjs file extension #45496
Closed
@typhonrt Michael Leahy (typhonrt) mentioned this pull request Sep 25, 2021
Use module: node12 in tsconfig.json; supports not transpiling import() / dynamic import for CommonJS code oclif/core#256
Closed
@mathiasbynens Mathias Bynens (mathiasbynens) mentioned this pull request Sep 28, 2021
Ship Puppeteer as JavaScript modules puppeteer/puppeteer#6753
Closed
@dabuside dabuside mentioned this pull request Sep 29, 2021
docs(modules): remove outdated .mjs notes mdn/content#9333
Merged
@ljharb Jordan Harband (ljharb) mentioned this pull request Sep 30, 2021
when using typescript recommended config it should allow for imports of js equivialent import-js/eslint-plugin-import#2111
Open
@ReallyBadNews Kenny Elshoff (ReallyBadNews) mentioned this pull request Sep 30, 2021
Distribute CommonJS for projects that cannot use ESM cloudinary/js-url-gen#444
Merged
2 tasks done
@nayeemrmn Nayeem Rahman (nayeemrmn) mentioned this pull request Oct 3, 2021
files are not scoped if they don't contain at least one export or import statement #18232
Closed
This was referenced Oct 12, 2021
Support type checking .cjs files #38784
Closed
Add support for .cjs and .mjs input files #39840
Closed
@frank-dspeed

Frank Lemanschik (frank-dspeed) commented Oct 14, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Wesley Wigham (@weswigham) i did test this beta get

Error: @rollup/plugin-typescript TS5070: Option '--resolveJsonModule' cannot be specified without 'node' module resolution strategy.
Error: @rollup/plugin-typescript TS5070: Option '--resolveJsonModule' cannot be specified without 'node' module resolution strategy.

so support for moduleResolution node12 and nodenext is needed in the array of supported modes for resolveJsonModule

#46362

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@sandersn
Nathan Shively-Sanders (sandersn) deleted the imports-exports-selfs branch October 14, 2021 15:59
@demurgos Charles Samborski (demurgos) mentioned this pull request Oct 15, 2021
Incompatible with node12 TypesScript module resolution ReactiveX/rxjs#6641
Closed
@JounQin

JounQin (JounQin) commented Oct 18, 2021

Copy link
Copy Markdown

I just tried the typescript@next and moduleResolution: 'node12' with @angular/compiler@v13, but tsc -b failed to build:

src/index.ts:1:15 - error TS2305: Module '"@angular/compiler"' has no exported member 'ParsedTemplate'.

1 import type { ParsedTemplate } from '@angular/compiler'
                ~~~~~~~~~~~~~~

src/index.ts:1:37 - error TS1471: Module '@angular/compiler' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.

1 import type { ParsedTemplate } from '@angular/compiler'
                                      ~~~~~~~~~~~~~~~~~~~

src/index.ts:2:30 - error TS7016: Could not find a declaration file for module 'synckit'. '/Users/JounQin/Workspaces/Local/test/node_modules/synckit/lib/index.cjs' implicitly has an 'any' type.
  Try `npm i --save-dev @types/synckit` if it exists or add a new declaration (.d.ts) file containing `declare module 'synckit';`

2 import { createSyncFn } from 'synckit'
                               ~~~~~~~~~

src/worker.ts:1:15 - error TS2305: Module '"@angular/compiler"' has no exported member 'ParsedTemplate'.

1 import type { ParsedTemplate } from '@angular/compiler'
                ~~~~~~~~~~~~~~

src/worker.ts:1:37 - error TS1471: Module '@angular/compiler' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.

1 import type { ParsedTemplate } from '@angular/compiler'
                                      ~~~~~~~~~~~~~~~~~~~

src/worker.ts:2:29 - error TS7016: Could not find a declaration file for module 'synckit'. '/Users/JounQin/Workspaces/Local/test/node_modules/synckit/lib/index.cjs' implicitly has an 'any' type.
  Try `npm i --save-dev @types/synckit` if it exists or add a new declaration (.d.ts) file containing `declare module 'synckit';`

2 import { runAsWorker } from 'synckit'
                              ~~~~~~~~~

src/worker.ts:5:11 - error TS2339: Property 'parseTemplate' does not exist on type 'typeof import("/Users/JounQin/Workspaces/Local/test/node_modules/@angular/compiler/index")'.

5   const { parseTemplate } = await import('@angular/compiler')
            ~~~~~~~~~~~~~


Found 7 errors.

@angular/compiler@v13 is ESM only, ParsedTemplate is typing exported from its types entry.

See https://unpkg.com/browse/@angular/[email protected]/package.json

synckit is both commonjs and ESM compatible.

See https://unpkg.com/browse/[email protected]/package.json

I have no idea how can it be fixed on my side.


Test source codes:

// worker.ts
import type { ParsedTemplate } from '@angular/compiler'
import { runAsWorker } from 'synckit'

runAsWorker<ParsedTemplate>(async (code: string, filePath: string) => {
  const { parseTemplate } = await import('@angular/compiler')
  return parseTemplate(code, filePath, {
    preserveWhitespaces: true,
    preserveLineEndings: true,
    collectCommentNodes: true,
  })
})
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@JounQin JounQin (JounQin) mentioned this pull request Oct 18, 2021
"moduleResolution": "node12" of Typescript 4.5 does not work as expected #46408
Closed
@SheetJSDev Eric P Sheets (SheetJSDev) mentioned this pull request Oct 24, 2021
Requesting ECMAScript module (ESM) bundle support SheetJS/sheetjs#2033
Closed
@demurgos Charles Samborski (demurgos) mentioned this pull request Oct 28, 2021
fix: Add types field to package.json stream-utils/raw-body#75
Closed
@loynoir loynoir mentioned this pull request Nov 3, 2021
Crash on new typescript file pattern .d.mts .d.cts rollup/plugins#1032
Closed
@DragonZV DragonZV mentioned this pull request Nov 29, 2021
Add support for the new .mts and .cts file extensions. codota/TabNine#486
Merged
@jasonwilliams Jason Williams (jasonwilliams) mentioned this pull request Dec 6, 2021
Enable consuming of ES modules in extensions microsoft/vscode#130367
Closed
sheetalkamat
Sheetal Nandi (sheetalkamat) reviewed Mar 11, 2022
View reviewed changes
Comment thread src/compiler/resolutionCache.ts
let i = 0;
for (const name of names) {
let resolution = resolutionsInFile.get(name);
const mode = containingSourceFile ? getModeForResolutionAtIndex(containingSourceFile, i) : undefined;

@sheetalkamat Sheetal Nandi (sheetalkamat) Mar 11, 2022

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

We cannot assume that module name is referenced at index i in containing source file because we could be calling you with only few module names from the source file. https://github.com/microsoft/TypeScript/blob/main/src/compiler/program.ts#L1571 shows that case

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

andrewbranch reacted with eyes emoji
All reactions
  • 👀 1 reaction
@sheetalkamat Sheetal Nandi (sheetalkamat) mentioned this pull request Mar 11, 2022
Referencing module name using index when resolving module name can be incorrect #48229
Closed
@microsoft Microsoft (microsoft) locked as resolved and limited conversation to collaborators Oct 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

@sheetalkamat Sheetal Nandi (sheetalkamat) sheetalkamat left review comments
@sandersn Nathan Shively-Sanders (sandersn) Awaiting requested review from sandersn
@DanielRosenwasser Daniel Rosenwasser (DanielRosenwasser) Awaiting requested review from DanielRosenwasser
@andrewbranch Andrew Branch (andrewbranch) Awaiting requested review from andrewbranch
@rbuckton Ron Buckton (rbuckton) Awaiting requested review from rbuckton

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@weswigham Wesley Wigham (weswigham)

Labels

Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

6 participants

@weswigham @typescript-bot @andrewbranch @frank-dspeed @JounQin @sheetalkamat
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.