Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/rstack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"./config": {
"types": "./dist/configExports.d.ts",
"default": "./dist/configExports.js"
},
Comment thread
chenjiahan marked this conversation as resolved.
"./app": {
"types": "./dist/app.d.ts",
"default": "./dist/app.js"
Expand Down
1 change: 1 addition & 0 deletions packages/rstack/rslib.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export default defineConfig({
source: {
entry: {
index: './src/index.ts',
configExports: './src/configExports.ts',
rsbuildConfig: './src/rsbuildConfig.ts',
rslibConfig: './src/rslibConfig.ts',
rslintConfig: './src/rslintConfig.ts',
Expand Down
4 changes: 2 additions & 2 deletions packages/rstack/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ export type Configs = {
staged?: StagedConfig;
};

type LoadedRstackConfig = {
export type LoadedRstackConfig = {
configs: Configs;
filePath: string | null;
dependencies: string[];
};

type LoadRstackConfigOptions = {
export type LoadRstackConfigOptions = {
/**
* The path to the Rstack config file, can be a relative or absolute path.
* If `configFilePath` is not provided, the config path set by the CLI is used.
Expand Down
7 changes: 7 additions & 0 deletions packages/rstack/src/configExports.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/** Public configuration APIs exposed through `rstack/config`. */
export {
loadRstackConfig,
type Configs,
type LoadedRstackConfig,
type LoadRstackConfigOptions,
} from './config.ts';
7 changes: 7 additions & 0 deletions packages/rstack/tests/exports/config-subpath/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { expect, test } from 'rstack/test';

test('should expose only the config loader API from `rstack/config`', async () => {
const config = await import('rstack/config');

expect(Object.keys(config)).toEqual(['loadRstackConfig']);
});
12 changes: 12 additions & 0 deletions packages/rstack/tests/types/resolution-bundler/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,24 @@ import 'rstack/test/importMeta';
import 'rstack/types';
import { define } from 'rstack';
import { createRsbuild, defineConfig as defineAppConfig } from 'rstack/app';
import {
loadRstackConfig,
type Configs,
type LoadedRstackConfig,
type LoadRstackConfigOptions,
} from 'rstack/config';
import { defineConfig as defineLibConfig } from 'rstack/lib';
import { js, ts } from 'rstack/lint';
import { expect as importedExpect, test as importedTest } from 'rstack/test';

const appConfig = defineAppConfig({});
const libConfig = defineLibConfig({});
const loadOptions: LoadRstackConfigOptions = { configFilePath: 'rstack.config.ts' };
const loadedConfig: Promise<LoadedRstackConfig> = loadRstackConfig(loadOptions);
const configs: Configs = {};

void loadedConfig;
void configs;

createRsbuild({ config: appConfig });
define.app(appConfig);
Expand Down
12 changes: 12 additions & 0 deletions packages/rstack/tests/types/resolution-nodenext/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,24 @@ import 'rstack/test/importMeta';
import 'rstack/types';
import { define } from 'rstack';
import { createRsbuild, defineConfig as defineAppConfig } from 'rstack/app';
import {
loadRstackConfig,
type Configs,
type LoadedRstackConfig,
type LoadRstackConfigOptions,
} from 'rstack/config';
import { defineConfig as defineLibConfig } from 'rstack/lib';
import { js, ts } from 'rstack/lint';
import { expect as importedExpect, test as importedTest } from 'rstack/test';

const appConfig = defineAppConfig({});
const libConfig = defineLibConfig({});
const loadOptions: LoadRstackConfigOptions = { configFilePath: 'rstack.config.ts' };
const loadedConfig: Promise<LoadedRstackConfig> = loadRstackConfig(loadOptions);
const configs: Configs = {};

void loadedConfig;
void configs;

createRsbuild({ config: appConfig });
define.app(appConfig);
Expand Down