Пример #1
0
		return new Promise((resolved, rejected) => {

			var files = [];
			files[filename] = data.toString();

			rollup.rollup({
				entry: filename,
				plugins: [
					{
						resolveId: (importee, importer) => {
							if (importee !== filename && importee.split('/').length > 1) {
								return new Promise((resolved, rejected) => {
									const file = path.resolve(path.dirname(importer), importee);
									async.reduce([
										file + '/index.js',
										file + '.js',
										file
									],
									[],
									(paths, path, callback) => {
										fs.stat(path, (err, stats) => {
											if (!err && stats && stats.isFile()) paths.push(path);
											callback(null, paths);
										});
									}, (err, paths) => {
										if (err) return rejected(err);
										if (paths[0]) {
											files = files.concat(paths[0]);
										}
										resolved(paths[0]);
									});
								});
							}
						}
					},
					hypothetical({
						files: files,
						allowRealFiles: true
					})
				],
				onwarn: (str) => {}
			}).then(bundle => {
				var result = bundle.generate({
					sourceMap: true
				});
				resolved({
					data: new Buffer(result.code),
					map: result.map,
					files: files.concat(filename)
				});
			}).catch(rejected);

		});
Пример #2
0
function pgl(plugins = []) {

  return [
    hypothetical({
      allowFallthrough: true,
      files: {
        'chalk': `
          export default null;
        `,
        'diff-match-patch': `
          export default null;
        `
      }
    }),
    nodeResolve(),
    ...plugins
  ];
}
Пример #3
0
import builtins from 'rollup-plugin-node-builtins';
import globals from 'rollup-plugin-node-globals';
import hypothetical from 'rollup-plugin-hypothetical';
import ignore from 'rollup-plugin-ignore';

const name = `irisLib`;

const plugins = [
  ignore(['gun/lib/then', 'gun/lib/load']),
  hypothetical({
    allowFallthrough: true,
    files: {
      'node-webcrypto-ossl/': `
        export default {};
      `,
      'text-encoding/': `
        export default {};
      `,
      '@trust/webcrypto/': `
        export default {};
      `
    }
  }),
  json(),
  babel({
    exclude: 'node_modules/**',
    plugins: ['external-helpers', 'transform-runtime'],
    runtimeHelpers: true
  }),
  builtins(),
  nodeResolve({
    module: true,