Skip to content

Instantly share code, notes, and snippets.

@c0bra
Last active November 18, 2019 17:05
Show Gist options
  • Save c0bra/ad46a88f3ebc13d1f3662ef401a9a770 to your computer and use it in GitHub Desktop.
Save c0bra/ad46a88f3ebc13d1f3662ef401a9a770 to your computer and use it in GitHub Desktop.
Testing Svelte with Jest
const rollup = require('rollup');
const esm = require('esm');
const { config } = esm(module)('../rollup.config');
function generateOptions(filePath, name) {
return {
input: { input: filePath, plugins: config.plugins },
output: {
file: `./dist/test/${name}.js`,
format: 'cjs',
},
};
}
function compile(filePath, name) {
const { input, output } = generateOptions(filePath, name);
return rollup.rollup(input)
.then(bundle => {
return bundle.generate(output);
})
.then(({ code, map }) => {
console.log('CODE', code);
return { code, map };
});
}
module.exports = { compile };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment