11import { join } from 'node:path' ;
2- import { buildAndGetResults } from 'test-helper' ;
2+ import { buildAndGetResults , queryContent } from 'test-helper' ;
33import { expect , test } from 'vitest' ;
44
55test ( 'single entry bundle' , async ( ) => {
@@ -20,20 +20,55 @@ test('single entry bundle', async () => {
2020
2121test ( 'multiple entry bundle' , async ( ) => {
2222 const fixturePath = join ( __dirname , 'multiple' ) ;
23- const { files } = await buildAndGetResults ( { fixturePath } ) ;
23+ const { files, contents } = await buildAndGetResults ( { fixturePath } ) ;
2424
2525 expect ( files ) . toMatchInlineSnapshot ( `
2626 {
2727 "cjs": [
2828 "<ROOT>/tests/integration/entry/multiple/dist/cjs/bar.cjs",
29+ "<ROOT>/tests/integration/entry/multiple/dist/cjs/foo.cjs",
2930 "<ROOT>/tests/integration/entry/multiple/dist/cjs/index.cjs",
31+ "<ROOT>/tests/integration/entry/multiple/dist/cjs/shared.cjs",
3032 ],
3133 "esm": [
3234 "<ROOT>/tests/integration/entry/multiple/dist/esm/bar.js",
35+ "<ROOT>/tests/integration/entry/multiple/dist/esm/foo.js",
3336 "<ROOT>/tests/integration/entry/multiple/dist/esm/index.js",
37+ "<ROOT>/tests/integration/entry/multiple/dist/esm/shared.js",
3438 ],
3539 }
3640 ` ) ;
41+
42+ const index = queryContent ( contents . esm , 'index.js' , { basename : true } ) ;
43+ expect ( index ) . toMatchInlineSnapshot ( `
44+ "const shared = 'shared';
45+ const foo = 'foo' + shared;
46+ const src_rslib_entry_text = ()=>\`hello \${foo} \${shared}\`;
47+ export { src_rslib_entry_text as text };
48+ "
49+ ` ) ;
50+
51+ const foo = queryContent ( contents . esm , 'foo.js' , { basename : true } ) ;
52+ expect ( foo ) . toMatchInlineSnapshot ( `
53+ "const shared = 'shared';
54+ const foo = 'foo' + shared;
55+ export { foo };
56+ "
57+ ` ) ;
58+
59+ const bar = queryContent ( contents . esm , 'bar.js' , { basename : true } ) ;
60+ expect ( bar ) . toMatchInlineSnapshot ( `
61+ "const bar = 'bar';
62+ export { bar };
63+ "
64+ ` ) ;
65+
66+ const shared = queryContent ( contents . esm , 'shared.js' , { basename : true } ) ;
67+ expect ( shared ) . toMatchInlineSnapshot ( `
68+ "const shared = 'shared';
69+ export { shared };
70+ "
71+ ` ) ;
3772} ) ;
3873
3974test ( 'glob entry bundleless' , async ( ) => {
0 commit comments