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

Prepare for 1.0 #37

Merged
merged 3 commits into from
Dec 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"presets": [
["env", { "targets": { "node": "current" } }]
["@babel/env", { "targets": { "node": "current" } }]
],
"plugins": [
"transform-flow-strip-types"
"@babel/transform-flow-strip-types"
]
}
}
6 changes: 6 additions & 0 deletions .huskyrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"hooks": {
"commit-msg": "commitlint -e $GIT_PARAMS",
"pre-commit": "lint-staged"
}
}
6 changes: 6 additions & 0 deletions .lintstagedrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"*.js": [
"prettier --write",
"git add"
]
}
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ sudo: false
language: node_js
cache: yarn
node_js:
- '10'
- '8'
- '6'
- '4'
script:
- ./script/lint-commits
- ./script/prettier-check
Expand Down
37 changes: 15 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,8 @@
"build": "rm -rf dist && rollup -c",
"pretest": "yarn run flow && yarn run build",
"test": "mocha",
"commitmsg": "commitlint -e $GIT_PARAMS",
"precommit": "lint-staged",
"prepublish": "yarn test"
},
"lint-staged": {
"*.js": [
"prettier --write",
"git add"
]
"prepare": "yarn build",
"prepublishOnly": "yarn test"
},
"repository": {
"type": "git",
Expand All @@ -39,20 +32,20 @@
"matched": "^1.0.2"
},
"devDependencies": {
"@commitlint/config-conventional": "^5.2.3",
"babel-core": "^6.26.0",
"babel-plugin-transform-flow-strip-types": "^6.14.0",
"babel-preset-env": "^1.6.1",
"babel-register": "^6.14.0",
"commitlint": "^5.2.8",
"flow-bin": "0.63.1",
"globby": "^7.1.1",
"husky": "^0.14.3",
"lint-staged": "^6.0.0",
"mocha": "^4.1.0",
"@babel/core": "^7.2.0",
"@babel/plugin-transform-flow-strip-types": "^7.2.0",
"@babel/preset-env": "^7.2.0",
"@babel/register": "^7.0.0",
"@commitlint/config-conventional": "^7.1.2",
"commitlint": "^7.2.1",
"flow-bin": "^0.87.0",
"globby": "^8.0.1",
"husky": "^1.2.0",
"lint-staged": "^8.1.0",
"mocha": "^5.2.0",
"prettier": "^1.9.2",
"prettier-check": "^2.0.0",
"rollup": "^0.53.3",
"rollup-plugin-babel": "^3.0.3"
"rollup": "^0.67.4",
"rollup-plugin-babel": "^4.0.3"
}
}
4 changes: 2 additions & 2 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ export default {
input: 'src/index.js',
plugins: [
babel({
presets: [['env', { targets: { node: '4' }, modules: false }]],
plugins: ['transform-flow-strip-types'],
presets: [['@babel/env', { targets: { node: '4' }, modules: false }]],
plugins: ['@babel/transform-flow-strip-types'],
babelrc: false
})
],
Expand Down
2 changes: 1 addition & 1 deletion test/mocha.opts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
--require babel-register
--require @babel/register
106 changes: 44 additions & 62 deletions test/test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import multiEntry from '../';
import { ok } from 'assert';
import { rollup } from 'rollup';
import multiEntry from '../';

function includes(string, substring) {
if (string.indexOf(substring) === -1) {
Expand All @@ -24,79 +24,61 @@ function doesNotInclude(string, substring) {
}
}

function makeBundle(entries) {
return rollup({ input: entries, plugins: [multiEntry()] });
function getCodeFromBundle(entries) {
return rollup({ input: entries, plugins: [multiEntry()] })
.then(bundle => bundle.generate({ format: 'cjs' }))
.then(generated =>
generated.output ? generated.output[0].code : generated.code
);
}

describe('rollup-plugin-multi-entry', () => {
it('takes a single file as input', () => {
return makeBundle('test/fixtures/0.js').then(bundle => {
return bundle.generate({ format: 'cjs' }).then(({ code }) => {
includes(code, 'exports.zero = zero;');
});
});
});
it('takes a single file as input', () =>
getCodeFromBundle('test/fixtures/0.js').then(code =>
includes(code, 'exports.zero = zero;')
));

it('takes an array of files as input', () => {
return makeBundle(['test/fixtures/0.js', 'test/fixtures/1.js']).then(
bundle => {
return bundle.generate({ format: 'cjs' }).then(({ code }) => {
includes(code, 'exports.zero = zero;');
includes(code, 'exports.one = one;');
});
it('takes an array of files as input', () =>
getCodeFromBundle(['test/fixtures/0.js', 'test/fixtures/1.js']).then(
code => {
includes(code, 'exports.zero = zero;');
includes(code, 'exports.one = one;');
}
);
});
));

it('allows an empty array as input', () => {
return makeBundle([]).then(bundle => {
return bundle.generate({ format: 'cjs' }).then(({ code }) => {
doesNotInclude(code, 'exports');
});
});
});
it('allows an empty array as input', () =>
getCodeFromBundle([]).then(code => doesNotInclude(code, 'exports')));

it('takes a glob as input', () => {
return makeBundle('test/fixtures/{0,1}.js').then(bundle => {
return bundle.generate({ format: 'cjs' }).then(({ code }) => {
it('takes a glob as input', () =>
getCodeFromBundle('test/fixtures/{0,1}.js').then(code => {
includes(code, 'exports.zero = zero;');
includes(code, 'exports.one = one;');
}));

it('takes an array of globs as input', () =>
getCodeFromBundle(['test/fixtures/{0,}.js', 'test/fixtures/{1,}.js']).then(
code => {
includes(code, 'exports.zero = zero;');
includes(code, 'exports.one = one;');
});
});
});

it('takes an array of globs as input', () => {
return makeBundle(['test/fixtures/{0,}.js', 'test/fixtures/{1,}.js']).then(
bundle => {
return bundle.generate({ format: 'cjs' }).then(({ code }) => {
includes(code, 'exports.zero = zero;');
includes(code, 'exports.one = one;');
});
}
);
});
));

it('takes an {include,exclude} object as input', () => {
return makeBundle({
it('takes an {include,exclude} object as input', () =>
getCodeFromBundle({
include: ['test/fixtures/*.js'],
exclude: ['test/fixtures/1.js']
}).then(bundle => {
return bundle.generate({ format: 'cjs' }).then(({ code }) => {
includes(code, 'exports.zero = zero;');
doesNotInclude(code, 'exports.one = one;');
});
});
});
}).then(code => {
includes(code, 'exports.zero = zero;');
doesNotInclude(code, 'exports.one = one;');
}));

it('allows to prevent exporting', () => {
return makeBundle({ include: ['test/fixtures/*.js'], exports: false }).then(
bundle => {
return bundle.generate({ format: 'cjs' }).then(({ code }) => {
includes(code, `console.log('Hello, 2');`);
doesNotInclude(code, 'zero');
doesNotInclude(code, 'one');
});
}
);
});
it('allows to prevent exporting', () =>
getCodeFromBundle({
include: ['test/fixtures/*.js'],
exports: false
}).then(code => {
includes(code, `console.log('Hello, 2');`);
doesNotInclude(code, 'zero');
doesNotInclude(code, 'one');
}));
});