Skip to content
This repository was archived by the owner on Mar 8, 2026. It is now read-only.
This repository was archived by the owner on Mar 8, 2026. It is now read-only.

ESM 更新 #300

@Diablohu

Description

@Diablohu

更新方式 https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c

Packages

  • Root
  • create-koot-app
  • koot
  • koot-webpack
  • koot-cli
  • koot-electron
  • koot-qiankun

根层代码库

  • camelcase v7
  • chalk v5
  • inquirer v9

koot

  • chalk v5
  • execa v6
  • inquirer v9
  • is-port-reachable v4
  • ora v6
  • os-locale v6

koot-cli

  • chalk v5
  • latest-version v7
  • npm-email v4
  • ora v6
  • os-locale v6
  • package-json v8

判断项目类型决定,如果是 ESM 添加

output: {
    chunkFormat: 'module',
    chunkLoading: 'import',
}

package.json

{
    "type": "module"
}

正则替换

^[a-zA-Z]+[ ]*(.+?)[ ]*=[ ]*require\((.+?)\) -> import $1 from $2


其他问题

import { dirname } from 'path';
import { fileURLToPath } from 'url';

export default () => dirname(fileURLToPath(import.meta.url));

__filename

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions