@embroider/core 0.29.0 → 0.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +10 -6
- package/src/app-files.d.ts +3 -2
- package/src/app-files.js +37 -5
- package/src/app-files.js.map +1 -1
- package/src/app.d.ts +7 -7
- package/src/app.js +117 -60
- package/src/app.js.map +1 -1
- package/src/babel-plugin-adjust-imports.js +30 -20
- package/src/babel-plugin-adjust-imports.js.map +1 -1
- package/src/babel-plugin-inline-hbs.d.ts +17 -0
- package/src/babel-plugin-inline-hbs.js +1 -1
- package/src/babel-plugin-inline-hbs.js.map +1 -1
- package/src/build-stage.d.ts +2 -2
- package/src/index.d.ts +1 -1
- package/src/index.js +3 -2
- package/src/index.js.map +1 -1
- package/src/options.d.ts +5 -0
- package/src/options.js +2 -0
- package/src/options.js.map +1 -1
- package/src/package-cache.d.ts +1 -1
- package/src/package-cache.js.map +1 -1
- package/src/package.js +2 -2
- package/src/package.js.map +1 -1
- package/src/portable-babel-config.d.ts +5 -8
- package/src/portable-babel-config.js +68 -19
- package/src/portable-babel-config.js.map +1 -1
- package/src/portable-babel-launcher.d.ts +6 -0
- package/src/portable-babel-launcher.js +75 -0
- package/src/portable-babel-launcher.js.map +1 -0
- package/src/portable.d.ts +23 -0
- package/src/{portable-plugin-config.js → portable.js} +93 -65
- package/src/portable.js.map +1 -0
- package/src/resolver.d.ts +3 -2
- package/src/stage.d.ts +2 -2
- package/src/template-compiler.d.ts +11 -18
- package/src/template-compiler.js +26 -89
- package/src/template-compiler.js.map +1 -1
- package/src/wait-for-trees.d.ts +5 -4
- package/src/wait-for-trees.js +2 -2
- package/src/wait-for-trees.js.map +1 -1
- package/src/portable-plugin-config.d.ts +0 -15
- package/src/portable-plugin-config.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@embroider/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.33.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A build system for EmberJS applications.",
|
|
6
6
|
"repository": {
|
|
@@ -24,15 +24,19 @@
|
|
|
24
24
|
"@babel/core": "^7.12.3",
|
|
25
25
|
"@babel/parser": "^7.12.3",
|
|
26
26
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
27
|
+
"@babel/plugin-transform-runtime": "^7.12.1",
|
|
28
|
+
"@babel/runtime": "^7.12.5",
|
|
27
29
|
"@babel/traverse": "^7.12.1",
|
|
28
30
|
"@babel/types": "^7.12.1",
|
|
29
|
-
"@embroider/macros": "0.
|
|
31
|
+
"@embroider/macros": "0.33.0",
|
|
30
32
|
"assert-never": "^1.1.0",
|
|
31
33
|
"babel-plugin-syntax-dynamic-import": "^6.18.0",
|
|
32
|
-
"broccoli-
|
|
33
|
-
"broccoli-
|
|
34
|
-
"broccoli-
|
|
34
|
+
"broccoli-node-api": "^1.7.0",
|
|
35
|
+
"broccoli-persistent-filter": "^3.1.2",
|
|
36
|
+
"broccoli-plugin": "^4.0.1",
|
|
37
|
+
"broccoli-source": "^3.0.0",
|
|
35
38
|
"debug": "^3.1.0",
|
|
39
|
+
"escape-string-regexp": "^4.0.0",
|
|
36
40
|
"fast-sourcemap-concat": "^1.4.0",
|
|
37
41
|
"filesize": "^4.1.2",
|
|
38
42
|
"fs-extra": "^7.0.1",
|
|
@@ -53,7 +57,7 @@
|
|
|
53
57
|
},
|
|
54
58
|
"devDependencies": {
|
|
55
59
|
"@embroider/sample-transforms": "0.0.0",
|
|
56
|
-
"@embroider/test-support": "0.
|
|
60
|
+
"@embroider/test-support": "0.33.0",
|
|
57
61
|
"@types/babel__core": "^7.1.10",
|
|
58
62
|
"@types/debug": "^0.0.31",
|
|
59
63
|
"@types/filesize": "^4.1.0",
|
package/src/app-files.d.ts
CHANGED
|
@@ -14,8 +14,9 @@ export declare class AppFiles {
|
|
|
14
14
|
readonly otherAppFiles: ReadonlyArray<string>;
|
|
15
15
|
readonly relocatedFiles: Map<string, string>;
|
|
16
16
|
readonly isFastbootOnly: Map<string, boolean>;
|
|
17
|
-
constructor(appDiffer: AppDiffer, resolvableExtensions: RegExp);
|
|
18
|
-
private
|
|
17
|
+
constructor(appDiffer: AppDiffer, resolvableExtensions: RegExp, podModulePrefix?: string);
|
|
18
|
+
private handleClassicRouteFile;
|
|
19
|
+
private handlePodsRouteFile;
|
|
19
20
|
get routeFiles(): Readonly<RouteFiles>;
|
|
20
21
|
}
|
|
21
22
|
export interface EngineSummary {
|
package/src/app-files.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.AppFiles = void 0;
|
|
4
4
|
const path_1 = require("path");
|
|
5
5
|
class AppFiles {
|
|
6
|
-
constructor(appDiffer, resolvableExtensions) {
|
|
6
|
+
constructor(appDiffer, resolvableExtensions, podModulePrefix) {
|
|
7
7
|
let tests = [];
|
|
8
8
|
let components = [];
|
|
9
9
|
let helpers = [];
|
|
@@ -27,8 +27,10 @@ class AppFiles {
|
|
|
27
27
|
}
|
|
28
28
|
// hbs files are resolvable, but not when they're inside the components
|
|
29
29
|
// directory (where they are used for colocation only)
|
|
30
|
-
if (relativePath.startsWith('components/')
|
|
31
|
-
|
|
30
|
+
if (relativePath.startsWith('components/')) {
|
|
31
|
+
if (!relativePath.endsWith('.hbs')) {
|
|
32
|
+
components.push(relativePath);
|
|
33
|
+
}
|
|
32
34
|
continue;
|
|
33
35
|
}
|
|
34
36
|
if (relativePath.startsWith('templates/components/')) {
|
|
@@ -39,7 +41,8 @@ class AppFiles {
|
|
|
39
41
|
helpers.push(relativePath);
|
|
40
42
|
continue;
|
|
41
43
|
}
|
|
42
|
-
if (this.
|
|
44
|
+
if (this.handleClassicRouteFile(relativePath) ||
|
|
45
|
+
(podModulePrefix !== undefined && this.handlePodsRouteFile(relativePath, podModulePrefix))) {
|
|
43
46
|
continue;
|
|
44
47
|
}
|
|
45
48
|
otherAppFiles.push(relativePath);
|
|
@@ -57,7 +60,7 @@ class AppFiles {
|
|
|
57
60
|
this.relocatedFiles = relocatedFiles;
|
|
58
61
|
this.isFastbootOnly = appDiffer.isFastbootOnly;
|
|
59
62
|
}
|
|
60
|
-
|
|
63
|
+
handleClassicRouteFile(relativePath) {
|
|
61
64
|
let [prefix, ...rest] = relativePath.replace(/\.\w{1,3}$/, '').split('/');
|
|
62
65
|
if (!['controllers', 'templates', 'routes'].includes(prefix)) {
|
|
63
66
|
return false;
|
|
@@ -78,6 +81,35 @@ class AppFiles {
|
|
|
78
81
|
cursor[type] = relativePath;
|
|
79
82
|
return true;
|
|
80
83
|
}
|
|
84
|
+
handlePodsRouteFile(relativePath, podModulePrefix) {
|
|
85
|
+
let parts = relativePath.replace(/\.\w{1,3}$/, '').split('/');
|
|
86
|
+
let type = parts.pop();
|
|
87
|
+
if (!type || !['controller', 'template', 'route'].includes(type)) {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
let podParts = podModulePrefix.split('/');
|
|
91
|
+
// The first part of podModulePrefix is the app's package name
|
|
92
|
+
podParts.shift();
|
|
93
|
+
for (let podPart of podParts) {
|
|
94
|
+
if (parts.shift() !== podPart) {
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
let cursor = this.perRoute;
|
|
99
|
+
for (let part of parts) {
|
|
100
|
+
let child = cursor.children.get(part);
|
|
101
|
+
if (child) {
|
|
102
|
+
cursor = child;
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
let newEntry = { children: new Map() };
|
|
106
|
+
cursor.children.set(part, newEntry);
|
|
107
|
+
cursor = newEntry;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
cursor[type] = relativePath;
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
81
113
|
get routeFiles() {
|
|
82
114
|
return this.perRoute;
|
|
83
115
|
}
|
package/src/app-files.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-files.js","sourceRoot":"","sources":["app-files.ts"],"names":[],"mappings":";;;AAAA,+BAA2B;AAW3B,MAAa,QAAQ;IASnB,YAAY,SAAoB,EAAE,oBAA4B;
|
|
1
|
+
{"version":3,"file":"app-files.js","sourceRoot":"","sources":["app-files.ts"],"names":[],"mappings":";;;AAAA,+BAA2B;AAW3B,MAAa,QAAQ;IASnB,YAAY,SAAoB,EAAE,oBAA4B,EAAE,eAAwB;QACtF,IAAI,KAAK,GAAa,EAAE,CAAC;QACzB,IAAI,UAAU,GAAa,EAAE,CAAC;QAC9B,IAAI,OAAO,GAAa,EAAE,CAAC;QAC3B,IAAI,aAAa,GAAa,EAAE,CAAC;QACjC,IAAI,CAAC,QAAQ,GAAG,EAAE,QAAQ,EAAE,IAAI,GAAG,EAAE,EAAE,CAAC;QACxC,KAAK,IAAI,YAAY,IAAI,SAAS,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE;YAC/C,YAAY,GAAG,YAAY,CAAC,KAAK,CAAC,UAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACjD,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE;gBAC5C,SAAS;aACV;YAED,IAAI,UAAU,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE;gBACjC,oEAAoE;gBACpE,4DAA4D;gBAC5D,SAAS;aACV;YAED,IAAI,YAAY,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE;gBACrC,IAAI,aAAa,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE;oBACpC,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;iBAC1B;gBACD,SAAS;aACV;YAED,uEAAuE;YACvE,sDAAsD;YACtD,IAAI,YAAY,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE;gBAC1C,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;oBAClC,UAAU,CAAC,IAAI,CAAC,YAAY,CA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;gBAC7B,OAAO,KAAK,CAAC;aACd;SACF;QAED,IAAI,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC3B,KAAK,IAAI,IAAI,IAAI,KAAK,EAAE;YACtB,IAAI,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YACtC,IAAI,KAAK,EAAE;gBACT,MAAM,GAAG,KAAK,CAAC;aAChB;iBAAM;gBACL,IAAI,QAAQ,GAAG,EAAE,QAAQ,EAAE,IAAI,GAAG,EAAE,EAAE,CAAC;gBACvC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;gBACpC,MAAM,GAAG,QAAQ,CAAC;aACnB;SACF;QACD,MAAM,CAAC,IAA2C,CAAC,GAAG,YAAY,CAAC;QACnE,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;CACF;AApID,4BAoIC"}
|
package/src/app.d.ts
CHANGED
|
@@ -2,10 +2,11 @@ import { OutputPaths } from './wait-for-trees';
|
|
|
2
2
|
import Package, { V2AddonPackage } from './package';
|
|
3
3
|
import { Asset } from './asset';
|
|
4
4
|
import Options from './options';
|
|
5
|
-
import { MacrosConfig } from '@embroider/macros';
|
|
5
|
+
import { MacrosConfig } from '@embroider/macros/src/node';
|
|
6
6
|
import { TransformOptions } from '@babel/core';
|
|
7
7
|
import { TemplateCompilerPlugins } from '.';
|
|
8
8
|
import { Resolver } from './resolver';
|
|
9
|
+
import { Options as AdjustImportsOptions } from './babel-plugin-adjust-imports';
|
|
9
10
|
export declare type EmberENV = unknown;
|
|
10
11
|
export interface AppAdapter<TreeNames> {
|
|
11
12
|
readonly allActiveAddons: V2AddonPackage[];
|
|
@@ -18,18 +19,14 @@ export interface AppAdapter<TreeNames> {
|
|
|
18
19
|
mainModule(): string;
|
|
19
20
|
mainModuleConfig(): unknown;
|
|
20
21
|
modulePrefix(): string;
|
|
22
|
+
podModulePrefix(): string | undefined;
|
|
21
23
|
rootURL(): string;
|
|
22
24
|
templateCompilerPath(): string;
|
|
23
25
|
templateResolver(): Resolver;
|
|
24
|
-
|
|
26
|
+
adjustImportsOptions(): AdjustImportsOptions;
|
|
25
27
|
htmlbarsPlugins(): TemplateCompilerPlugins;
|
|
26
28
|
babelConfig(): TransformOptions;
|
|
27
29
|
babelMajorVersion(): 6 | 7;
|
|
28
|
-
extraImports(): {
|
|
29
|
-
absPath: string;
|
|
30
|
-
target: string;
|
|
31
|
-
runtimeName?: string;
|
|
32
|
-
}[];
|
|
33
30
|
emberENV(): EmberENV;
|
|
34
31
|
strictV2Format(): boolean;
|
|
35
32
|
developingAddons(): string[];
|
|
@@ -74,11 +71,14 @@ export declare class AppBuilder<TreeNames> {
|
|
|
74
71
|
build(inputPaths: OutputPaths<TreeNames>): Promise<void>;
|
|
75
72
|
private combinePackageJSON;
|
|
76
73
|
private templateCompiler;
|
|
74
|
+
private get portableHints();
|
|
77
75
|
private addTemplateCompiler;
|
|
78
76
|
private addBabelConfig;
|
|
79
77
|
private shouldSplitRoute;
|
|
80
78
|
private splitRoute;
|
|
81
79
|
private topAppJSAsset;
|
|
80
|
+
private get staticAppPathsPattern();
|
|
81
|
+
private requiredOtherFiles;
|
|
82
82
|
private appJSAsset;
|
|
83
83
|
private get modulePrefix();
|
|
84
84
|
private importPaths;
|
package/src/app.js
CHANGED
|
@@ -41,16 +41,16 @@ const app_differ_1 = __importDefault(require("./app-differ"));
|
|
|
41
41
|
const ember_html_1 = require("./ember-html");
|
|
42
42
|
const assert_never_1 = __importDefault(require("assert-never"));
|
|
43
43
|
const fast_sourcemap_concat_1 = __importDefault(require("fast-sourcemap-concat"));
|
|
44
|
-
const
|
|
45
|
-
const portable_babel_config_1 =
|
|
46
|
-
const template_compiler_1 =
|
|
47
|
-
const os_1 = require("os");
|
|
44
|
+
const node_1 = require("@embroider/macros/src/node");
|
|
45
|
+
const portable_babel_config_1 = require("./portable-babel-config");
|
|
46
|
+
const template_compiler_1 = require("./template-compiler");
|
|
48
47
|
const paths_1 = require("./paths");
|
|
49
48
|
const engine_mangler_1 = require("./engine-mangler");
|
|
50
49
|
const app_files_1 = require("./app-files");
|
|
51
50
|
const partition_1 = __importDefault(require("lodash/partition"));
|
|
52
51
|
const mergeWith_1 = __importDefault(require("lodash/mergeWith"));
|
|
53
52
|
const cloneDeep_1 = __importDefault(require("lodash/cloneDeep"));
|
|
53
|
+
const escape_string_regexp_1 = __importDefault(require("escape-string-regexp"));
|
|
54
54
|
function excludeDotFiles(files) {
|
|
55
55
|
return files.filter(file => !file.startsWith('.') && !file.includes('/.'));
|
|
56
56
|
}
|
|
@@ -115,10 +115,10 @@ class AppBuilder {
|
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
117
|
get resolvableExtensionsPattern() {
|
|
118
|
-
return paths_1.extensionsPattern(this.adapter.
|
|
118
|
+
return paths_1.extensionsPattern(this.adapter.adjustImportsOptions().resolvableExtensions);
|
|
119
119
|
}
|
|
120
|
-
impliedAssets(type, emberENV) {
|
|
121
|
-
let result = this.impliedAddonAssets(type).map((sourcePath) => {
|
|
120
|
+
impliedAssets(type, engine, emberENV) {
|
|
121
|
+
let result = this.impliedAddonAssets(type, engine).map((sourcePath) => {
|
|
122
122
|
let stats = fs_extra_1.statSync(sourcePath);
|
|
123
123
|
return {
|
|
124
124
|
kind: 'on-disk',
|
|
@@ -171,16 +171,19 @@ class AppBuilder {
|
|
|
171
171
|
}
|
|
172
172
|
return result;
|
|
173
173
|
}
|
|
174
|
-
impliedAddonAssets(type) {
|
|
174
|
+
impliedAddonAssets(type, engine) {
|
|
175
175
|
let result = [];
|
|
176
|
-
for (let addon of sortBy_1.default(
|
|
176
|
+
for (let addon of sortBy_1.default(Array.from(engine.addons), this.scriptPriority.bind(this))) {
|
|
177
177
|
let implicitScripts = addon.meta[type];
|
|
178
178
|
if (implicitScripts) {
|
|
179
179
|
let styles = [];
|
|
180
180
|
let options = { basedir: addon.root };
|
|
181
181
|
for (let mod of implicitScripts) {
|
|
182
182
|
if (type === 'implicit-styles') {
|
|
183
|
-
|
|
183
|
+
// exclude engines because they will handle their own css importation
|
|
184
|
+
if (!addon.isLazyEngine()) {
|
|
185
|
+
styles.push(resolve_1.default.sync(mod, options));
|
|
186
|
+
}
|
|
184
187
|
}
|
|
185
188
|
else {
|
|
186
189
|
result.push(resolve_1.default.sync(mod, options));
|
|
@@ -207,7 +210,7 @@ class AppBuilder {
|
|
|
207
210
|
: '@babel/plugin-syntax-dynamic-import'));
|
|
208
211
|
return babel;
|
|
209
212
|
}
|
|
210
|
-
babelConfig(
|
|
213
|
+
babelConfig(templateCompilerParams, appFiles) {
|
|
211
214
|
let babel = this.adapter.babelConfig();
|
|
212
215
|
if (!babel.plugins) {
|
|
213
216
|
babel.plugins = [];
|
|
@@ -221,7 +224,7 @@ class AppBuilder {
|
|
|
221
224
|
babel.plugins.push([
|
|
222
225
|
path_1.join(__dirname, 'babel-plugin-inline-hbs.js'),
|
|
223
226
|
{
|
|
224
|
-
templateCompiler,
|
|
227
|
+
templateCompiler: templateCompilerParams,
|
|
225
228
|
stage: 3,
|
|
226
229
|
},
|
|
227
230
|
]);
|
|
@@ -229,34 +232,24 @@ class AppBuilder {
|
|
|
229
232
|
// this is @embroider/macros configured for full stage3 resolution
|
|
230
233
|
babel.plugins.push(this.macrosConfig.babelPluginConfig());
|
|
231
234
|
babel.plugins.push([require.resolve('./template-colocation-plugin')]);
|
|
232
|
-
|
|
235
|
+
// we can use globally shared babel runtime by default
|
|
236
|
+
babel.plugins.push([
|
|
237
|
+
require.resolve('@babel/plugin-transform-runtime'),
|
|
238
|
+
{ absoluteRuntime: __dirname, useESModules: true, regenerator: false },
|
|
239
|
+
]);
|
|
240
|
+
return portable_babel_config_1.makePortable(babel, { basedir: this.root }, this.portableHints);
|
|
233
241
|
}
|
|
234
242
|
adjustImportsPlugin(engines) {
|
|
235
|
-
let renamePackages = Object.assign({}, ...this.adapter.allActiveAddons.map(dep => dep.meta['renamed-packages']));
|
|
236
|
-
let renameModules = Object.assign({}, ...this.adapter.allActiveAddons.map(dep => dep.meta['renamed-modules']));
|
|
237
|
-
let activeAddons = {};
|
|
238
|
-
for (let addon of this.adapter.allActiveAddons) {
|
|
239
|
-
activeAddons[addon.name] = addon.root;
|
|
240
|
-
}
|
|
241
243
|
let relocatedFiles = {};
|
|
242
244
|
for (let { destPath, appFiles } of engines) {
|
|
243
245
|
for (let [relativePath, originalPath] of appFiles.relocatedFiles) {
|
|
244
246
|
relocatedFiles[path_1.join(destPath, relativePath).split(path_1.sep).join('/')] = originalPath;
|
|
245
247
|
}
|
|
246
248
|
}
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
extraImports: this.adapter.extraImports(),
|
|
252
|
-
relocatedFiles,
|
|
253
|
-
resolvableExtensions: this.adapter.resolvableExtensions(),
|
|
254
|
-
// it's important that this is a persistent location, because we fill it
|
|
255
|
-
// up as a side-effect of babel transpilation, and babel is subject to
|
|
256
|
-
// persistent caching.
|
|
257
|
-
externalsDir: path_1.join(os_1.tmpdir(), 'embroider', 'externals'),
|
|
258
|
-
};
|
|
259
|
-
return [require.resolve('./babel-plugin-adjust-imports'), adjustOptions];
|
|
249
|
+
return [
|
|
250
|
+
require.resolve('./babel-plugin-adjust-imports'),
|
|
251
|
+
Object.assign({}, this.adapter.adjustImportsOptions(), { relocatedFiles }),
|
|
252
|
+
];
|
|
260
253
|
}
|
|
261
254
|
insertEmberApp(asset, appFiles, prepared, emberENV) {
|
|
262
255
|
let html = asset.html;
|
|
@@ -282,7 +275,8 @@ class AppBuilder {
|
|
|
282
275
|
}
|
|
283
276
|
}
|
|
284
277
|
html.insertStyleLink(html.styles, `assets/${this.app.name}.css`);
|
|
285
|
-
|
|
278
|
+
const parentEngine = appFiles.find(e => !e.parent);
|
|
279
|
+
let vendorJS = this.implicitScriptsAsset(prepared, parentEngine, emberENV);
|
|
286
280
|
if (vendorJS) {
|
|
287
281
|
html.insertScriptTag(html.implicitScripts, vendorJS.relativePath);
|
|
288
282
|
}
|
|
@@ -294,7 +288,7 @@ class AppBuilder {
|
|
|
294
288
|
html.insertScriptTag(html.implicitScripts, script, { tag: 'fastboot-script' });
|
|
295
289
|
}
|
|
296
290
|
}
|
|
297
|
-
let implicitStyles = this.implicitStylesAsset(prepared);
|
|
291
|
+
let implicitStyles = this.implicitStylesAsset(prepared, parentEngine);
|
|
298
292
|
if (implicitStyles) {
|
|
299
293
|
html.insertStyleLink(html.implicitStyles, implicitStyles.relativePath);
|
|
300
294
|
}
|
|
@@ -304,19 +298,19 @@ class AppBuilder {
|
|
|
304
298
|
// Test-related assets happen below this point
|
|
305
299
|
let testJS = this.testJSEntrypoint(appFiles, prepared);
|
|
306
300
|
html.insertScriptTag(html.testJavascript, testJS.relativePath, { type: 'module' });
|
|
307
|
-
let implicitTestScriptsAsset = this.implicitTestScriptsAsset(prepared);
|
|
301
|
+
let implicitTestScriptsAsset = this.implicitTestScriptsAsset(prepared, parentEngine);
|
|
308
302
|
if (implicitTestScriptsAsset) {
|
|
309
303
|
html.insertScriptTag(html.implicitTestScripts, implicitTestScriptsAsset.relativePath);
|
|
310
304
|
}
|
|
311
|
-
let implicitTestStylesAsset = this.implicitTestStylesAsset(prepared);
|
|
305
|
+
let implicitTestStylesAsset = this.implicitTestStylesAsset(prepared, parentEngine);
|
|
312
306
|
if (implicitTestStylesAsset) {
|
|
313
307
|
html.insertStyleLink(html.implicitTestStyles, implicitTestStylesAsset.relativePath);
|
|
314
308
|
}
|
|
315
309
|
}
|
|
316
|
-
implicitScriptsAsset(prepared, emberENV) {
|
|
310
|
+
implicitScriptsAsset(prepared, application, emberENV) {
|
|
317
311
|
let asset = prepared.get('assets/vendor.js');
|
|
318
312
|
if (!asset) {
|
|
319
|
-
let implicitScripts = this.impliedAssets('implicit-scripts', emberENV);
|
|
313
|
+
let implicitScripts = this.impliedAssets('implicit-scripts', application, emberENV);
|
|
320
314
|
if (implicitScripts.length > 0) {
|
|
321
315
|
asset = new ConcatenatedAsset('assets/vendor.js', implicitScripts, this.resolvableExtensionsPattern);
|
|
322
316
|
prepared.set(asset.relativePath, asset);
|
|
@@ -324,21 +318,22 @@ class AppBuilder {
|
|
|
324
318
|
}
|
|
325
319
|
return asset;
|
|
326
320
|
}
|
|
327
|
-
implicitStylesAsset(prepared) {
|
|
321
|
+
implicitStylesAsset(prepared, application) {
|
|
328
322
|
let asset = prepared.get('assets/vendor.css');
|
|
329
323
|
if (!asset) {
|
|
330
|
-
let implicitStyles = this.impliedAssets('implicit-styles');
|
|
324
|
+
let implicitStyles = this.impliedAssets('implicit-styles', application);
|
|
331
325
|
if (implicitStyles.length > 0) {
|
|
332
|
-
|
|
326
|
+
// we reverse because we want the synthetic vendor style at the top
|
|
327
|
+
asset = new ConcatenatedAsset('assets/vendor.css', implicitStyles.reverse(), this.resolvableExtensionsPattern);
|
|
333
328
|
prepared.set(asset.relativePath, asset);
|
|
334
329
|
}
|
|
335
330
|
}
|
|
336
331
|
return asset;
|
|
337
332
|
}
|
|
338
|
-
implicitTestScriptsAsset(prepared) {
|
|
333
|
+
implicitTestScriptsAsset(prepared, application) {
|
|
339
334
|
let testSupportJS = prepared.get('assets/test-support.js');
|
|
340
335
|
if (!testSupportJS) {
|
|
341
|
-
let implicitTestScripts = this.impliedAssets('implicit-test-scripts');
|
|
336
|
+
let implicitTestScripts = this.impliedAssets('implicit-test-scripts', application);
|
|
342
337
|
if (implicitTestScripts.length > 0) {
|
|
343
338
|
testSupportJS = new ConcatenatedAsset('assets/test-support.js', implicitTestScripts, this.resolvableExtensionsPattern);
|
|
344
339
|
prepared.set(testSupportJS.relativePath, testSupportJS);
|
|
@@ -346,10 +341,10 @@ class AppBuilder {
|
|
|
346
341
|
}
|
|
347
342
|
return testSupportJS;
|
|
348
343
|
}
|
|
349
|
-
implicitTestStylesAsset(prepared) {
|
|
344
|
+
implicitTestStylesAsset(prepared, application) {
|
|
350
345
|
let asset = prepared.get('assets/test-support.css');
|
|
351
346
|
if (!asset) {
|
|
352
|
-
let implicitTestStyles = this.impliedAssets('implicit-test-styles');
|
|
347
|
+
let implicitTestStyles = this.impliedAssets('implicit-test-styles', application);
|
|
353
348
|
if (implicitTestStyles.length > 0) {
|
|
354
349
|
asset = new ConcatenatedAsset('assets/test-support.css', implicitTestStyles, this.resolvableExtensionsPattern);
|
|
355
350
|
prepared.set(asset.relativePath, asset);
|
|
@@ -447,7 +442,7 @@ class AppBuilder {
|
|
|
447
442
|
.forEach(a => a.differ.update());
|
|
448
443
|
return this.appDiffers.map(a => {
|
|
449
444
|
return Object.assign({}, a.engine, {
|
|
450
|
-
appFiles: new app_files_1.AppFiles(a.differ, this.resolvableExtensionsPattern),
|
|
445
|
+
appFiles: new app_files_1.AppFiles(a.differ, this.resolvableExtensionsPattern, this.adapter.podModulePrefix()),
|
|
451
446
|
});
|
|
452
447
|
});
|
|
453
448
|
}
|
|
@@ -624,7 +619,7 @@ class AppBuilder {
|
|
|
624
619
|
let finalAssets = await this.updateAssets(assets, appFiles, emberENV);
|
|
625
620
|
let templateCompiler = this.templateCompiler(emberENV);
|
|
626
621
|
let babelConfig = this.babelConfig(templateCompiler, appFiles);
|
|
627
|
-
this.addTemplateCompiler(templateCompiler);
|
|
622
|
+
let templateCompilerIsParallelSafe = this.addTemplateCompiler(templateCompiler);
|
|
628
623
|
this.addBabelConfig(babelConfig);
|
|
629
624
|
let assetPaths = assets.map(asset => asset.relativePath);
|
|
630
625
|
if (this.activeFastboot) {
|
|
@@ -645,7 +640,7 @@ class AppBuilder {
|
|
|
645
640
|
assets: assetPaths,
|
|
646
641
|
'template-compiler': {
|
|
647
642
|
filename: '_template_compiler_.js',
|
|
648
|
-
isParallelSafe:
|
|
643
|
+
isParallelSafe: templateCompilerIsParallelSafe,
|
|
649
644
|
},
|
|
650
645
|
babel: {
|
|
651
646
|
filename: '_babel_config_.js',
|
|
@@ -653,7 +648,7 @@ class AppBuilder {
|
|
|
653
648
|
majorVersion: this.adapter.babelMajorVersion(),
|
|
654
649
|
fileFilter: '_babel_filter_.js',
|
|
655
650
|
},
|
|
656
|
-
'resolvable-extensions': this.adapter.
|
|
651
|
+
'resolvable-extensions': this.adapter.adjustImportsOptions().resolvableExtensions,
|
|
657
652
|
'root-url': this.adapter.rootURL(),
|
|
658
653
|
};
|
|
659
654
|
if (!this.adapter.strictV2Format()) {
|
|
@@ -675,26 +670,41 @@ class AppBuilder {
|
|
|
675
670
|
if (!plugins.ast) {
|
|
676
671
|
plugins.ast = [];
|
|
677
672
|
}
|
|
678
|
-
let { plugins: macroPlugins, setConfig } =
|
|
673
|
+
let { plugins: macroPlugins, setConfig } = node_1.MacrosConfig.astPlugins();
|
|
679
674
|
setConfig(this.macrosConfig);
|
|
680
675
|
for (let macroPlugin of macroPlugins) {
|
|
681
676
|
plugins.ast.push(macroPlugin);
|
|
682
677
|
}
|
|
683
|
-
return
|
|
678
|
+
return {
|
|
684
679
|
plugins,
|
|
685
680
|
compilerPath: resolve_1.default.sync(this.adapter.templateCompilerPath(), { basedir: this.root }),
|
|
686
681
|
resolver: this.adapter.templateResolver(),
|
|
687
682
|
EmberENV: config,
|
|
683
|
+
};
|
|
684
|
+
}
|
|
685
|
+
get portableHints() {
|
|
686
|
+
return this.options.pluginHints.map(hint => {
|
|
687
|
+
let cursor = path_1.join(this.app.root, 'package.json');
|
|
688
|
+
for (let i = 0; i < hint.resolve.length; i++) {
|
|
689
|
+
let target = hint.resolve[i];
|
|
690
|
+
if (i < hint.resolve.length - 1) {
|
|
691
|
+
target = path_1.join(target, 'package.json');
|
|
692
|
+
}
|
|
693
|
+
cursor = resolve_1.default.sync(target, { basedir: path_1.dirname(cursor) });
|
|
694
|
+
}
|
|
695
|
+
return { requireFile: cursor, useMethod: hint.useMethod };
|
|
688
696
|
});
|
|
689
697
|
}
|
|
690
|
-
addTemplateCompiler(
|
|
691
|
-
|
|
698
|
+
addTemplateCompiler(params) {
|
|
699
|
+
let mod = template_compiler_1.templateCompilerModule(params, this.portableHints);
|
|
700
|
+
fs_extra_1.writeFileSync(path_1.join(this.root, '_template_compiler_.js'), mod.src, 'utf8');
|
|
701
|
+
return mod.isParallelSafe;
|
|
692
702
|
}
|
|
693
|
-
addBabelConfig(
|
|
694
|
-
if (!
|
|
703
|
+
addBabelConfig(pconfig) {
|
|
704
|
+
if (!pconfig.isParallelSafe) {
|
|
695
705
|
messages_1.warn('Your build is slower because some babel plugins are non-serializable');
|
|
696
706
|
}
|
|
697
|
-
fs_extra_1.writeFileSync(path_1.join(this.root, '_babel_config_.js'),
|
|
707
|
+
fs_extra_1.writeFileSync(path_1.join(this.root, '_babel_config_.js'), `module.exports = ${JSON.stringify(pconfig.config, null, 2)}`, 'utf8');
|
|
698
708
|
fs_extra_1.writeFileSync(path_1.join(this.root, '_babel_filter_.js'), babelFilterTemplate({ skipBabel: this.options.skipBabel }), 'utf8');
|
|
699
709
|
}
|
|
700
710
|
shouldSplitRoute(routeName) {
|
|
@@ -767,6 +777,26 @@ class AppBuilder {
|
|
|
767
777
|
appConfig: this.adapter.mainModuleConfig(),
|
|
768
778
|
});
|
|
769
779
|
}
|
|
780
|
+
get staticAppPathsPattern() {
|
|
781
|
+
if (this.options.staticAppPaths.length > 0) {
|
|
782
|
+
return new RegExp('^(?:' +
|
|
783
|
+
this.options.staticAppPaths.map(staticAppPath => escape_string_regexp_1.default(staticAppPath.replace(/\//g, path_1.sep))).join('|') +
|
|
784
|
+
')(?:$|' +
|
|
785
|
+
path_1.sep +
|
|
786
|
+
')');
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
requiredOtherFiles(appFiles) {
|
|
790
|
+
let pattern = this.staticAppPathsPattern;
|
|
791
|
+
if (pattern) {
|
|
792
|
+
return appFiles.otherAppFiles.filter(f => {
|
|
793
|
+
return !pattern.test(f);
|
|
794
|
+
});
|
|
795
|
+
}
|
|
796
|
+
else {
|
|
797
|
+
return appFiles.otherAppFiles;
|
|
798
|
+
}
|
|
799
|
+
}
|
|
770
800
|
appJSAsset(relativePath, engine, childEngines, prepared, entryParams) {
|
|
771
801
|
let { appFiles } = engine;
|
|
772
802
|
let cached = prepared.get(relativePath);
|
|
@@ -774,13 +804,27 @@ class AppBuilder {
|
|
|
774
804
|
return cached;
|
|
775
805
|
}
|
|
776
806
|
let eagerModules = [];
|
|
777
|
-
let requiredAppFiles = [appFiles
|
|
807
|
+
let requiredAppFiles = [this.requiredOtherFiles(appFiles)];
|
|
778
808
|
if (!this.options.staticComponents) {
|
|
779
809
|
requiredAppFiles.push(appFiles.components);
|
|
780
810
|
}
|
|
781
811
|
if (!this.options.staticHelpers) {
|
|
782
812
|
requiredAppFiles.push(appFiles.helpers);
|
|
783
813
|
}
|
|
814
|
+
let styles = [];
|
|
815
|
+
// only import styles from engines with a parent (this excludeds the parent application) as their styles
|
|
816
|
+
// will be inserted via a direct <link> tag.
|
|
817
|
+
if (engine.parent && engine.package.isLazyEngine()) {
|
|
818
|
+
let implicitStyles = this.impliedAssets('implicit-styles', engine);
|
|
819
|
+
for (let style of implicitStyles) {
|
|
820
|
+
styles.push({
|
|
821
|
+
path: paths_1.explicitRelative('assets/_engine_', style.relativePath),
|
|
822
|
+
});
|
|
823
|
+
}
|
|
824
|
+
styles.push({
|
|
825
|
+
path: paths_1.explicitRelative(relativePath, engine.package.name + '/' + engine.package.name + '.css'),
|
|
826
|
+
});
|
|
827
|
+
}
|
|
784
828
|
let lazyEngines = [];
|
|
785
829
|
for (let childEngine of childEngines) {
|
|
786
830
|
let asset = this.appJSAsset(`assets/_engine_/${encodeURIComponent(childEngine.package.name)}.js`, childEngine, [], prepared);
|
|
@@ -815,7 +859,7 @@ class AppBuilder {
|
|
|
815
859
|
// this is a backward-compatibility feature: addons can force inclusion of
|
|
816
860
|
// modules.
|
|
817
861
|
this.gatherImplicitModules('implicit-modules', relativePath, engine, amdModules);
|
|
818
|
-
let params = { amdModules, fastbootOnlyAmdModules, lazyRoutes, lazyEngines, eagerModules };
|
|
862
|
+
let params = { amdModules, fastbootOnlyAmdModules, lazyRoutes, lazyEngines, eagerModules, styles };
|
|
819
863
|
if (entryParams) {
|
|
820
864
|
Object.assign(params, entryParams);
|
|
821
865
|
}
|
|
@@ -937,21 +981,34 @@ __decorate([
|
|
|
937
981
|
__decorate([
|
|
938
982
|
typescript_memoize_1.Memoize()
|
|
939
983
|
], AppBuilder.prototype, "fastbootConfig", null);
|
|
984
|
+
__decorate([
|
|
985
|
+
typescript_memoize_1.Memoize()
|
|
986
|
+
], AppBuilder.prototype, "portableHints", null);
|
|
987
|
+
__decorate([
|
|
988
|
+
typescript_memoize_1.Memoize()
|
|
989
|
+
], AppBuilder.prototype, "staticAppPathsPattern", null);
|
|
940
990
|
__decorate([
|
|
941
991
|
typescript_memoize_1.Memoize()
|
|
942
992
|
], AppBuilder.prototype, "modulePrefix", null);
|
|
943
993
|
exports.AppBuilder = AppBuilder;
|
|
944
994
|
const entryTemplate = js_handlebars_1.compile(`
|
|
945
|
-
import { importSync as i } from '@embroider/macros';
|
|
995
|
+
import { importSync as i, macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
946
996
|
let w = window;
|
|
947
997
|
let d = w.define;
|
|
948
998
|
|
|
999
|
+
{{#if styles}}
|
|
1000
|
+
if (macroCondition(!getGlobalConfig().fastboot?.isRunning)) {
|
|
1001
|
+
{{#each styles as |stylePath| ~}}
|
|
1002
|
+
i("{{stylePath.path}}");
|
|
1003
|
+
{{/each}}
|
|
1004
|
+
}
|
|
1005
|
+
{{/if}}
|
|
1006
|
+
|
|
949
1007
|
{{#each amdModules as |amdModule| ~}}
|
|
950
1008
|
d("{{js-string-escape amdModule.runtime}}", function(){ return i("{{js-string-escape amdModule.buildtime}}");});
|
|
951
1009
|
{{/each}}
|
|
952
1010
|
|
|
953
1011
|
{{#if fastbootOnlyAmdModules}}
|
|
954
|
-
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
955
1012
|
if (macroCondition(getGlobalConfig().fastboot?.isRunning)) {
|
|
956
1013
|
{{#each fastbootOnlyAmdModules as |amdModule| ~}}
|
|
957
1014
|
d("{{js-string-escape amdModule.runtime}}", function(){ return i("{{js-string-escape amdModule.buildtime}}");});
|