From 429ec0366fa303c141b9b6bfc51c1433d82df966 Mon Sep 17 00:00:00 2001 From: Jakub Novak Date: Mon, 10 Feb 2025 18:34:10 -0800 Subject: [PATCH 1/3] Load update notifier dynamically --- packages/cli/src/index.ts | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/packages/cli/src/index.ts b/packages/cli/src/index.ts index 76cb6ec11..dac5762e6 100644 --- a/packages/cli/src/index.ts +++ b/packages/cli/src/index.ts @@ -1,7 +1,5 @@ #!/usr/bin/env -S node --enable-source-maps -import * as updateNotifier from 'update-notifier' - import * as commander from 'commander' import * as packageJSON from '../package.json' import { program } from './commands' @@ -9,12 +7,18 @@ import { commands2md } from './utils/commands2md' export const pkg = packageJSON -updateNotifier - .default({ - pkg, - updateCheckInterval: 1000 * 60 * 60 * 8, // 8 hours - }) - .notify() +async function loadUpdateNotifier() { + const updateNotifier = await import('update-notifier'); + return updateNotifier.default; +} + +loadUpdateNotifier().then(updateNotifier => { + updateNotifier({ + pkg, + updateCheckInterval:1000 * 60 * 60 * 8, // 8 hours + }) + .notify() +}) const prog = program.version( packageJSON.version, From ec36840c0417d29b77101c69bd2ee9f9e414592a Mon Sep 17 00:00:00 2001 From: Jakub Dobry Date: Fri, 21 Feb 2025 15:44:44 -0800 Subject: [PATCH 2/3] update the update-notifier import to esm, remove it from the excludedPackages --- packages/cli/src/index.ts | 16 +++++----------- packages/cli/tsup.config.js | 2 +- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/packages/cli/src/index.ts b/packages/cli/src/index.ts index dac5762e6..2354b8bc3 100644 --- a/packages/cli/src/index.ts +++ b/packages/cli/src/index.ts @@ -1,5 +1,6 @@ #!/usr/bin/env -S node --enable-source-maps +import updateNotifier from 'update-notifier' import * as commander from 'commander' import * as packageJSON from '../package.json' import { program } from './commands' @@ -7,18 +8,11 @@ import { commands2md } from './utils/commands2md' export const pkg = packageJSON -async function loadUpdateNotifier() { - const updateNotifier = await import('update-notifier'); - return updateNotifier.default; -} - -loadUpdateNotifier().then(updateNotifier => { - updateNotifier({ - pkg, - updateCheckInterval:1000 * 60 * 60 * 8, // 8 hours - }) - .notify() +updateNotifier({ + pkg, + updateCheckInterval:1000 * 60 * 60 * 8, // 8 hours }) + .notify() const prog = program.version( packageJSON.version, diff --git a/packages/cli/tsup.config.js b/packages/cli/tsup.config.js index 34906078b..b09a5f7d6 100644 --- a/packages/cli/tsup.config.js +++ b/packages/cli/tsup.config.js @@ -2,7 +2,7 @@ import { defineConfig } from 'tsup' import * as packageJSON from './package.json' -const excludedPackages = ['update-notifier', 'inquirer'] +const excludedPackages = ['inquirer'] export default defineConfig({ entry: ['src/index.ts'], From aa7a2bf58b32d59c092fb9553af3b3fbb9c93e6f Mon Sep 17 00:00:00 2001 From: Jakub Dobry Date: Fri, 21 Feb 2025 15:48:19 -0800 Subject: [PATCH 3/3] add changeset --- .changeset/stale-owls-own.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/stale-owls-own.md diff --git a/.changeset/stale-owls-own.md b/.changeset/stale-owls-own.md new file mode 100644 index 000000000..6870a75d2 --- /dev/null +++ b/.changeset/stale-owls-own.md @@ -0,0 +1,5 @@ +--- +'@e2b/cli': patch +--- + +Fix ESM import for older node versions