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

Commit cb696e5

Browse files
authored
Prepare for 1.0 (#37)
* chore(dependencies): upgrade dependencies * chore(package): add prepare script This will enable direct installation from Github * chore(tests): make tests 1.0 compatible This will make the tests compatible with version 1.0. Note that this there is still a change needed in rollup to properly sanitize chunk ids
1 parent e61288a commit cb696e5

9 files changed

Lines changed: 2808 additions & 1132 deletions

File tree

.babelrc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"presets": [
3-
["env", { "targets": { "node": "current" } }]
3+
["@babel/env", { "targets": { "node": "current" } }]
44
],
55
"plugins": [
6-
"transform-flow-strip-types"
6+
"@babel/transform-flow-strip-types"
77
]
8-
}
8+
}

.huskyrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"hooks": {
3+
"commit-msg": "commitlint -e $GIT_PARAMS",
4+
"pre-commit": "lint-staged"
5+
}
6+
}

.lintstagedrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"*.js": [
3+
"prettier --write",
4+
"git add"
5+
]
6+
}

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ sudo: false
22
language: node_js
33
cache: yarn
44
node_js:
5+
- '10'
56
- '8'
67
- '6'
7-
- '4'
88
script:
99
- ./script/lint-commits
1010
- ./script/prettier-check

package.json

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,8 @@
99
"build": "rm -rf dist && rollup -c",
1010
"pretest": "yarn run flow && yarn run build",
1111
"test": "mocha",
12-
"commitmsg": "commitlint -e $GIT_PARAMS",
13-
"precommit": "lint-staged",
14-
"prepublish": "yarn test"
15-
},
16-
"lint-staged": {
17-
"*.js": [
18-
"prettier --write",
19-
"git add"
20-
]
12+
"prepare": "yarn build",
13+
"prepublishOnly": "yarn test"
2114
},
2215
"repository": {
2316
"type": "git",
@@ -39,20 +32,20 @@
3932
"matched": "^1.0.2"
4033
},
4134
"devDependencies": {
42-
"@commitlint/config-conventional": "^5.2.3",
43-
"babel-core": "^6.26.0",
44-
"babel-plugin-transform-flow-strip-types": "^6.14.0",
45-
"babel-preset-env": "^1.6.1",
46-
"babel-register": "^6.14.0",
47-
"commitlint": "^5.2.8",
48-
"flow-bin": "0.63.1",
49-
"globby": "^7.1.1",
50-
"husky": "^0.14.3",
51-
"lint-staged": "^6.0.0",
52-
"mocha": "^4.1.0",
35+
"@babel/core": "^7.2.0",
36+
"@babel/plugin-transform-flow-strip-types": "^7.2.0",
37+
"@babel/preset-env": "^7.2.0",
38+
"@babel/register": "^7.0.0",
39+
"@commitlint/config-conventional": "^7.1.2",
40+
"commitlint": "^7.2.1",
41+
"flow-bin": "^0.87.0",
42+
"globby": "^8.0.1",
43+
"husky": "^1.2.0",
44+
"lint-staged": "^8.1.0",
45+
"mocha": "^5.2.0",
5346
"prettier": "^1.9.2",
5447
"prettier-check": "^2.0.0",
55-
"rollup": "^0.53.3",
56-
"rollup-plugin-babel": "^3.0.3"
48+
"rollup": "^0.67.4",
49+
"rollup-plugin-babel": "^4.0.3"
5750
}
5851
}

rollup.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ export default {
66
input: 'src/index.js',
77
plugins: [
88
babel({
9-
presets: [['env', { targets: { node: '4' }, modules: false }]],
10-
plugins: ['transform-flow-strip-types'],
9+
presets: [['@babel/env', { targets: { node: '4' }, modules: false }]],
10+
plugins: ['@babel/transform-flow-strip-types'],
1111
babelrc: false
1212
})
1313
],

test/mocha.opts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
--require babel-register
1+
--require @babel/register

test/test.js

Lines changed: 44 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import multiEntry from '../';
21
import { ok } from 'assert';
32
import { rollup } from 'rollup';
3+
import multiEntry from '../';
44

55
function includes(string, substring) {
66
if (string.indexOf(substring) === -1) {
@@ -24,79 +24,61 @@ function doesNotInclude(string, substring) {
2424
}
2525
}
2626

27-
function makeBundle(entries) {
28-
return rollup({ input: entries, plugins: [multiEntry()] });
27+
function getCodeFromBundle(entries) {
28+
return rollup({ input: entries, plugins: [multiEntry()] })
29+
.then(bundle => bundle.generate({ format: 'cjs' }))
30+
.then(generated =>
31+
generated.output ? generated.output[0].code : generated.code
32+
);
2933
}
3034

3135
describe('rollup-plugin-multi-entry', () => {
32-
it('takes a single file as input', () => {
33-
return makeBundle('test/fixtures/0.js').then(bundle => {
34-
return bundle.generate({ format: 'cjs' }).then(({ code }) => {
35-
includes(code, 'exports.zero = zero;');
36-
});
37-
});
38-
});
36+
it('takes a single file as input', () =>
37+
getCodeFromBundle('test/fixtures/0.js').then(code =>
38+
includes(code, 'exports.zero = zero;')
39+
));
3940

40-
it('takes an array of files as input', () => {
41-
return makeBundle(['test/fixtures/0.js', 'test/fixtures/1.js']).then(
42-
bundle => {
43-
return bundle.generate({ format: 'cjs' }).then(({ code }) => {
44-
includes(code, 'exports.zero = zero;');
45-
includes(code, 'exports.one = one;');
46-
});
41+
it('takes an array of files as input', () =>
42+
getCodeFromBundle(['test/fixtures/0.js', 'test/fixtures/1.js']).then(
43+
code => {
44+
includes(code, 'exports.zero = zero;');
45+
includes(code, 'exports.one = one;');
4746
}
48-
);
49-
});
47+
));
5048

51-
it('allows an empty array as input', () => {
52-
return makeBundle([]).then(bundle => {
53-
return bundle.generate({ format: 'cjs' }).then(({ code }) => {
54-
doesNotInclude(code, 'exports');
55-
});
56-
});
57-
});
49+
it('allows an empty array as input', () =>
50+
getCodeFromBundle([]).then(code => doesNotInclude(code, 'exports')));
5851

59-
it('takes a glob as input', () => {
60-
return makeBundle('test/fixtures/{0,1}.js').then(bundle => {
61-
return bundle.generate({ format: 'cjs' }).then(({ code }) => {
52+
it('takes a glob as input', () =>
53+
getCodeFromBundle('test/fixtures/{0,1}.js').then(code => {
54+
includes(code, 'exports.zero = zero;');
55+
includes(code, 'exports.one = one;');
56+
}));
57+
58+
it('takes an array of globs as input', () =>
59+
getCodeFromBundle(['test/fixtures/{0,}.js', 'test/fixtures/{1,}.js']).then(
60+
code => {
6261
includes(code, 'exports.zero = zero;');
6362
includes(code, 'exports.one = one;');
64-
});
65-
});
66-
});
67-
68-
it('takes an array of globs as input', () => {
69-
return makeBundle(['test/fixtures/{0,}.js', 'test/fixtures/{1,}.js']).then(
70-
bundle => {
71-
return bundle.generate({ format: 'cjs' }).then(({ code }) => {
72-
includes(code, 'exports.zero = zero;');
73-
includes(code, 'exports.one = one;');
74-
});
7563
}
76-
);
77-
});
64+
));
7865

79-
it('takes an {include,exclude} object as input', () => {
80-
return makeBundle({
66+
it('takes an {include,exclude} object as input', () =>
67+
getCodeFromBundle({
8168
include: ['test/fixtures/*.js'],
8269
exclude: ['test/fixtures/1.js']
83-
}).then(bundle => {
84-
return bundle.generate({ format: 'cjs' }).then(({ code }) => {
85-
includes(code, 'exports.zero = zero;');
86-
doesNotInclude(code, 'exports.one = one;');
87-
});
88-
});
89-
});
70+
}).then(code => {
71+
includes(code, 'exports.zero = zero;');
72+
doesNotInclude(code, 'exports.one = one;');
73+
}));
9074

91-
it('allows to prevent exporting', () => {
92-
return makeBundle({ include: ['test/fixtures/*.js'], exports: false }).then(
93-
bundle => {
94-
return bundle.generate({ format: 'cjs' }).then(({ code }) => {
95-
includes(code, `console.log('Hello, 2');`);
96-
doesNotInclude(code, 'zero');
97-
doesNotInclude(code, 'one');
98-
});
99-
}
100-
);
101-
});
75+
it('allows to prevent exporting', () =>
76+
getCodeFromBundle({
77+
include: ['test/fixtures/*.js'],
78+
exports: false
79+
}).then(code => {
80+
includes(code, `console.log('Hello, 2');`);
81+
doesNotInclude(code, 'zero');
82+
doesNotInclude(code, 'one');
83+
}));
10284
});

0 commit comments

Comments
 (0)