Skip to content

Commit

Permalink
fix: bundle generation for cjs
Browse files Browse the repository at this point in the history
  • Loading branch information
Diego committed Jul 18, 2018
1 parent 34779b0 commit 78b420a
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ const { version } = require('./package.json');
// -- Config ------------------------------------------------------------------
const input = path.resolve(__dirname, 'src/main.ts');
const umdDir = path.resolve(__dirname, 'dist/umd');
const cjsDir = path.resolve(__dirname, 'dist/commonjs');
const modulesDir = path.resolve(__dirname, 'dist/modules');
const banner = (`/**\n * Copyright (C) 2017 salesforce.com, inc.\n */`);
const footer = `/** version: ${version} */`;
const prodToken = JSON.stringify('production');

// -- Helpers -----------------------------------------------------------------
function inlineMinifyPlugin() {
Expand All @@ -23,14 +23,15 @@ function inlineMinifyPlugin() {
}

function rollupConfig({ formats, prod }) {
const replaceToken = JSON.stringify(prod ? 'production' : 'development');
const plugins = [
typescript({ target: 'es6', typescript: require('typescript') }),
prod && replace({ 'process.env.NODE_ENV': prodToken }),
prod !== undefined && replace({ 'process.env.NODE_ENV': replaceToken }),
prod && inlineMinifyPlugin({})
].filter(Boolean);

const output = formats.map(format => {
const targetDirectory = format === 'umd' ? umdDir : modulesDir;
const targetDirectory = format === 'umd' ? umdDir : format === 'cjs' ? cjsDir : modulesDir;
const targetName = `observable-membrane${prod ? '.min' : '' }.js`;

return {
Expand All @@ -48,6 +49,7 @@ function rollupConfig({ formats, prod }) {
// -- Rollup ------------------------------------------------------------------

module.exports = [
rollupConfig({ formats: ['umd', 'es'], prod: false }),
rollupConfig({ formats: ['cjs', 'es'] }),
rollupConfig({ formats: ['umd'], prod: false }),
rollupConfig({ formats: ['umd'], prod: true })
];

0 comments on commit 78b420a

Please sign in to comment.