UNPKG

3.1 kBTypeScriptView Raw
1/**
2 * @license
3 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
4 * This code may only be used under the BSD style license found at
5 * http://polymer.github.io/LICENSE.txt
6 * The complete set of authors may be found at
7 * http://polymer.github.io/AUTHORS.txt
8 * The complete set of contributors may be found at
9 * http://polymer.github.io/CONTRIBUTORS.txt
10 * Code distributed by Google as part of the polymer project is also
11 * subject to an additional IP rights grant found at
12 * http://polymer.github.io/PATENTS.txt
13 */
14import { Analyzer, Document, ResolvedUrl } from 'polymer-analyzer';
15import { BundleManifest, BundleStrategy, BundleUrlMapper } from './bundle-manifest';
16import { DocumentCollection } from './document-collection';
17export * from './bundle-manifest';
18export interface Options {
19 analyzer?: Analyzer;
20 excludes?: ResolvedUrl[];
21 inlineCss?: boolean;
22 inlineScripts?: boolean;
23 rewriteUrlsInTemplates?: boolean;
24 sourcemaps?: boolean;
25 stripComments?: boolean;
26 strategy?: BundleStrategy;
27 treeshake?: boolean;
28 urlMapper?: BundleUrlMapper;
29}
30export interface BundleResult {
31 documents: DocumentCollection;
32 manifest: BundleManifest;
33}
34export declare class Bundler {
35 analyzer: Analyzer;
36 enableCssInlining: boolean;
37 enableScriptInlining: boolean;
38 excludes: ResolvedUrl[];
39 rewriteUrlsInTemplates: boolean;
40 sourcemaps: boolean;
41 stripComments: boolean;
42 strategy: BundleStrategy;
43 treeshake: boolean;
44 urlMapper: BundleUrlMapper;
45 private _overlayUrlLoader;
46 constructor(options?: Options);
47 /**
48 * Analyze an HTML URL using the given contents in place of what would
49 * otherwise have been loaded.
50 */
51 analyzeContents(url: ResolvedUrl, contents: string, permanent?: boolean): Promise<Document>;
52 /**
53 * Given a manifest describing the bundles, produce a collection of bundled
54 * documents with HTML imports, external stylesheets and external scripts
55 * inlined according to the options for this Bundler.
56 *
57 * @param manifest - The manifest that describes the bundles to be produced.
58 */
59 bundle(manifest: BundleManifest): Promise<BundleResult>;
60 /**
61 * Generates a BundleManifest with all bundles defined, using entrypoints,
62 * strategy and mapper.
63 *
64 * @param entrypoints - The list of entrypoints that will be analyzed for
65 * dependencies. The results of the analysis will be passed to the
66 * `strategy`.
67 * @param strategy - The strategy used to construct the output bundles.
68 * See 'polymer-analyzer/src/bundle-manifest'.
69 * @param mapper - A function that produces URLs for the generated bundles.
70 * See 'polymer-analyzer/src/bundle-manifest'.
71 */
72 generateManifest(entrypoints: ResolvedUrl[]): Promise<BundleManifest>;
73 /**
74 * Given an array of Bundles, remove all files from bundles which are in the
75 * "excludes" set. Remove any bundles which are left empty after excluded
76 * files are removed.
77 */
78 private _filterExcludesFromBundles;
79}