web-infra-dev / rslib

The Rsbuild powered package build tool.
https://lib.rsbuild.dev/
MIT License
386 stars 19 forks source link

[Bug]: Error when calling build via JavaScript API #356

Open canyuegongzi opened 19 hours ago

canyuegongzi commented 19 hours ago

Version

"@rslib/core": "^0.0.15",

Details

错误:

× Failed to build.
error   TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined

示例代码:

import {LibConfig, RslibConfig, build as rsLibBuild} from "@rslib/core";
async function buildFun(): Promise<any> {
  console.log("build")
  const defaultConfig: RslibConfig = {
    lib: [
      {
        format: 'esm',
        source: {
          entry: {
            index: [path.resolve(process.cwd(), './src/**')],
          }
        },
        output: {
          distPath: {
            root: path.resolve(process.cwd(), './lib/esm'),
          }
        },
      }
    ],
    plugins: [
      pluginReact({
        swcReactOptions: {
          runtime: 'classic',
        },
      }),
      pluginSass(),
    ],
  }
  console.log("构建配置")
  console.log(JSON.stringify(defaultConfig, null, 2))
  await rsLibBuild(defaultConfig);
}

Reproduce link

https://github.com/canyuegongzi/rslib-example-bug

Reproduce Steps

1: npm install 2: npm run build:script

Timeless0911 commented 19 hours ago

Thanks, the js api of Rslib is not public yet. We will track it and write clear documentation when it is available.

canyuegongzi commented 19 hours ago

Thanks, the js api of Rslib is not public yet. We will track it and write clear documentation when it is available.

ok