Skip to content

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

@canyuegongzi

Description

@canyuegongzi

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

Metadata

Metadata

Assignees

Labels

🐞 bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions