RyanMyrvold / Performance-Decorators

🚀 Performance Decorators: A TypeScript library that simplifies performance tracking and optimization.
Other
22 stars 22 forks source link

yntaxError: Named export 'LogExecutionTime' not found #86

Closed tjx666 closed 1 month ago

tjx666 commented 1 month ago
node lib/backend/apps/pef.mjs
❯ node lib/backend/apps/pef.mjs
file:///Users/yutengjing/code/xxx/web/lib/yyy/apps/pef.mjs:1
import { LogExecutionTime } from 'performance-decorators/debugging';
         ^^^^^^^^^^^^^^^^
SyntaxError: Named export 'LogExecutionTime' not found. The requested module 'performance-decorators/debugging' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from 'performance-decorators/debugging';
const { LogExecutionTime } = pkg;

    at ModuleJob._instantiate (node:internal/modules/esm/module_job:123:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:191:5)
    at async ModuleLoader.import (node:internal/modules/esm/loader:337:24)
    at async loadESM (node:internal/process/esm_loader:34:7)
    at async handleMainPromise (node:internal/modules/run_main:106:12)

Node.js v18.20.2

Because your module is a pure esm module, you should add `"type": "module" to your package.json, or nodejs will treat it as commonjs

RyanMyrvold commented 1 month ago

This is related to the built-in decorators in TypeScript 5.5. I need to either revert TypeScript to a version earlier than 5.5 or convert the decorators to comply with the TypeScript 5.5 official specification.

RyanMyrvold commented 1 month ago

resolved by https://github.com/RyanMyrvold/Performance-Decorators/releases/tag/2.5.0

RyanMyrvold commented 1 month ago

Part of 2.6.0 Debugging Conversion to 5.5 Decorators.

RyanMyrvold commented 1 month ago

resolved by https://github.com/RyanMyrvold/Performance-Decorators/releases/tag/2.6.0