@rslib/core 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/rslib.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { logger, prepareCli, runCli } from '../dist/main.js';
2
+ import { logger, prepareCli, runCli } from '../dist/index.js';
3
3
 
4
4
  async function main() {
5
5
  prepareCli();
@@ -460,7 +460,7 @@ async function calcLongestCommonPath(absPaths) {
460
460
  return lca;
461
461
  }
462
462
  const readPackageJson = (rootPath)=>{
463
- const pkgJsonPath = external_node_path_namespaceObject["default"].resolve(rootPath, './package.json');
463
+ const pkgJsonPath = external_node_path_namespaceObject["default"].join(rootPath, './package.json');
464
464
  if (!external_node_fs_namespaceObject["default"].existsSync(pkgJsonPath)) {
465
465
  dist_logger.warn(`package.json does not exist in the ${rootPath} directory`);
466
466
  return;
@@ -525,7 +525,7 @@ function prepareCli() {
525
525
  if (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) {
526
526
  console.log();
527
527
  }
528
- dist_logger.greet(` ${`Rslib v${"0.0.2"}`}\n`);
528
+ dist_logger.greet(` ${`Rslib v${"0.0.3"}`}\n`);
529
529
  }
530
530
 
531
531
  ;// CONCATENATED MODULE: external "../compiled/commander/index.js"
@@ -755,11 +755,10 @@ const resolveConfigPath = (root, customConfig)=>{
755
755
  if (configFilePath) {
756
756
  return configFilePath;
757
757
  }
758
- return undefined;
758
+ throw new Error(`${DEFAULT_CONFIG_NAME} not found in ${root}`);
759
759
  };
760
- async function loadConfig(customConfig, envMode) {
761
- const root = process.cwd();
762
- const configFilePath = resolveConfigPath(root, customConfig);
760
+ async function loadConfig({ cwd = process.cwd(), path, envMode }) {
761
+ const configFilePath = resolveConfigPath(cwd, path);
763
762
  const { content } = await (0,core_namespaceObject.loadConfig)({
764
763
  cwd: (0,external_node_path_namespaceObject.dirname)(configFilePath),
765
764
  path: configFilePath,
@@ -900,9 +899,9 @@ const composeFormatConfig = (format)=>{
900
899
  throw new Error(`Unsupported format: ${format}`);
901
900
  }
902
901
  };
903
- const composeAutoExtensionConfig = (format, autoExtension, pkgJson)=>{
902
+ const composeAutoExtensionConfig = (config, autoExtension, pkgJson)=>{
904
903
  const { jsExtension, dtsExtension } = getDefaultExtension({
905
- format,
904
+ format: config.format,
906
905
  pkgJson,
907
906
  autoExtension
908
907
  });
@@ -910,7 +909,8 @@ const composeAutoExtensionConfig = (format, autoExtension, pkgJson)=>{
910
909
  config: {
911
910
  output: {
912
911
  filename: {
913
- js: `[name]${jsExtension}`
912
+ js: `[name]${jsExtension}`,
913
+ ...config.output?.filename
914
914
  }
915
915
  }
916
916
  },
@@ -985,8 +985,8 @@ const composeEntryConfig = async (entries, bundle, root)=>{
985
985
  for (const key of Object.keys(entries)){
986
986
  const entry = entries[key];
987
987
  // Entries in bundleless mode could be:
988
- // 1. A string of glob pattern: { entry: { main: 'src/*.ts' } }
989
- // 2. An array of glob patterns: { entry: { main: ['src/*.ts', 'src/*.tsx'] } }
988
+ // 1. A string of glob pattern: { entry: { index: 'src/*.ts' } }
989
+ // 2. An array of glob patterns: { entry: { index: ['src/*.ts', 'src/*.tsx'] } }
990
990
  // Not supported for now: entry description object
991
991
  const entryFiles = Array.isArray(entry) ? entry : typeof entry === 'string' ? [
992
992
  entry
@@ -1106,7 +1106,7 @@ async function composeLibRsbuildConfig(libConfig, rsbuildConfig, configPath) {
1106
1106
  const pkgJson = readPackageJson(rootPath);
1107
1107
  const { format, autoExtension = true, autoExternal = true } = config;
1108
1108
  const formatConfig = composeFormatConfig(format);
1109
- const { config: autoExtensionConfig, jsExtension, dtsExtension } = composeAutoExtensionConfig(format, autoExtension, pkgJson);
1109
+ const { config: autoExtensionConfig, jsExtension, dtsExtension } = composeAutoExtensionConfig(config, autoExtension, pkgJson);
1110
1110
  const bundleConfig = composeBundleConfig(jsExtension, config.bundle);
1111
1111
  const targetConfig = composeTargetConfig(config.output?.target);
1112
1112
  const syntaxConfig = composeSyntaxConfig(config.output?.syntax, config.output?.target);
@@ -1190,7 +1190,7 @@ const applyCommonOptions = (command)=>{
1190
1190
  command.option('-c --config <config>', 'specify the configuration file, can be a relative or absolute path').option('--env-mode <mode>', 'specify the env mode to load the `.env.[mode]` file');
1191
1191
  };
1192
1192
  function runCli() {
1193
- commander_index_js_namespaceObject.program.name('rslib').usage('<command> [options]').version("0.0.2");
1193
+ commander_index_js_namespaceObject.program.name('rslib').usage('<command> [options]').version("0.0.3");
1194
1194
  const buildCommand = commander_index_js_namespaceObject.program.command('build');
1195
1195
  const inspectCommand = commander_index_js_namespaceObject.program.command('inspect');
1196
1196
  [
@@ -1199,7 +1199,10 @@ function runCli() {
1199
1199
  ].forEach(applyCommonOptions);
1200
1200
  buildCommand.option('-w --watch', 'turn on watch mode, watch for changes and rebuild').description('build the library for production').action(async (options)=>{
1201
1201
  try {
1202
- const rslibConfig = await loadConfig(options.config, options.envMode);
1202
+ const rslibConfig = await loadConfig({
1203
+ path: options.config,
1204
+ envMode: options.envMode
1205
+ });
1203
1206
  await build(rslibConfig, options);
1204
1207
  } catch (err) {
1205
1208
  dist_logger.error('Failed to build.');
@@ -1210,7 +1213,10 @@ function runCli() {
1210
1213
  inspectCommand.description('inspect the Rslib / Rsbuild / Rspack configs').option('--env <env>', 'specify env mode', 'development').option('--output <output>', 'specify inspect content output path', './').option('--verbose', 'show full function definitions in output').action(async (options)=>{
1211
1214
  try {
1212
1215
  // TODO: inspect should output Rslib's config
1213
- const rslibConfig = await loadConfig(options.config, options.envMode);
1216
+ const rslibConfig = await loadConfig({
1217
+ path: options.config,
1218
+ envMode: options.envMode
1219
+ });
1214
1220
  const rsbuildInstance = await initRsbuild(rslibConfig);
1215
1221
  await rsbuildInstance.inspectConfig({
1216
1222
  mode: options.mode,
@@ -1233,6 +1239,6 @@ function runCli() {
1233
1239
 
1234
1240
 
1235
1241
 
1236
- const src_version = "0.0.2";
1242
+ const src_version = "0.0.3";
1237
1243
 
1238
1244
  export { build, defineConfig, loadConfig, dist_logger as logger, prepareCli, runCli, src_version as version };
@@ -8,7 +8,11 @@ export declare function defineConfig(config: RslibConfig): RslibConfig;
8
8
  export declare function defineConfig(config: RslibConfigSyncFn): RslibConfigSyncFn;
9
9
  export declare function defineConfig(config: RslibConfigAsyncFn): RslibConfigAsyncFn;
10
10
  export declare function defineConfig(config: RslibConfigExport): RslibConfigExport;
11
- export declare function loadConfig(customConfig?: string, envMode?: string): Promise<RslibConfig>;
11
+ export declare function loadConfig({ cwd, path, envMode, }: {
12
+ cwd?: string;
13
+ path?: string;
14
+ envMode?: string;
15
+ }): Promise<RslibConfig>;
12
16
  export declare const composeAutoExternalConfig: (options: {
13
17
  autoExternal: AutoExternal;
14
18
  pkgJson?: PkgJson;
@@ -1,4 +1,4 @@
1
- import type { Format, PkgJson } from 'src/types';
1
+ import type { Format, PkgJson } from '../types';
2
2
  export declare const getDefaultExtension: (options: {
3
3
  format: Format;
4
4
  pkgJson?: PkgJson;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rslib/core",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "The Rspack-based library build tool.",
5
5
  "homepage": "https://rslib.dev",
6
6
  "bugs": {
@@ -16,11 +16,11 @@
16
16
  "exports": {
17
17
  ".": {
18
18
  "types": "./dist-types/index.d.ts",
19
- "default": "./dist/main.js"
19
+ "default": "./dist/index.js"
20
20
  },
21
21
  "./package.json": "./package.json"
22
22
  },
23
- "main": "./dist/main.js",
23
+ "main": "./dist/index.js",
24
24
  "types": "./dist-types/index.d.ts",
25
25
  "bin": {
26
26
  "rslib": "./bin/rslib.js"
@@ -32,8 +32,8 @@
32
32
  "compiled"
33
33
  ],
34
34
  "dependencies": {
35
- "@rsbuild/core": "1.0.1-beta.11",
36
- "rsbuild-plugin-dts": "0.0.2"
35
+ "@rsbuild/core": "1.0.1-beta.16",
36
+ "rsbuild-plugin-dts": "0.0.3"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@types/fs-extra": "^11.0.4",
@@ -43,7 +43,7 @@
43
43
  "memfs": "^4.11.1",
44
44
  "picocolors": "1.0.1",
45
45
  "prebundle": "1.1.0",
46
- "rslib": "npm:@rslib/core@0.0.0",
46
+ "rslib": "npm:@rslib/core@0.0.2",
47
47
  "rslog": "^1.2.2",
48
48
  "typescript": "^5.5.4",
49
49
  "@rslib/tsconfig": "0.0.1"