Skip to content

Commit 1548cea

Browse files
committed
chore: use rslib config to get entryjs
1 parent bb95ba8 commit 1548cea

File tree

6 files changed

+23
-26
lines changed

6 files changed

+23
-26
lines changed

e2e/cases/alias/index.test.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ test('alias in js', async () => {
99

1010
const fixturePath = join(__dirname, 'js');
1111
const rslibConfig = await loadConfig(join(fixturePath, 'rslib.config.ts'));
12-
const instance = await build(rslibConfig);
13-
const results = await getEntryJsResults(instance);
12+
await build(rslibConfig);
13+
const results = await getEntryJsResults(rslibConfig);
1414

1515
expect(results.esm).toContain('hello world');
1616
expect(results.cjs).toContain('hello world');
@@ -21,8 +21,8 @@ test('alias in ts', async () => {
2121

2222
const fixturePath = join(__dirname, 'ts');
2323
const rslibConfig = await loadConfig(join(fixturePath, 'rslib.config.ts'));
24-
const instance = await build(rslibConfig);
25-
const results = await getEntryJsResults(instance);
24+
await build(rslibConfig);
25+
const results = await getEntryJsResults(rslibConfig);
2626

2727
expect(results.esm).toContain('hello world');
2828
expect(results.cjs).toContain('hello world');

e2e/cases/define/index.test.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ test('define in js', async () => {
99

1010
const fixturePath = join(__dirname, 'js');
1111
const rslibConfig = await loadConfig(join(fixturePath, 'rslib.config.ts'));
12-
const instance = await build(rslibConfig);
13-
const results = await getEntryJsResults(instance);
12+
await build(rslibConfig);
13+
const results = await getEntryJsResults(rslibConfig);
1414

1515
expect(results.esm).not.toContain('console.info(VERSION)');
1616
expect(results.esm).toContain('1.0.0');
@@ -23,8 +23,8 @@ test('define in ts', async () => {
2323

2424
const fixturePath = join(__dirname, 'ts');
2525
const rslibConfig = await loadConfig(join(fixturePath, 'rslib.config.ts'));
26-
const instance = await build(rslibConfig);
27-
const results = await getEntryJsResults(instance);
26+
await build(rslibConfig);
27+
const results = await getEntryJsResults(rslibConfig);
2828

2929
expect(results.esm).not.toContain('console.info(VERSION)');
3030
expect(results.esm).toContain('1.0.0');

e2e/scripts/shared.ts

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { join } from 'node:path';
2-
import type { LibConfig, RsbuildInstance } from '@rslib/core';
2+
import type { LibConfig, RslibConfig } from '@rslib/core';
33
import { globContentJSON } from '#helper';
44

55
export function generateBundleEsmConfig(cwd: string): LibConfig {
@@ -24,20 +24,19 @@ export function generateBundleCjsConfig(cwd: string): LibConfig {
2424
};
2525
}
2626

27-
export async function getEntryJsResults(instance: RsbuildInstance[]) {
27+
export async function getEntryJsResults(rslibConfig: RslibConfig) {
2828
const results: Record<string, string> = {};
2929

30-
for (let i = 0; i < instance.length; i++) {
31-
const result = await globContentJSON(instance[i]!.context.distPath, {
30+
for (const libConfig of rslibConfig.lib) {
31+
const result = await globContentJSON(libConfig?.output?.distPath?.root!, {
3232
absolute: true,
3333
ignore: ['/**/*.map'],
3434
});
3535

3636
const entryJs = Object.keys(result).find((file) => file.endsWith('.js'));
37-
const format = instance[i]!.context.distPath.split('/').pop();
3837

3938
if (entryJs) {
40-
results[format!] = result[entryJs]!;
39+
results[libConfig.format!] = result[entryJs]!;
4140
}
4241
}
4342

packages/core/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"prebundle": "prebundle"
3939
},
4040
"dependencies": {
41-
"@rsbuild/core": "0.7.9"
41+
"@rsbuild/core": "0.7.10"
4242
},
4343
"devDependencies": {
4444
"@rslib/tsconfig": "workspace:*",

packages/core/src/index.ts

-2
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,3 @@ export * from './utils/helper';
99
export * from './types/config';
1010

1111
export const version = RSLIB_VERSION;
12-
13-
export type { RsbuildInstance } from '@rsbuild/core';

pnpm-lock.yaml

+9-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)