Skip to content

新版 #bfsp.ts 的格式 #34

@Gaubee

Description

@Gaubee
const npm = new NpmPackageManager("yarn@1.22.8");
const git = new GitManager();

import { tui } from "@bfchain/pkgm-tui";

// [features]
// android = ["ndk-sys"]
// v2 = ["xxx/android"]
// default = ["android"]

// #cjs
// #node
// #default

export default defineConfig((info) => {
  // .bfsp/${profles}/package.json
  /**
   * 默认情况下,生成
   * workspace.writeFile("./package.json",{})
   * workspace.writeFile("./tsconfig-${profles}.json",{})
   * workspace会将文件写到 .bfsp/${profles}/ 路径下
   *
   * 在use模式下,会将 ?/package.json,?/tsconfig-${profles}.json 链接到 /package.json,/tsconfig.json 路径下
   */

  return {
    profiles: {
      use: info.profiles ?? ["node", "cjs"],
      define: {
        format: ["cjs", "esm"],
        runtime: {
          node: {
            before: [importMapPlugin({})],
          },
          deno: {
            before: [importMapPlugin({})],
          },
          web: {
            before: [importMapPlugin({})],
          },
        },
      },
      tasks: {
        "npm-build": [
          ["node", "cjs"],
          ["node", "esm"],
          ["web", "cjs"],
          ["web", "esm"],
        ],
      },
    },
    before: [
      importMapPlugin({
        // tsconfig.json 的path
        name1: pnpm.install({}), // 执行 npm install 或者 yarn add
        name2: npm.installDev({}), // 执行 npm install --dev 或者 yarn add --dev
        name3: git.submodule({
          "./path/to/submoule": "github.com/xx/xx",
        }),
        "@bfchain/util-xxx": `../xxx`,
      }),
    ],
    after:
      info.mode === "prod"
        ? [
            esbuildBundlePlugin({
              taskId: info.pid,// 用于清理文件夹的时候,避免重复清理
              format: info.profiles.get("format") ?? "cjs",
              platform: info.profiles.get("runtime") ?? "browser",
            }).par(),
            npmBundlePlugin({}),
          ]
        : [],
    //   server:[tui()]
    // server:[{
    //     in: StreamRead(),
    //     out: StreamWrite()
    // }]
    // - gitignore 不再需要这个配置项,在 new GitManager 的时候就会初始化好:.git仓库 与 .gitignore文件
    // - npmignore 不再需要这个配置项,在 new NpmPackageManager 的时候就会初始化好:package.json文件 与 .npmignore 文件
  };
});

这样一来,package-lock.json文件yarn.lock文件就不该 ignore 掉

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions