Skip to content

Commit

Permalink
fix: esm suport
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoxiangmoe committed Jan 26, 2025
1 parent 90afa28 commit 08b29e7
Showing 1 changed file with 22 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,29 @@
*/
import * as process from 'process';

let getMachineId: () => Promise<string>;
let getMachineIdImpl: () => Promise<string>;
async function getMachineId(): Promise<string> {
if (!getMachineIdImpl) {
switch (process.platform) {
case 'darwin':
getMachineIdImpl = (await import('./getMachineId-darwin')).getMachineId;

Check failure on line 23 in packages/opentelemetry-resources/src/detectors/platform/node/machine-id/getMachineId.ts

View workflow job for this annotation

GitHub Actions / node-tests (22)

Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './getMachineId-darwin.js'?

Check failure on line 23 in packages/opentelemetry-resources/src/detectors/platform/node/machine-id/getMachineId.ts

View workflow job for this annotation

GitHub Actions / node-tests (22)

Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'.

Check failure on line 23 in packages/opentelemetry-resources/src/detectors/platform/node/machine-id/getMachineId.ts

View workflow job for this annotation

GitHub Actions / node-tests (22)

Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './getMachineId-darwin.js'?

Check failure on line 23 in packages/opentelemetry-resources/src/detectors/platform/node/machine-id/getMachineId.ts

View workflow job for this annotation

GitHub Actions / browser-tests

Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './getMachineId-darwin.js'?

Check failure on line 23 in packages/opentelemetry-resources/src/detectors/platform/node/machine-id/getMachineId.ts

View workflow job for this annotation

GitHub Actions / browser-tests

Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'.

Check failure on line 23 in packages/opentelemetry-resources/src/detectors/platform/node/machine-id/getMachineId.ts

View workflow job for this annotation

GitHub Actions / browser-tests

Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './getMachineId-darwin.js'?

Check failure on line 23 in packages/opentelemetry-resources/src/detectors/platform/node/machine-id/getMachineId.ts

View workflow job for this annotation

GitHub Actions / webworker-tests

Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './getMachineId-darwin.js'?

Check failure on line 23 in packages/opentelemetry-resources/src/detectors/platform/node/machine-id/getMachineId.ts

View workflow job for this annotation

GitHub Actions / webworker-tests

Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'.

Check failure on line 23 in packages/opentelemetry-resources/src/detectors/platform/node/machine-id/getMachineId.ts

View workflow job for this annotation

GitHub Actions / webworker-tests

Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './getMachineId-darwin.js'?

Check failure on line 23 in packages/opentelemetry-resources/src/detectors/platform/node/machine-id/getMachineId.ts

View workflow job for this annotation

GitHub Actions / node-tests (20)

Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './getMachineId-darwin.js'?

Check failure on line 23 in packages/opentelemetry-resources/src/detectors/platform/node/machine-id/getMachineId.ts

View workflow job for this annotation

GitHub Actions / node-tests (20)

Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'.

Check failure on line 23 in packages/opentelemetry-resources/src/detectors/platform/node/machine-id/getMachineId.ts

View workflow job for this annotation

GitHub Actions / node-tests (20)

Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './getMachineId-darwin.js'?

Check failure on line 23 in packages/opentelemetry-resources/src/detectors/platform/node/machine-id/getMachineId.ts

View workflow job for this annotation

GitHub Actions / node-tests (18)

Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './getMachineId-darwin.js'?

Check failure on line 23 in packages/opentelemetry-resources/src/detectors/platform/node/machine-id/getMachineId.ts

View workflow job for this annotation

GitHub Actions / node-tests (18)

Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'.

Check failure on line 23 in packages/opentelemetry-resources/src/detectors/platform/node/machine-id/getMachineId.ts

View workflow job for this annotation

GitHub Actions / node-tests (18)

Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './getMachineId-darwin.js'?

Check failure on line 23 in packages/opentelemetry-resources/src/detectors/platform/node/machine-id/getMachineId.ts

View workflow job for this annotation

GitHub Actions / node-windows-tests

Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './getMachineId-darwin.js'?

Check failure on line 23 in packages/opentelemetry-resources/src/detectors/platform/node/machine-id/getMachineId.ts

View workflow job for this annotation

GitHub Actions / node-windows-tests

Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'.

Check failure on line 23 in packages/opentelemetry-resources/src/detectors/platform/node/machine-id/getMachineId.ts

View workflow job for this annotation

GitHub Actions / node-windows-tests

Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './getMachineId-darwin.js'?
break;
case 'linux':
getMachineIdImpl = (await import('./getMachineId-linux')).getMachineId;

Check failure on line 26 in packages/opentelemetry-resources/src/detectors/platform/node/machine-id/getMachineId.ts

View workflow job for this annotation

GitHub Actions / node-tests (22)

Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './getMachineId-linux.js'?

Check failure on line 26 in packages/opentelemetry-resources/src/detectors/platform/node/machine-id/getMachineId.ts

View workflow job for this annotation

GitHub Actions / node-tests (22)

Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'.

Check failure on line 26 in packages/opentelemetry-resources/src/detectors/platform/node/machine-id/getMachineId.ts

View workflow job for this annotation

GitHub Actions / node-tests (22)

Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './getMachineId-linux.js'?

Check failure on line 26 in packages/opentelemetry-resources/src/detectors/platform/node/machine-id/getMachineId.ts

View workflow job for this annotation

GitHub Actions / browser-tests

Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './getMachineId-linux.js'?

Check failure on line 26 in packages/opentelemetry-resources/src/detectors/platform/node/machine-id/getMachineId.ts

View workflow job for this annotation

GitHub Actions / browser-tests

Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'.

Check failure on line 26 in packages/opentelemetry-resources/src/detectors/platform/node/machine-id/getMachineId.ts

View workflow job for this annotation

GitHub Actions / browser-tests

Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './getMachineId-linux.js'?

Check failure on line 26 in packages/opentelemetry-resources/src/detectors/platform/node/machine-id/getMachineId.ts

View workflow job for this annotation

GitHub Actions / webworker-tests

Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './getMachineId-linux.js'?

Check failure on line 26 in packages/opentelemetry-resources/src/detectors/platform/node/machine-id/getMachineId.ts

View workflow job for this annotation

GitHub Actions / webworker-tests

Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'.

Check failure on line 26 in packages/opentelemetry-resources/src/detectors/platform/node/machine-id/getMachineId.ts

View workflow job for this annotation

GitHub Actions / webworker-tests

Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './getMachineId-linux.js'?

Check failure on line 26 in packages/opentelemetry-resources/src/detectors/platform/node/machine-id/getMachineId.ts

View workflow job for this annotation

GitHub Actions / node-tests (20)

Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './getMachineId-linux.js'?

Check failure on line 26 in packages/opentelemetry-resources/src/detectors/platform/node/machine-id/getMachineId.ts

View workflow job for this annotation

GitHub Actions / node-tests (20)

Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'.

Check failure on line 26 in packages/opentelemetry-resources/src/detectors/platform/node/machine-id/getMachineId.ts

View workflow job for this annotation

GitHub Actions / node-tests (20)

Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './getMachineId-linux.js'?

Check failure on line 26 in packages/opentelemetry-resources/src/detectors/platform/node/machine-id/getMachineId.ts

View workflow job for this annotation

GitHub Actions / node-tests (18)

Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './getMachineId-linux.js'?

Check failure on line 26 in packages/opentelemetry-resources/src/detectors/platform/node/machine-id/getMachineId.ts

View workflow job for this annotation

GitHub Actions / node-tests (18)

Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'.

Check failure on line 26 in packages/opentelemetry-resources/src/detectors/platform/node/machine-id/getMachineId.ts

View workflow job for this annotation

GitHub Actions / node-tests (18)

Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './getMachineId-linux.js'?

Check failure on line 26 in packages/opentelemetry-resources/src/detectors/platform/node/machine-id/getMachineId.ts

View workflow job for this annotation

GitHub Actions / node-windows-tests

Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './getMachineId-linux.js'?

Check failure on line 26 in packages/opentelemetry-resources/src/detectors/platform/node/machine-id/getMachineId.ts

View workflow job for this annotation

GitHub Actions / node-windows-tests

Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'.

Check failure on line 26 in packages/opentelemetry-resources/src/detectors/platform/node/machine-id/getMachineId.ts

View workflow job for this annotation

GitHub Actions / node-windows-tests

Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './getMachineId-linux.js'?
break;
case 'freebsd':
getMachineIdImpl = (await import('./getMachineId-bsd')).getMachineId;

Check failure on line 29 in packages/opentelemetry-resources/src/detectors/platform/node/machine-id/getMachineId.ts

View workflow job for this annotation

GitHub Actions / node-tests (22)

Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './getMachineId-bsd.js'?

Check failure on line 29 in packages/opentelemetry-resources/src/detectors/platform/node/machine-id/getMachineId.ts

View workflow job for this annotation

GitHub Actions / node-tests (22)

Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'.

Check failure on line 29 in packages/opentelemetry-resources/src/detectors/platform/node/machine-id/getMachineId.ts

View workflow job for this annotation

GitHub Actions / browser-tests

Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './getMachineId-bsd.js'?

Check failure on line 29 in packages/opentelemetry-resources/src/detectors/platform/node/machine-id/getMachineId.ts

View workflow job for this annotation

GitHub Actions / browser-tests

Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'.

Check failure on line 29 in packages/opentelemetry-resources/src/detectors/platform/node/machine-id/getMachineId.ts

View workflow job for this annotation

GitHub Actions / webworker-tests

Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './getMachineId-bsd.js'?

Check failure on line 29 in packages/opentelemetry-resources/src/detectors/platform/node/machine-id/getMachineId.ts

View workflow job for this annotation

GitHub Actions / webworker-tests

Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'.

Check failure on line 29 in packages/opentelemetry-resources/src/detectors/platform/node/machine-id/getMachineId.ts

View workflow job for this annotation

GitHub Actions / node-tests (20)

Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './getMachineId-bsd.js'?

Check failure on line 29 in packages/opentelemetry-resources/src/detectors/platform/node/machine-id/getMachineId.ts

View workflow job for this annotation

GitHub Actions / node-tests (20)

Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'.

Check failure on line 29 in packages/opentelemetry-resources/src/detectors/platform/node/machine-id/getMachineId.ts

View workflow job for this annotation

GitHub Actions / node-tests (18)

Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './getMachineId-bsd.js'?

Check failure on line 29 in packages/opentelemetry-resources/src/detectors/platform/node/machine-id/getMachineId.ts

View workflow job for this annotation

GitHub Actions / node-tests (18)

Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'.

Check failure on line 29 in packages/opentelemetry-resources/src/detectors/platform/node/machine-id/getMachineId.ts

View workflow job for this annotation

GitHub Actions / node-windows-tests

Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './getMachineId-bsd.js'?

Check failure on line 29 in packages/opentelemetry-resources/src/detectors/platform/node/machine-id/getMachineId.ts

View workflow job for this annotation

GitHub Actions / node-windows-tests

Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'.
break;
case 'win32':
getMachineIdImpl = (await import('./getMachineId-win')).getMachineId;

Check failure on line 32 in packages/opentelemetry-resources/src/detectors/platform/node/machine-id/getMachineId.ts

View workflow job for this annotation

GitHub Actions / node-tests (22)

Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './getMachineId-win.js'?

Check failure on line 32 in packages/opentelemetry-resources/src/detectors/platform/node/machine-id/getMachineId.ts

View workflow job for this annotation

GitHub Actions / browser-tests

Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './getMachineId-win.js'?

Check failure on line 32 in packages/opentelemetry-resources/src/detectors/platform/node/machine-id/getMachineId.ts

View workflow job for this annotation

GitHub Actions / webworker-tests

Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './getMachineId-win.js'?

Check failure on line 32 in packages/opentelemetry-resources/src/detectors/platform/node/machine-id/getMachineId.ts

View workflow job for this annotation

GitHub Actions / node-tests (20)

Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './getMachineId-win.js'?

Check failure on line 32 in packages/opentelemetry-resources/src/detectors/platform/node/machine-id/getMachineId.ts

View workflow job for this annotation

GitHub Actions / node-tests (18)

Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './getMachineId-win.js'?

Check failure on line 32 in packages/opentelemetry-resources/src/detectors/platform/node/machine-id/getMachineId.ts

View workflow job for this annotation

GitHub Actions / node-windows-tests

Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './getMachineId-win.js'?
break;
default:
getMachineIdImpl = (await import('./getMachineId-unsupported')).getMachineId;

Check failure on line 35 in packages/opentelemetry-resources/src/detectors/platform/node/machine-id/getMachineId.ts

View workflow job for this annotation

GitHub Actions / node-tests (22)

Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './getMachineId-unsupported.js'?

Check failure on line 35 in packages/opentelemetry-resources/src/detectors/platform/node/machine-id/getMachineId.ts

View workflow job for this annotation

GitHub Actions / browser-tests

Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './getMachineId-unsupported.js'?

Check failure on line 35 in packages/opentelemetry-resources/src/detectors/platform/node/machine-id/getMachineId.ts

View workflow job for this annotation

GitHub Actions / webworker-tests

Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './getMachineId-unsupported.js'?

Check failure on line 35 in packages/opentelemetry-resources/src/detectors/platform/node/machine-id/getMachineId.ts

View workflow job for this annotation

GitHub Actions / node-tests (20)

Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './getMachineId-unsupported.js'?

Check failure on line 35 in packages/opentelemetry-resources/src/detectors/platform/node/machine-id/getMachineId.ts

View workflow job for this annotation

GitHub Actions / node-tests (18)

Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './getMachineId-unsupported.js'?

Check failure on line 35 in packages/opentelemetry-resources/src/detectors/platform/node/machine-id/getMachineId.ts

View workflow job for this annotation

GitHub Actions / node-windows-tests

Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './getMachineId-unsupported.js'?
break;
}
}

switch (process.platform) {
case 'darwin':
({ getMachineId } = require('./getMachineId-darwin'));
break;
case 'linux':
({ getMachineId } = require('./getMachineId-linux'));
break;
case 'freebsd':
({ getMachineId } = require('./getMachineId-bsd'));
break;
case 'win32':
({ getMachineId } = require('./getMachineId-win'));
break;
default:
({ getMachineId } = require('./getMachineId-unsupported'));
return getMachineIdImpl();
}

export { getMachineId };

0 comments on commit 08b29e7

Please sign in to comment.