UNPKG

24.8 kBJavaScriptView Raw
1'use strict';
2
3function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
4
5var path = _interopDefault(require('path'));
6var rollupPluginutils = require('rollup-pluginutils');
7var Concat = _interopDefault(require('concat-with-sourcemaps'));
8var series = _interopDefault(require('promise.series'));
9var importCwd = _interopDefault(require('import-cwd'));
10var postcss = _interopDefault(require('postcss'));
11var findPostcssConfig = _interopDefault(require('postcss-load-config'));
12var reserved = _interopDefault(require('reserved-words'));
13var pify = _interopDefault(require('pify'));
14var resolve = _interopDefault(require('resolve'));
15var PQueue = _interopDefault(require('p-queue'));
16
17function asyncGeneratorStep(gen, resolve$$1, reject, _next, _throw, key, arg) {
18 try {
19 var info = gen[key](arg);
20 var value = info.value;
21 } catch (error) {
22 reject(error);
23 return;
24 }
25
26 if (info.done) {
27 resolve$$1(value);
28 } else {
29 Promise.resolve(value).then(_next, _throw);
30 }
31}
32
33function _asyncToGenerator(fn) {
34 return function () {
35 var self = this,
36 args = arguments;
37 return new Promise(function (resolve$$1, reject) {
38 var gen = fn.apply(self, args);
39
40 function _next(value) {
41 asyncGeneratorStep(gen, resolve$$1, reject, _next, _throw, "next", value);
42 }
43
44 function _throw(err) {
45 asyncGeneratorStep(gen, resolve$$1, reject, _next, _throw, "throw", err);
46 }
47
48 _next(undefined);
49 });
50 };
51}
52
53function _defineProperty(obj, key, value) {
54 if (key in obj) {
55 Object.defineProperty(obj, key, {
56 value: value,
57 enumerable: true,
58 configurable: true,
59 writable: true
60 });
61 } else {
62 obj[key] = value;
63 }
64
65 return obj;
66}
67
68function _objectSpread(target) {
69 for (var i = 1; i < arguments.length; i++) {
70 var source = arguments[i] != null ? arguments[i] : {};
71 var ownKeys = Object.keys(source);
72
73 if (typeof Object.getOwnPropertySymbols === 'function') {
74 ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
75 return Object.getOwnPropertyDescriptor(source, sym).enumerable;
76 }));
77 }
78
79 ownKeys.forEach(function (key) {
80 _defineProperty(target, key, source[key]);
81 });
82 }
83
84 return target;
85}
86
87const humanlizePath = filepath => path.relative(process.cwd(), filepath);
88
89var normalizePath = (path$$1 => path$$1 && path$$1.replace(/\\+/g, '/'));
90
91const styleInjectPath = require.resolve('style-inject/dist/style-inject.es').replace(/[\\/]+/g, '/');
92
93function loadConfig(id, {
94 ctx: configOptions,
95 path: configPath
96}) {
97 const handleError = err => {
98 if (err.message.indexOf('No PostCSS Config found') === -1) {
99 throw err;
100 } // Return empty options for PostCSS
101
102
103 return {};
104 };
105
106 configPath = configPath ? path.resolve(configPath) : path.dirname(id);
107 const ctx = {
108 file: {
109 extname: path.extname(id),
110 dirname: path.dirname(id),
111 basename: path.basename(id)
112 },
113 options: configOptions || {}
114 };
115 return findPostcssConfig(ctx, configPath).catch(handleError);
116}
117
118function escapeClassNameDashes(str) {
119 return str.replace(/-+/g, match => {
120 return `$${match.replace(/-/g, '_')}$`;
121 });
122}
123
124function ensureClassName(name) {
125 name = escapeClassNameDashes(name);
126
127 if (reserved.check(name)) {
128 name = `$${name}$`;
129 }
130
131 return name;
132}
133
134function ensurePostCSSOption(option) {
135 return typeof option === 'string' ? importCwd(option) : option;
136}
137
138function isModuleFile(file) {
139 return /\.module\.[a-z]{2,6}$/.test(file);
140}
141
142var postcssLoader = {
143 name: 'postcss',
144 alwaysProcess: true,
145
146 // `test` option is dynamically set in ./loaders
147 process({
148 code,
149 map
150 }) {
151 var _this = this;
152
153 return _asyncToGenerator(function* () {
154 const config = _this.options.config ? yield loadConfig(_this.id, _this.options.config) : {};
155 const options = _this.options;
156 const plugins = [...(options.postcss.plugins || []), ...(config.plugins || [])];
157 const shouldExtract = options.extract;
158 const shouldInject = options.inject;
159 const modulesExported = {};
160 const autoModules = options.autoModules !== false && isModuleFile(_this.id);
161 const supportModules = options.modules || autoModules;
162
163 if (supportModules) {
164 plugins.push(require('postcss-modules')(_objectSpread({
165 // In tests
166 // Skip hash in names since css content on windows and linux would differ because of `new line` (\r?\n)
167 generateScopedName: process.env.ROLLUP_POSTCSS_TEST ? '[name]_[local]' : '[name]_[local]__[hash:base64:5]'
168 }, options.modules, {
169 getJSON(filepath, json, outpath) {
170 modulesExported[filepath] = json;
171
172 if (typeof options.modules === 'object' && typeof options.modules.getJSON === 'function') {
173 return options.modules.getJSON(filepath, json, outpath);
174 }
175 }
176
177 })));
178 } // If shouldExtract, minimize is done after all CSS are extracted to a file
179
180
181 if (!shouldExtract && options.minimize) {
182 plugins.push(require('cssnano')(options.minimize));
183 }
184
185 const postcssOpts = _objectSpread({}, _this.options.postcss, config.options, {
186 // Followings are never modified by user config config
187 from: _this.id,
188 to: _this.id,
189 map: _this.sourceMap ? shouldExtract ? {
190 inline: false,
191 annotation: false
192 } : {
193 inline: true,
194 annotation: false
195 } : false
196 });
197
198 delete postcssOpts.plugins;
199 postcssOpts.parser = ensurePostCSSOption(postcssOpts.parser);
200 postcssOpts.syntax = ensurePostCSSOption(postcssOpts.syntax);
201 postcssOpts.stringifier = ensurePostCSSOption(postcssOpts.stringifier);
202
203 if (map && postcssOpts.map) {
204 postcssOpts.map.prev = typeof map === 'string' ? JSON.parse(map) : map;
205 }
206
207 if (plugins.length === 0) {
208 // Prevent from postcss warning:
209 // You did not set any plugins, parser, or stringifier. Right now, PostCSS does nothing. Pick plugins for your case on https://www.postcss.parts/ and use them in postcss.config.js
210 const noopPlugin = postcss.plugin('postcss-noop-plugin', () => () => {
211 /* noop */
212 });
213 plugins.push(noopPlugin());
214 }
215
216 const res = yield postcss(plugins).process(code, postcssOpts);
217 var _iteratorNormalCompletion = true;
218 var _didIteratorError = false;
219 var _iteratorError = undefined;
220
221 try {
222 for (var _iterator = res.messages[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
223 const msg = _step.value;
224
225 if (msg.type === 'dependency') {
226 _this.dependencies.add(msg.file);
227 }
228 }
229 } catch (err) {
230 _didIteratorError = true;
231 _iteratorError = err;
232 } finally {
233 try {
234 if (!_iteratorNormalCompletion && _iterator.return != null) {
235 _iterator.return();
236 }
237 } finally {
238 if (_didIteratorError) {
239 throw _iteratorError;
240 }
241 }
242 }
243
244 var _iteratorNormalCompletion2 = true;
245 var _didIteratorError2 = false;
246 var _iteratorError2 = undefined;
247
248 try {
249 for (var _iterator2 = res.warnings()[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
250 const warning = _step2.value;
251
252 _this.warn(warning);
253 }
254 } catch (err) {
255 _didIteratorError2 = true;
256 _iteratorError2 = err;
257 } finally {
258 try {
259 if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
260 _iterator2.return();
261 }
262 } finally {
263 if (_didIteratorError2) {
264 throw _iteratorError2;
265 }
266 }
267 }
268
269 const outputMap = res.map && JSON.parse(res.map.toString());
270
271 if (outputMap && outputMap.sources) {
272 outputMap.sources = outputMap.sources.map(v => normalizePath(v));
273 }
274
275 let output = '';
276 let extracted;
277
278 if (options.namedExports) {
279 const json = modulesExported[_this.id];
280 const getClassName = typeof options.namedExports === 'function' ? options.namedExports : ensureClassName; // eslint-disable-next-line guard-for-in
281
282 for (const name in json) {
283 const newName = getClassName(name); // Log transformed class names
284 // But skip this when namedExports is a function
285 // Since a user like you can manually log that if you want
286
287 if (name !== newName && typeof options.namedExports !== 'function') {
288 _this.warn(`Exported "${name}" as "${newName}" in ${humanlizePath(_this.id)}`);
289 }
290
291 if (!json[newName]) {
292 json[newName] = json[name];
293 }
294
295 output += `export var ${newName} = ${JSON.stringify(json[name])};\n`;
296 }
297 }
298
299 if (shouldExtract) {
300 output += `export default ${JSON.stringify(modulesExported[_this.id])};`;
301 extracted = {
302 id: _this.id,
303 code: res.css,
304 map: outputMap
305 };
306 } else {
307 output += `var css = ${JSON.stringify(res.css)};\nexport default ${supportModules ? JSON.stringify(modulesExported[_this.id]) : 'css'};`;
308 }
309
310 if (!shouldExtract && shouldInject) {
311 output += `\nimport styleInject from '${styleInjectPath}';\nstyleInject(css${Object.keys(options.inject).length > 0 ? `,${JSON.stringify(options.inject)}` : ''});`;
312 }
313
314 return {
315 code: output,
316 map: outputMap,
317 extracted
318 };
319 })();
320 }
321
322};
323
324// See: https://github.com/sass/node-sass/issues/857
325
326const threadPoolSize = process.env.UV_THREADPOOL_SIZE || 4;
327const workQueue = new PQueue({
328 concurrency: threadPoolSize - 1
329});
330const moduleRe = /^~([a-z0-9]|@).+/i;
331
332const getUrlOfPartial = url => {
333 const parsedUrl = path.parse(url);
334 return `${parsedUrl.dir}${path.sep}_${parsedUrl.base}`;
335};
336
337const resolvePromise = pify(resolve);
338var sassLoader = {
339 name: 'sass',
340 test: /\.s[ac]ss$/,
341
342 process({
343 code
344 }) {
345 return new Promise((resolve$$1, reject) => {
346 const sass = importCwd.silent('node-sass') || importCwd.silent('sass');
347
348 if (!sass) {
349 throw new Error(`You need to install either node-sass or sass in order to process Sass files`);
350 }
351
352 const render = pify(sass.render.bind(sass));
353 return workQueue.add(() => render(_objectSpread({}, this.options, {
354 file: this.id,
355 data: code,
356 indentedSyntax: /\.sass$/.test(this.id),
357 sourceMap: this.sourceMap,
358 importer: [(url, importer, done) => {
359 if (!moduleRe.test(url)) return done({
360 file: url
361 });
362 const moduleUrl = url.slice(1);
363 const partialUrl = getUrlOfPartial(moduleUrl);
364 const options = {
365 basedir: path.dirname(importer),
366 extensions: ['.scss', '.sass', '.css']
367 };
368
369 const finishImport = id => {
370 done({
371 // Do not add `.css` extension in order to inline the file
372 file: id.endsWith('.css') ? id.replace(/\.css$/, '') : id
373 });
374 };
375
376 const next = () => {
377 // Catch all resolving errors, return the original file and pass responsibility back to other custom importers
378 done({
379 file: url
380 });
381 }; // Give precedence to importing a partial
382
383
384 resolvePromise(partialUrl, options).then(finishImport).catch(err => {
385 if (err.code === 'MODULE_NOT_FOUND' || err.code === 'ENOENT') {
386 resolvePromise(moduleUrl, options).then(finishImport).catch(next);
387 } else {
388 next();
389 }
390 });
391 }].concat(this.options.importer || [])
392 })).then(res => {
393 var _iteratorNormalCompletion = true;
394 var _didIteratorError = false;
395 var _iteratorError = undefined;
396
397 try {
398 for (var _iterator = res.stats.includedFiles[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
399 const file = _step.value;
400 this.dependencies.add(file);
401 }
402 } catch (err) {
403 _didIteratorError = true;
404 _iteratorError = err;
405 } finally {
406 try {
407 if (!_iteratorNormalCompletion && _iterator.return != null) {
408 _iterator.return();
409 }
410 } finally {
411 if (_didIteratorError) {
412 throw _iteratorError;
413 }
414 }
415 }
416
417 resolve$$1({
418 code: res.css.toString(),
419 map: res.map && res.map.toString()
420 });
421 }).catch(reject));
422 });
423 }
424
425};
426
427var stylusLoader = {
428 name: 'stylus',
429 test: /\.(styl|stylus)$/,
430
431 process({
432 code
433 }) {
434 var _this = this;
435
436 return _asyncToGenerator(function* () {
437 const stylus = importCwd('stylus');
438 const style = stylus(code, _objectSpread({}, _this.options, {
439 filename: _this.id,
440 sourcemap: _this.sourceMap && {}
441 }));
442 const css = yield pify(style.render.bind(style))();
443 const deps = style.deps();
444 var _iteratorNormalCompletion = true;
445 var _didIteratorError = false;
446 var _iteratorError = undefined;
447
448 try {
449 for (var _iterator = deps[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
450 const dep = _step.value;
451
452 _this.dependencies.add(dep);
453 }
454 } catch (err) {
455 _didIteratorError = true;
456 _iteratorError = err;
457 } finally {
458 try {
459 if (!_iteratorNormalCompletion && _iterator.return != null) {
460 _iterator.return();
461 }
462 } finally {
463 if (_didIteratorError) {
464 throw _iteratorError;
465 }
466 }
467 }
468
469 return {
470 code: css,
471 map: style.sourcemap
472 };
473 })();
474 }
475
476};
477
478var lessLoader = {
479 name: 'less',
480 test: /\.less$/,
481
482 process({
483 code
484 }) {
485 var _this = this;
486
487 return _asyncToGenerator(function* () {
488 const less = importCwd('less');
489
490 let _ref = yield pify(less.render.bind(less))(code, _objectSpread({}, _this.options, {
491 sourceMap: _this.sourceMap && {},
492 filename: _this.id
493 })),
494 css = _ref.css,
495 map = _ref.map,
496 imports = _ref.imports;
497
498 var _iteratorNormalCompletion = true;
499 var _didIteratorError = false;
500 var _iteratorError = undefined;
501
502 try {
503 for (var _iterator = imports[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
504 const dep = _step.value;
505
506 _this.dependencies.add(dep);
507 }
508 } catch (err) {
509 _didIteratorError = true;
510 _iteratorError = err;
511 } finally {
512 try {
513 if (!_iteratorNormalCompletion && _iterator.return != null) {
514 _iterator.return();
515 }
516 } finally {
517 if (_didIteratorError) {
518 throw _iteratorError;
519 }
520 }
521 }
522
523 if (map) {
524 map = JSON.parse(map);
525 map.sources = map.sources.map(source => humanlizePath(source));
526 }
527
528 return {
529 code: css,
530 map
531 };
532 })();
533 }
534
535};
536
537const matchFile = (filepath, condition) => {
538 if (typeof condition === 'function') {
539 return condition(filepath);
540 }
541
542 return condition && condition.test(filepath);
543};
544
545class Loaders {
546 constructor(options = {}) {
547 this.use = options.use.map(rule => {
548 if (typeof rule === 'string') {
549 return [rule];
550 }
551
552 if (Array.isArray(rule)) {
553 return rule;
554 }
555
556 throw new TypeError('The rule in `use` option must be string or Array!');
557 });
558 this.loaders = [];
559 const extensions = options.extensions || ['.css', '.sss', '.pcss'];
560
561 postcssLoader.test = filepath => extensions.some(ext => path.extname(filepath) === ext);
562
563 this.registerLoader(postcssLoader);
564 this.registerLoader(sassLoader);
565 this.registerLoader(stylusLoader);
566 this.registerLoader(lessLoader);
567
568 if (options.loaders) {
569 options.loaders.forEach(loader => this.registerLoader(loader));
570 }
571 }
572
573 registerLoader(loader) {
574 const existing = this.getLoader(loader.name);
575
576 if (existing) {
577 this.removeLoader(loader.name);
578 }
579
580 this.loaders.push(loader);
581 return this;
582 }
583
584 removeLoader(name) {
585 this.loaders = this.loaders.filter(loader => loader.name !== name);
586 return this;
587 }
588
589 isSupported(filepath) {
590 return this.loaders.some(loader => {
591 return matchFile(filepath, loader.test);
592 });
593 }
594 /**
595 * Process the resource with loaders in serial
596 * @param {object} resource
597 * @param {string} resource.code
598 * @param {any} resource.map
599 * @param {object} context
600 * @param {string} context.id The absolute path to resource
601 * @param {boolean | 'inline'} context.sourceMap
602 * @param {Set<string>} context.dependencies A set of dependencies to watch
603 * @returns {{code: string, map?: any}}
604 */
605
606
607 process({
608 code,
609 map
610 }, context) {
611 return series(this.use.slice().reverse().map(([name, options]) => {
612 const loader = this.getLoader(name);
613 const loaderContext = Object.assign({
614 options: options || {}
615 }, context);
616 return v => {
617 if (loader.alwaysProcess || matchFile(loaderContext.id, loader.test)) {
618 return loader.process.call(loaderContext, v);
619 } // Otherwise directly return input value
620
621
622 return v;
623 };
624 }), {
625 code,
626 map
627 });
628 }
629
630 getLoader(name) {
631 return this.loaders.find(loader => loader.name === name);
632 }
633
634}
635
636/**
637 * The options that could be `boolean` or `object`
638 * We convert it to an object when it's truthy
639 * Otherwise fallback to default value
640 */
641
642function inferOption(option, defaultValue) {
643 if (option === false) return false;
644 if (option && typeof option === 'object') return option;
645 return option ? {} : defaultValue;
646}
647
648var index = ((options = {}) => {
649 const filter = rollupPluginutils.createFilter(options.include, options.exclude);
650 const postcssPlugins = Array.isArray(options.plugins) ? options.plugins.filter(Boolean) : options.plugins;
651 const sourceMap = options.sourceMap;
652 const postcssLoaderOptions = {
653 /** Inject CSS as `<style>` to `<head>` */
654 inject: inferOption(options.inject, {}),
655
656 /** Extract CSS */
657 extract: typeof options.extract === 'undefined' ? false : options.extract,
658
659 /** CSS modules */
660 modules: inferOption(options.modules, false),
661 namedExports: options.namedExports,
662
663 /** Automatically CSS modules for .module.xxx files */
664 autoModules: options.autoModules,
665
666 /** Options for cssnano */
667 minimize: inferOption(options.minimize, false),
668
669 /** Postcss config file */
670 config: inferOption(options.config, {}),
671
672 /** PostCSS options */
673 postcss: {
674 parser: options.parser,
675 plugins: postcssPlugins,
676 syntax: options.syntax,
677 stringifier: options.stringifier,
678 exec: options.exec
679 }
680 };
681 const use = options.use || ['sass', 'stylus', 'less'];
682 use.unshift(['postcss', postcssLoaderOptions]);
683 const loaders = new Loaders({
684 use,
685 loaders: options.loaders,
686 extensions: options.extensions
687 });
688 const extracted = new Map();
689 return {
690 name: 'postcss',
691
692 transform(code, id) {
693 var _this = this;
694
695 return _asyncToGenerator(function* () {
696 if (!filter(id) || !loaders.isSupported(id)) {
697 return null;
698 }
699
700 if (typeof options.onImport === 'function') {
701 options.onImport(id);
702 }
703
704 const loaderContext = {
705 id,
706 sourceMap,
707 dependencies: new Set(),
708 warn: _this.warn.bind(_this),
709 plugin: _this
710 };
711 const res = yield loaders.process({
712 code,
713 map: undefined
714 }, loaderContext);
715 var _iteratorNormalCompletion = true;
716 var _didIteratorError = false;
717 var _iteratorError = undefined;
718
719 try {
720 for (var _iterator = loaderContext.dependencies[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
721 const dep = _step.value;
722
723 _this.addWatchFile(dep);
724 }
725 } catch (err) {
726 _didIteratorError = true;
727 _iteratorError = err;
728 } finally {
729 try {
730 if (!_iteratorNormalCompletion && _iterator.return != null) {
731 _iterator.return();
732 }
733 } finally {
734 if (_didIteratorError) {
735 throw _iteratorError;
736 }
737 }
738 }
739
740 if (postcssLoaderOptions.extract) {
741 extracted.set(id, res.extracted);
742 return {
743 code: res.code,
744 map: {
745 mappings: ''
746 }
747 };
748 }
749
750 return {
751 code: res.code,
752 map: res.map || {
753 mappings: ''
754 }
755 };
756 })();
757 },
758
759 generateBundle(opts, bundle) {
760 return _asyncToGenerator(function* () {
761 if (extracted.size === 0) return; // TODO: support `[hash]`
762
763 const dir = opts.dir || path.dirname(opts.file);
764 const file = opts.file || path.join(opts.dir, Object.keys(bundle).find(fileName => bundle[fileName].isEntry));
765
766 const getExtracted = () => {
767 const fileName = typeof postcssLoaderOptions.extract === 'string' ? path.relative(dir, postcssLoaderOptions.extract) : `${path.basename(file, path.extname(file))}.css`;
768 const concat = new Concat(true, fileName, '\n');
769 const entries = Array.from(extracted.values());
770 const modules = bundle[path.relative(dir, file)].modules;
771
772 if (modules) {
773 const fileList = Object.keys(modules);
774 entries.sort((a, b) => fileList.indexOf(a.id) - fileList.indexOf(b.id));
775 }
776
777 for (var _i = 0; _i < entries.length; _i++) {
778 const res = entries[_i];
779 const relative = path.relative(dir, res.id);
780 const map = res.map || null;
781
782 if (map) {
783 map.file = fileName;
784 }
785
786 concat.add(relative, res.code, map);
787 }
788
789 let code = concat.content;
790
791 if (sourceMap === 'inline') {
792 code += `\n/*# sourceMappingURL=data:application/json;base64,${Buffer.from(concat.sourceMap, 'utf8').toString('base64')}*/`;
793 } else if (sourceMap === true) {
794 code += `\n/*# sourceMappingURL=${fileName}.map */`;
795 }
796
797 return {
798 code,
799 map: sourceMap === true && concat.sourceMap,
800 codeFileName: fileName,
801 mapFileName: fileName + '.map'
802 };
803 };
804
805 if (options.onExtract) {
806 const shouldExtract = yield options.onExtract(getExtracted);
807
808 if (shouldExtract === false) {
809 return;
810 }
811 }
812
813 let _getExtracted = getExtracted(),
814 code = _getExtracted.code,
815 codeFileName = _getExtracted.codeFileName,
816 map = _getExtracted.map,
817 mapFileName = _getExtracted.mapFileName; // Perform cssnano on the extracted file
818
819
820 if (postcssLoaderOptions.minimize) {
821 const cssOpts = postcssLoaderOptions.minimize;
822 cssOpts.from = codeFileName;
823
824 if (sourceMap === 'inline') {
825 cssOpts.map = {
826 inline: true
827 };
828 } else if (sourceMap === true && map) {
829 cssOpts.map = {
830 prev: map
831 };
832 cssOpts.to = codeFileName;
833 }
834
835 const result = yield require('cssnano').process(code, cssOpts);
836 code = result.css;
837
838 if (sourceMap === true && result.map && result.map.toString) {
839 map = result.map.toString();
840 }
841 }
842
843 const codeFile = {
844 fileName: codeFileName,
845 isAsset: true,
846 source: code
847 };
848 bundle[codeFile.fileName] = codeFile;
849
850 if (map) {
851 const mapFile = {
852 fileName: mapFileName,
853 isAsset: true,
854 source: map
855 };
856 bundle[mapFile.fileName] = mapFile;
857 }
858 })();
859 }
860
861 };
862});
863
864module.exports = index;