Skip to content

Commit

Permalink
Move importGot -> importEsm, introduce static import definition
Browse files Browse the repository at this point in the history
  • Loading branch information
Jkovarik committed Apr 26, 2024
1 parent 2cadc6c commit 2ff5403
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
8 changes: 6 additions & 2 deletions packages/common/importGot.js → packages/common/importEsm.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
const imports = Object.freeze({
got: 'got',
});

/**
* Asynchronously imports the 'got' module.
*
Expand All @@ -9,8 +13,8 @@
* @throws {Error} If an error occurs while importing the module.
*/
const importGot = async () => {
const { default: got } = await import('got');
const { default: got } = await import(imports.got);
return got;
}
};

module.exports = { importGot };
2 changes: 2 additions & 0 deletions packages/common/src/importEsm.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
declare module 'importEsm';
export {};
2 changes: 0 additions & 2 deletions packages/common/src/importGot.d.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/common/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import BucketsConfig = require('./BucketsConfig');
export { BucketsConfig };

export * as importGot from './importGot';
export * as importEsm from './importEsm';
export * as cliUtils from './cli-utils';
export * as envUtils from './env';
export * as fakeProvider from './fake-provider';
Expand Down
2 changes: 1 addition & 1 deletion packages/ingest/src/HttpProviderClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const { PassThrough } = require('stream');
const Crawler = require('simplecrawler');
const { CookieJar } = require('tough-cookie');
const { promisify } = require('util');
const { importGot } = require('@cumulus/common/importGot');
const { importGot } = require('@cumulus/common/importEsm');

const {
buildS3Uri,
Expand Down

1 comment on commit 2ff5403

@etcart
Copy link
Contributor

@etcart etcart commented on 2ff5403 Apr 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks great

Please sign in to comment.