const buildCjs = ({ env }) => ({
  input,
  external,
  output: {
    file: `./dist/${pkg.name}.cjs.${env}.js`,
    format: "cjs",
    sourcemap: true,
  },
  plugins: [
    resolve(),
    replace({
      "process.env.NODE_ENV": JSON.stringify(env),
    }),
    sourceMaps(),
    sizeSnapshot(),
    env === "production" &&
      terser({
        sourcemap: true,
        output: { comments: false },
        compress: {
          keep_infinity: true,
          pure_getters: true,
        },
        warnings: true,
        ecma: 5,
        // Compress and/or mangle variables in top level scope.
        // @see https://github.com/terser-js/terser
        toplevel: true,
      }),
  ],
});
Example #2
0
function transpileAMD(pkgName, esVersion, tree) {
  let bundleName = pkgName.replace('/', '-').replace('@', '');
  let pkgTree = funnel(tree, {
    include: [`${pkgName}/**/*`],
    exclude: ['**/*.d.ts']
  });

  // Provide Rollup a list of package names it should not try to include in the
  // bundle.
  let external = ['@glimmer/local-debug-flags', ...project.dependencies];

  let plugins = [sourcemaps()];

  let options = {
    annotation: `Transpile AMD - ${pkgName} - ${esVersion}`,
    rollup: {
      entry: `${pkgName}/index.js`,
      external,
      plugins,
      targets: [{
        dest: `${pkgName}/dist/amd/${esVersion}/${bundleName}.js`,
        format: 'amd',
        exports: 'named',
        moduleId: pkgName,
        sourceMap: 'inline'
      }]
    }
  };

  return new Rollup(pkgTree, options);
}
Example #3
0
function getDefaultPlugins() { // need to be instantiated each time
  let plugins = [ resolve() ] // for tslib

  if (isDev) {
    plugins.push(sourcemaps()) // for reading/writing sourcemaps
  }

  return plugins
}
const buildUmd = ({ env }) => ({
  input,
  external: ["react", "react-native"],
  output: {
    name: "ReactFuzzyFilter",
    format: "umd",
    sourcemap: true,
    file: `./dist/react-fuzzy-filter.umd.${env}.js`,
    exports: "named",
    globals: {
      react: "React",
      "react-native": "ReactNative",
    },
  },

  plugins: [
    rollupAlias({
      valoo: 'valoo/dist/valoo'
    }),
    resolve(),
    babel(babelOptions),
    replace({
      "process.env.NODE_ENV": JSON.stringify(env),
    }),
    commonjs({
      include: /node_modules/,
      namedExports: {
        "node_modules/prop-types/index.js": [
          "object",
          "oneOfType",
          "string",
          "node",
          "func",
          "bool",
          "element",
        ],
      },
    }),
    sourceMaps(),
    sizeSnapshot(),
    env === "production" &&
      terser({
        sourcemap: true,
        output: { comments: false },
        compress: {
          keep_infinity: true,
          pure_getters: true,
        },
        warnings: true,
        ecma: 5,
        toplevel: false,
      }),
  ],
});
Example #5
0
const buildUmd = ({ env }) => ({
  input,
  external,
  output: {
    name: 'Formik',
    format: 'umd',
    sourcemap: true,
    file:
      env === 'production'
        ? `./dist/formik.umd.${env}.js`
        : `./dist/formik.umd.${env}.js`,
    exports: 'named',
    globals: {
      react: 'React',
      'react-native': 'ReactNative',
    },
  },

  plugins: [
    resolve(),
    replace({
      exclude: 'node_modules/**',
      'process.env.NODE_ENV': JSON.stringify(env),
    }),
    commonjs({
      include: /node_modules/,
      namedExports: {
        'node_modules/prop-types/index.js': [
          'object',
          'oneOfType',
          'string',
          'node',
          'func',
          'bool',
          'element',
        ],
      },
    }),
    sourceMaps(),
    env === 'production' && filesize(),
    env === 'production' &&
      uglify({
        output: { comments: false },
        compress: {
          keep_infinity: true,
          pure_getters: true,
        },
        warnings: true,
        ecma: 5,
        toplevel: false,
      }),
  ],
});
Example #6
0
const bundle = () => {
    return rollup({
        entry: "./src/index.js",
        plugins: [sourcemap(),
            commonjs({
                ignoreGlobal: true,
            }),
            npm({
                jsnext: true,
                main: true,
                browser: true
            }),
        ]
    });
};
Example #7
0
const buildCjs = ({ env }) => ({
  input,
  external: external.concat(Object.keys(pkg.dependencies)),
  output: [
    {
      file: `./dist/${pkg.name}.cjs.${env}.js`,
      format: 'cjs',
      sourcemap: true,
    },
  ],
  plugins: [
    resolve(),
    replace({
      exclude: 'node_modules/**',
      'process.env.NODE_ENV': JSON.stringify(env),
    }),
    sourceMaps(),
    filesize(),
  ],
})
var typescript = require('rollup-plugin-typescript');
var sourcemaps = require('rollup-plugin-sourcemaps');
var sass = require('rollup-plugin-sass');

module.exports = {
  entry: './src/angular2-data-table.ts',
  sourceMap: true,
  moduleId: 'angular2-data-table',
  moduleName: 'angular2DataTable',

  external: [
		'typescript'
	],

  plugins: [
    typescript({
      typescript: require('typescript')
    }),
    sourcemaps(),
    sass()
  ]
}
Example #9
0
 * @license MIT License, http://www.opensource.org/licenses/MIT
 */`;

const uglifyOpts = { output: {} };
// retain multiline comment with @license
uglifyOpts.output.comments = (node, comment) => comment.type === 'comment2' && /@license/i.test(comment.value);

const onwarn = warning => {
  // Suppress this error message... https://github.com/rollup/rollup/wiki/Troubleshooting#this-is-undefined
  const ignores = ['THIS_IS_UNDEFINED'];
  if (!ignores.some(code => code === warning.code)) {
    console.error(warning.message);
  }
};

const plugins = [nodeResolve({ jsnext: true }), sourcemaps()];

if (MINIFY) plugins.push(uglify(uglifyOpts));

const extension = MINIFY ? '.min.js' : '.js';

const BASE_CONFIG = {
  onwarn: onwarn,
  plugins: plugins,
};

const BASE_OUTPUT = {
  banner: banner,
  exports: 'named',
  format: 'umd',
  sourcemap: true,
Example #10
0
async function main()
{
    const plugins = [
        sourcemaps(),
        resolve({
            browser: true,
            preferBuiltins: false,
        }),
        commonjs({
            namedExports: {
                'resource-loader': ['Resource'],
            },
        }),
        string({
            include: [
                '**/*.frag',
                '**/*.vert',
            ],
        }),
        replace({
            __VERSION__: repo.version,
        }),
        transpile(),
    ];

    const compiled = (new Date()).toUTCString().replace(/GMT/g, 'UTC');
    const sourcemap = true;
    const results = [];

    // Support --scope and --ignore globs if passed in via commandline
    const { scope, ignore } = minimist(process.argv.slice(2));
    const packages = await getSortedPackages(scope, ignore);

    const namespaces = {};
    const pkgData = {};

    // Create a map of globals to use for bundled packages
    packages.forEach((pkg) =>
    {
        const data = pkg.toJSON();

        pkgData[pkg.name] = data;
        namespaces[pkg.name] = data.namespace || 'PIXI';
    });

    packages.forEach((pkg) =>
    {
        let banner = [
            `/*!`,
            ` * ${pkg.name} - v${pkg.version}`,
            ` * Compiled ${compiled}`,
            ` *`,
            ` * ${pkg.name} is licensed under the MIT License.`,
            ` * http://www.opensource.org/licenses/mit-license`,
            ` */`,
        ].join('\n');

        // Check for bundle folder
        const external = Object.keys(pkg.dependencies || []);
        const basePath = path.relative(__dirname, pkg.location);
        const input = path.join(basePath, 'src/index.js');
        const {
            main,
            module,
            bundle,
            bundleInput,
            bundleOutput,
            bundleNoExports,
            standalone } = pkgData[pkg.name];
        const freeze = false;

        results.push({
            input,
            output: [
                {
                    banner,
                    file: path.join(basePath, main),
                    format: 'cjs',
                    freeze,
                    sourcemap,
                },
                {
                    banner,
                    file: path.join(basePath, module),
                    format: 'esm',
                    freeze,
                    sourcemap,
                },
            ],
            external,
            plugins,
        });

        // The package.json file has a bundle field
        // we'll use this to generate the bundle file
        // this will package all dependencies
        if (bundle)
        {
            const input = path.join(basePath, bundleInput || 'src/index.js');
            const file = path.join(basePath, bundle);
            const external = standalone ? null : Object.keys(namespaces);
            const globals = standalone ? null : namespaces;
            const ns = namespaces[pkg.name];
            const name = pkg.name.replace(/[^a-z]+/g, '_');
            let footer;

            // Ignore self-contained packages like polyfills and unsafe-eval
            // as well as the bundles pixi.js and pixi.js-legacy
            if (!standalone)
            {
                if (bundleNoExports !== true)
                {
                    footer = `Object.assign(this.${ns}, ${name});`;
                }

                if (ns.includes('.'))
                {
                    const base = ns.split('.')[0];

                    banner += `\nthis.${base} = this.${base} || {};`;
                }

                banner += `\nthis.${ns} = this.${ns} || {};`;
            }

            results.push({
                input,
                external,
                output: Object.assign({
                    banner,
                    file,
                    format: 'iife',
                    freeze,
                    globals,
                    name,
                    footer,
                    sourcemap,
                }, bundleOutput),
                treeshake: false,
                plugins,
            });

            if (process.env.NODE_ENV === 'production')
            {
                results.push({
                    input,
                    external,
                    output: Object.assign({
                        banner,
                        file: file.replace(/\.js$/, '.min.js'),
                        format: 'iife',
                        freeze,
                        globals,
                        name,
                        footer,
                        sourcemap,
                    }, bundleOutput),
                    treeshake: false,
                    plugins: [...plugins, terser({
                        output: {
                            comments: (node, comment) => comment.line === 1,
                        },
                    })],
                });
            }
        }
    });

    return results;
}
Example #11
0
  $resolved = result;
  return result;
}
`;

module.exports = {
  entry: '../../dist/packages-dist/language-service/esm5/language-service.js',
  dest: '../../dist/packages-dist/language-service/bundles/language-service.umd.js',
  format: 'amd',
  amd: {
      // Don't name this module, causes
      // Loading the language service caused the following exception: TypeError:
      // $deferred.modules.map is not a function
      // id: '@angular/language-service'
  },
  moduleName: 'ng.language_service',
  exports: 'named',
  external: [
    'fs',
    'path',
    'typescript',
  ],
  globals: {
    'typescript': 'ts',
    'path': 'path',
    'fs': 'fs',
  },
  banner: banner,
  plugins: [{resolveId: resolve}, commonjs(), sourcemaps()]
};
// TODO, break this out into its own browser repo to avoid the need for builtins and globals
import babel from 'rollup-plugin-babel'
import nodeResolve from 'rollup-plugin-node-resolve'
import commonjs from 'rollup-plugin-commonjs'
import builtins from 'rollup-plugin-node-builtins'
import globals from 'rollup-plugin-node-globals'
import sourcemaps from 'rollup-plugin-sourcemaps'

export default {
  input: 'index.browser.js',
  plugins: [nodeResolve(), commonjs(), builtins(), globals(), babel(), sourcemaps()],
  output: [
    {
      format: 'umd',
      file: 'dist/indian-ocean.js',
      name: 'io',
      sourcemap: true
    }, {
      format: 'es',
      file: 'dist/indian-ocean.browser.es6.js',
      name: 'io',
      sourcemap: true
    }
  ]
}
Example #13
0
/**
 * @license
 * Copyright Google Inc. All Rights Reserved.
 *
 * Use of this source code is governed by an MIT-style license that can be
 * found in the LICENSE file at https://angular.io/license
 */

const sourcemaps = require('rollup-plugin-sourcemaps');

module.exports = {
  plugins: [sourcemaps()]
};
import babel from 'rollup-plugin-babel'
import nodeResolve from 'rollup-plugin-node-resolve'
import commonjs from 'rollup-plugin-commonjs'
import sourcemaps from 'rollup-plugin-sourcemaps'

export default {
  input: 'index.node.js',
  output: {
    format: 'cjs',
    file: 'dist/indian-ocean.cjs.js',
    sourcemap: true
  },
  plugins: [ nodeResolve(), commonjs(), babel(), sourcemaps() ],
  external: ['fs', 'path', 'util', 'shapefile']
}
Example #15
0
  'startOfMonth',
  'endOfMonth',
  'subMonths',
  'startOfYear',
  'endOfYear',
  'subYears',
  'addDays',
];

const listOfReplace = listOfDateFns.map(name => {
  const map = {};
  map[`import * as ${name}`] = `import ${name}`;
  return replace(map);
});

const plugins = [sourcemaps(), ...listOfReplace, resolve()];

switch (target) {
  case 'esm':
    Object.assign(globals, {
      tslib: 'tslib',
    });
    break;
  case 'mumd':
    // @ts-ignore
    plugins.push(uglify());
    break;
}

module.exports = {
  plugins,
Example #16
0
 * @license
 * Copyright Google Inc. All Rights Reserved.
 *
 * Use of this source code is governed by an MIT-style license that can be
 * found in the LICENSE file at https://angular.io/license
 */

import resolve from 'rollup-plugin-node-resolve';
import sourcemaps from 'rollup-plugin-sourcemaps';

const globals = {
  '@angular/core': 'ng.core',
  '@angular/common': 'ng.common',
  '@angular/compiler': 'ng.compiler',
  '@angular/platform-browser': 'ng.platformBrowser',
  '@angular/platform-browser-dynamic': 'ng.platformBrowserDynamic',
  '@angular/platform-webworker': 'ng.platformWebworker',
};

export default {
  entry: '../../dist/packages-dist/platform-webworker-dynamic/esm5/index.js',
  dest:
      '../../dist/packages-dist/platform-webworker-dynamic/bundles/platform-webworker-dynamic.umd.js',
  format: 'umd',
  exports: 'named',
  moduleName: 'ng.platformWebworkerDynamic',
  plugins: [resolve(), sourcemaps()],
  external: Object.keys(globals),
  globals: globals
};
Example #17
0
})

export default [
  buildUmd({ env: 'production' }),
  buildUmd({ env: 'development' }),
  buildCjs({ env: 'production' }),
  buildCjs({ env: 'development' }),
  {
    input,
    external: external.concat(Object.keys(pkg.dependencies)),
    output: [
      {
        file: pkg.module,
        format: 'es',
        sourcemap: true,
      },
      {
        file: pkg.main,
        format: 'cjs',
        sourcemap: true,
      },
    ],
    plugins: [
      resolve(),
      
      sourceMaps(),
      filesize(),
    ],
  },
];
Example #18
0
async function main()
{
	const plugins = [
		sourcemaps(),
		typescript(),
		resolve({
			browser: true,
			preferBuiltins: false,
		}),
		commonjs({extensions: ['.js', '.ts']}),
	];

	const compiled = (new Date()).toUTCString().replace(/GMT/g, 'UTC');
	const sourcemap = true;
	const results = [];

	const pkg = require('./package.json');
	const banner = [
		`/*!`,
		` * ${pkg.name} - v${pkg.version}`,
		` * Compiled ${compiled}`,
		` *`,
		` * ${pkg.name} is licensed under the MIT License.`,
		` * http://www.opensource.org/licenses/mit-license`,
		` */`,
	].join('\n');

	// Check for bundle folder
	const basePath = __dirname;
	const input = path.join(basePath, 'src/index.ts');
	const freeze = false;

	results.push({
		input,
		output: [
			{
				banner,
				file: path.join(basePath, pkg.main),
				format: 'cjs',
				freeze,
				sourcemap,
			},
			{
				banner,
				file: path.join(basePath, pkg.module),
				format: 'es',
				freeze,
				sourcemap,
			},
		],
		external: ['pixi.js'],
		plugins: [jscc({values:{_IIFE:false}})].concat(plugins)
	});

	// The package.json file has a bundle field
	// we'll use this to generate the bundle file
	// this will package all dependencies
	if (pkg.bundle)
	{
		results.push({
			input,
			output: {
				banner,
				file: path.join(basePath, pkg.bundle),
				format: 'iife',
				freeze,
				name: 'PIXI.particles',
				sourcemap,
				extend: true,
				globals: {
					'pixi.js': 'PIXI'
				}
			},
			treeshake: false,
			external: ['pixi.js'],
			plugins: [jscc({values:{_IIFE:true}})].concat(plugins),
		});
	}

	return results;
}
Example #19
0
const doRollup = (libName, dirs) => {
    const nameParts = extractName(libName);
    const es5Entry = path.resolve(dirs.es5, `${nameParts.package}.js`);
    const es2015Entry = path.resolve(dirs.es2015, `${nameParts.package}.js`);
    const destinations = generateDestinations(dirs.dist, nameParts);
    const baseConfig = generateConfig({
        input: es5Entry,
        external: Object.keys(rollupGlobals),
        globals: rollupGlobals,
        name: librarianUtils.caseConvert.dashToCamel(nameParts.package),
        onwarn: function rollupOnWarn(warning) {
            // keeps TypeScript this errors down
            if (warning.code !== 'THIS_IS_UNDEFINED') {
                console.warn(warning.message);
            }
        },
        plugins: [
            rollupNodeResolve({
                jsnext: true,
                module: true
            }),
            rollupSourcemaps()
        ],
        sourcemap: true
    }, dirs.root);
    const fesm2015Config = Object.assign({}, baseConfig, {
        input: es2015Entry,
        output: {
            file: destinations.fesm2015,
            format: 'es'
        }
    });
    const fesm5Config = Object.assign({}, baseConfig, {
        output: {
            file: destinations.fesm5,
            format: 'es'
        }
    });
    const minUmdConfig = Object.assign({}, baseConfig, {
        output: {
            file: destinations.minUmd,
            format: 'umd'
        },
        plugins: baseConfig.plugins.concat([rollupUglify({})])
    });
    const umdConfig = Object.assign({}, baseConfig, {
        output: {
            file: destinations.umd,
            format: 'umd'
        }
    });

    const bundles = [
        fesm2015Config,
        fesm5Config,
        minUmdConfig,
        umdConfig
    ].map(config =>
        rollup.rollup(config)
            .then(bundle => bundle.write({
                file: config.output.file,
                format: config.output.format,
                ...config
            }))
        );

    return Promise.all(bundles);
};
          keep_infinity: true,
          pure_getters: true,
        },
        warnings: true,
        ecma: 5,
        // Compress and/or mangle variables in top level scope.
        // @see https://github.com/terser-js/terser
        toplevel: true,
      }),
  ],
});

export default [
  buildUmd({ env: "production" }),
  buildUmd({ env: "development" }),
  buildCjs({ env: "production" }),
  buildCjs({ env: "development" }),
  {
    input,
    external,
    output: [
      {
        file: pkg.module,
        format: "esm",
        sourcemap: true,
      },
    ],
    plugins: [resolve(), babel(babelOptions), sizeSnapshot(), sourceMaps()],
  },
];