-
Notifications
You must be signed in to change notification settings - Fork 295
chore: update imports for node 24 #6513
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
base: master
Are you sure you want to change the base?
Conversation
5de4b91
to
d67d7a2
Compare
As a separate item to action, we should probably move from |
5e4c0a7
to
95317fd
Compare
67af8e2
to
36d3798
Compare
36d3798
to
c312320
Compare
c312320
to
730df86
Compare
MessageOptions, | ||
MessageStandardType, | ||
} from '@bitgo/sdk-core'; | ||
import * as sdkCore from '@bitgo/sdk-core'; |
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.
Less effective, often pulls in more code than necessary.
import { BaseMessage, BaseMessageBuilder, BaseMessageBuilderFactory, IMessage, IMessageBuilder, MessageOptions, MessageStandardType, } from '@bitgo/sdk-core';
was good. While you can import type separately for readability but importing by first approach is still considered as good due to:
- Optimal Tree Shaking
- Clear Intent
- Simplicity
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.
@prabh-codes This was done more so to resolve this type of error rather than readability:
@bitgo/abstract-eth: file:///Users/michaelhahn/bitgo/BitGoJS/modules/abstract-eth/test/unit/token.ts:1
@bitgo/abstract-eth: import { TestBitGo, TestBitGoAPI } from '@bitgo/sdk-test';
@bitgo/abstract-eth: ^^^^^^^^^^^^
@bitgo/abstract-eth: SyntaxError: Named export 'TestBitGoAPI' not found. The requested module '@bitgo/sdk-test' is a CommonJS module, which may not support all module.exports as named exports.
@bitgo/abstract-eth: CommonJS modules can always be imported via the default export, for example using:
@bitgo/abstract-eth: import pkg from '@bitgo/sdk-test';
@bitgo/abstract-eth: const { TestBitGo, TestBitGoAPI } = pkg;
@bitgo/abstract-eth: at ModuleJob.#_instantiate (node:internal/modules/esm/module_job:254:21)
@bitgo/abstract-eth: at async ModuleJob.run (node:internal/modules/esm/module_job:362:5)
@bitgo/abstract-eth: at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:665:26)
@bitgo/abstract-eth: at async formattedImport (/Users/michaelhahn/bitgo/BitGoJS/node_modules/mocha/lib/nodejs/esm-utils.js:7:14)
@bitgo/abstract-eth: at async Object.exports.requireOrImport (/Users/michaelhahn/bitgo/BitGoJS/node_modules/mocha/lib/nodejs/esm-utils.js:48:32)
@bitgo/abstract-eth: at async Object.exports.loadFilesAsync (/Users/michaelhahn/bitgo/BitGoJS/node_modules/mocha/lib/nodejs/esm-utils.js:103:20)
@bitgo/abstract-eth: at async singleRun (/Users/michaelhahn/bitgo/BitGoJS/node_modules/mocha/lib/cli/run-helpers.js:125:3)
@bitgo/abstract-eth: at async Object.exports.handler (/Users/michaelhahn/bitgo/BitGoJS/node_modules/mocha/lib/cli/run.js:374:5)
@bitgo/abstract-eth: error Command failed with exit code 1.
@bitgo/abstract-eth: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
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.
The error you post is related to @bitgo/sdk-test
, not @bitgo/sdk-core
. Regardless, @prabh-codes is correct. You should go fix this in the module you are importing from, rather than just importing everything with a *
wild card.
This is done for Node.js 24 compatibility
Replace
import assert = require('assert')
withimport assert from 'assert'
to resolve "TypeScript import equals declaration is not supported in strip-only mode" errorUse type-only imports to resolve ESM issues
Replace
const ... = require('')
toimport
statementsMove type classifiers out of constructors
TICKET: CAAS-325