astro/packages/astro/test/astro-component-bundling.test.js
Bjorn Lu 04e624d062
Treeshake exported client components that are not imported (#6527)
* Treeshake exported client components that are not imported

* Fix plugin name

* Fix mdx test
2023-03-13 13:16:56 -04:00

20 lines
660 B
JavaScript

import { expect } from 'chai';
import { loadFixture } from './test-utils.js';
describe('Component bundling', () => {
let fixture;
before(async () => {
fixture = await loadFixture({ root: './fixtures/astro-component-bundling/' });
await fixture.build();
});
it('should treeshake FooComponent', async () => {
const astroChunkDir = await fixture.readdir('/_astro');
const manyComponentsChunkName = astroChunkDir.find((chunk) =>
chunk.startsWith('ManyComponents')
);
const manyComponentsChunkContent = await fixture.readFile(`/_astro/${manyComponentsChunkName}`);
expect(manyComponentsChunkContent).to.not.include('FooComponent');
});
});