Skip to content

Commit

Permalink
Merge branch 'master' into boneskull/rollup-umd
Browse files Browse the repository at this point in the history
  • Loading branch information
boneskull committed Jul 7, 2020
2 parents 640cfab + 7c8896c commit 81339e5
Show file tree
Hide file tree
Showing 7 changed files with 1,363 additions and 1,296 deletions.
1 change: 1 addition & 0 deletions karma.conf.js
Expand Up @@ -155,6 +155,7 @@ module.exports = config => {

if (MOCHA_TEST !== 'requirejs') {
cfg.files.unshift(
require.resolve('sinon/pkg/sinon.js'),
require.resolve('unexpected/unexpected'),
{
pattern: require.resolve('unexpected/unexpected.js.map'),
Expand Down
2 changes: 1 addition & 1 deletion lib/cli/cli.js
Expand Up @@ -52,7 +52,7 @@ exports.main = (argv = process.argv.slice(2)) => {
debug('caught error sometime before command handler: %O', err);
yargs.showHelp();
console.error(`\n${symbols.error} ${ansi.red('ERROR:')} ${msg}`);
yargs.exit(1);
process.exitCode = 1;
})
.help('help', 'Show usage information & exit')
.alias('help', 'h')
Expand Down
2,563 changes: 1,299 additions & 1,264 deletions package-lock.json

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions package.json
Expand Up @@ -80,13 +80,13 @@
"devDependencies": {
"@11ty/eleventy": "^0.10.0",
"@11ty/eleventy-plugin-inclusive-language": "^1.0.0",
"@babel/preset-env": "^7.10.2",
"@babel/preset-env": "^7.10.4",
"@mocha/docdash": "^2.1.3",
"@rollup/plugin-babel": "^5.0.3",
"@rollup/plugin-commonjs": "^11.0.2",
"@rollup/plugin-json": "^4.0.2",
"@rollup/plugin-babel": "^5.0.4",
"@rollup/plugin-commonjs": "^13.0.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-multi-entry": "^3.0.1",
"@rollup/plugin-node-resolve": "^7.1.1",
"@rollup/plugin-node-resolve": "^8.1.0",
"assetgraph-builder": "^8.0.1",
"autoprefixer": "^9.7.4",
"babel-eslint": "^10.1.0",
Expand Down Expand Up @@ -134,7 +134,7 @@
"requirejs": "^2.3.6",
"rewiremock": "^3.14.1",
"rimraf": "^3.0.2",
"rollup": "^2.10.2",
"rollup": "^2.18.2",
"rollup-plugin-node-builtins": "^2.1.2",
"rollup-plugin-node-globals": "^1.4.0",
"rollup-plugin-visualizer": "^3.3.2",
Expand Down
8 changes: 7 additions & 1 deletion rollup.config.js
Expand Up @@ -49,7 +49,13 @@ const config = {
],
babelHelpers: 'bundled'
})
]
],
onwarn: (warning, warn) => {
if (warning.code === 'CIRCULAR_DEPENDENCY') return;

// Use default for everything else
warn(warning);
}
};

if (!process.env.CI) {
Expand Down
27 changes: 16 additions & 11 deletions scripts/karma-rollup-plugin.js
Expand Up @@ -34,7 +34,6 @@ const fs = require('fs');
const path = require('path');
const uuid = require('uuid');
const rollup = require('rollup');
const glob = require('glob');
const minimatch = require('minimatch');
const loadConfigFile = require('rollup/dist/loadConfigFile');
const multiEntry = require('@rollup/plugin-multi-entry');
Expand All @@ -58,15 +57,12 @@ function framework(fileConfigs, pluginConfig, basePath, preprocessors) {
)
);

const bundleFiles = [
...new Set(bundlePatterns.map(pattern => glob.sync(pattern)).flat())
];

const bundleFilename = `${uuid.v4()}.rollup.js`;
let bundleLocation = path.resolve(
pluginConfig.bundleDirPath ? pluginConfig.bundleDirPath : os.tmpdir(),
bundleFilename
);

if (process.platform === 'win32') {
bundleLocation = bundleLocation.replace(/\\/g, '/');
}
Expand All @@ -75,7 +71,7 @@ function framework(fileConfigs, pluginConfig, basePath, preprocessors) {
preprocessors[bundleLocation] = ['rollup'];

// Save file mapping for later
fileMap.set(bundleLocation, bundleFiles);
fileMap.set(bundleLocation, bundlePatterns);

// Remove all file match patterns that were included in bundle
// And inject the bundle in their place.
Expand Down Expand Up @@ -121,18 +117,27 @@ function bundlePreprocessor(config) {

return async function(content, file, done) {
const {options, warnings} = await configPromise;
const pluginConfig = options[0].plugins || [];
const outputConfig = options[0].output || [];

const config = options[0];
const pluginConfig = config.plugins || [];
const outputConfig = {
...(config.output ? config.output[0] : {}),
globals: {sinon: 'sinon'},
file: file.path
};

warnings.flush();

const bundle = await rollup.rollup({
input: fileMap.get(file.path),
plugins: [...pluginConfig, multiEntry({exports: false})]
plugins: [...pluginConfig, multiEntry({exports: false})],
external: ['sinon'],
onwarn: config.onwarn
});
const {output} = await bundle.generate(outputConfig[0]);

await bundle.write({...outputConfig[0], file: file.path});
const {output} = await bundle.generate(outputConfig);

await bundle.write(outputConfig);
console.error(`wrote bundle to ${file.path}`);

done(null, output[0].code);
Expand Down
46 changes: 33 additions & 13 deletions test/integration/init.spec.js
Expand Up @@ -23,19 +23,39 @@ describe('init command', function() {
} catch (ignored) {}
});

it('should break if no path supplied', function(done) {
invokeMocha(
['init'],
function(err, result) {
if (err) {
return done(err);
}
expect(result, 'to have failed');
expect(result.output, 'to match', /not enough non-option arguments/i);
done();
},
{stdio: 'pipe'}
);
describe('when no path is supplied', function() {
it('should fail', function(done) {
invokeMocha(
['init'],
function(err, result) {
if (err) {
return done(err);
}
expect(
result,
'to have failed with output',
/not enough non-option arguments/i
);
done();
},
{stdio: 'pipe'}
);
});
it('should not throw', function(done) {
invokeMocha(
['init'],
function(err, result) {
if (err) {
return done(err);
}
expect(result, 'to have failed').and('not to satisfy', {
output: /throw/i
});
done();
},
{stdio: 'pipe'}
);
});
});

it('should create some files in the dest dir', function(done) {
Expand Down

0 comments on commit 81339e5

Please sign in to comment.