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

Upgrade to long 5.0.0 for ESM support #377

Closed
stephenh opened this issue Oct 28, 2021 · 8 comments
Closed

Upgrade to long 5.0.0 for ESM support #377

stephenh opened this issue Oct 28, 2021 · 8 comments

Comments

@stephenh
Copy link
Owner

stephenh commented Oct 28, 2021

In theory some of our import hacks can go away now? Probably needs to be a breaking change for ts-proto as well.

@badeAdebayo
Copy link

when do you plan to update?

@stephenh
Copy link
Owner Author

@badeAdebayo I'm not personally planning on working on this soon; PR's would be great if you're interested!

@gotjoshua
Copy link

i am running into an issue importing ts-proto files into an oclif command, and i think this would fix it.
even with esModuleInterop: true i get:

This module can only be referenced with ECMAScript imports/exports by 
turning on the 'esModuleInterop' flag and referencing its default export.

3 import * as Long from 'long';

search and replace
import * as Long from 'long';
with
import Long from 'long';

gets it working (but not sure if that will break something else)
would it break some functionality in ts-proto to import in this way instead?

in the meantime is there a way to avoid this?

@alexisvisco
Copy link

Same issue here

@Tera
Copy link

Tera commented Oct 18, 2022

same issue

@AnotiaWang
Copy link

Same issue

@Eashiong
Copy link

With --ts_proto_opt=esModuleInterop=true changes output to be esModuleInterop compliant.

Specifically the Long imports will be generated as import Long from 'long' instead of import * as Long from 'long'.

@stephenh
Copy link
Owner Author

I've merged #882 that:

a) upgrades ts-proto's internal usages of long (for reading protobuf descriptors) to long v5
b) changes the non-esModuleInterop to use the import Long = require("long") syntax, which I believe is the more correct way of importing long when not using esModuleInterop.

But, as @Eashiong as noted, if you're using esModuleInterop in your tsconfig.json, which I believe most projects do these days, then using esModuleInterop=true as the ts-proto opt is a good idea anyway.

We should probably make esModuleInterop=true the default at some point, but either way closing this issue as resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants