本文整理汇总了TypeScript中browserify.default函数的典型用法代码示例。如果您正苦于以下问题:TypeScript default函数的具体用法?TypeScript default怎么用?TypeScript default使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了default函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: getBrowserCodeStream
export function getBrowserCodeStream(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(' + stringifyWithFunctions(opts) + ');\n\n'))
.pipe(rename('preboot.js'));
// uglify if the option is passed in
return opts.uglify ? outputStream.pipe(uglify()) : outputStream;
}
示例2: function
app.get('/browserify/*', function(req, res) {
//TODO: cache this in production or generate all files beforehand
let reqFile:string = req.params[0]
let stream = browserify(["./public/ts/"+reqFile]).bundle()
stream.on("data", function(buffer){
res.write(buffer)
})
stream.on("end", function(){
res.end()
})
});
示例3: getBrowserify
async function getBrowserify(inputRootDir: FilePath, sourceFile: FilePath) {
return browserify({
debug: true,
//entries: [inputRootDir + "/" + sourceFile],
entries: [sourceFile],
cache: {},
packageCache: {},
// TODO: decide how to pass parameter
basedir: inputRootDir
});
//return pluginsCommon(browserifyInstance);
}
示例4: constructor
constructor (public path: string){
let that = this;
this.path = path;
this.sourcemap = !$.prod || $.config.scripts.sourcemap;
this.bundler = browserify({
//entries: [$.config.scripts.dev + this.path],
debug: this.sourcemap,
cache: {},
packageCache: {},
fullPaths: !$.prod
}).add($.config.scripts.dev + this.path);
if (!$.prod) {
this.bundler = watchify(this.bundler);
this.bundler.on('update', () => {
this.build();
$.plugin.util.log($.plugin.util.colors.green(`Rebundle ${this.path}`));
});
}
}
示例5: function
gulp.task('compile-ts', function () {
var opts = {
basedir: config.paths.app,
debug: true
};
var b = browserify(opts)
.add(config.paths.app + '/main.ts')
.external('jquery')
.plugin(tsify, {
removeComments: true,
noImplicitAny: true,
target: 'es5'
})
.transform(debowerify);
return b.bundle()
.on('error', gutil.log.bind(gutil, 'Browserify Error'))
.pipe(exorcist(config.paths.pub + '/app.js.map'))
.pipe(source('app.js'))
.pipe(gulp.dest(config.paths.pub));
});
示例6: bundle
function bundle(namespace: string) {
let bundler = browserify(
SOURCE_DIR + '/' + namespace + '/app/app-' + env + '.js',
{
debug: true
}
).transform(babelify, { presets: ['es2015'] });
return bundler.bundle()
.on('error', function (err) {
console.log(err);
this.emit('end');
})
.pipe(source('app.js'))
.pipe(buffer())
.pipe(sourcemaps.init({ loadMaps: true }))
.pipe(gulpif(minify, uglify()))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest(DEST_DIR + '/' + namespace));
}
示例7: async
export const createTestBundle = async (modulePath: string): Promise<TestBundle> => {
const bundler = browserify(modulePath, {
// Generate sourcemaps for debugging
debug: true,
// Expose the module under this global variable
standalone: 'moduleUnderTest',
// rootDir for sourcemaps
basedir: __dirname + '/../../src',
})
bundler.plugin(tsify, { project: __dirname + '/../../tsconfig.test.json' })
// If running through nyc, instrument bundle for coverage reporting too
if (process.env.NYC_CONFIG) {
bundler.transform(babelify.configure({ plugins: [babelPluginIstanbul], extensions: ['.tsx', '.ts'] }))
}
const spinner = ora(`Bundling ${modulePath}`)
bundler.on('file', (file, id) => {
spinner.text = `Bundling ${id}`
})
spinner.start()
try {
const bundle = await getStream(bundler.bundle())
return {
load(): DOMModuleSandbox {
const jsdom = new JSDOM('', { runScripts: 'dangerously' }) as JSDOM & {
window: { moduleUnderTest: any }
}
jsdom.window.eval(bundle)
return { window: jsdom.window, module: jsdom.window.moduleUnderTest }
},
}
} finally {
spinner.stop()
}
}
示例8: require
/// <reference path="browserify.d.ts"/>
import browserify = require("browserify");
import fs = require("fs");
var b: BrowserifyObject = browserify();
b.add('./browser/main.js');
b.transform('deamdify');
b.bundle().pipe(fs.createWriteStream('bundle.js'));
var customBrowsify: Browserify = require("browserify");
customBrowsify({entries: []});