Compass helpers for node platforms
    Preparing search index...

    Function importESM

    • Type Parameters

      • T = unknown

      Parameters

      • modulePath: string

        模块路径或模块名

      • Optionaloptions: ImportOptions

        配置项

        • cwd

          工作目录,默认为 process.cwd()

      Returns Promise<T>

      Promise<模块导出内容>

      动态导入 ES 模块(异步)

      // 导入本地 ES 模块
      const { default: config } = await importESM<{ default: Config }>('./config.mjs');

      // 导入 npm 包
      const { default: chalk } = await importESM<typeof import('chalk')>('chalk');

      // 指定工作目录
      const module = await importESM('./module.js', { cwd: '/custom/path' });