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.

Wrong import when using `--es_opt=target=ts`

See original GitHub issue

👋 Hello,

I’ve noticed a problem when I import a type between my protos while using --es_opt=target=ts.

in a.proto:

enum MyEnum {
  SOME_VAL = 0;
}

in b.proto:

import 'a.proto';

message MyMessage {
  MyEnum type = 1;
}

and when using

protoc -I proto/*.proto --es_opt=target=ts --plugin=protoc-gen-es=./node_modules/.bin/protoc-gen-es ...

the generated b_pb.ts contains

...
import {MyEnum} from "./a_pb.js";
...

which is invalid since the file name is of course a_pb.ts.

I guess it should either generate the import with the .ts suffix OR just leave it off since that’s valid, too?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
satetsu888commented, Sep 24, 2022

Thanks for this issue and answer! This helps me so much.

I met a similar issue with using Next.js, but this is simply solved by add a resolve rule in webpack. I am leaving this just for next one who came here using Next.js 😃

Add below to next.config.js

  ...
  webpack: (config, options) => {
    config.module.rules.push({
      resolve: {
        extensionAlias: {
            '.js': ['.ts', '.js'],
        },
      }
    })
    return config
  },
  ...
1reaction
smaye81commented, Sep 12, 2022

@stephanos I added an example using Jest and esbuild to our connect-web-integration repo here. I actually was able to get things running with mostly the same setup as we have documented, so I think our documentation may be ok.

At any rate, maybe this will provide some help in your issue from last week. I know you mentioned you were working, but just wanted to let you know this was available.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Avoiding pylint complaints when importing Python packages ...
Configure pylint. Disabling the wrong-import-position checker in .pylintrc is the simplest solution, but throws away valid warnings.
Read more >
Resolve the "Export EXPORT_NAME cannot be updated as it ...
You get this error when one or more stacks are importing an exported output ... Update the importing stack using the modified template....
Read more >
Review and troubleshoot import errors
Below, learn how to resolve errors detected during an import, download an error file, view error details, and correct issues in your import...
Read more >
Outlook shows a Translation Error during the import of a CSV file
Outlook shows a translation error when you try to import a .csv file in Outlook 2010 or Outlook 2013. This article explains how...
Read more >
Fix import errors for audience-specific pages - Atlassian Support
You must be using an audience-specific page to import users. If you are trying to import ... This error means the wrong import...
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