本文整理汇总了TypeScript中rollup.rollup函数的典型用法代码示例。如果您正苦于以下问题:TypeScript rollup函数的具体用法?TypeScript rollup怎么用?TypeScript rollup使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rollup函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: createRollupBundle
/** Creates a rollup bundle of a specified JavaScript file.*/
private async createRollupBundle(config: RollupBundleConfig) {
const bundleOptions = {
context: 'this',
external: Object.keys(rollupGlobals),
input: config.entry,
onwarn: (message: string) => {
// TODO(jelbourn): figure out *why* rollup warns about certain symbols not being found
// when those symbols don't appear to be in the input file in the first place.
if (/but never used/.test(message)) {
return false;
}
console.warn(message);
},
plugins: [
rollupRemoveLicensesPlugin,
]
};
const writeOptions = {
name: config.moduleName || 'ng.flexLayout',
amd: {id: config.importName},
banner: buildConfig.licenseBanner,
format: config.format,
file: config.dest,
globals: rollupGlobals,
sourcemap: true
};
// For UMD bundles, we need to adjust the `external` bundle option in order to include
// all necessary code in the bundle.
if (config.format === 'umd') {
bundleOptions.plugins.push(rollupNodeResolutionPlugin());
// For all UMD bundles, we want to exclude tslib from the `external` bundle option so that
// it is inlined into the bundle.
let external = Object.keys(rollupGlobals);
external.splice(external.indexOf('tslib'), 1);
// If each secondary entry-point is re-exported at the root, we want to exlclude those
// secondary entry-points from the rollup globals because we want the UMD for this package
// to include *all* of the sources for those entry-points.
if (this.buildPackage.exportsSecondaryEntryPointsAtRoot &&
config.moduleName === `ng.${this.buildPackage.name}`) {
const importRegex = new RegExp(`@angular/${this.buildPackage.name}/.+`);
external = external.filter(e => !importRegex.test(e));
// Use the rollup-alias plugin to map imports of the form `@angular/material/button`
// to the actual file location so that rollup can resolve the imports (otherwise they
// will be treated as external dependencies and not included in the bundle).
bundleOptions.plugins.push(
rollupAlias(this.getResolvedSecondaryEntryPointImportPaths(config.dest)));
}
bundleOptions.external = external;
}
return rollup.rollup(bundleOptions).then((bundle: any) => bundle.write(writeOptions));
}
开发者ID:marffox,项目名称:flex-layout,代码行数:61,代码来源:build-bundles.ts
示例2: createRollupBundle
export function createRollupBundle(config: BundleConfig): Promise<any> {
const bundleOptions: any = {
context: 'this',
external: config.external,
entry: config.entry,
};
const writeOptions = {
// Keep the moduleId empty because we don't want to force developers to a specific moduleId.
moduleId: '',
moduleName: config.moduleName,
// banner: buildConfig.licenseBanner,
format: config.format,
dest: config.dest,
globals: config.globals,
sourceMap: true
};
// When creating a UMD, we want to exclude tslib from the `external` bundle option so that it
// is inlined into the bundle.
if (config.format === 'umd') {
bundleOptions.plugins = [resolve()];
if (bundleOptions.external && bundleOptions.external.indexOf('tslib') > -1) {
bundleOptions.external.splice(bundleOptions.external.indexOf('tslib'), 1);
}
}
return rollup.rollup(bundleOptions).then((bundle: any) => bundle.write(writeOptions));
}
开发者ID:shlomiassaf,项目名称:ng2-chess,代码行数:30,代码来源:rollup.ts
示例3: loadConfigFile
export default function loadConfigFile(
configFile: string,
commandOptions: any = {}
): Promise<InputOptions[]> {
const silent = commandOptions.silent || false;
const warnings = batchWarnings();
return rollup
.rollup({
input: configFile,
external: (id: string) => {
return (id[0] !== '.' && !path.isAbsolute(id)) || id.slice(-5, id.length) === '.json';
},
onwarn: warnings.add
})
.then((bundle: RollupSingleFileBuild) => {
if (!silent && warnings.count > 0) {
stderr(tc.bold(`loaded ${relativeId(configFile)} with warnings`));
warnings.flush();
}
return bundle.generate({
format: 'cjs'
});
})
.then(({ code }: { code: string }) => {
// temporarily override require
const defaultLoader = require.extensions['.js'];
require.extensions['.js'] = (module: NodeModuleWithCompile, filename: string) => {
if (filename === configFile) {
module._compile(code, filename);
} else {
defaultLoader(module, filename);
}
};
delete require.cache[configFile];
return Promise.resolve(require(configFile))
.then(configFileContent => {
if (typeof configFileContent === 'function') {
return configFileContent(commandOptions);
}
return configFileContent;
})
.then(configs => {
if (Object.keys(configs).length === 0) {
handleError({
code: 'MISSING_CONFIG',
message: 'Config file must export an options object, or an array of options objects',
url: 'https://rollupjs.org/guide/en#configuration-files'
});
}
require.extensions['.js'] = defaultLoader;
return Array.isArray(configs) ? configs : [configs];
});
});
}
开发者ID:tivac,项目名称:rollup,代码行数:60,代码来源:loadConfigFile.ts
示例4: compileGlobals
private static compileGlobals(cachePath: string, tree: PageTree) {
const pageCachePath = join(cachePath, tree.context.$PAGE.$name);
return rollup.rollup({
entry: tree.scripts.globals.map(x => x.path),
context: "window",
plugins: [
includes({ paths: [ join(pageCachePath, "scripts")] }),
multientry({ exports: false }),
nodeResolve({ jsnext: true }),
commonjs({}),
babel({
presets: [
[
"es2015",
{
"modules": false
}
]
],
"plugins": [
"external-helpers"
],
exclude: "node_modules/**"
})
]
}).then(bundle => bundle.generate({format: "iife", exports: "none", sourceMap: true}).code);
}
开发者ID:tbtimes,项目名称:lede,代码行数:27,代码来源:Es6Compiler.ts
示例5: generateToolsJs
async function generateToolsJs(): Promise<void> {
for (const bin of ["configure-ui", "dump-data-model"]) {
const inputFile = path.resolve(INPUT_DIR, `tools/${bin}`);
const outputFile = path.resolve(OUTPUT_DIR, `tools/${bin}`);
const bundle = await rollup({
input: inputFile,
external: externals,
acorn: {
allowHashBang: true
},
plugins: [
rollupReplace({
delimiters: ["", ""],
"#!/usr/bin/env -S node -r esm -r ts-node/register/transpile-only": ""
}),
typescript({
tsconfig: "./tsconfig.json",
include: [`tools/${bin}`, "lib/**/*.ts"]
}),
MODE === "production" ? terser() : null
]
});
await bundle.write({
format: "cjs",
preferConst: true,
banner: "#!/usr/bin/env node",
file: outputFile
});
// Mark as executable
const mode = fs.statSync(outputFile).mode;
fs.chmodSync(outputFile, mode | 73);
}
}
开发者ID:zaidka,项目名称:genieacs,代码行数:35,代码来源:build.ts
示例6: createRollupBundle
export function createRollupBundle(config: BundleConfig): Promise<any> {
const bundleOptions: any = {
context: 'this',
external: Object.keys(ROLLUP_GLOBALS),
entry: config.entry,
};
const writeOptions = {
// Keep the moduleId empty because we don't want to force developers to a specific moduleId.
moduleId: '',
moduleName: config.moduleName || 'ng.material',
banner: LICENSE_BANNER,
format: config.format,
dest: config.dest,
globals: ROLLUP_GLOBALS,
sourceMap: true
};
// When creating a UMD, we want to exclude tslib from the `external` bundle option so that it
// is inlined into the bundle.
if (config.format === 'umd') {
bundleOptions.plugins = [rollupNodeResolutionPlugin()];
const external = Object.keys(ROLLUP_GLOBALS);
external.splice(external.indexOf('tslib'), 1);
bundleOptions.external = external;
}
return rollup.rollup(bundleOptions).then((bundle: any) => bundle.write(writeOptions));
}
开发者ID:StefanSinapov,项目名称:material2,代码行数:30,代码来源:rollup-helpers.ts
示例7: join
export = (done: any) => {
rollup
.rollup(config)
.then((bundle: any) =>
bundle.generate({
format: 'iife',
sourcemap: Config.PRESERVE_SOURCE_MAPS
})
)
.then((result: any) => {
const path = join(Config.TMP_DIR, 'bundle.js');
parallel(getTasks(path, result), (error: any, results: boolean[]) => {
if (error && results.indexOf(false) === -1) {
console.error(error);
process.exit(0);
}
done();
});
})
.catch((error: any) => {
console.error(error);
process.exit(0);
});
};
开发者ID:albogdano,项目名称:angular2-para,代码行数:25,代码来源:build.bundles.app.rollup.aot.ts
示例8: Promise
return new Promise((resolve, reject) => {
let rollupConfig = getRollupConfig(context, configFile);
rollupConfig.dest = getOutputDest(context, rollupConfig);
// replace any path vars like {{TMP}} with the real path
rollupConfig.entry = replacePathVars(context, normalize(rollupConfig.entry));
rollupConfig.dest = replacePathVars(context, normalize(rollupConfig.dest));
addRollupPluginIfNecessary(context, rollupConfig.plugins);
// tell rollup to use a previous bundle as its starting point
rollupConfig.cache = cachedBundle;
if (!rollupConfig.onwarn) {
// use our own logger if one wasn't already provided
rollupConfig.onwarn = createOnWarnFn();
}
Logger.debug(`entry: ${rollupConfig.entry}, dest: ${rollupConfig.dest}, cache: ${rollupConfig.cache}, format: ${rollupConfig.format}`);
// bundle the app then create create css
rollupBundler.rollup(rollupConfig)
.then((bundle: RollupBundle) => {
Logger.debug(`bundle.modules: ${bundle.modules.length}`);
// set the module files used in this bundle
// this reference can be used elsewhere in the build (sass)
context.moduleFiles = bundle.modules.map((m) => {
// sometimes, Rollup appends weird prefixes to the path like commonjs:proxy
const index = m.id.indexOf(sep);
if (index >= 0) {
return m.id.substring(index);
}
return m.id;
});
// cache our bundle for later use
if (context.isWatch) {
cachedBundle = bundle;
}
// write the bundle
return bundle.write(rollupConfig);
})
.then(() => {
// clean up any references (overkill yes, but let's play it safe)
rollupConfig = rollupConfig.cache = rollupConfig.onwarn = rollupConfig.plugins = null;
resolve();
})
.catch((err: any) => {
// ensure references are cleared up when there's an error
cachedBundle = rollupConfig = rollupConfig.cache = rollupConfig.onwarn = rollupConfig.plugins = null;
reject(new BuildError(err));
});
});
开发者ID:Kode-Kitchen,项目名称:ionic-app-scripts,代码行数:58,代码来源:rollup.ts
示例9: task
task(':build:components:rollup', [':build:components:inline'], () => {
const globals: { [name: string]: string } = {
// Angular dependencies
'@angular/core': 'ng.core',
'@angular/common': 'ng.common',
'@angular/forms': 'ng.forms',
'@angular/http': 'ng.http',
'@angular/platform-browser': 'ng.platformBrowser',
'@angular/platform-browser-dynamic': 'ng.platformBrowserDynamic',
'@angular/material': 'ng.material',
// Rxjs dependencies
'rxjs/Observable': 'Rx',
'rxjs/Subject': 'Rx',
'rxjs/BehaviorSubject': 'Rx',
'rxjs/scheduler/queue': 'Rx',
'rxjs/add/observable/from': 'Rx.Observable',
'rxjs/add/observable/of': 'Rx.Observable',
'rxjs/add/operator/distinctUntilChanged': 'Rx.Observable.prototype',
'rxjs/add/operator/filter': 'Rx.Observable.prototype',
'rxjs/add/operator/let': 'Rx.Observable.prototype',
'rxjs/add/operator/map': 'Rx.Observable.prototype',
'rxjs/add/operator/mergeMap': 'Rx.Observable.prototype',
'rxjs/add/operator/observeOn': 'Rx.Observable.prototype',
'rxjs/add/operator/pluck': 'Rx.Observable.prototype',
'rxjs/add/operator/scan': 'Rx.Observable.prototype',
'rxjs/add/operator/skip': 'Rx.Observable.prototype',
'rxjs/add/operator/take': 'Rx.Observable.prototype',
'rxjs/add/operator/takeUntil': 'Rx.Observable.prototype',
'rxjs/add/operator/withLatestFrom': 'Rx.Observable.prototype',
};
// Rollup the UMD bundle from all ES5 + imports JavaScript files built.
return rollup({
entry: path.join(DIST_COMPONENTS_ROOT, 'index.js'),
context: 'this',
external: Object.keys(globals)
}).then((bundle: { generate: any }) => {
const result = bundle.generate({
moduleName: 'ng2-md-datatable',
format: 'umd',
globals,
sourceMap: true,
dest: path.join(DIST_COMPONENTS_ROOT, 'ng2-md-datatable.umd.js')
});
// Add source map URL to the code.
result.code += '\n\n//# sourceMappingURL=./ng2-md-datatable.umd.js.map\n';
// Format mapping to show properly in the browser. Rollup by default will put the path
// as relative to the file, and since that path is in src/lib and the file is in
// dist/@angular/material, we need to kill a few `../`.
result.map.sources = result.map.sources.map((s: string) => s.replace(/^(\.\.\/)+/, ''));
writeFileSync(path.join(DIST_COMPONENTS_ROOT, 'ng2-md-datatable.umd.js'), result.code, 'utf8');
writeFileSync(path.join(DIST_COMPONENTS_ROOT, 'ng2-md-datatable.umd.js.map'), result.map, 'utf8');
});
});
开发者ID:jwmao,项目名称:ng2-md-datatable,代码行数:57,代码来源:components.ts
示例10: generateBackendJs
async function generateBackendJs(): Promise<void> {
for (const bin of [
"genieacs-cwmp",
"genieacs-ext",
"genieacs-nbi",
"genieacs-fs",
"genieacs-ui"
]) {
const inputFile = path.resolve(INPUT_DIR, `bin/${bin}`);
const outputFile = path.resolve(OUTPUT_DIR, `bin/${bin}`);
const bundle = await rollup({
input: inputFile,
external: externals,
acorn: {
allowHashBang: true
},
treeshake: {
propertyReadSideEffects: false,
pureExternalModules: true
},
plugins: [
rollupReplace({
delimiters: ["", ""],
"#!/usr/bin/env -S node -r esm -r ts-node/register/transpile-only": ""
}),
rollupJson({ preferConst: true }),
{
resolveId: (importee, importer) => {
if (importee.endsWith("/package.json")) {
const p = path.resolve(path.dirname(importer), importee);
if (p === path.resolve(INPUT_DIR, "package.json"))
return path.resolve(OUTPUT_DIR, "package.json");
}
return null;
}
},
typescript({
tsconfig: "./tsconfig.json",
include: [`bin/${bin}`, "lib/**/*.ts"]
}),
MODE === "production" ? terser() : null
]
});
await bundle.write({
format: "cjs",
preferConst: true,
banner: "#!/usr/bin/env node",
file: outputFile
});
// Mark as executable
const mode = fs.statSync(outputFile).mode;
fs.chmodSync(outputFile, mode | 73);
}
}
开发者ID:zaidka,项目名称:genieacs,代码行数:56,代码来源:build.ts
示例11: rollup
.then(() => {
return rollup({
entry: path.join(DIST_COMPONENTS_ROOT, name, 'index.js'),
context: 'window',
external: [
...Object.keys(globals),
...components.map(name => `@angular2-material/${name}`)
]
});
})
开发者ID:jimitndiaye,项目名称:material2,代码行数:10,代码来源:components.ts
示例12: build
export default function build (inputOptions: InputOptions, outputOptions: OutputOptions[], warnings: BatchWarnings, silent = false) {
const useStdout = outputOptions.length === 1 && !outputOptions[0].file && inputOptions.input instanceof Array === false;
const start = Date.now();
const files = useStdout
? ['stdout']
: outputOptions.map(t => relativeId(t.file || t.dir));
if (!silent)
stderr(
chalk.cyan(
`\n${chalk.bold(typeof inputOptions.input === 'string' ? inputOptions.input : inputOptions.input && inputOptions.input.join(', '))} â ${chalk.bold(
files.join(', ')
)}...`
)
);
return rollup
.rollup(inputOptions)
.then((bundle: OutputChunk) => {
if (useStdout) {
const output = outputOptions[0];
if (output.sourcemap && output.sourcemap !== 'inline') {
handleError({
code: 'MISSING_OUTPUT_OPTION',
message:
'You must specify an --output (-o) option when creating a file with a sourcemap'
});
}
return bundle.generate(output).then(({ code, map }: { code: string, map: SourceMap }) => {
if (output.sourcemap === 'inline') {
code += `\n//# ${SOURCEMAPPING_URL}=${map.toUrl()}\n`;
}
process.stdout.write(code);
});
}
return mapSequence(outputOptions, output => {
return bundle.write(output);
});
})
.then(() => {
warnings.flush();
if (!silent)
stderr(
chalk.green(
`created ${chalk.bold(files.join(', '))} in ${chalk.bold(
ms(Date.now() - start)
)}`
)
);
})
.catch(handleError);
}
开发者ID:joeldenning,项目名称:rollup,代码行数:55,代码来源:build.ts
示例13: rollup
const bundle = () => {
return rollup({
entry: 'mochats/component.ts',
plugins: [
angular(),
commonjs(),
typescript({
typescript: require('./../../node_modules/typescript')
})
]
});
}
开发者ID:cebor,项目名称:rollup-plugin-angular,代码行数:12,代码来源:component.spec.ts
示例14: build
export async function build(filename, css = false): Promise<string> {
const cacheKey = JSON.stringify({filename, css})
if (cacheKey in cache) return cache[cacheKey]
let style: string | undefined
const input = filename + '__app.js'
const options = {defaultLang: {markdown: 'pluginMarkdown'}, css: css, style: {
postcssPlugins: [assets({ basePath: '/' })]
}}
const bundle = await rollup({
input,
plugins: [
pluginCreateVueApp(input, filename),
pluginCSS({
output: (s: string) => {
style = s
}
}),
pluginVue(options),
...plugins
],
external: ['vue']
})
const output = await bundle.generate({
format: 'iife',
name: 'App',
sourcemap: true,
globals: {
vue: 'Vue'
}
})
let outputCode = output.code
if (style) {
outputCode += `\n;(function() {
var s = document.createElement('style');
s.type = 'text/css';
document.head.appendChild(s);
s.appendChild(document.createTextNode(${JSON.stringify(style)}))
})()`
}
outputCode += `\n\n//# sourceMappingURL=data:application/json;base64,${new Buffer(JSON.stringify(output.map)).toString('base64')}\n`
cache[cacheKey] = outputCode
return outputCode
}
开发者ID:liekkas,项目名称:rollup-plugin-vue,代码行数:49,代码来源:index.ts
示例15:
...src_paths.map(async sourcePath => {
const bundle = await rollup.rollup({
...rollupConfig.input,
input: sourcePath,
});
const fileName = path.basename(sourcePath, path.extname(sourcePath));
return bundle.write({
...rollupConfig.output,
exports: folder === "l10n" ? "named" : "default",
sourcemap: false,
file: sourcePath.replace("src", "dist").replace(".ts", ".js"),
name: customModuleNames[fileName] || fileName,
});
}),
开发者ID:jeremyrazzano,项目名称:flatpickr,代码行数:16,代码来源:build.ts
示例16: main
async function main() {
const bundle = await rollup({
entry: 'main.js',
cache,
})
const result = bundle.generate({
format: 'cjs',
})
cache = bundle
await bundle.write({
format: 'cjs',
dest: 'bundle.js',
})
}
开发者ID:Crevil,项目名称:DefinitelyTyped,代码行数:17,代码来源:rollup-tests.ts
示例17: SwRewriter
gulp.task('task:worker:test:bundle', done => rollup
.rollup({
entry: 'tmp/esm/src/worker/builds/test.js',
plugins: [
new SwRewriter(),
nodeResolve({jsnext: true, main: true}),
commonjs({
include: 'node_modules/**',
namedExports: {
'node_modules/jshashes/hashes.js': ['SHA1']
}
})
]
})
.then(bundle => bundle.write({
format: 'iife',
dest: 'tmp/es5/bundles/worker-test.js',
})));
开发者ID:webmaxru,项目名称:mobile-toolkit,代码行数:18,代码来源:gulpfile.ts
示例18: generateFrontendJs
async function generateFrontendJs(): Promise<void> {
const inputFile = path.resolve(INPUT_DIR, "ui/app.ts");
const outputFile = path.resolve(OUTPUT_DIR, "public/app.js");
const bundle = await rollup({
input: inputFile,
external: externals,
plugins: [
rollupJson({ preferConst: true }),
typescript({ tsconfig: "./tsconfig.json" })
],
inlineDynamicImports: true,
treeshake: {
propertyReadSideEffects: false,
pureExternalModules: true
},
onwarn: ((warning, warn) => {
// Ignore circular dependency warnings
if (warning.code !== "CIRCULAR_DEPENDENCY") warn(warning);
}) as WarningHandler
});
await bundle.write({
preferConst: true,
format: "esm",
file: outputFile
});
const webpackConf = {
mode: MODE,
entry: outputFile,
resolve: {
aliasFields: ["module"]
},
output: {
path: path.resolve(OUTPUT_DIR, "public"),
filename: "app.js"
}
};
const stats = await promisify(webpack)(webpackConf);
process.stdout.write(stats.toString({ colors: true }) + "\n");
}
开发者ID:zaidka,项目名称:genieacs,代码行数:43,代码来源:build.ts
示例19: task
task('release.createUmdBundle', (done: Function) => {
return rollup({
entry: DIST_BUILD_UMD_BUNDLE_ENTRYPOINT,
plugins: [
nodeResolve({
module: true,
jsnext: true,
main: true
}),
commonjs()
]
}).then((bundle) => {
return bundle.write({
format: 'umd',
moduleName: 'ionicBundle',
dest: `${DIST_BUNDLE_ROOT}/ionic.umd.js`
});
});
});
开发者ID:HugoHeneault,项目名称:ionic,代码行数:19,代码来源:release.ts
示例20: bundle
export function bundle(jsFiles: Dic<BabelFile>, opts: FableOptions, fableProc: child_process.ChildProcess, continuation: Continuation) {
var rollupOpts = Object.assign({}, opts.rollup);
rollupOpts.cache = bundleCache;
rollupOpts.plugins.splice(0, 0, hypothetical({
files: jsFiles, allowRealFiles: true, allowExternalModules: true
}));
if (rollupOpts.entry == null) {
rollupOpts.entry = Object.getOwnPropertyNames(jsFiles)
.find(function(f) { return jsFiles[f].isEntry });
}
fableLib.stdoutLog("Bundling...");
rollup.rollup(rollupOpts)
.then((bundle: any) => {
var parsed = bundle.generate(rollupOpts);
if (opts.watch) {
bundleCache = bundle;
}
// Write to disk, bundle.write doesn't seem to work
// bundle.write({ dest: rollupOpts.dest, format: rollupOpts.format, sourceMap: rollupOpts.sourceMap });
fableLib.writeFile(rollupOpts.dest, parsed.code,
rollupOpts.sourceMap === true ? parsed.map : null);
fableLib.stdoutLog("Bundled " + path.relative(opts.workingDir, rollupOpts.dest) + " at " + (new Date()).toLocaleTimeString());
postbuild(opts, "SUCCESS", fableProc, continuation);
})
.catch((err: Error) => {
// The stack here is a bit noisy just report the message
fableLib.stderrLog(err.message);
bundleCache = null;
let buildResult: BuildResult = null;
if (!fullRebuildTriggered) {
fullRebuildTriggered = true;
buildResult = "NEEDS_FULL_REBUILD";
}
else {
fullRebuildTriggered = false; // Prevent infinite loop
buildResult = "FAIL";
}
postbuild(opts, buildResult, fableProc, continuation);
});
}
开发者ID:fdcastel,项目名称:Fable,代码行数:42,代码来源:bundle.ts
注:本文中的rollup.rollup函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论