UNPKG

26 kBJavaScriptView Raw
1"use strict";
2/**
3 * @license
4 * Copyright (c) 2016 The Polymer Project Authors. All rights reserved.
5 * This code may only be used under the BSD style license found at
6 * http://polymer.github.io/LICENSE.txt
7 * The complete set of authors may be found at
8 * http://polymer.github.io/AUTHORS.txt
9 * The complete set of contributors may be found at
10 * http://polymer.github.io/CONTRIBUTORS.txt
11 * Code distributed by Google as part of the polymer project is also
12 * subject to an additional IP rights grant found at
13 * http://polymer.github.io/PATENTS.txt
14 */
15var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
16 return new (P || (P = Promise))(function (resolve, reject) {
17 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
18 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
19 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
20 step((generator = generator.apply(thisArg, _arguments || [])).next());
21 });
22};
23var __asyncValues = (this && this.__asyncValues) || function (o) {
24 if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
25 var m = o[Symbol.asyncIterator], i;
26 return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
27 function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
28 function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
29};
30var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
31var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
32 if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
33 var g = generator.apply(thisArg, _arguments || []), i, q = [];
34 return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
35 function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
36 function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
37 function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
38 function fulfill(value) { resume("next", value); }
39 function reject(value) { resume("throw", value); }
40 function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
41};
42Object.defineProperty(exports, "__esModule", { value: true });
43const chai_1 = require("chai");
44const polymer_analyzer_1 = require("polymer-analyzer");
45const polymer_bundler_1 = require("polymer-bundler");
46const polymer_project_config_1 = require("polymer-project-config");
47const dom5 = require("dom5/lib/index-next");
48const parse5_1 = require("parse5");
49const path = require("path");
50const mergeStream = require('merge-stream');
51const analyzer_1 = require("../analyzer");
52const bundle_1 = require("../bundle");
53const streams_1 = require("../streams");
54const defaultRoot = path.resolve('test-fixtures/bundler-data');
55class FileTransform extends streams_1.AsyncTransformStream {
56 constructor(transform) {
57 super({ objectMode: true });
58 this.transform = transform;
59 }
60 _transformIter(files) {
61 return __asyncGenerator(this, arguments, function* _transformIter_1() {
62 var e_1, _a;
63 try {
64 for (var files_1 = __asyncValues(files), files_1_1; files_1_1 = yield __await(files_1.next()), !files_1_1.done;) {
65 const file = files_1_1.value;
66 this.transform(this, file.clone());
67 }
68 }
69 catch (e_1_1) { e_1 = { error: e_1_1 }; }
70 finally {
71 try {
72 if (files_1_1 && !files_1_1.done && (_a = files_1.return)) yield __await(_a.call(files_1));
73 }
74 finally { if (e_1) throw e_1.error; }
75 }
76 });
77 }
78}
79function resolveUrls(root, urls) {
80 const resolver = new polymer_analyzer_1.FsUrlResolver(root);
81 return urls.map((u) => resolver.resolve(u));
82}
83suite('BuildBundler', () => {
84 let root;
85 let bundler;
86 let bundledStream;
87 let files;
88 const setupTest = (projectOptions, bundlerOptions, transform) => __awaiter(this, void 0, void 0, function* () {
89 return new Promise((resolve, reject) => {
90 if (projectOptions.root === undefined) {
91 throw new Error('projectOptions.root is undefined');
92 }
93 root = projectOptions.root;
94 const config = new polymer_project_config_1.ProjectConfig(projectOptions);
95 const analyzer = new analyzer_1.BuildAnalyzer(config);
96 bundler = new bundle_1.BuildBundler(config, analyzer, bundlerOptions);
97 bundledStream = mergeStream(analyzer.sources(), analyzer.dependencies());
98 if (transform) {
99 bundledStream = bundledStream.pipe(transform);
100 }
101 bundledStream = bundledStream.pipe(bundler);
102 bundler = new bundle_1.BuildBundler(config, analyzer);
103 files = new Map();
104 bundledStream.on('data', (file) => {
105 files.set(file.path, file);
106 });
107 bundledStream.on('end', () => {
108 resolve(files);
109 });
110 bundledStream.on('error', (err) => {
111 reject(err);
112 });
113 });
114 });
115 const getFile = (filename) => {
116 // we're getting FS paths, so add root
117 const file = files.get(path.resolve(root, filename));
118 return file && file.contents && file.contents.toString();
119 };
120 const getFileOrDie = (filename) => {
121 const file = getFile(filename);
122 if (file == null) {
123 throw new Error(`Unable to get file with filename ${filename}`);
124 }
125 return file;
126 };
127 const hasMarker = (doc, id) => {
128 const marker = dom5.query(doc, dom5.predicates.AND(dom5.predicates.hasTagName('div'), dom5.predicates.hasAttrValue('id', id)));
129 return marker != null;
130 };
131 const hasImport = (doc, url) => {
132 const link = dom5.query(doc, dom5.predicates.AND(dom5.predicates.hasTagName('link'), dom5.predicates.hasAttrValue('rel', 'import'), dom5.predicates.hasAttrValue('href', url)));
133 return link != null;
134 };
135 const addHeaders = new FileTransform((stream, file) => {
136 if (path.extname(file.path) === '.html') {
137 file.contents =
138 Buffer.from(`<!-- ${path.basename(file.path)} -->${file.contents}`);
139 }
140 else if (path.extname(file.path).match(/^\.(js|css)$/)) {
141 file.contents =
142 Buffer.from(`/* ${path.basename(file.path)} */${file.contents}`);
143 }
144 stream.push(file);
145 });
146 test('entrypoint only', () => __awaiter(this, void 0, void 0, function* () {
147 yield setupTest({
148 root: defaultRoot,
149 entrypoint: 'entrypoint-only.html',
150 });
151 const doc = parse5_1.parse(getFileOrDie('entrypoint-only.html'));
152 chai_1.assert.isTrue(hasMarker(doc, 'framework'), 'has framework');
153 chai_1.assert.isFalse(hasImport(doc, 'framework.html'));
154 chai_1.assert.isNotOk(getFile('shared_bundle_1.html'));
155 }));
156 test('two fragments', () => __awaiter(this, void 0, void 0, function* () {
157 yield setupTest({
158 root: defaultRoot,
159 entrypoint: 'entrypoint-a.html',
160 fragments: ['shell.html', 'entrypoint-a.html'],
161 });
162 // shell doesn't import framework
163 const shellDoc = parse5_1.parse(getFileOrDie('shell.html'));
164 chai_1.assert.isFalse(hasMarker(shellDoc, 'framework'));
165 chai_1.assert.isFalse(hasImport(shellDoc, 'framework.html'));
166 // entrypoint doesn't import framework
167 const entrypointDoc = parse5_1.parse(getFileOrDie('entrypoint-a.html'));
168 chai_1.assert.isFalse(hasMarker(entrypointDoc, 'framework'));
169 chai_1.assert.isFalse(hasImport(entrypointDoc, 'framework.html'));
170 // No shared-bundle bundles framework
171 const sharedDoc = parse5_1.parse(getFileOrDie('shared_bundle_1.html'));
172 chai_1.assert.isTrue(hasMarker(sharedDoc, 'framework'));
173 chai_1.assert.isFalse(hasImport(sharedDoc, 'framework.html'));
174 // fragments import shared-bundle
175 chai_1.assert.isTrue(hasImport(entrypointDoc, 'shared_bundle_1.html'));
176 chai_1.assert.isTrue(hasImport(shellDoc, 'shared_bundle_1.html'));
177 }));
178 // TODO(usergenic): It appears that this test is aspirational. It wants
179 // build to manipulate the entrypoint to remove things that have been bundled
180 // into the shell, in this case, but we don't yet support manipulating the
181 // entrypoint properly. In part, this is because entrypoints can not have
182 // relative paths, since they can be served from any url. Note that the
183 // test 'entrypoint and fragments' below is skipped for the same reason.
184 test.skip('shell and entrypoint', () => __awaiter(this, void 0, void 0, function* () {
185 yield setupTest({
186 entrypoint: 'entrypoint-a.html',
187 shell: 'shell.html',
188 });
189 // shell bundles framework
190 const shellDoc = parse5_1.parse(getFileOrDie('shell.html'));
191 chai_1.assert.isTrue(hasMarker(shellDoc, 'framework'));
192 // entrypoint doesn't import framework
193 const entrypointDoc = parse5_1.parse(getFileOrDie('entrypoint-a.html'));
194 chai_1.assert.isFalse(hasMarker(entrypointDoc, 'framework'));
195 chai_1.assert.isFalse(hasImport(entrypointDoc, 'framework.html'));
196 // entrypoint imports shell
197 chai_1.assert.isTrue(hasImport(entrypointDoc, 'shell.html'));
198 // No shared-bundle with a shell
199 chai_1.assert.isNotOk(getFile('shared_bundle_1.html'));
200 }));
201 test('shell and fragments with shared dependency', () => __awaiter(this, void 0, void 0, function* () {
202 yield setupTest({
203 root: defaultRoot,
204 entrypoint: 'entrypoint-a.html',
205 shell: 'shell.html',
206 fragments: ['entrypoint-b.html', 'entrypoint-c.html'],
207 });
208 // shell bundles framework
209 const shellDoc = parse5_1.parse(getFileOrDie('shell.html'));
210 chai_1.assert.isTrue(hasMarker(shellDoc, 'framework'));
211 chai_1.assert.isFalse(hasImport(shellDoc, 'framework.html'));
212 // shell bundles commonDep
213 chai_1.assert.isTrue(hasMarker(shellDoc, 'commonDep'));
214 chai_1.assert.isFalse(hasImport(shellDoc, 'common-dependency.html'));
215 // entrypoint B doesn't import commonDep
216 const entrypointBDoc = parse5_1.parse(getFileOrDie('entrypoint-b.html'));
217 chai_1.assert.isFalse(hasMarker(entrypointBDoc, 'commonDep'));
218 chai_1.assert.isFalse(hasImport(entrypointBDoc, 'common-dependency.html'));
219 // entrypoint C doesn't import commonDep
220 const entrypointCDoc = parse5_1.parse(getFileOrDie('entrypoint-c.html'));
221 chai_1.assert.isFalse(hasMarker(entrypointCDoc, 'commonDep'));
222 chai_1.assert.isFalse(hasImport(entrypointCDoc, 'common-dependency.html'));
223 // entrypoints don't import shell
224 chai_1.assert.isFalse(hasImport(entrypointBDoc, 'shell.html'));
225 chai_1.assert.isFalse(hasImport(entrypointCDoc, 'shell.html'));
226 // No shared-bundle with a shell
227 chai_1.assert.isNotOk(getFile('shared_bundle_1.html'));
228 }));
229 // TODO(usergenic): This test is skipped for the same reason as the test
230 // above called 'shell and entrypoint'.
231 test.skip('entrypoint and fragments', () => __awaiter(this, void 0, void 0, function* () {
232 yield setupTest({
233 entrypoint: 'entrypoint-a.html',
234 fragments: [
235 'shell.html',
236 'entrypoint-b.html',
237 'entrypoint-c.html',
238 ],
239 });
240 // shared bundle was emitted
241 const bundle = getFileOrDie('shared_bundle_1.html');
242 chai_1.assert.ok(bundle);
243 const bundleDoc = parse5_1.parse(bundle);
244 // shared-bundle bundles framework
245 chai_1.assert.isTrue(hasMarker(bundleDoc, 'framework'));
246 chai_1.assert.isFalse(hasImport(bundleDoc, 'framework.html'));
247 // shared-bundle bundles commonDep
248 chai_1.assert.isTrue(hasMarker(bundleDoc, 'commonDep'));
249 chai_1.assert.isFalse(hasImport(bundleDoc, 'common-dependency.html'));
250 // entrypoint doesn't import framework
251 const entrypointDoc = parse5_1.parse(getFileOrDie('entrypoint-a.html'));
252 chai_1.assert.isFalse(hasMarker(entrypointDoc, 'framework'));
253 chai_1.assert.isFalse(hasImport(entrypointDoc, 'framework.html'));
254 // shell doesn't import framework
255 const shellDoc = parse5_1.parse(getFileOrDie('entrypoint-a.html'));
256 chai_1.assert.isFalse(hasMarker(shellDoc, 'framework'));
257 chai_1.assert.isFalse(hasImport(shellDoc, 'framework.html'));
258 // entrypoint B doesn't import commonDep
259 const entrypointBDoc = parse5_1.parse(getFileOrDie('entrypoint-b.html'));
260 chai_1.assert.isFalse(hasMarker(entrypointBDoc, 'commonDep'));
261 chai_1.assert.isFalse(hasImport(entrypointBDoc, 'common-dependency.html'));
262 // entrypoint C doesn't import commonDep
263 const entrypointCDoc = parse5_1.parse(getFileOrDie('entrypoint-c.html'));
264 chai_1.assert.isFalse(hasMarker(entrypointCDoc, 'commonDep'));
265 chai_1.assert.isFalse(hasImport(entrypointCDoc, 'common-dependency.html'));
266 // entrypoint and fragments import shared-bundle
267 chai_1.assert.isTrue(hasImport(entrypointDoc, 'shared_bundle_1.html'));
268 chai_1.assert.isTrue(hasImport(entrypointBDoc, 'shared_bundle_1.html'));
269 chai_1.assert.isTrue(hasImport(entrypointCDoc, 'shared_bundle_1.html'));
270 chai_1.assert.isTrue(hasImport(shellDoc, 'shared_bundle_1.html'));
271 }));
272 test('bundler loads changed files from stream', () => __awaiter(this, void 0, void 0, function* () {
273 yield setupTest({
274 root: path.resolve('test-fixtures/bundle-project'),
275 entrypoint: 'index.html',
276 }, {}, addHeaders);
277 const bundledHtml = getFileOrDie('index.html');
278 // In setupTest, we use a transform stream that to prepends
279 // each file with a comment including its basename before it makes it
280 // into the bundler. This verifies that bundler is processing files from
281 // the stream instead of from the filesystem.
282 chai_1.assert.include(bundledHtml, '<!-- index.html -->');
283 chai_1.assert.include(bundledHtml, '<!-- simple-import.html -->');
284 chai_1.assert.include(bundledHtml, '<!-- simple-import-2.html -->');
285 chai_1.assert.include(bundledHtml, '/* simple-style.css */');
286 }));
287 test('bundler deals with win32 platform separators on win32', () => __awaiter(this, void 0, void 0, function* () {
288 const platformSepPaths = new FileTransform((stream, file) => {
289 if (path.sep === '\\') {
290 file.path = file.path.replace(/\//g, path.sep);
291 }
292 stream.push(file);
293 });
294 yield setupTest({
295 root: path.resolve('test-fixtures/bundle-project'),
296 entrypoint: 'index.html',
297 }, {}, platformSepPaths);
298 const bundledHtml = getFileOrDie('index.html');
299 // In setupTest, we use a transform stream that forces the file paths to
300 // be in the original platform form (this only changes/matters for win32)
301 // and it verifies that bundler can process files that may be merged in
302 // or have otherwise reverted form paths in win32 separator form.
303 chai_1.assert.include(bundledHtml, '<title>Sample Build</title>', 'index.html');
304 chai_1.assert.include(bundledHtml, '<dom-module id="my-element">', 'simple-import.html');
305 chai_1.assert.include(bundledHtml, '<dom-module id="my-element-2">', 'simple-import-2.html');
306 chai_1.assert.include(bundledHtml, '.simply-red', 'simple-style.css');
307 }));
308 test('bundler deals with posix platform separators on win32', () => __awaiter(this, void 0, void 0, function* () {
309 const posixSepPaths = new FileTransform((stream, file) => {
310 if (path.sep === '\\') {
311 file.path = file.path.replace(/\\/g, '/');
312 }
313 stream.push(file);
314 });
315 yield setupTest({
316 root: path.resolve('test-fixtures/bundle-project'),
317 entrypoint: 'index.html'
318 }, {}, posixSepPaths);
319 const bundledHtml = getFileOrDie('index.html');
320 // In setupTest, we use a transform stream that forces the file paths to
321 // be in the posix form (this only changes/matters for win32)
322 // and it verifies that bundler can process files that may be merged in
323 // or have otherwise have paths in posix separator form.
324 chai_1.assert.include(bundledHtml, '<title>Sample Build</title>', 'index.html');
325 chai_1.assert.include(bundledHtml, '<dom-module id="my-element">', 'simple-import.html');
326 chai_1.assert.include(bundledHtml, '<dom-module id="my-element-2">', 'simple-import-2.html');
327 chai_1.assert.include(bundledHtml, '.simply-red', 'simple-style.css');
328 }));
329 test('bundler does not output inlined html imports', () => __awaiter(this, void 0, void 0, function* () {
330 yield setupTest({ root: defaultRoot, entrypoint: 'entrypoint-only.html' });
331 // We should have an entrypoint-only.html file (bundled).
332 chai_1.assert.isOk(getFile('entrypoint-only.html'));
333 // We should not have the inlined file in the output.
334 chai_1.assert.isNotOk(getFile('framework.html'));
335 }));
336 test('bundler outputs html imports that are not inlined', () => __awaiter(this, void 0, void 0, function* () {
337 yield setupTest({ root: defaultRoot, entrypoint: 'entrypoint-only.html' }, { excludes: resolveUrls(defaultRoot, ['framework.html']) });
338 // We should have an entrypoint-only.html file (bundled).
339 chai_1.assert.isOk(getFile('entrypoint-only.html'));
340 // We should have the html import that was excluded from inlining.
341 chai_1.assert.isOk(getFile('framework.html'));
342 }));
343 test('bundler does not output inlined scripts or styles', () => __awaiter(this, void 0, void 0, function* () {
344 yield setupTest({
345 root: path.resolve('test-fixtures/bundle-project'),
346 entrypoint: 'index.html',
347 });
348 chai_1.assert.deepEqual([...files.keys()].sort(), [path.resolve('test-fixtures/bundle-project/index.html')]);
349 }));
350 test('bundler does output scripts and styles not inlined', () => __awaiter(this, void 0, void 0, function* () {
351 yield setupTest({
352 root: path.resolve('test-fixtures/bundle-project'),
353 entrypoint: 'index.html',
354 }, {
355 inlineCss: false,
356 inlineScripts: false,
357 });
358 chai_1.assert.deepEqual([...files.keys()].sort(), [
359 'test-fixtures/bundle-project/index.html',
360 'test-fixtures/bundle-project/simple-script.js',
361 'test-fixtures/bundle-project/simple-style.css'
362 ].map((p) => path.resolve(p)));
363 }));
364 suite('options', () => {
365 const projectOptions = {
366 root: 'test-fixtures/test-project',
367 entrypoint: 'index.html',
368 fragments: ['shell.html'],
369 componentDir: 'bower_components',
370 };
371 test('excludes: html file urls listed are not inlined', () => __awaiter(this, void 0, void 0, function* () {
372 yield setupTest(projectOptions, {
373 excludes: resolveUrls(projectOptions.root, ['bower_components/loads-external-dependencies.html']),
374 });
375 chai_1.assert.isOk(getFile('bower_components/loads-external-dependencies.html'), 'Excluded import is passed through the bundler');
376 chai_1.assert.include(getFileOrDie('shell.html'), '<link rel="import" href="bower_components/loads-external-dependencies.html">');
377 }));
378 test('excludes: html files in folders listed are not inlined', () => __awaiter(this, void 0, void 0, function* () {
379 yield setupTest(projectOptions, { excludes: resolveUrls(projectOptions.root, ['bower_components/']) });
380 chai_1.assert.include(getFileOrDie('shell.html'), '<link rel="import" href="bower_components/dep.html">');
381 }));
382 test('excludes: nothing is excluded when no excludes are given', () => __awaiter(this, void 0, void 0, function* () {
383 yield setupTest(projectOptions, { excludes: [] });
384 chai_1.assert.isNotOk(getFile('bower_components/loads-external-dependencies.html'), 'Inlined imports are not passed through the bundler');
385 chai_1.assert.notInclude(getFileOrDie('shell.html'), '<link rel="import" href="bower_components/loads-external-dependencies.html">');
386 chai_1.assert.include(getFileOrDie('shell.html'), '<script src="https://www.example.com/script.js">', 'Inlined import content');
387 }));
388 test('inlineCss: false, does not inline external stylesheets', () => __awaiter(this, void 0, void 0, function* () {
389 yield setupTest(projectOptions, { inlineCss: false });
390 chai_1.assert.notInclude(getFileOrDie('shell.html'), '.test-project-style');
391 }));
392 test('inlineCss: true, inlines external stylesheets', () => __awaiter(this, void 0, void 0, function* () {
393 yield setupTest(projectOptions, { inlineCss: true });
394 chai_1.assert.include(getFileOrDie('shell.html'), '.test-project-style');
395 }));
396 test('inlineScripts: false, does not inline external scripts', () => __awaiter(this, void 0, void 0, function* () {
397 yield setupTest(projectOptions, { inlineScripts: false });
398 chai_1.assert.notInclude(getFileOrDie('shell.html'), 'console.log(\'shell\')');
399 }));
400 test('inlineScripts: true, inlines external scripts', () => __awaiter(this, void 0, void 0, function* () {
401 yield setupTest(projectOptions, { inlineScripts: true });
402 chai_1.assert.include(getFileOrDie('shell.html'), 'console.log(\'shell\')');
403 }));
404 test('rewriteUrlsInTemplates: false, does not rewrite urls', () => __awaiter(this, void 0, void 0, function* () {
405 yield setupTest(projectOptions, { rewriteUrlsInTemplates: false });
406 chai_1.assert.include(getFileOrDie('shell.html'), 'url(\'dep-bg.png\')');
407 }));
408 test('rewriteUrlsInTemplates: true, rewrites relative urls', () => __awaiter(this, void 0, void 0, function* () {
409 yield setupTest(projectOptions, { rewriteUrlsInTemplates: true });
410 chai_1.assert.include(getFileOrDie('shell.html'), 'url("bower_components/dep-bg.png")');
411 }));
412 test('stripComments: false, does not strip html comments', () => __awaiter(this, void 0, void 0, function* () {
413 yield setupTest(projectOptions, { stripComments: false });
414 chai_1.assert.include(getFileOrDie('shell.html'), '<!-- remote dependencies should be ignored during build -->');
415 }));
416 test('stripComments: true, strips html comments', () => __awaiter(this, void 0, void 0, function* () {
417 yield setupTest(projectOptions, { stripComments: true });
418 chai_1.assert.notInclude(getFileOrDie('shell.html'), '<!-- remote dependencies should be ignored during build -->');
419 }));
420 test('strategy: fn(), applies bundle strategy function', () => __awaiter(this, void 0, void 0, function* () {
421 yield setupTest(projectOptions, {
422 // Custom strategy creates a separate bundle for everything in the
423 // `bower_components` folder.
424 strategy: (bundles) => {
425 const bowerBundle = new polymer_bundler_1.Bundle('html-fragment');
426 bundles.forEach((bundle) => {
427 bundle.files.forEach((file) => {
428 if (file.includes('bower_components')) {
429 bowerBundle.files.add(file);
430 bundle.files.delete(file);
431 }
432 });
433 });
434 return bundles.concat(bowerBundle);
435 }
436 });
437 chai_1.assert.isOk(getFile('shared_bundle_1.html'));
438 chai_1.assert.include(getFileOrDie('shared_bundle_1.html'), '<dom-module id="dep" assetpath="bower_components/"');
439 }));
440 test('urlMapper: fn(), applies bundle url mapper function', () => __awaiter(this, void 0, void 0, function* () {
441 const urlResolver = new polymer_analyzer_1.FsUrlResolver(projectOptions.root);
442 yield setupTest(projectOptions, {
443 urlMapper: (bundles) => {
444 const map = new Map();
445 for (const bundle of bundles) {
446 map.set(urlResolver.resolve(`bundled/${[...bundle.entrypoints]
447 .map((u) => urlResolver.relative(u))
448 .join()}`), bundle);
449 }
450 return map;
451 }
452 });
453 chai_1.assert.isOk(getFile('bundled/shell.html'));
454 }));
455 });
456});
457//# sourceMappingURL=bundle_test.js.map
\No newline at end of file