-
Notifications
You must be signed in to change notification settings - Fork 2
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
Importing divviup-ts from Node #89
Comments
These links provide a good overview of the situation: https://stackoverflow.com/a/57539446, microsoft/TypeScript#15479 (comment), and microsoft/TypeScript#15479 (comment). Compiler options will only affect the compiler's internal resolution of imports, but won't affect code generation. We are presented with a choice between exclusively using relative module import paths or adding another build step after I think this would be best resolved via Parcel, following #34. It appears that the "alias" field can address this. |
#34 has solved most of this, the only remaining hiccup is that the {
"dependencies": {
"@divviup/dap": "file:../../Code/ppm/divviup-ts/packages/dap"
}
} const DAPClient = require("@divviup/dap").default;
async function main() {
const client = new DAPClient({
type: "sum",
bits: 2,
taskId: ...,
leader: ...,
helper: ...,
minBatchDurationSeconds: 300,
});
console.log("Start time is", Math.floor(new Date().getTime() / 1000 / 300) * 300);
for (var i = 0; i < 10; i++) {
await client.sendMeasurement(1);
}
console.log("Done uploading");
console.log("End time is", Math.ceil(new Date().getTime() / 1000 / 300) * 300);
}
main().catch(console.error); |
I ran into some issues when trying to import the divviup-ts library from plain Node, and I'm wondering if there's some combination of TypeScript settings we could use to improve this. It appears we are using TypeScript's classic module resolution strategy, and internal module dependencies use "non-relative module imports". I got things to work by changing all internal dependencies to use relative imports, (a very invasive change, which we may not want to do) and importing the result as follows.
The text was updated successfully, but these errors were encountered: