Skip to content
This repository was archived by the owner on Aug 5, 2021. It is now read-only.

Commit e8e1c3e

Browse files
feat: remove old API
BREAKING CHANGE: the `entry` named export no longer exists, so users should use the API as documented in the README. See #8.
1 parent 7dbf0b0 commit e8e1c3e

File tree

2 files changed

+18
-31
lines changed

2 files changed

+18
-31
lines changed

index.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
type Config = string | Array<string> | { include: Array<string>, exclude: Array<string> };
1+
/* @flow */
2+
3+
type Config = string | Array<string> | { include?: Array<string>, exclude?: Array<string>, exports?: boolean };
24

35
import glob from 'glob';
46

5-
export const entry = '\0rollup-plugin-multi-entry:entry-point';
7+
const entry = '\0rollup-plugin-multi-entry:entry-point';
68

79
export default function multiEntry(config: ?Config=null) {
810
let include = [];
@@ -15,7 +17,8 @@ export default function multiEntry(config: ?Config=null) {
1517
} else if (Array.isArray(config)) {
1618
include = config;
1719
} else {
18-
({ include = [], exclude = [] } = config);
20+
include = config.include || [];
21+
exclude = config.exclude || [];
1922
if (config.exports === false) {
2023
exporter = path => `import ${JSON.stringify(path)};`;
2124
}
@@ -27,7 +30,7 @@ export default function multiEntry(config: ?Config=null) {
2730
}
2831

2932
return {
30-
options(options: {entry: string}) {
33+
options(options: { entry: ?string }) {
3134
if (options.entry && options.entry !== entry) {
3235
configure(options.entry);
3336
}

test/test.js

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import multiEntry, { entry } from '../';
1+
import multiEntry from '../';
22
import { ok } from 'assert';
33
import { rollup } from 'rollup';
44

@@ -14,48 +14,42 @@ function doesNotInclude(string, substring) {
1414
}
1515
}
1616

17-
function makeBundle(entries, useOldAPI) {
18-
return rollup(
19-
!useOldAPI ?
20-
{ entry: entries, plugins: [multiEntry()] } :
21-
{ entry, plugins: [multiEntry(entries)] }
22-
);
17+
function makeBundle(entries) {
18+
return rollup({ entry: entries, plugins: [multiEntry()] });
2319
}
2420

25-
function setupTests(options) {
26-
const useOldAPI = options ? options.useOldAPI : false;
27-
21+
describe('rollup-plugin-multi-entry', () => {
2822
it('takes a single file as input', () =>
29-
makeBundle('test/fixtures/0.js', useOldAPI).then(bundle => {
23+
makeBundle('test/fixtures/0.js').then(bundle => {
3024
includes(bundle.generate({ format: 'cjs' }).code, 'exports.zero = zero;');
3125
})
3226
);
3327

3428
it('takes an array of files as input', () =>
35-
makeBundle(['test/fixtures/0.js', 'test/fixtures/1.js'], useOldAPI).then(bundle => {
29+
makeBundle(['test/fixtures/0.js', 'test/fixtures/1.js']).then(bundle => {
3630
const code = bundle.generate({ format: 'cjs' }).code;
3731
includes(code, 'exports.zero = zero;');
3832
includes(code, 'exports.one = one;');
3933
})
4034
);
4135

4236
it('allows an empty array as input', () =>
43-
makeBundle([], useOldAPI).then(bundle => {
37+
makeBundle([]).then(bundle => {
4438
const code = bundle.generate({ format: 'cjs' }).code;
4539
doesNotInclude(code, 'exports');
4640
})
4741
);
4842

4943
it('takes a glob as input', () =>
50-
makeBundle('test/fixtures/{0,1}.js', useOldAPI).then(bundle => {
44+
makeBundle('test/fixtures/{0,1}.js').then(bundle => {
5145
const code = bundle.generate({ format: 'cjs' }).code;
5246
includes(code, 'exports.zero = zero;');
5347
includes(code, 'exports.one = one;');
5448
})
5549
);
5650

5751
it('takes an array of globs as input', () =>
58-
makeBundle(['test/fixtures/{0,}.js', 'test/fixtures/{1,}.js'], useOldAPI).then(bundle => {
52+
makeBundle(['test/fixtures/{0,}.js', 'test/fixtures/{1,}.js']).then(bundle => {
5953
const code = bundle.generate({ format: 'cjs' }).code;
6054
includes(code, 'exports.zero = zero;');
6155
includes(code, 'exports.one = one;');
@@ -64,8 +58,7 @@ function setupTests(options) {
6458

6559
it('takes an {include,exclude} object as input', () =>
6660
makeBundle(
67-
{ include: ['test/fixtures/*.js'], exclude: ['test/fixtures/1.js'] },
68-
useOldAPI
61+
{ include: ['test/fixtures/*.js'], exclude: ['test/fixtures/1.js'] }
6962
).then(bundle => {
7063
const code = bundle.generate({ format: 'cjs' }).code;
7164
includes(code, 'exports.zero = zero;');
@@ -75,21 +68,12 @@ function setupTests(options) {
7568

7669
it('allows to prevent exporting', () =>
7770
makeBundle(
78-
{ include: ['test/fixtures/*.js'], exports: false },
79-
useOldAPI
71+
{ include: ['test/fixtures/*.js'], exports: false }
8072
).then(bundle => {
8173
const code = bundle.generate({ format: 'iife' }).code;
8274
includes(code, `console.log('Hello, 2');`)
8375
doesNotInclude(code, 'zero');
8476
doesNotInclude(code, 'one');
8577
})
8678
);
87-
}
88-
89-
describe('rollup-plugin-multi-entry', () => {
90-
setupTests({ useOldAPI: false });
91-
92-
describe('with old API', () => {
93-
setupTests({ useOldAPI: true });
94-
});
9579
});

0 commit comments

Comments
 (0)