Skip to content

Commit

Permalink
Don't swallow build failures
Browse files Browse the repository at this point in the history
Removes try/catch so that we know if a build fails in CI.
  • Loading branch information
salmoro committed Jun 7, 2023
1 parent c6c041f commit 0ce4343
Showing 1 changed file with 62 additions and 67 deletions.
129 changes: 62 additions & 67 deletions rollup.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,75 +35,70 @@ async function generateBundle() {
console.log(new Date().toString());
}

try {
const bundle = await rollup.rollup({
cache,
input: 'src/player.js',
plugins: [
babel(),
commonjs(),
nodeResolve()
]
});

cache = bundle;

let { output } = await bundle.generate({
format: 'umd',
name: 'Vimeo.Player',
sourcemap: true,
sourcemapFile: 'dist/player.js.map',
banner
});

let { code, map } = output[0];

fs.writeFileSync('dist/player.js', `${code}\n//# sourceMappingURL=player.js.map`);
fs.writeFileSync('dist/player.js.map', map.toString());

const size = maxmin(code, code, true).replace(/^(.*? → )/, '');
console.log(`Created bundle ${chalk.cyan('player.js')}: ${size}`);

const minified = uglifyJs.minify(code, {
sourceMap: {
content: map,
url: 'dist/player.min.js.map'
},
output: {
preamble: banner
},
mangle: {
reserved: ['Player']
}
});

fs.writeFileSync('dist/player.min.js', minified.code.replace(/\/\/# sourceMappingURL=\S+/, ''));
fs.writeFileSync('dist/player.min.js.map', minified.map);

const minifiedSize = maxmin(code, minified.code, true);
console.log(`Created bundle ${chalk.cyan('player.min.js')}: ${minifiedSize}`);

({ output } = await bundle.generate({
format: 'es',
banner
}));

({ code, map } = output[0]);

fs.writeFileSync('dist/player.es.js', code);
const esSize = maxmin(code, code, true).replace(/^(.*? → )/, '');
console.log(`Created bundle ${chalk.cyan('player.es.js')}: ${esSize}`);

building = false;

if (needsRebuild) {
await generateBundle();
const bundle = await rollup.rollup({
cache,
input: 'src/player.js',
plugins: [
babel(),
commonjs(),
nodeResolve()
]
});

cache = bundle;

let { output } = await bundle.generate({
format: 'umd',
name: 'Vimeo.Player',
sourcemap: true,
sourcemapFile: 'dist/player.js.map',
banner
});

let { code, map } = output[0];

fs.writeFileSync('dist/player.js', `${code}\n//# sourceMappingURL=player.js.map`);
fs.writeFileSync('dist/player.js.map', map.toString());

const size = maxmin(code, code, true).replace(/^(.*? → )/, '');
console.log(`Created bundle ${chalk.cyan('player.js')}: ${size}`);

const minified = uglifyJs.minify(code, {
sourceMap: {
content: map,
url: 'dist/player.min.js.map'
},
output: {
preamble: banner
},
mangle: {
reserved: ['Player']
}
});

} catch(error) {
console.log(error);
};
};
fs.writeFileSync('dist/player.min.js', minified.code.replace(/\/\/# sourceMappingURL=\S+/, ''));
fs.writeFileSync('dist/player.min.js.map', minified.map);

const minifiedSize = maxmin(code, minified.code, true);
console.log(`Created bundle ${chalk.cyan('player.min.js')}: ${minifiedSize}`);

({ output } = await bundle.generate({
format: 'es',
banner
}));

({ code, map } = output[0]);

fs.writeFileSync('dist/player.es.js', code);
const esSize = maxmin(code, code, true).replace(/^(.*? → )/, '');
console.log(`Created bundle ${chalk.cyan('player.es.js')}: ${esSize}`);

building = false;

if (needsRebuild) {
await generateBundle();
}
}

generateBundle();

Expand Down

0 comments on commit 0ce4343

Please sign in to comment.