UNPKG

1.84 kBJavaScriptView Raw
1"use strict";
2/*
3 This module is the only place where we make assumptions about Ember's default
4 "app" vs "test" bundles.
5*/
6Object.defineProperty(exports, "__esModule", { value: true });
7const path_1 = require("path");
8const testsPattern = new RegExp(`^/?[^/]+/(tests|test-support)/`);
9class BundleConfig {
10 constructor(emberApp) {
11 this.emberApp = emberApp;
12 }
13 // This list of valid bundles, in priority order. The first one in the list that
14 // needs a given import will end up with that import.
15 get names() {
16 return Object.freeze(['app', 'tests']);
17 }
18 get types() {
19 return Object.freeze(['js', 'css']);
20 }
21 // Which final JS file the given bundle's dependencies should go into.
22 bundleEntrypoint(name, type) {
23 switch (name) {
24 case 'tests':
25 switch (type) {
26 case 'js':
27 return 'assets/test-support.js';
28 case 'css':
29 return 'assets/test-support.css';
30 }
31 case 'app':
32 switch (type) {
33 case 'js':
34 return this.emberApp.options.outputPaths.vendor.js.replace(/^\//, '');
35 case 'css':
36 return this.emberApp.options.outputPaths.vendor.css.replace(/^\//, '');
37 }
38 }
39 }
40 // For any relative path to a module in our application, return which bundle its
41 // imports go into.
42 bundleForPath(path) {
43 if (testsPattern.test(path)) {
44 return 'tests';
45 }
46 else {
47 return 'app';
48 }
49 }
50 get lazyChunkPath() {
51 return path_1.dirname(this.bundleEntrypoint(this.names[0], 'js'));
52 }
53}
54exports.default = BundleConfig;
55//# sourceMappingURL=bundle-config.js.map
\No newline at end of file