@embroider/compat 3.6.2-unstable.a691d39 → 3.6.2-unstable.f7656a3
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 +8 -6
- package/src/audit.js +13 -16
- package/src/audit.js.map +1 -1
- package/src/babel-plugin-adjust-imports.js +17 -16
- package/src/babel-plugin-adjust-imports.js.map +1 -1
- package/src/babel.d.ts +19 -0
- package/src/babel.js +153 -0
- package/src/babel.js.map +1 -0
- package/src/compat-app-builder.d.ts +2 -15
- package/src/compat-app-builder.js +49 -320
- package/src/compat-app-builder.js.map +1 -1
- package/src/compat-app.d.ts +2 -2
- package/src/compat-app.js +19 -46
- package/src/compat-app.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/resolver-transform.js +2 -2
- package/src/resolver-transform.js.map +1 -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
|
@@ -11,19 +11,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.CompatAppBuilder = void 0;
|
|
13
13
|
const core_1 = require("@embroider/core");
|
|
14
|
-
const path_1 = require("path");
|
|
15
14
|
const dependency_rules_1 = require("./dependency-rules");
|
|
16
|
-
const flatMap_1 = __importDefault(require("lodash/flatMap"));
|
|
17
|
-
const cloneDeep_1 = __importDefault(require("lodash/cloneDeep"));
|
|
18
|
-
const bind_decorator_1 = __importDefault(require("bind-decorator"));
|
|
19
15
|
const fs_extra_1 = require("fs-extra");
|
|
20
|
-
const portable_babel_config_1 = require("@embroider/core/src/portable-babel-config");
|
|
21
16
|
const portable_1 = require("@embroider/core/src/portable");
|
|
22
17
|
const typescript_memoize_1 = require("typescript-memoize");
|
|
23
|
-
const
|
|
18
|
+
const path_1 = require("path");
|
|
24
19
|
const resolve_1 = __importDefault(require("resolve"));
|
|
25
20
|
const fs_extra_2 = require("fs-extra");
|
|
26
21
|
const node_1 = require("@embroider/macros/src/node");
|
|
22
|
+
const module_resolver_options_1 = require("@embroider/core/src/module-resolver-options");
|
|
27
23
|
// This exists during the actual broccoli build step. As opposed to CompatApp,
|
|
28
24
|
// which also exists during pipeline-construction time.
|
|
29
25
|
class CompatAppBuilder {
|
|
@@ -37,292 +33,57 @@ class CompatAppBuilder {
|
|
|
37
33
|
this.synthVendor = synthVendor;
|
|
38
34
|
this.synthStyles = synthStyles;
|
|
39
35
|
}
|
|
40
|
-
activeAddonChildren(pkg) {
|
|
41
|
-
let result = pkg.dependencies.filter(this.isActiveAddon).filter(
|
|
42
|
-
// When looking for child addons, we want to ignore 'peerDependencies' of
|
|
43
|
-
// a given package, to align with how ember-cli resolves addons. So here
|
|
44
|
-
// we only include dependencies that are definitely active due to one of
|
|
45
|
-
// the other sections.
|
|
46
|
-
addon => pkg.categorizeDependency(addon.name) !== 'peerDependencies');
|
|
47
|
-
if (pkg === this.appPackageWithMovedDeps) {
|
|
48
|
-
let extras = [this.synthVendor, this.synthStyles].filter(this.isActiveAddon);
|
|
49
|
-
result = [...result, ...extras];
|
|
50
|
-
}
|
|
51
|
-
return result.sort(this.orderAddons);
|
|
52
|
-
}
|
|
53
|
-
get allActiveAddons() {
|
|
54
|
-
let result = this.appPackageWithMovedDeps.findDescendants(this.isActiveAddon);
|
|
55
|
-
let extras = [this.synthVendor, this.synthStyles].filter(this.isActiveAddon);
|
|
56
|
-
let extraDescendants = (0, flatMap_1.default)(extras, dep => dep.findDescendants(this.isActiveAddon));
|
|
57
|
-
result = [...result, ...extras, ...extraDescendants];
|
|
58
|
-
return result.sort(this.orderAddons);
|
|
59
|
-
}
|
|
60
|
-
isActiveAddon(pkg) {
|
|
61
|
-
// stage1 already took care of converting everything that's actually active
|
|
62
|
-
// into v2 addons. If it's not a v2 addon, we don't want it.
|
|
63
|
-
//
|
|
64
|
-
// We can encounter v1 addons here when there is inactive stuff floating
|
|
65
|
-
// around in the node_modules that accidentally satisfy something like an
|
|
66
|
-
// optional peer dep.
|
|
67
|
-
return pkg.isV2Addon();
|
|
68
|
-
}
|
|
69
|
-
orderAddons(depA, depB) {
|
|
70
|
-
let depAIdx = 0;
|
|
71
|
-
let depBIdx = 0;
|
|
72
|
-
if (depA && depA.meta && depA.isV2Addon()) {
|
|
73
|
-
depAIdx = depA.meta['order-index'] || 0;
|
|
74
|
-
}
|
|
75
|
-
if (depB && depB.meta && depB.isV2Addon()) {
|
|
76
|
-
depBIdx = depB.meta['order-index'] || 0;
|
|
77
|
-
}
|
|
78
|
-
return depAIdx - depBIdx;
|
|
79
|
-
}
|
|
80
|
-
resolvableExtensions() {
|
|
81
|
-
let fromEnv = process.env.EMBROIDER_RESOLVABLE_EXTENSIONS;
|
|
82
|
-
if (fromEnv) {
|
|
83
|
-
return fromEnv.split(',');
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
return ['.mjs', '.gjs', '.js', '.mts', '.gts', '.ts', '.hbs', '.hbs.js', '.json'];
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
36
|
modulePrefix() {
|
|
90
37
|
return this.configTree.readConfig().modulePrefix;
|
|
91
38
|
}
|
|
92
39
|
podModulePrefix() {
|
|
93
40
|
return this.configTree.readConfig().podModulePrefix;
|
|
94
41
|
}
|
|
95
|
-
|
|
96
|
-
return (0,
|
|
97
|
-
|
|
98
|
-
...this.allActiveAddons.filter(p => p.meta['auto-upgraded']),
|
|
99
|
-
]);
|
|
100
|
-
}
|
|
101
|
-
resolverConfig(engines) {
|
|
102
|
-
let renamePackages = Object.assign({}, ...this.allActiveAddons.map(dep => dep.meta['renamed-packages']));
|
|
103
|
-
let renameModules = Object.assign({}, ...this.allActiveAddons.map(dep => dep.meta['renamed-modules']));
|
|
104
|
-
let options = {
|
|
105
|
-
staticHelpers: this.options.staticHelpers,
|
|
106
|
-
staticModifiers: this.options.staticModifiers,
|
|
107
|
-
staticComponents: this.options.staticComponents,
|
|
108
|
-
allowUnsafeDynamicComponents: this.options.allowUnsafeDynamicComponents,
|
|
109
|
-
};
|
|
110
|
-
let config = {
|
|
111
|
-
// this part is the base ModuleResolverOptions as required by @embroider/core
|
|
112
|
-
renameModules,
|
|
113
|
-
renamePackages,
|
|
114
|
-
resolvableExtensions: this.resolvableExtensions(),
|
|
115
|
-
appRoot: this.origAppPackage.root,
|
|
116
|
-
engines: engines.map(engine => ({
|
|
117
|
-
packageName: engine.package.name,
|
|
118
|
-
// we need to use the real path here because webpack requests always use the real path i.e. follow symlinks
|
|
119
|
-
root: (0, fs_extra_1.realpathSync)(engine.package.root),
|
|
120
|
-
fastbootFiles: {},
|
|
121
|
-
activeAddons: [...engine.addons]
|
|
122
|
-
.map(([addon, canResolveFromFile]) => ({
|
|
123
|
-
name: addon.name,
|
|
124
|
-
root: addon.root,
|
|
125
|
-
canResolveFromFile,
|
|
126
|
-
}))
|
|
127
|
-
// the traditional order is the order in which addons will run, such
|
|
128
|
-
// that the last one wins. Our resolver's order is the order to
|
|
129
|
-
// search, so first one wins.
|
|
130
|
-
.reverse(),
|
|
131
|
-
isLazy: engine.package.isLazyEngine(),
|
|
132
|
-
})),
|
|
133
|
-
amdCompatibility: this.options.amdCompatibility,
|
|
134
|
-
// this is the additional stufff that @embroider/compat adds on top to do
|
|
135
|
-
// global template resolving
|
|
42
|
+
get resolverConfig() {
|
|
43
|
+
return (0, module_resolver_options_1.buildResolverOptions)({
|
|
44
|
+
appPackage: this.appPackageWithMovedDeps,
|
|
136
45
|
modulePrefix: this.modulePrefix(),
|
|
137
|
-
splitAtRoutes: this.options.splitAtRoutes,
|
|
138
46
|
podModulePrefix: this.podModulePrefix(),
|
|
139
|
-
|
|
140
|
-
options,
|
|
141
|
-
autoRun: this.compatApp.autoRun,
|
|
47
|
+
splitAtRoutes: this.options.splitAtRoutes,
|
|
142
48
|
staticAppPaths: this.options.staticAppPaths,
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
// https://github.com/webpack/webpack/issues/12154
|
|
155
|
-
babel.plugins.push(require.resolve('./rename-require-plugin'));
|
|
156
|
-
babel.plugins.push([
|
|
157
|
-
require.resolve('babel-plugin-ember-template-compilation'),
|
|
158
|
-
await this.etcOptions(resolverConfig),
|
|
159
|
-
]);
|
|
160
|
-
// this is @embroider/macros configured for full stage3 resolution
|
|
161
|
-
babel.plugins.push(...this.compatApp.macrosConfig.babelPluginConfig());
|
|
162
|
-
let colocationOptions = {
|
|
163
|
-
appRoot: this.origAppPackage.root,
|
|
164
|
-
// This extra weirdness is a compromise in favor of build performance.
|
|
165
|
-
//
|
|
166
|
-
// 1. When auto-upgrading an addon from v1 to v2, we definitely want to
|
|
167
|
-
// run any custom AST transforms in stage1.
|
|
168
|
-
//
|
|
169
|
-
// 2. In general case, AST transforms are allowed to manipulate Javascript
|
|
170
|
-
// scope. This means that running transforms -- even when we're doing
|
|
171
|
-
// source-to-source compilation that emits handlebars and not wire
|
|
172
|
-
// format -- implies changing .hbs files into .js files.
|
|
173
|
-
//
|
|
174
|
-
// 3. So stage1 may need to rewrite .hbs to .hbs.js (to avoid colliding
|
|
175
|
-
// with an existing co-located .js file).
|
|
176
|
-
//
|
|
177
|
-
// 4. But stage1 doesn't necessarily want to run babel over the
|
|
178
|
-
// corresponding JS file. Most of the time, that's just an
|
|
179
|
-
// unnecessarily expensive second parse. (We only run it in stage1 to
|
|
180
|
-
// eliminate an addon's custom babel plugins, and many addons don't
|
|
181
|
-
// have any.)
|
|
182
|
-
//
|
|
183
|
-
// 5. Therefore, the work of template-colocation gets defered until here,
|
|
184
|
-
// and it may see co-located templates named `.hbs.js` instead of the
|
|
185
|
-
// usual `.hbs.
|
|
186
|
-
templateExtensions: ['.hbs', '.hbs.js'],
|
|
187
|
-
// All of the above only applies to auto-upgraded packages that were
|
|
188
|
-
// authored in v1. V2 packages don't get any of this complexity, they're
|
|
189
|
-
// supposed to take care of colocating their own templates explicitly.
|
|
190
|
-
packageGuard: true,
|
|
191
|
-
};
|
|
192
|
-
babel.plugins.push([core_1.templateColocationPluginPath, colocationOptions]);
|
|
193
|
-
babel.plugins.push([
|
|
194
|
-
require.resolve('./babel-plugin-adjust-imports'),
|
|
195
|
-
(() => {
|
|
196
|
-
let pluginConfig = {
|
|
197
|
-
appRoot: resolverConfig.appRoot,
|
|
49
|
+
extraDeps: new Map([[this.appPackageWithMovedDeps.root, [this.synthVendor, this.synthStyles]]]),
|
|
50
|
+
extend: (options, allActiveAddons) => {
|
|
51
|
+
options.activePackageRules = (0, dependency_rules_1.activePackageRules)(this.options.packageRules.concat(defaultAddonPackageRules()), [
|
|
52
|
+
{ name: this.origAppPackage.name, version: this.origAppPackage.version, root: this.origAppPackage.root },
|
|
53
|
+
...allActiveAddons.filter(p => p.meta['auto-upgraded']),
|
|
54
|
+
]);
|
|
55
|
+
options.options = {
|
|
56
|
+
staticHelpers: this.options.staticHelpers,
|
|
57
|
+
staticModifiers: this.options.staticModifiers,
|
|
58
|
+
staticComponents: this.options.staticComponents,
|
|
59
|
+
allowUnsafeDynamicComponents: this.options.allowUnsafeDynamicComponents,
|
|
198
60
|
};
|
|
199
|
-
return
|
|
200
|
-
})(),
|
|
201
|
-
]);
|
|
202
|
-
// we can use globally shared babel runtime by default
|
|
203
|
-
babel.plugins.push([
|
|
204
|
-
require.resolve('@babel/plugin-transform-runtime'),
|
|
205
|
-
{ absoluteRuntime: __dirname, useESModules: true, regenerator: false },
|
|
206
|
-
]);
|
|
207
|
-
const portable = (0, portable_babel_config_1.makePortable)(babel, { basedir: this.origAppPackage.root }, this.portableHints);
|
|
208
|
-
addCachablePlugin(portable.config);
|
|
209
|
-
return portable;
|
|
210
|
-
}
|
|
211
|
-
// recurse to find all active addons that don't cross an engine boundary.
|
|
212
|
-
// Inner engines themselves will be returned, but not those engines' children.
|
|
213
|
-
// The output set's insertion order is the proper ember-cli compatible
|
|
214
|
-
// ordering of the addons.
|
|
215
|
-
findActiveAddons(pkg, engine, isChild = false) {
|
|
216
|
-
for (let child of this.activeAddonChildren(pkg)) {
|
|
217
|
-
if (!child.isEngine()) {
|
|
218
|
-
this.findActiveAddons(child, engine, true);
|
|
219
|
-
}
|
|
220
|
-
let canResolveFrom = (0, path_1.resolve)(pkg.root, 'package.json');
|
|
221
|
-
engine.addons.set(child, canResolveFrom);
|
|
222
|
-
}
|
|
223
|
-
// ensure addons are applied in the correct order, if set (via @embroider/compat/v1-addon)
|
|
224
|
-
if (!isChild) {
|
|
225
|
-
engine.addons = new Map([...engine.addons].sort(([a], [b]) => {
|
|
226
|
-
return (a.meta['order-index'] || 0) - (b.meta['order-index'] || 0);
|
|
227
|
-
}));
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
partitionEngines() {
|
|
231
|
-
let queue = [
|
|
232
|
-
{
|
|
233
|
-
package: this.appPackageWithMovedDeps,
|
|
234
|
-
addons: new Map(),
|
|
235
|
-
isApp: true,
|
|
236
|
-
modulePrefix: this.modulePrefix(),
|
|
237
|
-
appRelativePath: '.',
|
|
61
|
+
return options;
|
|
238
62
|
},
|
|
239
|
-
|
|
240
|
-
let done = [];
|
|
241
|
-
let seenEngines = new Set();
|
|
242
|
-
while (true) {
|
|
243
|
-
let current = queue.shift();
|
|
244
|
-
if (!current) {
|
|
245
|
-
break;
|
|
246
|
-
}
|
|
247
|
-
this.findActiveAddons(current.package, current);
|
|
248
|
-
for (let addon of current.addons.keys()) {
|
|
249
|
-
if (addon.isEngine() && !seenEngines.has(addon)) {
|
|
250
|
-
seenEngines.add(addon);
|
|
251
|
-
queue.push({
|
|
252
|
-
package: addon,
|
|
253
|
-
addons: new Map(),
|
|
254
|
-
isApp: !current,
|
|
255
|
-
modulePrefix: addon.name,
|
|
256
|
-
appRelativePath: (0, core_1.explicitRelative)(this.origAppPackage.root, addon.root),
|
|
257
|
-
});
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
done.push(current);
|
|
261
|
-
}
|
|
262
|
-
return done;
|
|
263
|
-
}
|
|
264
|
-
emberVersion() {
|
|
265
|
-
let pkg = this.activeAddonChildren(this.appPackageWithMovedDeps).find(a => a.name === 'ember-source');
|
|
266
|
-
if (!pkg) {
|
|
267
|
-
throw new Error('no ember version!');
|
|
268
|
-
}
|
|
269
|
-
return pkg.version;
|
|
63
|
+
});
|
|
270
64
|
}
|
|
271
65
|
async build() {
|
|
272
66
|
// on the first build, we lock down the macros config. on subsequent builds,
|
|
273
67
|
// this doesn't do anything anyway because it's idempotent.
|
|
274
68
|
this.compatApp.macrosConfig.finalize();
|
|
275
|
-
|
|
276
|
-
this.engines = this.partitionEngines();
|
|
277
|
-
}
|
|
278
|
-
let resolverConfig = this.resolverConfig(this.engines);
|
|
69
|
+
let resolverConfig = this.resolverConfig;
|
|
279
70
|
let config = this.configTree.readConfig();
|
|
280
71
|
let contentForConfig = this.contentForTree.readContents();
|
|
281
72
|
this.addResolverConfig(resolverConfig);
|
|
282
73
|
this.addContentForConfig(contentForConfig);
|
|
283
74
|
this.addEmberEnvConfig(config.EmberENV);
|
|
284
75
|
this.outputAppBootError(config.modulePrefix, config.APP, contentForConfig);
|
|
285
|
-
|
|
286
|
-
this.addBabelConfig(babelConfig);
|
|
287
|
-
this.addMacrosConfig(this.compatApp.macrosConfig.babelPluginConfig()[0]);
|
|
288
|
-
}
|
|
289
|
-
async etcOptions(resolverConfig) {
|
|
290
|
-
let transforms = this.compatApp.htmlbarsPlugins;
|
|
291
|
-
let { plugins: macroPlugins, setConfig } = node_1.MacrosConfig.transforms();
|
|
292
|
-
setConfig(this.compatApp.macrosConfig);
|
|
293
|
-
for (let macroPlugin of macroPlugins) {
|
|
294
|
-
transforms.push(macroPlugin);
|
|
295
|
-
}
|
|
296
|
-
if (this.options.staticComponents ||
|
|
297
|
-
this.options.staticHelpers ||
|
|
298
|
-
this.options.staticModifiers ||
|
|
299
|
-
globalThis.embroider_audit) {
|
|
300
|
-
let opts = {
|
|
301
|
-
appRoot: resolverConfig.appRoot,
|
|
302
|
-
emberVersion: this.emberVersion(),
|
|
303
|
-
};
|
|
304
|
-
transforms.push([require.resolve('./resolver-transform'), opts]);
|
|
305
|
-
}
|
|
306
|
-
let resolver = new core_1.Resolver(resolverConfig);
|
|
307
|
-
let resolution = await resolver.nodeResolve('ember-source/vendor/ember/ember-template-compiler', (0, path_1.resolve)(this.origAppPackage.root, 'package.json'));
|
|
308
|
-
if (resolution.type !== 'real') {
|
|
309
|
-
throw new Error(`bug: unable to resolve ember-template-compiler from ${this.origAppPackage.root}`);
|
|
310
|
-
}
|
|
311
|
-
return {
|
|
312
|
-
transforms,
|
|
313
|
-
compilerPath: resolution.filename,
|
|
314
|
-
enableLegacyModules: ['ember-cli-htmlbars', 'ember-cli-htmlbars-inline-precompile', 'htmlbars-inline-precompile'],
|
|
315
|
-
};
|
|
76
|
+
this.addBabelCompat();
|
|
316
77
|
}
|
|
317
78
|
get portableHints() {
|
|
318
79
|
return this.options.pluginHints.map(hint => {
|
|
319
|
-
let cursor = (0,
|
|
80
|
+
let cursor = (0, path_1.join)(this.origAppPackage.root, 'package.json');
|
|
320
81
|
for (let i = 0; i < hint.resolve.length; i++) {
|
|
321
82
|
let target = hint.resolve[i];
|
|
322
83
|
if (i < hint.resolve.length - 1) {
|
|
323
|
-
target = (0,
|
|
84
|
+
target = (0, path_1.join)(target, 'package.json');
|
|
324
85
|
}
|
|
325
|
-
cursor = resolve_1.default.sync(target, { basedir: (0,
|
|
86
|
+
cursor = resolve_1.default.sync(target, { basedir: (0, path_1.dirname)(cursor) });
|
|
326
87
|
}
|
|
327
88
|
return {
|
|
328
89
|
requireFile: cursor,
|
|
@@ -331,18 +92,32 @@ class CompatAppBuilder {
|
|
|
331
92
|
};
|
|
332
93
|
});
|
|
333
94
|
}
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
95
|
+
addBabelCompat() {
|
|
96
|
+
let plugins = this.compatApp.extraBabelPlugins();
|
|
97
|
+
let templateTransforms = this.compatApp.htmlbarsPlugins;
|
|
98
|
+
let babelMacros = this.compatApp.macrosConfig.babelPluginConfig();
|
|
99
|
+
let { plugins: templateMacros, setConfig } = node_1.MacrosConfig.transforms();
|
|
100
|
+
setConfig(this.compatApp.macrosConfig);
|
|
101
|
+
let config = {
|
|
102
|
+
plugins,
|
|
103
|
+
templateTransforms,
|
|
104
|
+
babelMacros,
|
|
105
|
+
templateMacros: templateMacros,
|
|
106
|
+
};
|
|
107
|
+
let portableConfig = new portable_1.Portable({ hints: this.portableHints }).dehydrate(config);
|
|
108
|
+
if (!portableConfig.isParallelSafe) {
|
|
109
|
+
throw new Error(`non-serializble babel plugins or AST transforms found in your app`);
|
|
337
110
|
}
|
|
338
|
-
(0, fs_extra_1.writeFileSync)((0,
|
|
339
|
-
|
|
111
|
+
(0, fs_extra_1.writeFileSync)((0, path_1.join)((0, core_1.locateEmbroiderWorkingDir)(this.compatApp.root), '_babel_compat_.js'), `
|
|
112
|
+
const { Portable } = require('@embroider/core/src/portable');
|
|
113
|
+
module.exports = new Portable().hydrate(${JSON.stringify(portableConfig.value, null, 2)});
|
|
114
|
+
`, 'utf8');
|
|
340
115
|
}
|
|
341
116
|
addResolverConfig(config) {
|
|
342
|
-
(0, fs_extra_1.outputJSONSync)((0,
|
|
117
|
+
(0, fs_extra_1.outputJSONSync)((0, path_1.join)((0, core_1.locateEmbroiderWorkingDir)(this.compatApp.root), 'resolver.json'), config, { spaces: 2 });
|
|
343
118
|
}
|
|
344
119
|
addContentForConfig(contentForConfig) {
|
|
345
|
-
(0, fs_extra_1.outputJSONSync)((0,
|
|
120
|
+
(0, fs_extra_1.outputJSONSync)((0, path_1.join)((0, core_1.locateEmbroiderWorkingDir)(this.compatApp.root), 'content-for.json'), contentForConfig, {
|
|
346
121
|
spaces: 2,
|
|
347
122
|
});
|
|
348
123
|
// In addition to outputting content-for.json, we also want to check if content-for 'config-module' has a custom content.
|
|
@@ -370,12 +145,7 @@ class CompatAppBuilder {
|
|
|
370
145
|
}
|
|
371
146
|
}
|
|
372
147
|
addEmberEnvConfig(emberEnvConfig) {
|
|
373
|
-
(0, fs_extra_1.outputJSONSync)((0,
|
|
374
|
-
spaces: 2,
|
|
375
|
-
});
|
|
376
|
-
}
|
|
377
|
-
addMacrosConfig(macrosConfig) {
|
|
378
|
-
(0, fs_extra_1.outputJSONSync)((0, path_2.join)((0, core_1.locateEmbroiderWorkingDir)(this.compatApp.root), 'macros-config.json'), macrosConfig, {
|
|
148
|
+
(0, fs_extra_1.outputJSONSync)((0, path_1.join)((0, core_1.locateEmbroiderWorkingDir)(this.compatApp.root), 'ember-env.json'), emberEnvConfig, {
|
|
379
149
|
spaces: 2,
|
|
380
150
|
});
|
|
381
151
|
}
|
|
@@ -412,60 +182,19 @@ class CompatAppBuilder {
|
|
|
412
182
|
exports.CompatAppBuilder = CompatAppBuilder;
|
|
413
183
|
__decorate([
|
|
414
184
|
(0, typescript_memoize_1.Memoize)()
|
|
415
|
-
], CompatAppBuilder.prototype, "
|
|
416
|
-
__decorate([
|
|
417
|
-
bind_decorator_1.default
|
|
418
|
-
], CompatAppBuilder.prototype, "isActiveAddon", null);
|
|
419
|
-
__decorate([
|
|
420
|
-
bind_decorator_1.default
|
|
421
|
-
], CompatAppBuilder.prototype, "orderAddons", null);
|
|
422
|
-
__decorate([
|
|
423
|
-
(0, typescript_memoize_1.Memoize)()
|
|
424
|
-
], CompatAppBuilder.prototype, "activeRules", null);
|
|
425
|
-
__decorate([
|
|
426
|
-
(0, typescript_memoize_1.Memoize)()
|
|
427
|
-
], CompatAppBuilder.prototype, "babelConfig", null);
|
|
185
|
+
], CompatAppBuilder.prototype, "resolverConfig", null);
|
|
428
186
|
__decorate([
|
|
429
187
|
(0, typescript_memoize_1.Memoize)()
|
|
430
188
|
], CompatAppBuilder.prototype, "portableHints", null);
|
|
431
189
|
function defaultAddonPackageRules() {
|
|
432
|
-
return (0, fs_extra_2.readdirSync)((0,
|
|
190
|
+
return (0, fs_extra_2.readdirSync)((0, path_1.join)(__dirname, 'addon-dependency-rules'))
|
|
433
191
|
.map(filename => {
|
|
434
192
|
if (filename.endsWith('.js')) {
|
|
435
193
|
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
436
|
-
return require((0,
|
|
194
|
+
return require((0, path_1.join)(__dirname, 'addon-dependency-rules', filename)).default;
|
|
437
195
|
}
|
|
438
196
|
})
|
|
439
197
|
.filter(Boolean)
|
|
440
198
|
.reduce((a, b) => a.concat(b), []);
|
|
441
199
|
}
|
|
442
|
-
const babelFilterTemplate = (0, core_1.jsHandlebarsCompile)(`
|
|
443
|
-
const { babelFilter } = require(${JSON.stringify(require.resolve('@embroider/core'))});
|
|
444
|
-
module.exports = babelFilter({{json-stringify skipBabel}}, "{{js-string-escape appRoot}}");
|
|
445
|
-
`);
|
|
446
|
-
function addCachablePlugin(babelConfig) {
|
|
447
|
-
if (Array.isArray(babelConfig.plugins) && babelConfig.plugins.length > 0) {
|
|
448
|
-
const plugins = Object.create(null);
|
|
449
|
-
plugins[core_1.cacheBustingPluginPath] = core_1.cacheBustingPluginVersion;
|
|
450
|
-
for (const plugin of babelConfig.plugins) {
|
|
451
|
-
let absolutePathToPlugin;
|
|
452
|
-
if (Array.isArray(plugin) && typeof plugin[0] === 'string') {
|
|
453
|
-
absolutePathToPlugin = plugin[0];
|
|
454
|
-
}
|
|
455
|
-
else if (typeof plugin === 'string') {
|
|
456
|
-
absolutePathToPlugin = plugin;
|
|
457
|
-
}
|
|
458
|
-
else {
|
|
459
|
-
throw new Error(`[Embroider] a babel plugin without an absolute path was from: ${plugin}`);
|
|
460
|
-
}
|
|
461
|
-
plugins[absolutePathToPlugin] = (0, portable_1.maybeNodeModuleVersion)(absolutePathToPlugin);
|
|
462
|
-
}
|
|
463
|
-
babelConfig.plugins.push([
|
|
464
|
-
core_1.cacheBustingPluginPath,
|
|
465
|
-
{
|
|
466
|
-
plugins,
|
|
467
|
-
},
|
|
468
|
-
]);
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
200
|
//# sourceMappingURL=compat-app-builder.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compat-app-builder.js","sourceRoot":"","sources":["compat-app-builder.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,0CASyB;AACzB,+BAA8C;AAI9C,yDAAwD;AACxD,6DAAqC;AACrC,iEAAyC;AACzC,oEAAkC;AAClC,uCAAuE;AAIvE,qFAAyE;AAEzE,2DAAsE;AACtE,2DAA6C;AAC7C,+BAAqC;AACrC,sDAA8B;AAI9B,uCAAuC;AAEvC,qDAA0D;AAI1D,8EAA8E;AAC9E,uDAAuD;AAEvD,MAAa,gBAAgB;IAC3B,YACU,cAAuB,EACvB,uBAAgC,EAChC,OAA0B,EAC1B,SAAoB,EACpB,UAAoB,EACpB,cAAgC,EAChC,WAAoB,EACpB,WAAoB;QAPpB,mBAAc,GAAd,cAAc,CAAS;QACvB,4BAAuB,GAAvB,uBAAuB,CAAS;QAChC,YAAO,GAAP,OAAO,CAAmB;QAC1B,cAAS,GAAT,SAAS,CAAW;QACpB,eAAU,GAAV,UAAU,CAAU;QACpB,mBAAc,GAAd,cAAc,CAAkB;QAChC,gBAAW,GAAX,WAAW,CAAS;QACpB,gBAAW,GAAX,WAAW,CAAS;IAC3B,CAAC;IAEI,mBAAmB,CAAC,GAAY;QACtC,IAAI,MAAM,GAAI,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,CAAoB,CAAC,MAAM;QACjF,yEAAyE;QACzE,wEAAwE;QACxE,wEAAwE;QACxE,sBAAsB;QACtB,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,oBAAoB,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,kBAAkB,CACrE,CAAC;QACF,IAAI,GAAG,KAAK,IAAI,CAAC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,CAAC,CAAC,KAAK,QAAQ,EAAE,CAAC;gBAC3D,oBAAoB,GAAG,MAAM,CAAC,CAAC,CAAW,CAAC;YAC7C,CAAC;iBAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;gBACtC,oBAAoB,GAAG,MAAM,CAAC;YAChC,CAAC;iBAAM,CAAC;gBACN,MAAM,IAAI,KAAK,CAAC,iEAAiE,MAAM,EAAE,CAAC,CAAC;YAC7F,CAAC;YAED,OAAO,CAAC,oBAAoB,CAAC,GAAG,IAAA,iCAAsB,EAAC,oBAAoB,CAAC,CAAC;QAC/E,CAAC;QAED,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC;YACvB,6BAAsB;YACtB;gBACE,OAAO;aACR;SACF,CAAC,CAAC;IACL,CAAC;AACH,CAAC","sourcesContent":["import type { AddonPackage, Engine, TemplateColocationPluginOptions } from '@embroider/core';\nimport {\n explicitRelative,\n warn,\n jsHandlebarsCompile,\n templateColocationPluginPath,\n cacheBustingPluginVersion,\n cacheBustingPluginPath,\n Resolver,\n locateEmbroiderWorkingDir,\n} from '@embroider/core';\nimport { resolve as resolvePath } from 'path';\nimport type Options from './options';\nimport type { CompatResolverOptions } from './resolver-transform';\nimport type { PackageRules } from './dependency-rules';\nimport { activePackageRules } from './dependency-rules';\nimport flatMap from 'lodash/flatMap';\nimport cloneDeep from 'lodash/cloneDeep';\nimport bind from 'bind-decorator';\nimport { outputJSONSync, writeFileSync, realpathSync } from 'fs-extra';\nimport type { Options as EtcOptions } from 'babel-plugin-ember-template-compilation';\nimport type { Options as ResolverTransformOptions } from './resolver-transform';\nimport type { Options as AdjustImportsOptions } from './babel-plugin-adjust-imports';\nimport { makePortable } from '@embroider/core/src/portable-babel-config';\nimport type { PortableHint } from '@embroider/core/src/portable';\nimport { maybeNodeModuleVersion } from '@embroider/core/src/portable';\nimport { Memoize } from 'typescript-memoize';\nimport { join, dirname } from 'path';\nimport resolve from 'resolve';\nimport type ContentForConfig from './content-for-config';\nimport type { V1Config } from './v1-config';\nimport type { Package } from '@embroider/core';\nimport { readdirSync } from 'fs-extra';\nimport type { TransformOptions } from '@babel/core';\nimport { MacrosConfig } from '@embroider/macros/src/node';\n\nimport type CompatApp from './compat-app';\n\n// This exists during the actual broccoli build step. As opposed to CompatApp,\n// which also exists during pipeline-construction time.\n\nexport class CompatAppBuilder {\n constructor(\n private origAppPackage: Package,\n private appPackageWithMovedDeps: Package,\n private options: Required<Options>,\n private compatApp: CompatApp,\n private configTree: V1Config,\n private contentForTree: ContentForConfig,\n private synthVendor: Package,\n private synthStyles: Package\n ) {}\n\n private activeAddonChildren(pkg: Package): AddonPackage[] {\n let result = (pkg.dependencies.filter(this.isActiveAddon) as AddonPackage[]).filter(\n // When looking for child addons, we want to ignore 'peerDependencies' of\n // a given package, to align with how ember-cli resolves addons. So here\n // we only include dependencies that are definitely active due to one of\n // the other sections.\n addon => pkg.categorizeDependency(addon.name) !== 'peerDependencies'\n );\n if (pkg === this.appPackageWithMovedDeps) {\n let extras = [this.synthVendor, this.synthStyles].filter(this.isActiveAddon) as AddonPackage[];\n result = [...result, ...extras];\n }\n return result.sort(this.orderAddons);\n }\n\n @Memoize()\n private get allActiveAddons(): AddonPackage[] {\n let result = this.appPackageWithMovedDeps.findDescendants(this.isActiveAddon) as AddonPackage[];\n let extras = [this.synthVendor, this.synthStyles].filter(this.isActiveAddon) as AddonPackage[];\n let extraDescendants = flatMap(extras, dep => dep.findDescendants(this.isActiveAddon)) as AddonPackage[];\n result = [...result, ...extras, ...extraDescendants];\n return result.sort(this.orderAddons);\n }\n\n @bind\n private isActiveAddon(pkg: Package): boolean {\n // stage1 already took care of converting everything that's actually active\n // into v2 addons. If it's not a v2 addon, we don't want it.\n //\n // We can encounter v1 addons here when there is inactive stuff floating\n // around in the node_modules that accidentally satisfy something like an\n // optional peer dep.\n return pkg.isV2Addon();\n }\n\n @bind\n private orderAddons(depA: Package, depB: Package): number {\n let depAIdx = 0;\n let depBIdx = 0;\n\n if (depA && depA.meta && depA.isV2Addon()) {\n depAIdx = depA.meta['order-index'] || 0;\n }\n if (depB && depB.meta && depB.isV2Addon()) {\n depBIdx = depB.meta['order-index'] || 0;\n }\n\n return depAIdx - depBIdx;\n }\n\n private resolvableExtensions(): string[] {\n let fromEnv = process.env.EMBROIDER_RESOLVABLE_EXTENSIONS;\n if (fromEnv) {\n return fromEnv.split(',');\n } else {\n return ['.mjs', '.gjs', '.js', '.mts', '.gts', '.ts', '.hbs', '.hbs.js', '.json'];\n }\n }\n\n private modulePrefix(): string {\n return this.configTree.readConfig().modulePrefix;\n }\n\n private podModulePrefix(): string | undefined {\n return this.configTree.readConfig().podModulePrefix;\n }\n\n @Memoize()\n private activeRules() {\n return activePackageRules(this.options.packageRules.concat(defaultAddonPackageRules()), [\n { name: this.origAppPackage.name, version: this.origAppPackage.version, root: this.origAppPackage.root },\n ...this.allActiveAddons.filter(p => p.meta['auto-upgraded']),\n ]);\n }\n\n private resolverConfig(engines: Engine[]): CompatResolverOptions {\n let renamePackages = Object.assign({}, ...this.allActiveAddons.map(dep => dep.meta['renamed-packages']));\n let renameModules = Object.assign({}, ...this.allActiveAddons.map(dep => dep.meta['renamed-modules']));\n\n let options: CompatResolverOptions['options'] = {\n staticHelpers: this.options.staticHelpers,\n staticModifiers: this.options.staticModifiers,\n staticComponents: this.options.staticComponents,\n allowUnsafeDynamicComponents: this.options.allowUnsafeDynamicComponents,\n };\n\n let config: CompatResolverOptions = {\n // this part is the base ModuleResolverOptions as required by @embroider/core\n renameModules,\n renamePackages,\n resolvableExtensions: this.resolvableExtensions(),\n appRoot: this.origAppPackage.root,\n engines: engines.map(engine => ({\n packageName: engine.package.name,\n // we need to use the real path here because webpack requests always use the real path i.e. follow symlinks\n root: realpathSync(engine.package.root),\n fastbootFiles: {},\n activeAddons: [...engine.addons]\n .map(([addon, canResolveFromFile]) => ({\n name: addon.name,\n root: addon.root,\n canResolveFromFile,\n }))\n // the traditional order is the order in which addons will run, such\n // that the last one wins. Our resolver's order is the order to\n // search, so first one wins.\n .reverse(),\n isLazy: engine.package.isLazyEngine(),\n })),\n amdCompatibility: this.options.amdCompatibility,\n\n // this is the additional stufff that @embroider/compat adds on top to do\n // global template resolving\n modulePrefix: this.modulePrefix(),\n splitAtRoutes: this.options.splitAtRoutes,\n podModulePrefix: this.podModulePrefix(),\n activePackageRules: this.activeRules(),\n options,\n autoRun: this.compatApp.autoRun,\n staticAppPaths: this.options.staticAppPaths,\n };\n\n return config;\n }\n\n @Memoize()\n private async babelConfig(resolverConfig: CompatResolverOptions) {\n let babel = cloneDeep(this.compatApp.babelConfig());\n\n if (!babel.plugins) {\n babel.plugins = [];\n }\n\n // Our stage3 code is always allowed to use dynamic import. We may emit it\n // ourself when splitting routes.\n babel.plugins.push(require.resolve('@babel/plugin-syntax-dynamic-import'));\n\n // https://github.com/webpack/webpack/issues/12154\n babel.plugins.push(require.resolve('./rename-require-plugin'));\n\n babel.plugins.push([\n require.resolve('babel-plugin-ember-template-compilation'),\n await this.etcOptions(resolverConfig),\n ]);\n\n // this is @embroider/macros configured for full stage3 resolution\n babel.plugins.push(...this.compatApp.macrosConfig.babelPluginConfig());\n\n let colocationOptions: TemplateColocationPluginOptions = {\n appRoot: this.origAppPackage.root,\n\n // This extra weirdness is a compromise in favor of build performance.\n //\n // 1. When auto-upgrading an addon from v1 to v2, we definitely want to\n // run any custom AST transforms in stage1.\n //\n // 2. In general case, AST transforms are allowed to manipulate Javascript\n // scope. This means that running transforms -- even when we're doing\n // source-to-source compilation that emits handlebars and not wire\n // format -- implies changing .hbs files into .js files.\n //\n // 3. So stage1 may need to rewrite .hbs to .hbs.js (to avoid colliding\n // with an existing co-located .js file).\n //\n // 4. But stage1 doesn't necessarily want to run babel over the\n // corresponding JS file. Most of the time, that's just an\n // unnecessarily expensive second parse. (We only run it in stage1 to\n // eliminate an addon's custom babel plugins, and many addons don't\n // have any.)\n //\n // 5. Therefore, the work of template-colocation gets defered until here,\n // and it may see co-located templates named `.hbs.js` instead of the\n // usual `.hbs.\n templateExtensions: ['.hbs', '.hbs.js'],\n\n // All of the above only applies to auto-upgraded packages that were\n // authored in v1. V2 packages don't get any of this complexity, they're\n // supposed to take care of colocating their own templates explicitly.\n packageGuard: true,\n };\n babel.plugins.push([templateColocationPluginPath, colocationOptions]);\n\n babel.plugins.push([\n require.resolve('./babel-plugin-adjust-imports'),\n (() => {\n let pluginConfig: AdjustImportsOptions = {\n appRoot: resolverConfig.appRoot,\n };\n return pluginConfig;\n })(),\n ]);\n\n // we can use globally shared babel runtime by default\n babel.plugins.push([\n require.resolve('@babel/plugin-transform-runtime'),\n { absoluteRuntime: __dirname, useESModules: true, regenerator: false },\n ]);\n\n const portable = makePortable(babel, { basedir: this.origAppPackage.root }, this.portableHints);\n addCachablePlugin(portable.config);\n return portable;\n }\n\n // recurse to find all active addons that don't cross an engine boundary.\n // Inner engines themselves will be returned, but not those engines' children.\n // The output set's insertion order is the proper ember-cli compatible\n // ordering of the addons.\n private findActiveAddons(pkg: Package, engine: Engine, isChild = false): void {\n for (let child of this.activeAddonChildren(pkg)) {\n if (!child.isEngine()) {\n this.findActiveAddons(child, engine, true);\n }\n let canResolveFrom = resolvePath(pkg.root, 'package.json');\n engine.addons.set(child, canResolveFrom);\n }\n // ensure addons are applied in the correct order, if set (via @embroider/compat/v1-addon)\n if (!isChild) {\n engine.addons = new Map(\n [...engine.addons].sort(([a], [b]) => {\n return (a.meta['order-index'] || 0) - (b.meta['order-index'] || 0);\n })\n );\n }\n }\n\n private partitionEngines(): Engine[] {\n let queue: Engine[] = [\n {\n package: this.appPackageWithMovedDeps,\n addons: new Map(),\n isApp: true,\n modulePrefix: this.modulePrefix(),\n appRelativePath: '.',\n },\n ];\n let done: Engine[] = [];\n let seenEngines: Set<Package> = new Set();\n while (true) {\n let current = queue.shift();\n if (!current) {\n break;\n }\n this.findActiveAddons(current.package, current);\n for (let addon of current.addons.keys()) {\n if (addon.isEngine() && !seenEngines.has(addon)) {\n seenEngines.add(addon);\n queue.push({\n package: addon,\n addons: new Map(),\n isApp: !current,\n modulePrefix: addon.name,\n appRelativePath: explicitRelative(this.origAppPackage.root, addon.root),\n });\n }\n }\n done.push(current);\n }\n return done;\n }\n\n private emberVersion() {\n let pkg = this.activeAddonChildren(this.appPackageWithMovedDeps).find(a => a.name === 'ember-source');\n if (!pkg) {\n throw new Error('no ember version!');\n }\n return pkg.version;\n }\n\n private engines: Engine[] | undefined;\n\n async build() {\n // on the first build, we lock down the macros config. on subsequent builds,\n // this doesn't do anything anyway because it's idempotent.\n this.compatApp.macrosConfig.finalize();\n\n if (!this.engines) {\n this.engines = this.partitionEngines();\n }\n\n let resolverConfig = this.resolverConfig(this.engines);\n let config = this.configTree.readConfig();\n let contentForConfig = this.contentForTree.readContents();\n\n this.addResolverConfig(resolverConfig);\n this.addContentForConfig(contentForConfig);\n this.addEmberEnvConfig(config.EmberENV);\n this.outputAppBootError(config.modulePrefix, config.APP, contentForConfig);\n let babelConfig = await this.babelConfig(resolverConfig);\n this.addBabelConfig(babelConfig);\n this.addMacrosConfig(this.compatApp.macrosConfig.babelPluginConfig()[0]);\n }\n\n private async etcOptions(resolverConfig: CompatResolverOptions): Promise<EtcOptions> {\n let transforms = this.compatApp.htmlbarsPlugins;\n\n let { plugins: macroPlugins, setConfig } = MacrosConfig.transforms();\n setConfig(this.compatApp.macrosConfig);\n for (let macroPlugin of macroPlugins) {\n transforms.push(macroPlugin as any);\n }\n\n if (\n this.options.staticComponents ||\n this.options.staticHelpers ||\n this.options.staticModifiers ||\n (globalThis as any).embroider_audit\n ) {\n let opts: ResolverTransformOptions = {\n appRoot: resolverConfig.appRoot,\n emberVersion: this.emberVersion(),\n };\n transforms.push([require.resolve('./resolver-transform'), opts]);\n }\n\n let resolver = new Resolver(resolverConfig);\n let resolution = await resolver.nodeResolve(\n 'ember-source/vendor/ember/ember-template-compiler',\n resolvePath(this.origAppPackage.root, 'package.json')\n );\n if (resolution.type !== 'real') {\n throw new Error(`bug: unable to resolve ember-template-compiler from ${this.origAppPackage.root}`);\n }\n\n return {\n transforms,\n compilerPath: resolution.filename,\n enableLegacyModules: ['ember-cli-htmlbars', 'ember-cli-htmlbars-inline-precompile', 'htmlbars-inline-precompile'],\n };\n }\n\n @Memoize()\n private get portableHints(): PortableHint[] {\n return this.options.pluginHints.map(hint => {\n let cursor = join(this.origAppPackage.root, 'package.json');\n for (let i = 0; i < hint.resolve.length; i++) {\n let target = hint.resolve[i];\n if (i < hint.resolve.length - 1) {\n target = join(target, 'package.json');\n }\n cursor = resolve.sync(target, { basedir: dirname(cursor) });\n }\n\n return {\n requireFile: cursor,\n useMethod: hint.useMethod,\n packageVersion: maybeNodeModuleVersion(cursor),\n };\n });\n }\n\n private addBabelConfig(pconfig: { config: TransformOptions; isParallelSafe: boolean }) {\n if (!pconfig.isParallelSafe) {\n warn('Your build is slower because some babel plugins are non-serializable');\n }\n writeFileSync(\n join(locateEmbroiderWorkingDir(this.compatApp.root), '_babel_config_.js'),\n `module.exports = ${JSON.stringify(pconfig.config, null, 2)}`,\n 'utf8'\n );\n writeFileSync(\n join(locateEmbroiderWorkingDir(this.compatApp.root), '_babel_filter_.js'),\n babelFilterTemplate({ skipBabel: this.options.skipBabel, appRoot: this.origAppPackage.root }),\n 'utf8'\n );\n }\n\n private addResolverConfig(config: CompatResolverOptions) {\n outputJSONSync(join(locateEmbroiderWorkingDir(this.compatApp.root), 'resolver.json'), config, { spaces: 2 });\n }\n\n private addContentForConfig(contentForConfig: any) {\n outputJSONSync(join(locateEmbroiderWorkingDir(this.compatApp.root), 'content-for.json'), contentForConfig, {\n spaces: 2,\n });\n\n // In addition to outputting content-for.json, we also want to check if content-for 'config-module' has a custom content.\n // If so, it means some classic addons used to provide this custom content, which is no longer supported.\n // Developers can deactivate this check (and the subsequent warning) with useAddonConfigModule\n if (this.compatApp.options.useAddonConfigModule) {\n let modulePrefix = this.configTree.readConfig().modulePrefix;\n\n // This is the default script provided by https://github.com/ember-cli/ember-cli/blob/master/lib/utilities/ember-app-utils.js#L84\n // When storeConfigInMeta is true, this content is always present in the config-module key of content-for.json\n const defaultConfigModule =\n `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(\n /\\s/g,\n ''\n );\n\n const configModule = contentForConfig['/index.html']['config-module'];\n const diff = configModule.replace(/\\s/g, '').replace(defaultConfigModule, '');\n\n if (diff.length) {\n throw new Error(`\n Your app uses at least one classic addon that provides content-for 'config-module'. This is no longer supported.\n With Embroider, you have full control over the config module, so classic addons no longer need to modify it under the hood.\n The following code is included via content-for 'config-module':\n\n ${configModule}\n\n 1. If you want to keep the same behavior, add it to the app/environment.js.\n 2. Once app/environment.js has the content you need, remove the present error by setting \"useAddonConfigModule\" to false in the build options.\n `);\n }\n }\n }\n\n private addEmberEnvConfig(emberEnvConfig: any) {\n outputJSONSync(join(locateEmbroiderWorkingDir(this.compatApp.root), 'ember-env.json'), emberEnvConfig, {\n spaces: 2,\n });\n }\n\n private addMacrosConfig(macrosConfig: any) {\n outputJSONSync(join(locateEmbroiderWorkingDir(this.compatApp.root), 'macros-config.json'), macrosConfig, {\n spaces: 2,\n });\n }\n\n // Classic addons providing custom content-for \"app-boot\" is no longer supported.\n // The purpose of this error message is to help developers to move the classic addons code.\n // Developers can deactivate it with useAddonAppBoot build option.\n private outputAppBootError(modulePrefix: string, appConfig: any, contentForConfig: any) {\n if (!this.compatApp.options.useAddonAppBoot) {\n return;\n }\n\n // This is the default script provided by\n // https://github.com/ember-cli/ember-cli/blob/master/lib/utilities/ember-app-utils.js#L103\n const defaultAppBoot = `\n if (!runningTests) {\n require(\"${modulePrefix}/app\")[\"default\"].create(${JSON.stringify(appConfig || {})});\n }\n `.replace(/\\s/g, '');\n\n const appBoot = contentForConfig['/index.html']['app-boot'];\n const diff = appBoot.replace(/\\s/g, '').replace(defaultAppBoot, '');\n\n if (diff.length) {\n throw new Error(`\n Your app uses at least one classic addon that provides content-for 'app-boot'. This is no longer supported.\n With Embroider, you have full control over the app-boot script, so classic addons no longer need to modify it under the hood.\n The following code is used for your app boot:\n\n ${appBoot}\n\n 1. If you want to keep the same behavior, copy and paste it to the app-boot script included in app/index.html.\n 2. Once app/index.html has the content you need, remove the present error by setting \"useAddonAppBoot\" to false in the build options.\n `);\n }\n }\n}\n\nfunction defaultAddonPackageRules(): PackageRules[] {\n return readdirSync(join(__dirname, 'addon-dependency-rules'))\n .map(filename => {\n if (filename.endsWith('.js')) {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n return require(join(__dirname, 'addon-dependency-rules', filename)).default;\n }\n })\n .filter(Boolean)\n .reduce((a, b) => a.concat(b), []);\n}\n\nconst babelFilterTemplate = jsHandlebarsCompile(`\nconst { babelFilter } = require(${JSON.stringify(require.resolve('@embroider/core'))});\nmodule.exports = babelFilter({{json-stringify skipBabel}}, \"{{js-string-escape appRoot}}\");\n`) as (params: { skipBabel: Options['skipBabel']; appRoot: string }) => string;\n\nfunction addCachablePlugin(babelConfig: TransformOptions) {\n if (Array.isArray(babelConfig.plugins) && babelConfig.plugins.length > 0) {\n const plugins = Object.create(null);\n plugins[cacheBustingPluginPath] = cacheBustingPluginVersion;\n\n for (const plugin of babelConfig.plugins) {\n let absolutePathToPlugin: string;\n if (Array.isArray(plugin) && typeof plugin[0] === 'string') {\n absolutePathToPlugin = plugin[0] as string;\n } else if (typeof plugin === 'string') {\n absolutePathToPlugin = plugin;\n } else {\n throw new Error(`[Embroider] a babel plugin without an absolute path was from: ${plugin}`);\n }\n\n plugins[absolutePathToPlugin] = maybeNodeModuleVersion(absolutePathToPlugin);\n }\n\n babelConfig.plugins.push([\n cacheBustingPluginPath,\n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AC;;KAErF,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAErB,MAAM,OAAO,GAAG,gBAAgB,CAAC,aAAa,CAAC,CAAC,UAAU,CAAC,CAAC;QAC5D,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC;QAEpE,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,MAAM,IAAI,KAAK,CAAC;;;;;UAKZ,OAAO;;;;OAIV,CAAC,CAAC;QACL,CAAC;IACH,CAAC;CACF;AA7LD,4CA6LC;AAxKC;IADC,IAAA,4BAAO,GAAE;sDAuBT;AAmBD;IADC,IAAA,4BAAO,GAAE;qDAkBT;AAgHH,SAAS,wBAAwB;IAC/B,OAAO,IAAA,sBAAW,EAAC,IAAA,WAAI,EAAC,SAAS,EAAE,wBAAwB,CAAC,CAAC;SAC1D,GAAG,CAAC,QAAQ,CAAC,EAAE;QACd,IAAI,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YAC7B,iEAAiE;YACjE,OAAO,OAAO,CAAC,IAAA,WAAI,EAAC,SAAS,EAAE,wBAAwB,EAAE,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC;QAC9E,CAAC;IACH,CAAC,CAAC;SACD,MAAM,CAAC,OAAO,CAAC;SACf,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AACvC,CAAC","sourcesContent":["import type { AddonPackage } from '@embroider/core';\nimport { locateEmbroiderWorkingDir } from '@embroider/core';\nimport type Options from './options';\nimport type { CompatResolverOptions } from './resolver-transform';\nimport type { PackageRules } from './dependency-rules';\nimport { activePackageRules } from './dependency-rules';\nimport { outputJSONSync, writeFileSync } from 'fs-extra';\nimport type { PortableHint } from '@embroider/core/src/portable';\nimport { maybeNodeModuleVersion, Portable } from '@embroider/core/src/portable';\nimport { Memoize } from 'typescript-memoize';\nimport { join, dirname } from 'path';\nimport resolve from 'resolve';\nimport type ContentForConfig from './content-for-config';\nimport type { V1Config } from './v1-config';\nimport type { Package } from '@embroider/core';\nimport { readdirSync } from 'fs-extra';\n\nimport type CompatApp from './compat-app';\nimport type { CompatBabelState } from './babel';\nimport { MacrosConfig } from '@embroider/macros/src/node';\nimport { buildResolverOptions } from '@embroider/core/src/module-resolver-options';\n\n// This exists during the actual broccoli build step. As opposed to CompatApp,\n// which also exists during pipeline-construction time.\n\nexport class CompatAppBuilder {\n constructor(\n private origAppPackage: Package,\n private appPackageWithMovedDeps: Package,\n private options: Required<Options>,\n private compatApp: CompatApp,\n private configTree: V1Config,\n private contentForTree: ContentForConfig,\n private synthVendor: Package,\n private synthStyles: Package\n ) {}\n\n private modulePrefix(): string {\n return this.configTree.readConfig().modulePrefix;\n }\n\n private podModulePrefix(): string | undefined {\n return this.configTree.readConfig().podModulePrefix;\n }\n\n @Memoize()\n private get resolverConfig(): CompatResolverOptions {\n return buildResolverOptions({\n appPackage: this.appPackageWithMovedDeps,\n modulePrefix: this.modulePrefix(),\n podModulePrefix: this.podModulePrefix(),\n splitAtRoutes: this.options.splitAtRoutes,\n staticAppPaths: this.options.staticAppPaths,\n extraDeps: new Map([[this.appPackageWithMovedDeps.root, [this.synthVendor, this.synthStyles] as AddonPackage[]]]),\n extend: (options: CompatResolverOptions, allActiveAddons) => {\n options.activePackageRules = activePackageRules(this.options.packageRules.concat(defaultAddonPackageRules()), [\n { name: this.origAppPackage.name, version: this.origAppPackage.version, root: this.origAppPackage.root },\n ...allActiveAddons.filter(p => p.meta['auto-upgraded']),\n ]);\n options.options = {\n staticHelpers: this.options.staticHelpers,\n staticModifiers: this.options.staticModifiers,\n staticComponents: this.options.staticComponents,\n allowUnsafeDynamicComponents: this.options.allowUnsafeDynamicComponents,\n };\n return options;\n },\n });\n }\n\n async build() {\n // on the first build, we lock down the macros config. on subsequent builds,\n // this doesn't do anything anyway because it's idempotent.\n this.compatApp.macrosConfig.finalize();\n\n let resolverConfig = this.resolverConfig;\n let config = this.configTree.readConfig();\n let contentForConfig = this.contentForTree.readContents();\n\n this.addResolverConfig(resolverConfig);\n this.addContentForConfig(contentForConfig);\n this.addEmberEnvConfig(config.EmberENV);\n this.outputAppBootError(config.modulePrefix, config.APP, contentForConfig);\n this.addBabelCompat();\n }\n\n @Memoize()\n private get portableHints(): PortableHint[] {\n return this.options.pluginHints.map(hint => {\n let cursor = join(this.origAppPackage.root, 'package.json');\n for (let i = 0; i < hint.resolve.length; i++) {\n let target = hint.resolve[i];\n if (i < hint.resolve.length - 1) {\n target = join(target, 'package.json');\n }\n cursor = resolve.sync(target, { basedir: dirname(cursor) });\n }\n\n return {\n requireFile: cursor,\n useMethod: hint.useMethod,\n packageVersion: maybeNodeModuleVersion(cursor),\n };\n });\n }\n\n private addBabelCompat() {\n let plugins = this.compatApp.extraBabelPlugins();\n let templateTransforms = this.compatApp.htmlbarsPlugins;\n let babelMacros = this.compatApp.macrosConfig.babelPluginConfig();\n let { plugins: templateMacros, setConfig } = MacrosConfig.transforms();\n setConfig(this.compatApp.macrosConfig);\n\n let config: CompatBabelState = {\n plugins,\n templateTransforms,\n babelMacros,\n templateMacros: templateMacros as any,\n };\n\n let portableConfig = new Portable({ hints: this.portableHints }).dehydrate(config);\n if (!portableConfig.isParallelSafe) {\n throw new Error(`non-serializble babel plugins or AST transforms found in your app`);\n }\n\n writeFileSync(\n join(locateEmbroiderWorkingDir(this.compatApp.root), '_babel_compat_.js'),\n `\n const { Portable } = require('@embroider/core/src/portable');\n module.exports = new Portable().hydrate(${JSON.stringify(portableConfig.value, null, 2)});\n `,\n 'utf8'\n );\n }\n\n private addResolverConfig(config: CompatResolverOptions) {\n outputJSONSync(join(locateEmbroiderWorkingDir(this.compatApp.root), 'resolver.json'), config, { spaces: 2 });\n }\n\n private addContentForConfig(contentForConfig: any) {\n outputJSONSync(join(locateEmbroiderWorkingDir(this.compatApp.root), 'content-for.json'), contentForConfig, {\n spaces: 2,\n });\n\n // In addition to outputting content-for.json, we also want to check if content-for 'config-module' has a custom content.\n // If so, it means some classic addons used to provide this custom content, which is no longer supported.\n // Developers can deactivate this check (and the subsequent warning) with useAddonConfigModule\n if (this.compatApp.options.useAddonConfigModule) {\n let modulePrefix = this.configTree.readConfig().modulePrefix;\n\n // This is the default script provided by https://github.com/ember-cli/ember-cli/blob/master/lib/utilities/ember-app-utils.js#L84\n // When storeConfigInMeta is true, this content is always present in the config-module key of content-for.json\n const defaultConfigModule =\n `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(\n /\\s/g,\n ''\n );\n\n const configModule = contentForConfig['/index.html']['config-module'];\n const diff = configModule.replace(/\\s/g, '').replace(defaultConfigModule, '');\n\n if (diff.length) {\n throw new Error(`\n Your app uses at least one classic addon that provides content-for 'config-module'. This is no longer supported.\n With Embroider, you have full control over the config module, so classic addons no longer need to modify it under the hood.\n The following code is included via content-for 'config-module':\n\n ${configModule}\n\n 1. If you want to keep the same behavior, add it to the app/environment.js.\n 2. Once app/environment.js has the content you need, remove the present error by setting \"useAddonConfigModule\" to false in the build options.\n `);\n }\n }\n }\n\n private addEmberEnvConfig(emberEnvConfig: any) {\n outputJSONSync(join(locateEmbroiderWorkingDir(this.compatApp.root), 'ember-env.json'), emberEnvConfig, {\n spaces: 2,\n });\n }\n\n // Classic addons providing custom content-for \"app-boot\" is no longer supported.\n // The purpose of this error message is to help developers to move the classic addons code.\n // Developers can deactivate it with useAddonAppBoot build option.\n private outputAppBootError(modulePrefix: string, appConfig: any, contentForConfig: any) {\n if (!this.compatApp.options.useAddonAppBoot) {\n return;\n }\n\n // This is the default script provided by\n // https://github.com/ember-cli/ember-cli/blob/master/lib/utilities/ember-app-utils.js#L103\n const defaultAppBoot = `\n if (!runningTests) {\n require(\"${modulePrefix}/app\")[\"default\"].create(${JSON.stringify(appConfig || {})});\n }\n `.replace(/\\s/g, '');\n\n const appBoot = contentForConfig['/index.html']['app-boot'];\n const diff = appBoot.replace(/\\s/g, '').replace(defaultAppBoot, '');\n\n if (diff.length) {\n throw new Error(`\n Your app uses at least one classic addon that provides content-for 'app-boot'. This is no longer supported.\n With Embroider, you have full control over the app-boot script, so classic addons no longer need to modify it under the hood.\n The following code is used for your app boot:\n\n ${appBoot}\n\n 1. If you want to keep the same behavior, copy and paste it to the app-boot script included in app/index.html.\n 2. Once app/index.html has the content you need, remove the present error by setting \"useAddonAppBoot\" to false in the build options.\n `);\n }\n }\n}\n\nfunction defaultAddonPackageRules(): PackageRules[] {\n return readdirSync(join(__dirname, 'addon-dependency-rules'))\n .map(filename => {\n if (filename.endsWith('.js')) {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n return require(join(__dirname, 'addon-dependency-rules', filename)).default;\n }\n })\n .filter(Boolean)\n .reduce((a, b) => a.concat(b), []);\n}\n"]}
|
package/src/compat-app.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { Stage, Package } from '@embroider/core';
|
|
|
3
3
|
import type Options from './options';
|
|
4
4
|
import { V1Config } from './v1-config';
|
|
5
5
|
import type { EmberAppInstance } from '@embroider/core';
|
|
6
|
-
import type {
|
|
6
|
+
import type { PluginItem } from '@babel/core';
|
|
7
7
|
import { MacrosConfig } from '@embroider/macros/src/node';
|
|
8
8
|
import type { Transform } from 'babel-plugin-ember-template-compilation';
|
|
9
9
|
export default class CompatApp {
|
|
@@ -35,7 +35,7 @@ export default class CompatApp {
|
|
|
35
35
|
private get storeConfigInMeta();
|
|
36
36
|
private get configReplacePatterns();
|
|
37
37
|
private get filteredPatternsByContentFor();
|
|
38
|
-
|
|
38
|
+
extraBabelPlugins(): PluginItem[];
|
|
39
39
|
babelMajorVersion(): 7;
|
|
40
40
|
private transformedNodeFiles;
|
|
41
41
|
private preresolvedNodeFile;
|