question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add file extensions to generated imports.

See original GitHub issue

Files generated by the protoc plugin, currently, import witht he following syntax import {x} from 'y' however for reasons outlined in https://github.com/nodejs/modules/issues/444, the following syntax should be used for forward compatibility with esmodules import {x} from 'y.js'

Further reading: https://nodejs.org/api/esm.html#import-specifiers https://devblogs.microsoft.com/typescript/announcing-typescript-4-5-beta/

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:2
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
nvandammecommented, Feb 27, 2022
0reactions
timostammcommented, Nov 6, 2021

There is also the deprecated packages/plugin-framework/src/typescript-import-manager.ts, which can be ignored - it is not used anymore.

There is a spec file for parts of typescript-imports.ts. It is probably best to extend the test coverage a bit (its not actually covering TypeScriptImports yet) and implement against it.

I don’t think it will be feasible to add test coverage in @protobuf-ts/plugin, because if I’m not mistaken, it uses a TypeScript version that does not support the .js imports yet.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Appending .js extension on relative import statements during ...
For new files, it is possible to simply add ".js" extension in the import statement in Typescript file while editing. Example: import { ......
Read more >
Provide a way to add the '.js' file extension to the end ... - GitHub
TypeScript transpiles to JS but then generates broken (modern) JS code. Just add the option already to generate the ".js" extension for imports...
Read more >
Automatically add file extensions in imports in files with .mjs ...
Automatically add file extensions in imports in files with .mjs extension. 1.
Read more >
add-js-extension - npm
It appends the .js file extensions to the import statements in the JavaScript files that are generated by TypeScript when it is necessary....
Read more >
Documentation - Module Resolution - TypeScript
To accomplish this, TypeScript overlays the TypeScript source file extensions ( .ts , .tsx , and .d.ts ) over Node's resolution logic. TypeScript...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found