rollup#ExternalOption TypeScript Examples
The following examples show how to use
rollup#ExternalOption.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: config.test.ts From backstage with Apache License 2.0 | 6 votes |
describe('makeRollupConfigs', () => {
it('should mark external modules correctly', async () => {
const importerPath = '/some/path.ts'; // when specified we don't care about the path
const [config] = await makeRollupConfigs({
outputs: new Set([Output.cjs]),
});
const external = config.external as Exclude<
ExternalOption,
string | RegExp | (string | RegExp)[]
>;
expect(external('foo', importerPath, false)).toBe(true);
expect(external('./foo', importerPath, false)).toBe(false);
expect(external('/foo', importerPath, false)).toBe(false);
expect(external('.\\foo', importerPath, false)).toBe(false);
expect(external('c:\\foo', importerPath, false)).toBe(false);
expect(external('@foo/bar', importerPath, false)).toBe(true);
expect(external('../foo', importerPath, false)).toBe(false);
// Modules without an importer are entry points, i.e. not external
expect(external('foo', undefined, false)).toBe(false);
expect(external('./foo', undefined, false)).toBe(false);
expect(external('/foo', undefined, false)).toBe(false);
expect(external('.\\foo', undefined, false)).toBe(false);
expect(external('c:\\foo', undefined, false)).toBe(false);
expect(external('@foo/bar', undefined, false)).toBe(false);
expect(external('../foo', undefined, false)).toBe(false);
// After modules have been resolved they're never marked as external
expect(external('foo', importerPath, true)).toBe(false);
expect(external('./foo', importerPath, true)).toBe(false);
expect(external('/foo', importerPath, true)).toBe(false);
expect(external('.\\foo', importerPath, true)).toBe(false);
expect(external('c:\\foo', importerPath, true)).toBe(false);
expect(external('@foo/bar', importerPath, true)).toBe(false);
expect(external('../foo', importerPath, true)).toBe(false);
});
});