當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript browserify.default方法代碼示例

本文整理匯總了TypeScript中browserify.default方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript browserify.default方法的具體用法?TypeScript browserify.default怎麽用?TypeScript browserify.default使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在browserify的用法示例。


在下文中一共展示了browserify.default方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: Browserify

export default function Browserify() {
    let smildSettings = helper.getSettings(),
        browserifySettings = {
            entries: [getBootstrapperPath()],
            basedir: process.cwd(),
            debug: !helper.isRelease(),
            cache: {},
            packageCache: {},
            fullPaths: true
        },
        bundleStream = helper.isWatching() ? watchify(browserify(browserifySettings), {
                poll: /^win/.test(process.platform)
            }) : browserify(browserifySettings);

    bundleStream = bundleStream.plugin(tsify, {
        project: new TypescriptSettingsParser().parse(),
        typescript: require(smildSettings.typescriptPath)
    });

    if (helper.isWatching())
        bundleStream.on('update', () => rebundleDevelopment(bundleStream));

    function getBootstrapperPath() {
        let target = helper.getCurrentTarget();
        return path.resolve(smildSettings.targets, target, 'bootstrapper.ts');
    }

    function rebundleDevelopment(bundleStream) {
        let bundle = bundleStream.bundle();
        if (buildHelper.isWatching())
            bundle = bundle.on('error', function (err) {
                console.error(err.message);
                this.emit("end");
            });
        return bundle
            .pipe(source('main.js'))
            .pipe(transform(() => {
                return exorcist(helper.getTempFolder() + '/js/main.map.js');
            }))
            .pipe(gulp.dest(helper.getTempFolder() + '/js'))
            .pipe(refresh({
                start: helper.isWatching(),
                port: smildSettings.liveReloadPort
            }));
    }

    function rebundleRelease(bundleStream) {
        return bundleStream.bundle()
            .pipe(source('main.js'))
            .pipe(streamify(uglify(smildSettings.uglifyjs)))
            .pipe(buffer())
            .pipe(gulp.dest(helper.getTempFolder() + '/js'));
    }

    return helper.isRelease() ? rebundleRelease(bundleStream) : rebundleDevelopment(bundleStream);
}
開發者ID:mtfranchetto,項目名稱:smild,代碼行數:56,代碼來源:Browserify.ts

示例2: bundleCasesFrom

function bundleCasesFrom(i: number) {
	if (i >= cases.length) return;
	const b = browserify();
	b.ignore("tape");
	b.add(`${__dirname}/${cases[i]}.js`);
	b.transform(path.normalize(__dirname + "/../cwise.js"));
	tape(cases[i], (t) => { // Without nested tests, the asynchronous nature of bundle causes issues with tape...
		b.bundle((err, src) => {
			if (err) {
				throw new Error("failed to bundle!");
			}
			vm.runInNewContext(src.toString(), {
				test: t.test.bind(t),
				Buffer,
				Int8Array,
				Int16Array,
				Int32Array,
				Float32Array,
				Float64Array,
				Uint8Array,
				Uint16Array,
				Uint32Array,
				Uint8ClampedArray,
				console: { log: console.log.bind(console) }
			});
			t.end();
		});
	});
	bundleCasesFrom(i + 1);
}
開發者ID:AbraaoAlves,項目名稱:DefinitelyTyped,代碼行數:30,代碼來源:cwise-tests.ts

示例3: build

export function build(srcPath: string, destPath: string, cb: Function){
	const tempPath = $path(process.cwd(), './temp/ts');
	const builder = new Builder({
		destPath,
		srcPath,
		tempPath 
	}); 	
	const meta = builder.buildSubs('.');
	const compSet: IComponentSet = {
		name: null,
		items: meta
	};
	const includeCode = genIncludeFile(compSet, srcPath, tempPath);
	const includeFilePath = $path(tempPath, './include.ts');
	fs.writeFileSync(includeFilePath, includeCode);
	const brofy = browserify({
		debug: true
	});
	brofy
		.add(includeFilePath)
		.external([
			"fg-js/build/client/main"
		])
		.plugin(tsify, {
			project: buildCfg
		})
		.bundle(function(err: any, code: Buffer){
			if (err){
				console.error(err);
				return;
			};
			fs.writeFileSync(destPath, code);
			cb(null);
		});
};
開發者ID:int0h,項目名稱:fg,代碼行數:35,代碼來源:builder.ts

示例4: getBrowserCodeStream

export function getBrowserCodeStream(appName: string, opts?: PrebootOptions): any {
  opts = normalize(opts);

  let bOpts = {
    entries: [__dirname + '/../browser/preboot_browser.js'],
    standalone: 'preboot',
    basedir: __dirname + '/../browser',
    browserField: false
  };
  let b = browserify(bOpts);

  // ignore any strategies that are not being used
  ignoreUnusedStrategies(b, bOpts, opts.listen, listenStrategies, './listen/listen_by_');
  ignoreUnusedStrategies(b, bOpts, opts.replay, replayStrategies, './replay/replay_after_');

  if (opts.freeze) {
    ignoreUnusedStrategies(b, bOpts, [opts.freeze], freezeStrategies, './freeze/freeze_with_');
  }

  // ignore other code not being used
  if (!opts.buffer) { b.ignore('./buffer_manager.js', bOpts); }
  if (!opts.debug) { b.ignore('./log.js', bOpts); }

  // use gulp to get the stream with the custom preboot browser code
  let outputStream = b.bundle()
    .pipe(source('src/browser/preboot_browser.js'))
    .pipe(buffer())
    .pipe(insert.append('\n\n;preboot.init("' + appName + '",' + stringifyWithFunctions(opts) + ');\n\n'))
    .pipe(insert.append('\n\n;preboot.init("' + appName + '2",' + stringifyWithFunctions(opts) + ');\n\n'))
    .pipe(rename('preboot.js'));

  // uglify if the option is passed in
  return opts.uglify ? outputStream.pipe(uglify()) : outputStream;
}
開發者ID:StevenLudwig,項目名稱:universal,代碼行數:34,代碼來源:browser_code_generator.ts

示例5: builderjs

function builderjs(src: string[], dest: string, fWatch:boolean, fMinify: boolean, externals: string[], requires: string[]) {
    var bundler = browserify({
            basedir: '.',
            debug: true,
            entries: src,
            cache: {},
            packageCache: {}
        })
        .plugin(tsify, tsoptions.compilerOptions)
        .external(externals);
    bundler = requires.reduce((b, id) => bundler.require(resolve.sync(id), {expose: id}), bundler);

    function rebundle() {
        return bundler
            .bundle()
            .on('error', function(er:any)  
            {
                console.log(er.message);
                this.emit('end');
            })
            .pipe(source(dest))
            .pipe(gulp.dest(paths.dest));
    }

    if (fWatch) {
        bundler = watchify(bundler);
        bundler.on("update", rebundle);
        bundler.on("log", gutil.log);
        gulp.watch('src/**/*.json', [])
            .on("change", rebundle);
    }

    return rebundle();
}
開發者ID:pzahoran,項目名稱:reactive-angular2,代碼行數:34,代碼來源:gulpfile.ts

示例6: return

 return (next: (arg?: any) => void) => {
   if (argv.verbose) gutil.log(`Building ${plugin_name}`)
   const pluginOpts = {
     entries: [path.resolve(path.join(paths.buildDir.jsTree, main))],
     extensions: [".js"],
     debug: true,
     preludePath: pluginPreludePath,
     prelude: pluginPreludeText,
     paths: ['./node_modules', paths.buildDir.jsTree],
   }
   const plugin = browserify(pluginOpts)
   labels[plugin_name] = namedLabeler(plugin, labels.bokehjs)
   for (const file in labels.bokehjs) {
     const name = labels.bokehjs[file]
     if (name !== "_process")
       plugin.external(file)
   }
   plugin
     .bundle()
     .pipe(source((paths.coffee as any)[plugin_name].destination.full))
     .pipe(buffer())
     .pipe(sourcemaps.init({loadMaps: true}))
     // This solves a conflict when requirejs is loaded on the page. Backbone
     // looks for `define` before looking for `module.exports`, which eats up
     // our backbone.
     .pipe(change((content: string) => {
       return `(function() { var define = undefined; return ${content} })()`
     }))
     .pipe(insert.append(license))
     .pipe(sourcemaps.write('./'))
     .pipe(gulp.dest(paths.buildDir.js))
     .on('end', () => next())
 }
開發者ID:bgyarfas,項目名稱:bokeh,代碼行數:33,代碼來源:scripts.ts

示例7: browserify

		const tasks = files.map((entry: string) => {
			return browserify({ entries: [entry] })
				.bundle()
				.pipe(source(entry.replace('tmp', 'resources')))
				.pipe(buffer())
				.pipe(uglify())
				.pipe(dest('./built'));
		});
開發者ID:armchair-philosophy,項目名稱:Misskey-Web,代碼行數:8,代碼來源:gulpfile.ts

示例8: Promise

 return new Promise((resolve, reject) => {
   let b = browserify({basedir: cwd, debug: debug});
   b.require(requireable);
   b.add(toAdd);
   b.transform(babelify, {presets: require('babel-preset-es2015')});
   b.bundle((err, res) => {
     if (err) return reject(err);
     return resolve(res.toString())
   })
 });
開發者ID:tbtimes,項目名稱:ledeTwo,代碼行數:10,代碼來源:Es6Compiler.ts

示例9: bundleApp

 function bundleApp() {
   return browserify(join(TMP_DIR, 'main'))
     .bundle()
     .pipe(require('vinyl-source-stream')(JS_PROD_APP_BUNDLE))
     .pipe(require('vinyl-buffer')())
     .pipe(plugins.uglify({
       mangle: false
     }))
     .pipe(gulp.dest(JS_DEST));
 }
開發者ID:HilmiDEV,項目名稱:viewchildren-contentchildren-demo,代碼行數:10,代碼來源:build.bundles.ts

示例10: browserify

 let bundleApp = () => {
   return browserify(join(TMP_DIR, 'main'))
     .bundle()
     .pipe(vinylSourceStream(JS_PROD_APP_BUNDLE))
     .pipe(vinylBuffer())
     // Strip comments and sourcemaps
     .pipe(plugins.uglify({
       mangle: true,
       compress: true,
       preserveComments: 'license'
     }))
     .pipe(gulp.dest(JS_DEST));
 };
開發者ID:ouq77,項目名稱:portfolio-web,代碼行數:13,代碼來源:build.bundles.ts


注:本文中的browserify.default方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。