@embroider/compat 3.6.0 → 3.6.2-unstable.2ff89c0
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/babel.js +1 -0
- package/package.json +12 -10
- package/src/audit/babel-visitor.js +7 -1
- package/src/audit/babel-visitor.js.map +1 -1
- package/src/audit/build.js.map +1 -1
- package/src/audit.d.ts +6 -53
- package/src/audit.js +98 -285
- package/src/audit.js.map +1 -1
- package/src/babel-plugin-adjust-imports.js +2 -2
- package/src/babel-plugin-adjust-imports.js.map +1 -1
- package/src/babel.d.ts +19 -0
- package/src/babel.js +141 -0
- package/src/babel.js.map +1 -0
- package/src/compat-adapters/@ember-data/store.d.ts +1 -5
- package/src/compat-adapters/@ember-data/store.js +3 -15
- package/src/compat-adapters/@ember-data/store.js.map +1 -1
- package/src/compat-adapters/ember-fetch.d.ts +5 -0
- package/src/compat-adapters/ember-fetch.js +19 -0
- package/src/compat-adapters/ember-fetch.js.map +1 -0
- package/src/compat-adapters/ember-resolver.d.ts +4 -0
- package/src/compat-adapters/ember-resolver.js +21 -0
- package/src/compat-adapters/ember-resolver.js.map +1 -0
- package/src/compat-addons.js +1 -1
- package/src/compat-addons.js.map +1 -1
- package/src/compat-app-builder.d.ts +8 -53
- package/src/compat-app-builder.js +117 -1130
- package/src/compat-app-builder.js.map +1 -1
- package/src/compat-app.d.ts +4 -22
- package/src/compat-app.js +70 -216
- package/src/compat-app.js.map +1 -1
- package/src/content-for-config.d.ts +11 -0
- package/src/content-for-config.js +66 -0
- package/src/content-for-config.js.map +1 -0
- package/src/default-pipeline.d.ts +2 -2
- package/src/default-pipeline.js +21 -0
- package/src/default-pipeline.js.map +1 -1
- package/src/dependency-rules.js +17 -10
- package/src/dependency-rules.js.map +1 -1
- package/src/detect-babel-plugins.d.ts +1 -0
- package/src/detect-babel-plugins.js +14 -0
- package/src/detect-babel-plugins.js.map +1 -1
- package/src/http-audit.d.ts +13 -0
- package/src/http-audit.js +60 -0
- package/src/http-audit.js.map +1 -0
- package/src/index.d.ts +1 -2
- package/src/index.js +2 -3
- package/src/index.js.map +1 -1
- package/src/module-visitor.d.ts +52 -0
- package/src/module-visitor.js +285 -0
- package/src/module-visitor.js.map +1 -0
- package/src/options.d.ts +3 -2
- package/src/options.js +3 -0
- package/src/options.js.map +1 -1
- package/src/resolver-transform.js +7 -4
- package/src/resolver-transform.js.map +1 -1
- package/src/standalone-addon-build.js +6 -15
- package/src/standalone-addon-build.js.map +1 -1
- package/src/v1-config.d.ts +0 -8
- package/src/v1-config.js +1 -51
- package/src/v1-config.js.map +1 -1
- package/src/compat-adapters/@ember-data/debug.d.ts +0 -6
- package/src/compat-adapters/@ember-data/debug.js +0 -22
- package/src/compat-adapters/@ember-data/debug.js.map +0 -1
- package/src/rename-require-plugin.d.ts +0 -1
- package/src/rename-require-plugin.js +0 -15
- package/src/rename-require-plugin.js.map +0 -1
- package/src/sync-dir.d.ts +0 -8
- package/src/sync-dir.js +0 -68
- package/src/sync-dir.js.map +0 -1
- package/src/template-tag-codemod.d.ts +0 -10
- package/src/template-tag-codemod.js +0 -258
- package/src/template-tag-codemod.js.map +0 -1
- package/src/v1-appboot.d.ts +0 -14
- package/src/v1-appboot.js +0 -47
- package/src/v1-appboot.js.map +0 -1
|
@@ -1,133 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
2
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
3
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
4
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
5
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
7
|
};
|
|
24
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
25
|
-
if (mod && mod.__esModule) return mod;
|
|
26
|
-
var result = {};
|
|
27
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
28
|
-
__setModuleDefault(result, mod);
|
|
29
|
-
return result;
|
|
30
|
-
};
|
|
31
8
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
32
9
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
33
10
|
};
|
|
34
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
12
|
exports.CompatAppBuilder = void 0;
|
|
36
13
|
const core_1 = require("@embroider/core");
|
|
37
|
-
const walk_sync_1 = __importDefault(require("walk-sync"));
|
|
38
14
|
const path_1 = require("path");
|
|
39
15
|
const dependency_rules_1 = require("./dependency-rules");
|
|
40
16
|
const flatMap_1 = __importDefault(require("lodash/flatMap"));
|
|
41
|
-
const sortBy_1 = __importDefault(require("lodash/sortBy"));
|
|
42
|
-
const flatten_1 = __importDefault(require("lodash/flatten"));
|
|
43
|
-
const partition_1 = __importDefault(require("lodash/partition"));
|
|
44
|
-
const mergeWith_1 = __importDefault(require("lodash/mergeWith"));
|
|
45
|
-
const cloneDeep_1 = __importDefault(require("lodash/cloneDeep"));
|
|
46
|
-
const resolve_1 = require("resolve");
|
|
47
17
|
const bind_decorator_1 = __importDefault(require("bind-decorator"));
|
|
48
18
|
const fs_extra_1 = require("fs-extra");
|
|
49
|
-
const ember_html_1 = require("@embroider/core/src/ember-html");
|
|
50
|
-
const portable_babel_config_1 = require("@embroider/core/src/portable-babel-config");
|
|
51
|
-
const app_files_1 = require("@embroider/core/src/app-files");
|
|
52
19
|
const portable_1 = require("@embroider/core/src/portable");
|
|
53
|
-
const assert_never_1 = __importDefault(require("assert-never"));
|
|
54
20
|
const typescript_memoize_1 = require("typescript-memoize");
|
|
55
21
|
const path_2 = require("path");
|
|
56
|
-
const
|
|
22
|
+
const resolve_1 = __importDefault(require("resolve"));
|
|
57
23
|
const fs_extra_2 = require("fs-extra");
|
|
58
24
|
const node_1 = require("@embroider/macros/src/node");
|
|
59
|
-
const fast_sourcemap_concat_1 = __importDefault(require("fast-sourcemap-concat"));
|
|
60
|
-
const escape_string_regexp_1 = __importDefault(require("escape-string-regexp"));
|
|
61
|
-
const sync_dir_1 = require("./sync-dir");
|
|
62
25
|
// This exists during the actual broccoli build step. As opposed to CompatApp,
|
|
63
26
|
// which also exists during pipeline-construction time.
|
|
64
27
|
class CompatAppBuilder {
|
|
65
|
-
constructor(
|
|
66
|
-
this.root = root;
|
|
28
|
+
constructor(origAppPackage, appPackageWithMovedDeps, options, compatApp, configTree, contentForTree, synthVendor, synthStyles) {
|
|
67
29
|
this.origAppPackage = origAppPackage;
|
|
68
30
|
this.appPackageWithMovedDeps = appPackageWithMovedDeps;
|
|
69
31
|
this.options = options;
|
|
70
32
|
this.compatApp = compatApp;
|
|
71
33
|
this.configTree = configTree;
|
|
34
|
+
this.contentForTree = contentForTree;
|
|
72
35
|
this.synthVendor = synthVendor;
|
|
73
36
|
this.synthStyles = synthStyles;
|
|
74
|
-
// for each relativePath, an Asset we have already emitted
|
|
75
|
-
this.assets = new Map();
|
|
76
|
-
this.firstBuild = true;
|
|
77
|
-
}
|
|
78
|
-
fastbootJSSrcDir() {
|
|
79
|
-
let target = (0, path_2.join)(this.compatApp.root, 'fastboot');
|
|
80
|
-
if ((0, fs_extra_2.pathExistsSync)(target)) {
|
|
81
|
-
return target;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
extractAssets(treePaths) {
|
|
85
|
-
let assets = [];
|
|
86
|
-
// Everything in our traditional public tree is an on-disk asset
|
|
87
|
-
if (treePaths.publicTree) {
|
|
88
|
-
walk_sync_1.default
|
|
89
|
-
.entries(treePaths.publicTree, {
|
|
90
|
-
directories: false,
|
|
91
|
-
})
|
|
92
|
-
.forEach(entry => {
|
|
93
|
-
assets.push({
|
|
94
|
-
kind: 'on-disk',
|
|
95
|
-
relativePath: entry.relativePath,
|
|
96
|
-
sourcePath: entry.fullPath,
|
|
97
|
-
mtime: entry.mtime, // https://github.com/joliss/node-walk-sync/pull/38
|
|
98
|
-
size: entry.size,
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
// ember-cli traditionally outputs a dummy testem.js file to prevent
|
|
103
|
-
// spurious errors when running tests under "ember s".
|
|
104
|
-
if (this.compatApp.shouldBuildTests) {
|
|
105
|
-
let testemAsset = this.findTestemAsset();
|
|
106
|
-
if (testemAsset) {
|
|
107
|
-
assets.push(testemAsset);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
for (let asset of this.emberEntrypoints(treePaths.htmlTree)) {
|
|
111
|
-
assets.push(asset);
|
|
112
|
-
}
|
|
113
|
-
return assets;
|
|
114
|
-
}
|
|
115
|
-
findTestemAsset() {
|
|
116
|
-
let sourcePath;
|
|
117
|
-
try {
|
|
118
|
-
sourcePath = (0, resolve_1.sync)('ember-cli/lib/broccoli/testem.js', { basedir: this.root });
|
|
119
|
-
}
|
|
120
|
-
catch (err) { }
|
|
121
|
-
if (sourcePath) {
|
|
122
|
-
let stat = (0, fs_extra_1.statSync)(sourcePath);
|
|
123
|
-
return {
|
|
124
|
-
kind: 'on-disk',
|
|
125
|
-
relativePath: 'testem.js',
|
|
126
|
-
sourcePath,
|
|
127
|
-
mtime: stat.mtime.getTime(),
|
|
128
|
-
size: stat.size,
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
37
|
}
|
|
132
38
|
activeAddonChildren(pkg) {
|
|
133
39
|
let result = pkg.dependencies.filter(this.isActiveAddon).filter(
|
|
@@ -170,49 +76,12 @@ class CompatAppBuilder {
|
|
|
170
76
|
return depAIdx - depBIdx;
|
|
171
77
|
}
|
|
172
78
|
resolvableExtensions() {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
//
|
|
177
|
-
// For TS, we defer to ember-cli-babel, and the setting for
|
|
178
|
-
// "enableTypescriptTransform" can be set with and without
|
|
179
|
-
// ember-cli-typescript
|
|
180
|
-
return ['.wasm', '.mjs', '.js', '.json', '.ts', '.hbs', '.hbs.js'];
|
|
181
|
-
}
|
|
182
|
-
*emberEntrypoints(htmlTreePath) {
|
|
183
|
-
let classicEntrypoints = [
|
|
184
|
-
{ entrypoint: 'index.html', includeTests: false },
|
|
185
|
-
{ entrypoint: 'tests/index.html', includeTests: true },
|
|
186
|
-
];
|
|
187
|
-
if (!this.compatApp.shouldBuildTests) {
|
|
188
|
-
classicEntrypoints.pop();
|
|
79
|
+
let fromEnv = process.env.EMBROIDER_RESOLVABLE_EXTENSIONS;
|
|
80
|
+
if (fromEnv) {
|
|
81
|
+
return fromEnv.split(',');
|
|
189
82
|
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
let stats = (0, fs_extra_1.statSync)(sourcePath);
|
|
193
|
-
let asset = {
|
|
194
|
-
kind: 'ember',
|
|
195
|
-
relativePath: entrypoint,
|
|
196
|
-
includeTests,
|
|
197
|
-
sourcePath,
|
|
198
|
-
mtime: stats.mtime.getTime(),
|
|
199
|
-
size: stats.size,
|
|
200
|
-
rootURL: this.rootURL(),
|
|
201
|
-
prepare: (dom) => {
|
|
202
|
-
let scripts = [...dom.window.document.querySelectorAll('script')];
|
|
203
|
-
let styles = [...dom.window.document.querySelectorAll('link[rel*="stylesheet"]')];
|
|
204
|
-
return {
|
|
205
|
-
javascript: this.compatApp.findAppScript(scripts, entrypoint),
|
|
206
|
-
styles: this.compatApp.findAppStyles(styles, entrypoint),
|
|
207
|
-
implicitScripts: this.compatApp.findVendorScript(scripts, entrypoint),
|
|
208
|
-
implicitStyles: this.compatApp.findVendorStyles(styles, entrypoint),
|
|
209
|
-
testJavascript: this.compatApp.findTestScript(scripts),
|
|
210
|
-
implicitTestScripts: this.compatApp.findTestSupportScript(scripts),
|
|
211
|
-
implicitTestStyles: this.compatApp.findTestSupportStyles(styles),
|
|
212
|
-
};
|
|
213
|
-
},
|
|
214
|
-
};
|
|
215
|
-
yield asset;
|
|
83
|
+
else {
|
|
84
|
+
return ['.mjs', '.gjs', '.js', '.mts', '.gts', '.ts', '.hbs', '.hbs.js', '.json'];
|
|
216
85
|
}
|
|
217
86
|
}
|
|
218
87
|
modulePrefix() {
|
|
@@ -221,22 +90,15 @@ class CompatAppBuilder {
|
|
|
221
90
|
podModulePrefix() {
|
|
222
91
|
return this.configTree.readConfig().podModulePrefix;
|
|
223
92
|
}
|
|
224
|
-
rootURL() {
|
|
225
|
-
return this.configTree.readConfig().rootURL;
|
|
226
|
-
}
|
|
227
93
|
activeRules() {
|
|
228
94
|
return (0, dependency_rules_1.activePackageRules)(this.options.packageRules.concat(defaultAddonPackageRules()), [
|
|
229
|
-
{ name: this.origAppPackage.name, version: this.origAppPackage.version, root: this.root },
|
|
95
|
+
{ name: this.origAppPackage.name, version: this.origAppPackage.version, root: this.origAppPackage.root },
|
|
230
96
|
...this.allActiveAddons.filter(p => p.meta['auto-upgraded']),
|
|
231
97
|
]);
|
|
232
98
|
}
|
|
233
99
|
resolverConfig(engines) {
|
|
234
100
|
let renamePackages = Object.assign({}, ...this.allActiveAddons.map(dep => dep.meta['renamed-packages']));
|
|
235
101
|
let renameModules = Object.assign({}, ...this.allActiveAddons.map(dep => dep.meta['renamed-modules']));
|
|
236
|
-
let activeAddons = {};
|
|
237
|
-
for (let addon of this.allActiveAddons) {
|
|
238
|
-
activeAddons[addon.name] = addon.root;
|
|
239
|
-
}
|
|
240
102
|
let options = {
|
|
241
103
|
staticHelpers: this.options.staticHelpers,
|
|
242
104
|
staticModifiers: this.options.staticModifiers,
|
|
@@ -245,292 +107,41 @@ class CompatAppBuilder {
|
|
|
245
107
|
};
|
|
246
108
|
let config = {
|
|
247
109
|
// this part is the base ModuleResolverOptions as required by @embroider/core
|
|
248
|
-
activeAddons,
|
|
249
110
|
renameModules,
|
|
250
111
|
renamePackages,
|
|
251
112
|
resolvableExtensions: this.resolvableExtensions(),
|
|
252
113
|
appRoot: this.origAppPackage.root,
|
|
253
|
-
engines: engines.map(
|
|
254
|
-
packageName:
|
|
255
|
-
// first engine is the app, which has been relocated to this.root
|
|
114
|
+
engines: engines.map(engine => ({
|
|
115
|
+
packageName: engine.package.name,
|
|
256
116
|
// we need to use the real path here because webpack requests always use the real path i.e. follow symlinks
|
|
257
|
-
root: (0, fs_extra_1.realpathSync)(
|
|
258
|
-
fastbootFiles:
|
|
259
|
-
activeAddons: [...
|
|
260
|
-
.map(
|
|
261
|
-
name:
|
|
262
|
-
root:
|
|
117
|
+
root: (0, fs_extra_1.realpathSync)(engine.package.root),
|
|
118
|
+
fastbootFiles: {},
|
|
119
|
+
activeAddons: [...engine.addons]
|
|
120
|
+
.map(([addon, canResolveFromFile]) => ({
|
|
121
|
+
name: addon.name,
|
|
122
|
+
root: addon.root,
|
|
123
|
+
canResolveFromFile,
|
|
263
124
|
}))
|
|
264
125
|
// the traditional order is the order in which addons will run, such
|
|
265
126
|
// that the last one wins. Our resolver's order is the order to
|
|
266
127
|
// search, so first one wins.
|
|
267
128
|
.reverse(),
|
|
129
|
+
isLazy: engine.package.isLazyEngine(),
|
|
268
130
|
})),
|
|
269
131
|
amdCompatibility: this.options.amdCompatibility,
|
|
270
132
|
// this is the additional stufff that @embroider/compat adds on top to do
|
|
271
133
|
// global template resolving
|
|
272
134
|
modulePrefix: this.modulePrefix(),
|
|
135
|
+
splitAtRoutes: this.options.splitAtRoutes,
|
|
273
136
|
podModulePrefix: this.podModulePrefix(),
|
|
274
137
|
activePackageRules: this.activeRules(),
|
|
275
138
|
options,
|
|
139
|
+
autoRun: this.compatApp.autoRun,
|
|
140
|
+
staticAppPaths: this.options.staticAppPaths,
|
|
141
|
+
emberVersion: this.emberVersion(),
|
|
276
142
|
};
|
|
277
143
|
return config;
|
|
278
144
|
}
|
|
279
|
-
scriptPriority(pkg) {
|
|
280
|
-
switch (pkg.name) {
|
|
281
|
-
case 'loader.js':
|
|
282
|
-
return 0;
|
|
283
|
-
case 'ember-source':
|
|
284
|
-
return 10;
|
|
285
|
-
default:
|
|
286
|
-
return 1000;
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
get resolvableExtensionsPattern() {
|
|
290
|
-
return (0, core_1.extensionsPattern)(this.resolvableExtensions());
|
|
291
|
-
}
|
|
292
|
-
impliedAssets(type, engine, emberENV) {
|
|
293
|
-
let result = this.impliedAddonAssets(type, engine).map((sourcePath) => {
|
|
294
|
-
let stats = (0, fs_extra_1.statSync)(sourcePath);
|
|
295
|
-
return {
|
|
296
|
-
kind: 'on-disk',
|
|
297
|
-
relativePath: (0, core_1.explicitRelative)(this.root, sourcePath),
|
|
298
|
-
sourcePath,
|
|
299
|
-
mtime: stats.mtimeMs,
|
|
300
|
-
size: stats.size,
|
|
301
|
-
};
|
|
302
|
-
});
|
|
303
|
-
if (type === 'implicit-scripts') {
|
|
304
|
-
result.unshift({
|
|
305
|
-
kind: 'in-memory',
|
|
306
|
-
relativePath: '_testing_prefix_.js',
|
|
307
|
-
source: `var runningTests=false;`,
|
|
308
|
-
});
|
|
309
|
-
result.unshift({
|
|
310
|
-
kind: 'in-memory',
|
|
311
|
-
relativePath: '_ember_env_.js',
|
|
312
|
-
source: `window.EmberENV={ ...(window.EmberENV || {}), ...${JSON.stringify(emberENV, null, 2)} };`,
|
|
313
|
-
});
|
|
314
|
-
result.push({
|
|
315
|
-
kind: 'in-memory',
|
|
316
|
-
relativePath: '_loader_.js',
|
|
317
|
-
source: `loader.makeDefaultExport=false;`,
|
|
318
|
-
});
|
|
319
|
-
}
|
|
320
|
-
if (type === 'implicit-test-scripts') {
|
|
321
|
-
// this is the traditional test-support-suffix.js
|
|
322
|
-
result.push({
|
|
323
|
-
kind: 'in-memory',
|
|
324
|
-
relativePath: '_testing_suffix_.js',
|
|
325
|
-
source: `
|
|
326
|
-
var runningTests=true;
|
|
327
|
-
if (typeof Testem !== 'undefined' && (typeof QUnit !== 'undefined' || typeof Mocha !== 'undefined')) {
|
|
328
|
-
Testem.hookIntoTestFramework();
|
|
329
|
-
}`,
|
|
330
|
-
});
|
|
331
|
-
// whether or not anybody was actually using @embroider/macros
|
|
332
|
-
// explicitly as an addon, we ensure its test-support file is always
|
|
333
|
-
// present.
|
|
334
|
-
if (!result.find(s => s.kind === 'on-disk' && s.sourcePath.endsWith('embroider-macros-test-support.js'))) {
|
|
335
|
-
result.unshift({
|
|
336
|
-
kind: 'on-disk',
|
|
337
|
-
sourcePath: require.resolve('@embroider/macros/src/vendor/embroider-macros-test-support'),
|
|
338
|
-
mtime: 0,
|
|
339
|
-
size: 0,
|
|
340
|
-
relativePath: 'embroider-macros-test-support.js',
|
|
341
|
-
});
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
return result;
|
|
345
|
-
}
|
|
346
|
-
impliedAddonAssets(type, { engine }) {
|
|
347
|
-
let result = [];
|
|
348
|
-
for (let addon of (0, sortBy_1.default)(Array.from(engine.addons), this.scriptPriority.bind(this))) {
|
|
349
|
-
let implicitScripts = addon.meta[type];
|
|
350
|
-
if (implicitScripts) {
|
|
351
|
-
let styles = [];
|
|
352
|
-
let options = { basedir: addon.root };
|
|
353
|
-
for (let mod of implicitScripts) {
|
|
354
|
-
if (type === 'implicit-styles') {
|
|
355
|
-
// exclude engines because they will handle their own css importation
|
|
356
|
-
if (!addon.isLazyEngine()) {
|
|
357
|
-
styles.push(resolve_2.default.sync(mod, options));
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
else {
|
|
361
|
-
result.push(resolve_2.default.sync(mod, options));
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
if (styles.length) {
|
|
365
|
-
result = [...styles, ...result];
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
return result;
|
|
370
|
-
}
|
|
371
|
-
babelConfig(resolverConfig) {
|
|
372
|
-
let babel = (0, cloneDeep_1.default)(this.compatApp.babelConfig());
|
|
373
|
-
if (!babel.plugins) {
|
|
374
|
-
babel.plugins = [];
|
|
375
|
-
}
|
|
376
|
-
// Our stage3 code is always allowed to use dynamic import. We may emit it
|
|
377
|
-
// ourself when splitting routes.
|
|
378
|
-
babel.plugins.push(require.resolve('@babel/plugin-syntax-dynamic-import'));
|
|
379
|
-
// https://github.com/webpack/webpack/issues/12154
|
|
380
|
-
babel.plugins.push(require.resolve('./rename-require-plugin'));
|
|
381
|
-
babel.plugins.push([require.resolve('babel-plugin-ember-template-compilation'), this.etcOptions(resolverConfig)]);
|
|
382
|
-
// this is @embroider/macros configured for full stage3 resolution
|
|
383
|
-
babel.plugins.push(...this.compatApp.macrosConfig.babelPluginConfig());
|
|
384
|
-
let colocationOptions = {
|
|
385
|
-
appRoot: this.origAppPackage.root,
|
|
386
|
-
// This extra weirdness is a compromise in favor of build performance.
|
|
387
|
-
//
|
|
388
|
-
// 1. When auto-upgrading an addon from v1 to v2, we definitely want to
|
|
389
|
-
// run any custom AST transforms in stage1.
|
|
390
|
-
//
|
|
391
|
-
// 2. In general case, AST transforms are allowed to manipulate Javascript
|
|
392
|
-
// scope. This means that running transforms -- even when we're doing
|
|
393
|
-
// source-to-source compilation that emits handlebars and not wire
|
|
394
|
-
// format -- implies changing .hbs files into .js files.
|
|
395
|
-
//
|
|
396
|
-
// 3. So stage1 may need to rewrite .hbs to .hbs.js (to avoid colliding
|
|
397
|
-
// with an existing co-located .js file).
|
|
398
|
-
//
|
|
399
|
-
// 4. But stage1 doesn't necessarily want to run babel over the
|
|
400
|
-
// corresponding JS file. Most of the time, that's just an
|
|
401
|
-
// unnecessarily expensive second parse. (We only run it in stage1 to
|
|
402
|
-
// eliminate an addon's custom babel plugins, and many addons don't
|
|
403
|
-
// have any.)
|
|
404
|
-
//
|
|
405
|
-
// 5. Therefore, the work of template-colocation gets defered until here,
|
|
406
|
-
// and it may see co-located templates named `.hbs.js` instead of the
|
|
407
|
-
// usual `.hbs.
|
|
408
|
-
templateExtensions: ['.hbs', '.hbs.js'],
|
|
409
|
-
// All of the above only applies to auto-upgraded packages that were
|
|
410
|
-
// authored in v1. V2 packages don't get any of this complexity, they're
|
|
411
|
-
// supposed to take care of colocating their own templates explicitly.
|
|
412
|
-
packageGuard: true,
|
|
413
|
-
};
|
|
414
|
-
babel.plugins.push([core_1.templateColocationPluginPath, colocationOptions]);
|
|
415
|
-
babel.plugins.push([
|
|
416
|
-
require.resolve('./babel-plugin-adjust-imports'),
|
|
417
|
-
(() => {
|
|
418
|
-
let pluginConfig = {
|
|
419
|
-
appRoot: resolverConfig.appRoot,
|
|
420
|
-
};
|
|
421
|
-
return pluginConfig;
|
|
422
|
-
})(),
|
|
423
|
-
]);
|
|
424
|
-
// we can use globally shared babel runtime by default
|
|
425
|
-
babel.plugins.push([
|
|
426
|
-
require.resolve('@babel/plugin-transform-runtime'),
|
|
427
|
-
{ absoluteRuntime: __dirname, useESModules: true, regenerator: false },
|
|
428
|
-
]);
|
|
429
|
-
const portable = (0, portable_babel_config_1.makePortable)(babel, { basedir: this.root }, this.portableHints);
|
|
430
|
-
addCachablePlugin(portable.config);
|
|
431
|
-
return portable;
|
|
432
|
-
}
|
|
433
|
-
insertEmberApp(asset, appFiles, prepared, emberENV) {
|
|
434
|
-
let html = asset.html;
|
|
435
|
-
if (this.fastbootConfig) {
|
|
436
|
-
// ignore scripts like ember-cli-livereload.js which are not really associated with
|
|
437
|
-
// "the app".
|
|
438
|
-
let ignoreScripts = html.dom.window.document.querySelectorAll('script');
|
|
439
|
-
ignoreScripts.forEach(script => {
|
|
440
|
-
script.setAttribute('data-fastboot-ignore', '');
|
|
441
|
-
});
|
|
442
|
-
}
|
|
443
|
-
// our tests entrypoint already includes a correct module dependency on the
|
|
444
|
-
// app, so we only insert the app when we're not inserting tests
|
|
445
|
-
if (!asset.fileAsset.includeTests) {
|
|
446
|
-
let appJS = this.topAppJSAsset(appFiles, prepared);
|
|
447
|
-
html.insertScriptTag(html.javascript, appJS.relativePath, { type: 'module' });
|
|
448
|
-
}
|
|
449
|
-
if (this.fastbootConfig) {
|
|
450
|
-
// any extra fastboot app files get inserted into our html.javascript
|
|
451
|
-
// section, after the app has been inserted.
|
|
452
|
-
for (let script of this.fastbootConfig.extraAppFiles) {
|
|
453
|
-
html.insertScriptTag(html.javascript, script, { tag: 'fastboot-script' });
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
html.insertStyleLink(html.styles, `assets/${this.origAppPackage.name}.css`);
|
|
457
|
-
const parentEngine = appFiles.find(e => !e.engine.parent);
|
|
458
|
-
let vendorJS = this.implicitScriptsAsset(prepared, parentEngine, emberENV);
|
|
459
|
-
if (vendorJS) {
|
|
460
|
-
html.insertScriptTag(html.implicitScripts, vendorJS.relativePath);
|
|
461
|
-
}
|
|
462
|
-
if (this.fastbootConfig) {
|
|
463
|
-
// any extra fastboot vendor files get inserted into our
|
|
464
|
-
// html.implicitScripts section, after the regular implicit script
|
|
465
|
-
// (vendor.js) have been inserted.
|
|
466
|
-
for (let script of this.fastbootConfig.extraVendorFiles) {
|
|
467
|
-
html.insertScriptTag(html.implicitScripts, script, { tag: 'fastboot-script' });
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
let implicitStyles = this.implicitStylesAsset(prepared, parentEngine);
|
|
471
|
-
if (implicitStyles) {
|
|
472
|
-
html.insertStyleLink(html.implicitStyles, implicitStyles.relativePath);
|
|
473
|
-
}
|
|
474
|
-
if (!asset.fileAsset.includeTests) {
|
|
475
|
-
return;
|
|
476
|
-
}
|
|
477
|
-
// Test-related assets happen below this point
|
|
478
|
-
let testJS = this.testJSEntrypoint(appFiles, prepared);
|
|
479
|
-
html.insertScriptTag(html.testJavascript, testJS.relativePath, { type: 'module' });
|
|
480
|
-
let implicitTestScriptsAsset = this.implicitTestScriptsAsset(prepared, parentEngine);
|
|
481
|
-
if (implicitTestScriptsAsset) {
|
|
482
|
-
html.insertScriptTag(html.implicitTestScripts, implicitTestScriptsAsset.relativePath);
|
|
483
|
-
}
|
|
484
|
-
let implicitTestStylesAsset = this.implicitTestStylesAsset(prepared, parentEngine);
|
|
485
|
-
if (implicitTestStylesAsset) {
|
|
486
|
-
html.insertStyleLink(html.implicitTestStyles, implicitTestStylesAsset.relativePath);
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
implicitScriptsAsset(prepared, application, emberENV) {
|
|
490
|
-
let asset = prepared.get('assets/vendor.js');
|
|
491
|
-
if (!asset) {
|
|
492
|
-
let implicitScripts = this.impliedAssets('implicit-scripts', application, emberENV);
|
|
493
|
-
if (implicitScripts.length > 0) {
|
|
494
|
-
asset = new ConcatenatedAsset('assets/vendor.js', implicitScripts, this.resolvableExtensionsPattern);
|
|
495
|
-
prepared.set(asset.relativePath, asset);
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
return asset;
|
|
499
|
-
}
|
|
500
|
-
implicitStylesAsset(prepared, application) {
|
|
501
|
-
let asset = prepared.get('assets/vendor.css');
|
|
502
|
-
if (!asset) {
|
|
503
|
-
let implicitStyles = this.impliedAssets('implicit-styles', application);
|
|
504
|
-
if (implicitStyles.length > 0) {
|
|
505
|
-
// we reverse because we want the synthetic vendor style at the top
|
|
506
|
-
asset = new ConcatenatedAsset('assets/vendor.css', implicitStyles.reverse(), this.resolvableExtensionsPattern);
|
|
507
|
-
prepared.set(asset.relativePath, asset);
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
|
-
return asset;
|
|
511
|
-
}
|
|
512
|
-
implicitTestScriptsAsset(prepared, application) {
|
|
513
|
-
let testSupportJS = prepared.get('assets/test-support.js');
|
|
514
|
-
if (!testSupportJS) {
|
|
515
|
-
let implicitTestScripts = this.impliedAssets('implicit-test-scripts', application);
|
|
516
|
-
if (implicitTestScripts.length > 0) {
|
|
517
|
-
testSupportJS = new ConcatenatedAsset('assets/test-support.js', implicitTestScripts, this.resolvableExtensionsPattern);
|
|
518
|
-
prepared.set(testSupportJS.relativePath, testSupportJS);
|
|
519
|
-
}
|
|
520
|
-
}
|
|
521
|
-
return testSupportJS;
|
|
522
|
-
}
|
|
523
|
-
implicitTestStylesAsset(prepared, application) {
|
|
524
|
-
let asset = prepared.get('assets/test-support.css');
|
|
525
|
-
if (!asset) {
|
|
526
|
-
let implicitTestStyles = this.impliedAssets('implicit-test-styles', application);
|
|
527
|
-
if (implicitTestStyles.length > 0) {
|
|
528
|
-
asset = new ConcatenatedAsset('assets/test-support.css', implicitTestStyles, this.resolvableExtensionsPattern);
|
|
529
|
-
prepared.set(asset.relativePath, asset);
|
|
530
|
-
}
|
|
531
|
-
}
|
|
532
|
-
return asset;
|
|
533
|
-
}
|
|
534
145
|
// recurse to find all active addons that don't cross an engine boundary.
|
|
535
146
|
// Inner engines themselves will be returned, but not those engines' children.
|
|
536
147
|
// The output set's insertion order is the proper ember-cli compatible
|
|
@@ -540,22 +151,22 @@ class CompatAppBuilder {
|
|
|
540
151
|
if (!child.isEngine()) {
|
|
541
152
|
this.findActiveAddons(child, engine, true);
|
|
542
153
|
}
|
|
543
|
-
|
|
154
|
+
let canResolveFrom = (0, path_1.resolve)(pkg.root, 'package.json');
|
|
155
|
+
engine.addons.set(child, canResolveFrom);
|
|
544
156
|
}
|
|
545
157
|
// ensure addons are applied in the correct order, if set (via @embroider/compat/v1-addon)
|
|
546
158
|
if (!isChild) {
|
|
547
|
-
engine.addons = new
|
|
159
|
+
engine.addons = new Map([...engine.addons].sort(([a], [b]) => {
|
|
548
160
|
return (a.meta['order-index'] || 0) - (b.meta['order-index'] || 0);
|
|
549
161
|
}));
|
|
550
162
|
}
|
|
551
163
|
}
|
|
552
|
-
partitionEngines(
|
|
164
|
+
partitionEngines() {
|
|
553
165
|
let queue = [
|
|
554
166
|
{
|
|
555
167
|
package: this.appPackageWithMovedDeps,
|
|
556
|
-
addons: new
|
|
557
|
-
|
|
558
|
-
sourcePath: appJSPath,
|
|
168
|
+
addons: new Map(),
|
|
169
|
+
isApp: true,
|
|
559
170
|
modulePrefix: this.modulePrefix(),
|
|
560
171
|
appRelativePath: '.',
|
|
561
172
|
},
|
|
@@ -568,16 +179,15 @@ class CompatAppBuilder {
|
|
|
568
179
|
break;
|
|
569
180
|
}
|
|
570
181
|
this.findActiveAddons(current.package, current);
|
|
571
|
-
for (let addon of current.addons) {
|
|
182
|
+
for (let addon of current.addons.keys()) {
|
|
572
183
|
if (addon.isEngine() && !seenEngines.has(addon)) {
|
|
573
184
|
seenEngines.add(addon);
|
|
574
185
|
queue.push({
|
|
575
186
|
package: addon,
|
|
576
|
-
addons: new
|
|
577
|
-
|
|
578
|
-
sourcePath: addon.root,
|
|
187
|
+
addons: new Map(),
|
|
188
|
+
isApp: !current,
|
|
579
189
|
modulePrefix: addon.name,
|
|
580
|
-
appRelativePath: (0, core_1.explicitRelative)(this.root, addon.root),
|
|
190
|
+
appRelativePath: (0, core_1.explicitRelative)(this.origAppPackage.root, addon.root),
|
|
581
191
|
});
|
|
582
192
|
}
|
|
583
193
|
}
|
|
@@ -585,9 +195,6 @@ class CompatAppBuilder {
|
|
|
585
195
|
}
|
|
586
196
|
return done;
|
|
587
197
|
}
|
|
588
|
-
get activeFastboot() {
|
|
589
|
-
return this.activeAddonChildren(this.appPackageWithMovedDeps).find(a => a.name === 'ember-cli-fastboot');
|
|
590
|
-
}
|
|
591
198
|
emberVersion() {
|
|
592
199
|
let pkg = this.activeAddonChildren(this.appPackageWithMovedDeps).find(a => a.name === 'ember-source');
|
|
593
200
|
if (!pkg) {
|
|
@@ -595,300 +202,21 @@ class CompatAppBuilder {
|
|
|
595
202
|
}
|
|
596
203
|
return pkg.version;
|
|
597
204
|
}
|
|
598
|
-
|
|
599
|
-
if (this.activeFastboot) {
|
|
600
|
-
// this is relying on work done in stage1 by @embroider/compat/src/compat-adapters/ember-cli-fastboot.ts
|
|
601
|
-
let packageJSON = (0, fs_extra_1.readJSONSync)((0, path_2.join)(this.activeFastboot.root, '_fastboot_', 'package.json'));
|
|
602
|
-
let { extraAppFiles, extraVendorFiles } = packageJSON['embroider-fastboot'];
|
|
603
|
-
delete packageJSON['embroider-fastboot'];
|
|
604
|
-
extraVendorFiles.push('assets/embroider_macros_fastboot_init.js');
|
|
605
|
-
return { packageJSON, extraAppFiles, extraVendorFiles };
|
|
606
|
-
}
|
|
607
|
-
}
|
|
608
|
-
updateAppJS(appJSPath) {
|
|
609
|
-
var _a;
|
|
610
|
-
if (!this.engines) {
|
|
611
|
-
this.engines = this.partitionEngines(appJSPath).map(engine => {
|
|
612
|
-
if (engine.sourcePath === appJSPath) {
|
|
613
|
-
// this is the app. We have more to do for the app than for other
|
|
614
|
-
// engines.
|
|
615
|
-
let fastbootSync;
|
|
616
|
-
if (this.activeFastboot) {
|
|
617
|
-
let fastbootDir = this.fastbootJSSrcDir();
|
|
618
|
-
if (fastbootDir) {
|
|
619
|
-
fastbootSync = new sync_dir_1.SyncDir(fastbootDir, (0, path_1.resolve)(this.root, '_fastboot_'));
|
|
620
|
-
}
|
|
621
|
-
}
|
|
622
|
-
return {
|
|
623
|
-
engine,
|
|
624
|
-
appSync: new sync_dir_1.SyncDir(appJSPath, this.root),
|
|
625
|
-
fastbootSync,
|
|
626
|
-
};
|
|
627
|
-
}
|
|
628
|
-
else {
|
|
629
|
-
// this is not the app, so it's some other engine. Engines are already
|
|
630
|
-
// built by stage1 like all other addons, so we only need to observe
|
|
631
|
-
// their files, not doing any actual copying or building.
|
|
632
|
-
return {
|
|
633
|
-
engine,
|
|
634
|
-
appSync: new sync_dir_1.SyncDir(engine.sourcePath, undefined),
|
|
635
|
-
// AFAIK, we've never supported a fastboot overlay directory in an
|
|
636
|
-
// engine. But if we do need that, it would go here.
|
|
637
|
-
fastbootSync: undefined,
|
|
638
|
-
};
|
|
639
|
-
}
|
|
640
|
-
});
|
|
641
|
-
}
|
|
642
|
-
for (let engine of this.engines) {
|
|
643
|
-
engine.appSync.update();
|
|
644
|
-
(_a = engine.fastbootSync) === null || _a === void 0 ? void 0 : _a.update();
|
|
645
|
-
}
|
|
646
|
-
return this.engines.map(({ engine, appSync, fastbootSync }) => {
|
|
647
|
-
var _a;
|
|
648
|
-
return new app_files_1.AppFiles(engine, appSync.files, (_a = fastbootSync === null || fastbootSync === void 0 ? void 0 : fastbootSync.files) !== null && _a !== void 0 ? _a : new Set(), this.resolvableExtensionsPattern, this.podModulePrefix());
|
|
649
|
-
});
|
|
650
|
-
}
|
|
651
|
-
prepareAsset(asset, appFiles, prepared, emberENV) {
|
|
652
|
-
if (asset.kind === 'ember') {
|
|
653
|
-
let prior = this.assets.get(asset.relativePath);
|
|
654
|
-
let parsed;
|
|
655
|
-
if (prior && prior.kind === 'built-ember' && prior.parsedAsset.validFor(asset)) {
|
|
656
|
-
// we can reuse the parsed html
|
|
657
|
-
parsed = prior.parsedAsset;
|
|
658
|
-
parsed.html.clear();
|
|
659
|
-
}
|
|
660
|
-
else {
|
|
661
|
-
parsed = new ParsedEmberAsset(asset);
|
|
662
|
-
}
|
|
663
|
-
this.insertEmberApp(parsed, appFiles, prepared, emberENV);
|
|
664
|
-
prepared.set(asset.relativePath, new BuiltEmberAsset(parsed));
|
|
665
|
-
}
|
|
666
|
-
else {
|
|
667
|
-
prepared.set(asset.relativePath, asset);
|
|
668
|
-
}
|
|
669
|
-
}
|
|
670
|
-
prepareAssets(requestedAssets, appFiles, emberENV) {
|
|
671
|
-
let prepared = new Map();
|
|
672
|
-
for (let asset of requestedAssets) {
|
|
673
|
-
this.prepareAsset(asset, appFiles, prepared, emberENV);
|
|
674
|
-
}
|
|
675
|
-
return prepared;
|
|
676
|
-
}
|
|
677
|
-
assetIsValid(asset, prior) {
|
|
678
|
-
if (!prior) {
|
|
679
|
-
return false;
|
|
680
|
-
}
|
|
681
|
-
switch (asset.kind) {
|
|
682
|
-
case 'on-disk':
|
|
683
|
-
return prior.kind === 'on-disk' && prior.size === asset.size && prior.mtime === asset.mtime;
|
|
684
|
-
case 'in-memory':
|
|
685
|
-
return prior.kind === 'in-memory' && stringOrBufferEqual(prior.source, asset.source);
|
|
686
|
-
case 'built-ember':
|
|
687
|
-
return prior.kind === 'built-ember' && prior.source === asset.source;
|
|
688
|
-
case 'concatenated-asset':
|
|
689
|
-
return (prior.kind === 'concatenated-asset' &&
|
|
690
|
-
prior.sources.length === asset.sources.length &&
|
|
691
|
-
prior.sources.every((priorFile, index) => {
|
|
692
|
-
let newFile = asset.sources[index];
|
|
693
|
-
return this.assetIsValid(newFile, priorFile);
|
|
694
|
-
}));
|
|
695
|
-
}
|
|
696
|
-
}
|
|
697
|
-
updateOnDiskAsset(asset) {
|
|
698
|
-
let destination = (0, path_2.join)(this.root, asset.relativePath);
|
|
699
|
-
(0, fs_extra_2.ensureDirSync)((0, path_2.dirname)(destination));
|
|
700
|
-
(0, fs_extra_2.copySync)(asset.sourcePath, destination, { dereference: true });
|
|
701
|
-
}
|
|
702
|
-
updateInMemoryAsset(asset) {
|
|
703
|
-
let destination = (0, path_2.join)(this.root, asset.relativePath);
|
|
704
|
-
(0, fs_extra_2.ensureDirSync)((0, path_2.dirname)(destination));
|
|
705
|
-
(0, fs_extra_1.writeFileSync)(destination, asset.source, 'utf8');
|
|
706
|
-
}
|
|
707
|
-
updateBuiltEmberAsset(asset) {
|
|
708
|
-
let destination = (0, path_2.join)(this.root, asset.relativePath);
|
|
709
|
-
(0, fs_extra_2.ensureDirSync)((0, path_2.dirname)(destination));
|
|
710
|
-
(0, fs_extra_1.writeFileSync)(destination, asset.source, 'utf8');
|
|
711
|
-
}
|
|
712
|
-
async updateConcatenatedAsset(asset) {
|
|
713
|
-
let concat = new fast_sourcemap_concat_1.default({
|
|
714
|
-
outputFile: (0, path_2.join)(this.root, asset.relativePath),
|
|
715
|
-
mapCommentType: asset.relativePath.endsWith('.js') ? 'line' : 'block',
|
|
716
|
-
baseDir: this.root,
|
|
717
|
-
});
|
|
718
|
-
if (process.env.EMBROIDER_CONCAT_STATS) {
|
|
719
|
-
let MeasureConcat = (await Promise.resolve().then(() => __importStar(require('@embroider/core/src/measure-concat')))).default;
|
|
720
|
-
concat = new MeasureConcat(asset.relativePath, concat, this.root);
|
|
721
|
-
}
|
|
722
|
-
for (let source of asset.sources) {
|
|
723
|
-
switch (source.kind) {
|
|
724
|
-
case 'on-disk':
|
|
725
|
-
concat.addFile((0, core_1.explicitRelative)(this.root, source.sourcePath));
|
|
726
|
-
break;
|
|
727
|
-
case 'in-memory':
|
|
728
|
-
if (typeof source.source !== 'string') {
|
|
729
|
-
throw new Error(`attempted to concatenated a Buffer-backed in-memory asset`);
|
|
730
|
-
}
|
|
731
|
-
concat.addSpace(source.source);
|
|
732
|
-
break;
|
|
733
|
-
default:
|
|
734
|
-
(0, assert_never_1.default)(source);
|
|
735
|
-
}
|
|
736
|
-
}
|
|
737
|
-
await concat.end();
|
|
738
|
-
}
|
|
739
|
-
async updateAssets(requestedAssets, appFiles, emberENV) {
|
|
740
|
-
let assets = this.prepareAssets(requestedAssets, appFiles, emberENV);
|
|
741
|
-
for (let asset of assets.values()) {
|
|
742
|
-
if (this.assetIsValid(asset, this.assets.get(asset.relativePath))) {
|
|
743
|
-
continue;
|
|
744
|
-
}
|
|
745
|
-
(0, core_1.debug)('rebuilding %s', asset.relativePath);
|
|
746
|
-
switch (asset.kind) {
|
|
747
|
-
case 'on-disk':
|
|
748
|
-
this.updateOnDiskAsset(asset);
|
|
749
|
-
break;
|
|
750
|
-
case 'in-memory':
|
|
751
|
-
this.updateInMemoryAsset(asset);
|
|
752
|
-
break;
|
|
753
|
-
case 'built-ember':
|
|
754
|
-
this.updateBuiltEmberAsset(asset);
|
|
755
|
-
break;
|
|
756
|
-
case 'concatenated-asset':
|
|
757
|
-
await this.updateConcatenatedAsset(asset);
|
|
758
|
-
break;
|
|
759
|
-
default:
|
|
760
|
-
(0, assert_never_1.default)(asset);
|
|
761
|
-
}
|
|
762
|
-
}
|
|
763
|
-
for (let oldAsset of this.assets.values()) {
|
|
764
|
-
if (!assets.has(oldAsset.relativePath)) {
|
|
765
|
-
(0, fs_extra_1.unlinkSync)((0, path_2.join)(this.root, oldAsset.relativePath));
|
|
766
|
-
}
|
|
767
|
-
}
|
|
768
|
-
this.assets = assets;
|
|
769
|
-
return [...assets.values()];
|
|
770
|
-
}
|
|
771
|
-
gatherAssets(inputPaths) {
|
|
772
|
-
// first gather all the assets out of addons
|
|
773
|
-
let assets = [];
|
|
774
|
-
for (let pkg of this.allActiveAddons) {
|
|
775
|
-
if (pkg.meta['public-assets']) {
|
|
776
|
-
for (let [filename, appRelativeURL] of Object.entries(pkg.meta['public-assets'] || {})) {
|
|
777
|
-
let sourcePath = (0, path_1.resolve)(pkg.root, filename);
|
|
778
|
-
let stats = (0, fs_extra_1.statSync)(sourcePath);
|
|
779
|
-
assets.push({
|
|
780
|
-
kind: 'on-disk',
|
|
781
|
-
sourcePath,
|
|
782
|
-
relativePath: appRelativeURL,
|
|
783
|
-
mtime: stats.mtimeMs,
|
|
784
|
-
size: stats.size,
|
|
785
|
-
});
|
|
786
|
-
}
|
|
787
|
-
}
|
|
788
|
-
}
|
|
789
|
-
if (this.activeFastboot) {
|
|
790
|
-
const source = `
|
|
791
|
-
(function(){
|
|
792
|
-
var key = '_embroider_macros_runtime_config';
|
|
793
|
-
if (!window[key]){ window[key] = [];}
|
|
794
|
-
window[key].push(function(m) {
|
|
795
|
-
m.setGlobalConfig('fastboot', Object.assign({}, m.getGlobalConfig().fastboot, { isRunning: true }));
|
|
796
|
-
});
|
|
797
|
-
}())`;
|
|
798
|
-
assets.push({
|
|
799
|
-
kind: 'in-memory',
|
|
800
|
-
source,
|
|
801
|
-
relativePath: 'assets/embroider_macros_fastboot_init.js',
|
|
802
|
-
});
|
|
803
|
-
}
|
|
804
|
-
// and finally tack on the ones from our app itself
|
|
805
|
-
return assets.concat(this.extractAssets(inputPaths));
|
|
806
|
-
}
|
|
807
|
-
async build(inputPaths) {
|
|
205
|
+
async build() {
|
|
808
206
|
// on the first build, we lock down the macros config. on subsequent builds,
|
|
809
207
|
// this doesn't do anything anyway because it's idempotent.
|
|
810
208
|
this.compatApp.macrosConfig.finalize();
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
(0, fs_extra_1.rmSync)(this.root, { recursive: true, force: true });
|
|
814
|
-
this.firstBuild = false;
|
|
815
|
-
}
|
|
816
|
-
let appFiles = this.updateAppJS(inputPaths.appJS);
|
|
817
|
-
let emberENV = this.configTree.readConfig().EmberENV;
|
|
818
|
-
let assets = this.gatherAssets(inputPaths);
|
|
819
|
-
let finalAssets = await this.updateAssets(assets, appFiles, emberENV);
|
|
820
|
-
let assetPaths = assets.map(asset => asset.relativePath);
|
|
821
|
-
if (this.activeFastboot) {
|
|
822
|
-
// when using fastboot, our own package.json needs to be in the output so fastboot can read it.
|
|
823
|
-
assetPaths.push('package.json');
|
|
824
|
-
}
|
|
825
|
-
for (let asset of finalAssets) {
|
|
826
|
-
// our concatenated assets all have map files that ride along. Here we're
|
|
827
|
-
// telling the final stage packager to be sure and serve the map files
|
|
828
|
-
// too.
|
|
829
|
-
if (asset.kind === 'concatenated-asset') {
|
|
830
|
-
assetPaths.push(asset.sourcemapPath);
|
|
831
|
-
}
|
|
209
|
+
if (!this.engines) {
|
|
210
|
+
this.engines = this.partitionEngines();
|
|
832
211
|
}
|
|
833
|
-
let
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
assets: assetPaths,
|
|
837
|
-
babel: {
|
|
838
|
-
filename: '_babel_config_.js',
|
|
839
|
-
isParallelSafe: true, // TODO
|
|
840
|
-
majorVersion: this.compatApp.babelMajorVersion(),
|
|
841
|
-
fileFilter: '_babel_filter_.js',
|
|
842
|
-
},
|
|
843
|
-
'root-url': this.rootURL(),
|
|
844
|
-
};
|
|
845
|
-
// all compat apps are auto-upgraded, there's no v2 app format here
|
|
846
|
-
meta['auto-upgraded'] = true;
|
|
847
|
-
let pkg = this.combinePackageJSON(meta);
|
|
848
|
-
(0, fs_extra_1.writeFileSync)((0, path_2.join)(this.root, 'package.json'), JSON.stringify(pkg, null, 2), 'utf8');
|
|
849
|
-
let resolverConfig = this.resolverConfig(appFiles);
|
|
212
|
+
let resolverConfig = this.resolverConfig(this.engines);
|
|
213
|
+
let config = this.configTree.readConfig();
|
|
214
|
+
let contentForConfig = this.contentForTree.readContents();
|
|
850
215
|
this.addResolverConfig(resolverConfig);
|
|
851
|
-
|
|
852
|
-
this.
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
let pkgLayers = [this.origAppPackage.packageJSON];
|
|
856
|
-
let fastbootConfig = this.fastbootConfig;
|
|
857
|
-
if (fastbootConfig) {
|
|
858
|
-
// fastboot-specific package.json output is allowed to add to our original package.json
|
|
859
|
-
pkgLayers.push(fastbootConfig.packageJSON);
|
|
860
|
-
}
|
|
861
|
-
// but our own new v2 app metadata takes precedence over both
|
|
862
|
-
pkgLayers.push({ keywords: ['ember-addon'], 'ember-addon': meta });
|
|
863
|
-
return combinePackageJSON(...pkgLayers);
|
|
864
|
-
}
|
|
865
|
-
etcOptions(resolverConfig) {
|
|
866
|
-
let transforms = this.compatApp.htmlbarsPlugins;
|
|
867
|
-
let { plugins: macroPlugins, setConfig } = node_1.MacrosConfig.transforms();
|
|
868
|
-
setConfig(this.compatApp.macrosConfig);
|
|
869
|
-
for (let macroPlugin of macroPlugins) {
|
|
870
|
-
transforms.push(macroPlugin);
|
|
871
|
-
}
|
|
872
|
-
if (this.options.staticComponents ||
|
|
873
|
-
this.options.staticHelpers ||
|
|
874
|
-
this.options.staticModifiers ||
|
|
875
|
-
globalThis.embroider_audit) {
|
|
876
|
-
let opts = {
|
|
877
|
-
appRoot: resolverConfig.appRoot,
|
|
878
|
-
emberVersion: this.emberVersion(),
|
|
879
|
-
};
|
|
880
|
-
transforms.push([require.resolve('./resolver-transform'), opts]);
|
|
881
|
-
}
|
|
882
|
-
let resolver = new core_1.Resolver(resolverConfig);
|
|
883
|
-
let resolution = resolver.nodeResolve('ember-source/vendor/ember/ember-template-compiler', (0, path_1.resolve)(this.root, 'package.json'));
|
|
884
|
-
if (resolution.type !== 'real') {
|
|
885
|
-
throw new Error(`bug: unable to resolve ember-template-compiler from ${this.root}`);
|
|
886
|
-
}
|
|
887
|
-
return {
|
|
888
|
-
transforms,
|
|
889
|
-
compilerPath: resolution.filename,
|
|
890
|
-
enableLegacyModules: ['ember-cli-htmlbars', 'ember-cli-htmlbars-inline-precompile', 'htmlbars-inline-precompile'],
|
|
891
|
-
};
|
|
216
|
+
this.addContentForConfig(contentForConfig);
|
|
217
|
+
this.addEmberEnvConfig(config.EmberENV);
|
|
218
|
+
this.outputAppBootError(config.modulePrefix, config.APP, contentForConfig);
|
|
219
|
+
this.addBabelCompat();
|
|
892
220
|
}
|
|
893
221
|
get portableHints() {
|
|
894
222
|
return this.options.pluginHints.map(hint => {
|
|
@@ -898,7 +226,7 @@ class CompatAppBuilder {
|
|
|
898
226
|
if (i < hint.resolve.length - 1) {
|
|
899
227
|
target = (0, path_2.join)(target, 'package.json');
|
|
900
228
|
}
|
|
901
|
-
cursor =
|
|
229
|
+
cursor = resolve_1.default.sync(target, { basedir: (0, path_2.dirname)(cursor) });
|
|
902
230
|
}
|
|
903
231
|
return {
|
|
904
232
|
requireFile: cursor,
|
|
@@ -907,250 +235,94 @@ class CompatAppBuilder {
|
|
|
907
235
|
};
|
|
908
236
|
});
|
|
909
237
|
}
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
238
|
+
addBabelCompat() {
|
|
239
|
+
let plugins = this.compatApp.extraBabelPlugins();
|
|
240
|
+
let templateTransforms = this.compatApp.htmlbarsPlugins;
|
|
241
|
+
let babelMacros = this.compatApp.macrosConfig.babelPluginConfig();
|
|
242
|
+
let { plugins: templateMacros, setConfig } = node_1.MacrosConfig.transforms();
|
|
243
|
+
setConfig(this.compatApp.macrosConfig);
|
|
244
|
+
let config = {
|
|
245
|
+
plugins,
|
|
246
|
+
templateTransforms,
|
|
247
|
+
babelMacros,
|
|
248
|
+
templateMacros: templateMacros,
|
|
249
|
+
};
|
|
250
|
+
let portableConfig = new portable_1.Portable({ hints: this.portableHints }).dehydrate(config);
|
|
251
|
+
if (!portableConfig.isParallelSafe) {
|
|
252
|
+
throw new Error(`non-serializble babel plugins or AST transforms found in your app`);
|
|
913
253
|
}
|
|
914
|
-
(0, fs_extra_1.writeFileSync)((0, path_2.join)(this.root, '
|
|
915
|
-
|
|
254
|
+
(0, fs_extra_1.writeFileSync)((0, path_2.join)((0, core_1.locateEmbroiderWorkingDir)(this.compatApp.root), '_babel_compat_.js'), `
|
|
255
|
+
const { Portable } = require('@embroider/core/src/portable');
|
|
256
|
+
module.exports = new Portable().hydrate(${JSON.stringify(portableConfig.value, null, 2)});
|
|
257
|
+
`, 'utf8');
|
|
916
258
|
}
|
|
917
259
|
addResolverConfig(config) {
|
|
918
260
|
(0, fs_extra_1.outputJSONSync)((0, path_2.join)((0, core_1.locateEmbroiderWorkingDir)(this.compatApp.root), 'resolver.json'), config, { spaces: 2 });
|
|
919
261
|
}
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
if (typeof pattern === 'string') {
|
|
924
|
-
return pattern === routeName;
|
|
925
|
-
}
|
|
926
|
-
else {
|
|
927
|
-
return pattern.test(routeName);
|
|
928
|
-
}
|
|
929
|
-
}));
|
|
930
|
-
}
|
|
931
|
-
splitRoute(routeName, files, addToParent, addLazyBundle) {
|
|
932
|
-
let shouldSplit = routeName && this.shouldSplitRoute(routeName);
|
|
933
|
-
let ownFiles = [];
|
|
934
|
-
let ownNames = new Set();
|
|
935
|
-
if (files.template) {
|
|
936
|
-
if (shouldSplit) {
|
|
937
|
-
ownFiles.push(files.template);
|
|
938
|
-
ownNames.add(routeName);
|
|
939
|
-
}
|
|
940
|
-
else {
|
|
941
|
-
addToParent(routeName, files.template);
|
|
942
|
-
}
|
|
943
|
-
}
|
|
944
|
-
if (files.controller) {
|
|
945
|
-
if (shouldSplit) {
|
|
946
|
-
ownFiles.push(files.controller);
|
|
947
|
-
ownNames.add(routeName);
|
|
948
|
-
}
|
|
949
|
-
else {
|
|
950
|
-
addToParent(routeName, files.controller);
|
|
951
|
-
}
|
|
952
|
-
}
|
|
953
|
-
if (files.route) {
|
|
954
|
-
if (shouldSplit) {
|
|
955
|
-
ownFiles.push(files.route);
|
|
956
|
-
ownNames.add(routeName);
|
|
957
|
-
}
|
|
958
|
-
else {
|
|
959
|
-
addToParent(routeName, files.route);
|
|
960
|
-
}
|
|
961
|
-
}
|
|
962
|
-
for (let [childName, childFiles] of files.children) {
|
|
963
|
-
this.splitRoute(`${routeName}.${childName}`, childFiles, (childRouteName, childFile) => {
|
|
964
|
-
// this is our child calling "addToParent"
|
|
965
|
-
if (shouldSplit) {
|
|
966
|
-
ownFiles.push(childFile);
|
|
967
|
-
ownNames.add(childRouteName);
|
|
968
|
-
}
|
|
969
|
-
else {
|
|
970
|
-
addToParent(childRouteName, childFile);
|
|
971
|
-
}
|
|
972
|
-
}, (routeNames, files) => {
|
|
973
|
-
addLazyBundle(routeNames, files);
|
|
974
|
-
});
|
|
975
|
-
}
|
|
976
|
-
if (ownFiles.length > 0) {
|
|
977
|
-
addLazyBundle([...ownNames], ownFiles);
|
|
978
|
-
}
|
|
979
|
-
}
|
|
980
|
-
topAppJSAsset(engines, prepared) {
|
|
981
|
-
let [app, ...childEngines] = engines;
|
|
982
|
-
let relativePath = `assets/${this.origAppPackage.name}.js`;
|
|
983
|
-
return this.appJSAsset(relativePath, app, childEngines, prepared, {
|
|
984
|
-
autoRun: this.compatApp.autoRun,
|
|
985
|
-
appBoot: !this.compatApp.autoRun ? this.compatApp.appBoot.readAppBoot() : '',
|
|
986
|
-
mainModule: (0, core_1.explicitRelative)((0, path_2.dirname)(relativePath), 'app'),
|
|
987
|
-
appConfig: this.configTree.readConfig().APP,
|
|
262
|
+
addContentForConfig(contentForConfig) {
|
|
263
|
+
(0, fs_extra_1.outputJSONSync)((0, path_2.join)((0, core_1.locateEmbroiderWorkingDir)(this.compatApp.root), 'content-for.json'), contentForConfig, {
|
|
264
|
+
spaces: 2,
|
|
988
265
|
});
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
}
|
|
1011
|
-
let eagerModules = [];
|
|
1012
|
-
let requiredAppFiles = [this.requiredOtherFiles(appFiles)];
|
|
1013
|
-
if (!this.options.staticComponents) {
|
|
1014
|
-
requiredAppFiles.push(appFiles.components);
|
|
1015
|
-
}
|
|
1016
|
-
if (!this.options.staticHelpers) {
|
|
1017
|
-
requiredAppFiles.push(appFiles.helpers);
|
|
1018
|
-
}
|
|
1019
|
-
if (!this.options.staticModifiers) {
|
|
1020
|
-
requiredAppFiles.push(appFiles.modifiers);
|
|
1021
|
-
}
|
|
1022
|
-
let styles = [];
|
|
1023
|
-
// only import styles from engines with a parent (this excludeds the parent application) as their styles
|
|
1024
|
-
// will be inserted via a direct <link> tag.
|
|
1025
|
-
if (appFiles.engine.parent && appFiles.engine.package.isLazyEngine()) {
|
|
1026
|
-
let implicitStyles = this.impliedAssets('implicit-styles', appFiles);
|
|
1027
|
-
for (let style of implicitStyles) {
|
|
1028
|
-
styles.push({
|
|
1029
|
-
path: (0, core_1.explicitRelative)('assets/_engine_', style.relativePath),
|
|
1030
|
-
});
|
|
1031
|
-
}
|
|
1032
|
-
let engineMeta = appFiles.engine.package.meta;
|
|
1033
|
-
if (engineMeta && engineMeta['implicit-styles']) {
|
|
1034
|
-
for (let style of engineMeta['implicit-styles']) {
|
|
1035
|
-
styles.push({
|
|
1036
|
-
path: (0, core_1.explicitRelative)((0, path_2.dirname)(relativePath), (0, path_2.join)(appFiles.engine.appRelativePath, style)),
|
|
1037
|
-
});
|
|
1038
|
-
}
|
|
1039
|
-
}
|
|
1040
|
-
}
|
|
1041
|
-
let lazyEngines = [];
|
|
1042
|
-
for (let childEngine of childEngines) {
|
|
1043
|
-
let asset = this.appJSAsset(`assets/_engine_/${encodeURIComponent(childEngine.engine.package.name)}.js`, childEngine, [], prepared);
|
|
1044
|
-
if (childEngine.engine.package.isLazyEngine()) {
|
|
1045
|
-
lazyEngines.push({
|
|
1046
|
-
names: [childEngine.engine.package.name],
|
|
1047
|
-
path: (0, core_1.explicitRelative)((0, path_2.dirname)(relativePath), asset.relativePath),
|
|
1048
|
-
});
|
|
1049
|
-
}
|
|
1050
|
-
else {
|
|
1051
|
-
eagerModules.push((0, core_1.explicitRelative)((0, path_2.dirname)(relativePath), asset.relativePath));
|
|
266
|
+
// In addition to outputting content-for.json, we also want to check if content-for 'config-module' has a custom content.
|
|
267
|
+
// If so, it means some classic addons used to provide this custom content, which is no longer supported.
|
|
268
|
+
// Developers can deactivate this check (and the subsequent warning) with useAddonConfigModule
|
|
269
|
+
if (this.compatApp.options.useAddonConfigModule) {
|
|
270
|
+
let modulePrefix = this.configTree.readConfig().modulePrefix;
|
|
271
|
+
// This is the default script provided by https://github.com/ember-cli/ember-cli/blob/master/lib/utilities/ember-app-utils.js#L84
|
|
272
|
+
// When storeConfigInMeta is true, this content is always present in the config-module key of content-for.json
|
|
273
|
+
const defaultConfigModule = `var prefix = '${modulePrefix}';\ntry {\n var metaName = prefix + '/config/environment';\n var rawConfig = document.querySelector('meta[name=\"' + metaName + '\"]').getAttribute('content');\n var config = JSON.parse(decodeURIComponent(rawConfig));\n\n var exports = { 'default': config };\n\n Object.defineProperty(exports, '__esModule', { value: true });\n\n return exports;\n}\ncatch(err) {\n throw new Error('Could not read config from meta tag with name \"' + metaName + '\".');\n}\n`.replace(/\s/g, '');
|
|
274
|
+
const configModule = contentForConfig['/index.html']['config-module'];
|
|
275
|
+
const diff = configModule.replace(/\s/g, '').replace(defaultConfigModule, '');
|
|
276
|
+
if (diff.length) {
|
|
277
|
+
throw new Error(`
|
|
278
|
+
Your app uses at least one classic addon that provides content-for 'config-module'. This is no longer supported.
|
|
279
|
+
With Embroider, you have full control over the config module, so classic addons no longer need to modify it under the hood.
|
|
280
|
+
The following code is included via content-for 'config-module':
|
|
281
|
+
|
|
282
|
+
${configModule}
|
|
283
|
+
|
|
284
|
+
1. If you want to keep the same behavior, add it to the app/environment.js.
|
|
285
|
+
2. Once app/environment.js has the content you need, remove the present error by setting "useAddonConfigModule" to false in the build options.
|
|
286
|
+
`);
|
|
1052
287
|
}
|
|
1053
288
|
}
|
|
1054
|
-
let lazyRoutes = [];
|
|
1055
|
-
for (let [routeName, routeFiles] of appFiles.routeFiles.children) {
|
|
1056
|
-
this.splitRoute(routeName, routeFiles, (_, filename) => {
|
|
1057
|
-
requiredAppFiles.push([filename]);
|
|
1058
|
-
}, (routeNames, files) => {
|
|
1059
|
-
let routeEntrypoint = `assets/_route_/${encodeURIComponent(routeNames[0])}.js`;
|
|
1060
|
-
if (!prepared.has(routeEntrypoint)) {
|
|
1061
|
-
prepared.set(routeEntrypoint, this.routeEntrypoint(appFiles, routeEntrypoint, files));
|
|
1062
|
-
}
|
|
1063
|
-
lazyRoutes.push({
|
|
1064
|
-
names: routeNames,
|
|
1065
|
-
path: this.importPaths(appFiles, routeEntrypoint).buildtime,
|
|
1066
|
-
});
|
|
1067
|
-
});
|
|
1068
|
-
}
|
|
1069
|
-
let [fastboot, nonFastboot] = (0, partition_1.default)(excludeDotFiles((0, flatten_1.default)(requiredAppFiles)), file => appFiles.isFastbootOnly.get(file));
|
|
1070
|
-
let amdModules = nonFastboot.map(file => this.importPaths(appFiles, file));
|
|
1071
|
-
let fastbootOnlyAmdModules = fastboot.map(file => this.importPaths(appFiles, file));
|
|
1072
|
-
// this is a backward-compatibility feature: addons can force inclusion of
|
|
1073
|
-
// modules.
|
|
1074
|
-
eagerModules.push('./-embroider-implicit-modules.js');
|
|
1075
|
-
let params = { amdModules, fastbootOnlyAmdModules, lazyRoutes, lazyEngines, eagerModules, styles };
|
|
1076
|
-
if (entryParams) {
|
|
1077
|
-
Object.assign(params, entryParams);
|
|
1078
|
-
}
|
|
1079
|
-
let source = entryTemplate(params);
|
|
1080
|
-
let asset = {
|
|
1081
|
-
kind: 'in-memory',
|
|
1082
|
-
source,
|
|
1083
|
-
relativePath,
|
|
1084
|
-
};
|
|
1085
|
-
prepared.set(relativePath, asset);
|
|
1086
|
-
return asset;
|
|
1087
|
-
}
|
|
1088
|
-
importPaths({ engine }, engineRelativePath) {
|
|
1089
|
-
let noHBS = engineRelativePath.replace(this.resolvableExtensionsPattern, '').replace(/\.hbs$/, '');
|
|
1090
|
-
return {
|
|
1091
|
-
runtime: `${engine.modulePrefix}/${noHBS}`,
|
|
1092
|
-
buildtime: path_1.posix.join(engine.package.name, engineRelativePath),
|
|
1093
|
-
};
|
|
1094
289
|
}
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
source: routeEntryTemplate({
|
|
1100
|
-
files: nonFastboot.map(f => this.importPaths(appFiles, f)),
|
|
1101
|
-
fastbootOnlyFiles: fastboot.map(f => this.importPaths(appFiles, f)),
|
|
1102
|
-
}),
|
|
1103
|
-
relativePath,
|
|
1104
|
-
};
|
|
1105
|
-
return asset;
|
|
290
|
+
addEmberEnvConfig(emberEnvConfig) {
|
|
291
|
+
(0, fs_extra_1.outputJSONSync)((0, path_2.join)((0, core_1.locateEmbroiderWorkingDir)(this.compatApp.root), 'ember-env.json'), emberEnvConfig, {
|
|
292
|
+
spaces: 2,
|
|
293
|
+
});
|
|
1106
294
|
}
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
295
|
+
// Classic addons providing custom content-for "app-boot" is no longer supported.
|
|
296
|
+
// The purpose of this error message is to help developers to move the classic addons code.
|
|
297
|
+
// Developers can deactivate it with useAddonAppBoot build option.
|
|
298
|
+
outputAppBootError(modulePrefix, appConfig, contentForConfig) {
|
|
299
|
+
if (!this.compatApp.options.useAddonAppBoot) {
|
|
300
|
+
return;
|
|
1111
301
|
}
|
|
1112
|
-
//
|
|
1113
|
-
//
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
302
|
+
// This is the default script provided by
|
|
303
|
+
// https://github.com/ember-cli/ember-cli/blob/master/lib/utilities/ember-app-utils.js#L103
|
|
304
|
+
const defaultAppBoot = `
|
|
305
|
+
if (!runningTests) {
|
|
306
|
+
require("${modulePrefix}/app")["default"].create(${JSON.stringify(appConfig || {})});
|
|
307
|
+
}
|
|
308
|
+
`.replace(/\s/g, '');
|
|
309
|
+
const appBoot = contentForConfig['/index.html']['app-boot'];
|
|
310
|
+
const diff = appBoot.replace(/\s/g, '').replace(defaultAppBoot, '');
|
|
311
|
+
if (diff.length) {
|
|
312
|
+
throw new Error(`
|
|
313
|
+
Your app uses at least one classic addon that provides content-for 'app-boot'. This is no longer supported.
|
|
314
|
+
With Embroider, you have full control over the app-boot script, so classic addons no longer need to modify it under the hood.
|
|
315
|
+
The following code is used for your app boot:
|
|
316
|
+
|
|
317
|
+
${appBoot}
|
|
318
|
+
|
|
319
|
+
1. If you want to keep the same behavior, copy and paste it to the app-boot script included in app/index.html.
|
|
320
|
+
2. Once app/index.html has the content you need, remove the present error by setting "useAddonAppBoot" to false in the build options.
|
|
321
|
+
`);
|
|
1132
322
|
}
|
|
1133
|
-
let source = entryTemplate({
|
|
1134
|
-
amdModules,
|
|
1135
|
-
eagerModules,
|
|
1136
|
-
testSuffix: true,
|
|
1137
|
-
});
|
|
1138
|
-
asset = {
|
|
1139
|
-
kind: 'in-memory',
|
|
1140
|
-
source,
|
|
1141
|
-
relativePath: myName,
|
|
1142
|
-
};
|
|
1143
|
-
prepared.set(asset.relativePath, asset);
|
|
1144
|
-
return asset;
|
|
1145
323
|
}
|
|
1146
324
|
}
|
|
1147
325
|
exports.CompatAppBuilder = CompatAppBuilder;
|
|
1148
|
-
__decorate([
|
|
1149
|
-
(0, typescript_memoize_1.Memoize)()
|
|
1150
|
-
], CompatAppBuilder.prototype, "fastbootJSSrcDir", null);
|
|
1151
|
-
__decorate([
|
|
1152
|
-
(0, typescript_memoize_1.Memoize)()
|
|
1153
|
-
], CompatAppBuilder.prototype, "findTestemAsset", null);
|
|
1154
326
|
__decorate([
|
|
1155
327
|
(0, typescript_memoize_1.Memoize)()
|
|
1156
328
|
], CompatAppBuilder.prototype, "allActiveAddons", null);
|
|
@@ -1163,24 +335,9 @@ __decorate([
|
|
|
1163
335
|
__decorate([
|
|
1164
336
|
(0, typescript_memoize_1.Memoize)()
|
|
1165
337
|
], CompatAppBuilder.prototype, "activeRules", null);
|
|
1166
|
-
__decorate([
|
|
1167
|
-
(0, typescript_memoize_1.Memoize)()
|
|
1168
|
-
], CompatAppBuilder.prototype, "resolvableExtensionsPattern", null);
|
|
1169
|
-
__decorate([
|
|
1170
|
-
(0, typescript_memoize_1.Memoize)()
|
|
1171
|
-
], CompatAppBuilder.prototype, "babelConfig", null);
|
|
1172
|
-
__decorate([
|
|
1173
|
-
(0, typescript_memoize_1.Memoize)()
|
|
1174
|
-
], CompatAppBuilder.prototype, "activeFastboot", null);
|
|
1175
|
-
__decorate([
|
|
1176
|
-
(0, typescript_memoize_1.Memoize)()
|
|
1177
|
-
], CompatAppBuilder.prototype, "fastbootConfig", null);
|
|
1178
338
|
__decorate([
|
|
1179
339
|
(0, typescript_memoize_1.Memoize)()
|
|
1180
340
|
], CompatAppBuilder.prototype, "portableHints", null);
|
|
1181
|
-
__decorate([
|
|
1182
|
-
(0, typescript_memoize_1.Memoize)()
|
|
1183
|
-
], CompatAppBuilder.prototype, "staticAppPathsPattern", null);
|
|
1184
341
|
function defaultAddonPackageRules() {
|
|
1185
342
|
return (0, fs_extra_2.readdirSync)((0, path_2.join)(__dirname, 'addon-dependency-rules'))
|
|
1186
343
|
.map(filename => {
|
|
@@ -1192,174 +349,4 @@ function defaultAddonPackageRules() {
|
|
|
1192
349
|
.filter(Boolean)
|
|
1193
350
|
.reduce((a, b) => a.concat(b), []);
|
|
1194
351
|
}
|
|
1195
|
-
const entryTemplate = (0, core_1.jsHandlebarsCompile)(`
|
|
1196
|
-
import { importSync as i, macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
1197
|
-
let w = window;
|
|
1198
|
-
let d = w.define;
|
|
1199
|
-
|
|
1200
|
-
{{#if styles}}
|
|
1201
|
-
if (macroCondition(!getGlobalConfig().fastboot?.isRunning)) {
|
|
1202
|
-
{{#each styles as |stylePath| ~}}
|
|
1203
|
-
i("{{js-string-escape stylePath.path}}");
|
|
1204
|
-
{{/each}}
|
|
1205
|
-
}
|
|
1206
|
-
{{/if}}
|
|
1207
|
-
|
|
1208
|
-
{{#each eagerModules as |eagerModule| ~}}
|
|
1209
|
-
i("{{js-string-escape eagerModule}}");
|
|
1210
|
-
{{/each}}
|
|
1211
|
-
|
|
1212
|
-
{{#each amdModules as |amdModule| ~}}
|
|
1213
|
-
d("{{js-string-escape amdModule.runtime}}", function(){ return i("{{js-string-escape amdModule.buildtime}}");});
|
|
1214
|
-
{{/each}}
|
|
1215
|
-
|
|
1216
|
-
{{#if fastbootOnlyAmdModules}}
|
|
1217
|
-
if (macroCondition(getGlobalConfig().fastboot?.isRunning)) {
|
|
1218
|
-
{{#each fastbootOnlyAmdModules as |amdModule| ~}}
|
|
1219
|
-
d("{{js-string-escape amdModule.runtime}}", function(){ return i("{{js-string-escape amdModule.buildtime}}");});
|
|
1220
|
-
{{/each}}
|
|
1221
|
-
}
|
|
1222
|
-
{{/if}}
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
{{#if lazyRoutes}}
|
|
1226
|
-
w._embroiderRouteBundles_ = [
|
|
1227
|
-
{{#each lazyRoutes as |route|}}
|
|
1228
|
-
{
|
|
1229
|
-
names: {{json-stringify route.names}},
|
|
1230
|
-
load: function() {
|
|
1231
|
-
return import("{{js-string-escape route.path}}");
|
|
1232
|
-
}
|
|
1233
|
-
},
|
|
1234
|
-
{{/each}}
|
|
1235
|
-
]
|
|
1236
|
-
{{/if}}
|
|
1237
|
-
|
|
1238
|
-
{{#if lazyEngines}}
|
|
1239
|
-
w._embroiderEngineBundles_ = [
|
|
1240
|
-
{{#each lazyEngines as |engine|}}
|
|
1241
|
-
{
|
|
1242
|
-
names: {{json-stringify engine.names}},
|
|
1243
|
-
load: function() {
|
|
1244
|
-
return import("{{js-string-escape engine.path}}");
|
|
1245
|
-
}
|
|
1246
|
-
},
|
|
1247
|
-
{{/each}}
|
|
1248
|
-
]
|
|
1249
|
-
{{/if}}
|
|
1250
|
-
|
|
1251
|
-
{{#if autoRun ~}}
|
|
1252
|
-
if (!runningTests) {
|
|
1253
|
-
i("{{js-string-escape mainModule}}").default.create({{json-stringify appConfig}});
|
|
1254
|
-
}
|
|
1255
|
-
{{else if appBoot ~}}
|
|
1256
|
-
{{ appBoot }}
|
|
1257
|
-
{{/if}}
|
|
1258
|
-
|
|
1259
|
-
{{#if testSuffix ~}}
|
|
1260
|
-
{{!- TODO: both of these suffixes should get dynamically generated so they incorporate
|
|
1261
|
-
any content-for added by addons. -}}
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
{{!- this is the traditional tests-suffix.js -}}
|
|
1265
|
-
i('../tests/test-helper');
|
|
1266
|
-
EmberENV.TESTS_FILE_LOADED = true;
|
|
1267
|
-
{{/if}}
|
|
1268
|
-
`);
|
|
1269
|
-
const routeEntryTemplate = (0, core_1.jsHandlebarsCompile)(`
|
|
1270
|
-
import { importSync as i } from '@embroider/macros';
|
|
1271
|
-
let d = window.define;
|
|
1272
|
-
{{#each files as |amdModule| ~}}
|
|
1273
|
-
d("{{js-string-escape amdModule.runtime}}", function(){ return i("{{js-string-escape amdModule.buildtime}}");});
|
|
1274
|
-
{{/each}}
|
|
1275
|
-
{{#if fastbootOnlyFiles}}
|
|
1276
|
-
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
1277
|
-
if (macroCondition(getGlobalConfig().fastboot?.isRunning)) {
|
|
1278
|
-
{{#each fastbootOnlyFiles as |amdModule| ~}}
|
|
1279
|
-
d("{{js-string-escape amdModule.runtime}}", function(){ return i("{{js-string-escape amdModule.buildtime}}");});
|
|
1280
|
-
{{/each}}
|
|
1281
|
-
}
|
|
1282
|
-
{{/if}}
|
|
1283
|
-
`);
|
|
1284
|
-
function stringOrBufferEqual(a, b) {
|
|
1285
|
-
if (typeof a === 'string' && typeof b === 'string') {
|
|
1286
|
-
return a === b;
|
|
1287
|
-
}
|
|
1288
|
-
if (a instanceof Buffer && b instanceof Buffer) {
|
|
1289
|
-
return Buffer.compare(a, b) === 0;
|
|
1290
|
-
}
|
|
1291
|
-
return false;
|
|
1292
|
-
}
|
|
1293
|
-
const babelFilterTemplate = (0, core_1.jsHandlebarsCompile)(`
|
|
1294
|
-
const { babelFilter } = require(${JSON.stringify(require.resolve('@embroider/core'))});
|
|
1295
|
-
module.exports = babelFilter({{json-stringify skipBabel}}, "{{js-string-escape appRoot}}");
|
|
1296
|
-
`);
|
|
1297
|
-
function combinePackageJSON(...layers) {
|
|
1298
|
-
function custom(objValue, srcValue, key, _object, _source, stack) {
|
|
1299
|
-
if (key === 'keywords' && stack.size === 0) {
|
|
1300
|
-
if (Array.isArray(objValue)) {
|
|
1301
|
-
return objValue.concat(srcValue);
|
|
1302
|
-
}
|
|
1303
|
-
}
|
|
1304
|
-
}
|
|
1305
|
-
return (0, mergeWith_1.default)({}, ...layers, custom);
|
|
1306
|
-
}
|
|
1307
|
-
function addCachablePlugin(babelConfig) {
|
|
1308
|
-
if (Array.isArray(babelConfig.plugins) && babelConfig.plugins.length > 0) {
|
|
1309
|
-
const plugins = Object.create(null);
|
|
1310
|
-
plugins[core_1.cacheBustingPluginPath] = core_1.cacheBustingPluginVersion;
|
|
1311
|
-
for (const plugin of babelConfig.plugins) {
|
|
1312
|
-
let absolutePathToPlugin;
|
|
1313
|
-
if (Array.isArray(plugin) && typeof plugin[0] === 'string') {
|
|
1314
|
-
absolutePathToPlugin = plugin[0];
|
|
1315
|
-
}
|
|
1316
|
-
else if (typeof plugin === 'string') {
|
|
1317
|
-
absolutePathToPlugin = plugin;
|
|
1318
|
-
}
|
|
1319
|
-
else {
|
|
1320
|
-
throw new Error(`[Embroider] a babel plugin without an absolute path was from: ${plugin}`);
|
|
1321
|
-
}
|
|
1322
|
-
plugins[absolutePathToPlugin] = (0, portable_1.maybeNodeModuleVersion)(absolutePathToPlugin);
|
|
1323
|
-
}
|
|
1324
|
-
babelConfig.plugins.push([
|
|
1325
|
-
core_1.cacheBustingPluginPath,
|
|
1326
|
-
{
|
|
1327
|
-
plugins,
|
|
1328
|
-
},
|
|
1329
|
-
]);
|
|
1330
|
-
}
|
|
1331
|
-
}
|
|
1332
|
-
function excludeDotFiles(files) {
|
|
1333
|
-
return files.filter(file => !file.startsWith('.') && !file.includes('/.'));
|
|
1334
|
-
}
|
|
1335
|
-
class ParsedEmberAsset {
|
|
1336
|
-
constructor(asset) {
|
|
1337
|
-
this.kind = 'parsed-ember';
|
|
1338
|
-
this.fileAsset = asset;
|
|
1339
|
-
this.html = new ember_html_1.PreparedEmberHTML(asset);
|
|
1340
|
-
this.relativePath = asset.relativePath;
|
|
1341
|
-
}
|
|
1342
|
-
validFor(other) {
|
|
1343
|
-
return this.fileAsset.mtime === other.mtime && this.fileAsset.size === other.size;
|
|
1344
|
-
}
|
|
1345
|
-
}
|
|
1346
|
-
class BuiltEmberAsset {
|
|
1347
|
-
constructor(asset) {
|
|
1348
|
-
this.kind = 'built-ember';
|
|
1349
|
-
this.parsedAsset = asset;
|
|
1350
|
-
this.source = asset.html.dom.serialize();
|
|
1351
|
-
this.relativePath = asset.relativePath;
|
|
1352
|
-
}
|
|
1353
|
-
}
|
|
1354
|
-
class ConcatenatedAsset {
|
|
1355
|
-
constructor(relativePath, sources, resolvableExtensions) {
|
|
1356
|
-
this.relativePath = relativePath;
|
|
1357
|
-
this.sources = sources;
|
|
1358
|
-
this.resolvableExtensions = resolvableExtensions;
|
|
1359
|
-
this.kind = 'concatenated-asset';
|
|
1360
|
-
}
|
|
1361
|
-
get sourcemapPath() {
|
|
1362
|
-
return this.relativePath.replace(this.resolvableExtensions, '') + '.map';
|
|
1363
|
-
}
|
|
1364
|
-
}
|
|
1365
352
|
//# sourceMappingURL=compat-app-builder.js.map
|