-
Notifications
You must be signed in to change notification settings - Fork 348
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: esModuleInterop not working for object-hash and dataloader imports #794
Conversation
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.
Hi @turulix , thanks for the PR! I've got a hopefully minor ask to try and let ts-poet do the rewriting/esModuleInterop conditionalization for us, but otherwise this looks great!
@@ -21,9 +21,6 @@ import SourceInfo, { Fields } from "./sourceInfo"; | |||
import { contextTypeVar } from "./main"; | |||
import { Context } from "./context"; | |||
|
|||
const hash = imp("hash*object-hash"); | |||
const dataloader = imp("DataLoader*dataloader"); |
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.
Fwiw, this is admittedly kind of cute, but if you'd like how I've handled this in the past is by having ts-poet rewrite the imports.
That was more useful when the imports were scattered all over the ts-proto codebase, while granted for these imports, they're only used ~once/twice so it's not that bad.
That said, if you'd like to try it, I just pushed a new version of ts-poet to handle default --> star rewrites (stephenh/ts-poet@29c834d) so, in theory you could:
- Bump ts-poet in package.json to 6.4.1
- Keep these consts by as `const hash = imp("hash=object-hash");
- Update
getTsPoetOpts
to includedataloader
andobject-hash
in theimports
list, which should a) leave them as-is ifesModuleInterop
is on, or b) rewrite them to the oldimport ... as *
ifesModuleInterop
is not on
Do you mind trying that and seeing if it works?
I will try it tomorrow or on Monday. Also, I noticed that the 'long' package is imported in the same way that I did in this pull request - I took the syntax from there. Should I do the same thing with it, as mentioned above? |
Ah yeah, if the long imports can take advantage of the new ts-poet capability, it'd be great to move those over too. I must have forgotten about those when I taught ts-poet how to handle the protobufjs esModuleInterop conditional imports. Thank you! |
Bumping ts-poet to 6.4.1 lets the |
Ah shoot...sorry about that; I think Glancing at it locally, it looks like just changing all the Would you like me to push out/merge a dedicated "bump-ts-poet" branch, or do you want to incorporate this fix into your branch? |
@turulix cool, I just merged the ts-poet bump to |
Not sure if i'm doing something wrong, but doing const imports = [
"protobufjs/minimal" + _options.importSuffix,
"object-hash" + _options.importSuffix,
"dataloader" + _options.importSuffix
]; leaves them as |
Ah yeah, you should be able to leave off the import suffix, so just like:
The import suffix is just for doing ...even |
I assumed its just an empty String if its not set, cause never saw it generate unless i explicitly set it. So it shouldnt have any impact on it |
It still dosn't change it when removing the suffix. |
## [1.148.2](v1.148.1...v1.148.2) (2023-06-04) ### Bug Fixes * esModuleInterop not working for object-hash and dataloader imports ([#794](#794)) ([9fc9632](9fc9632))
🎉 This PR is included in version 1.148.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Fixes #793