ember-cli 4.0.0 → 4.1.1
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/.github/workflows/ci.yml +4 -4
- package/CHANGELOG.md +42 -2
- package/blueprints/addon/additional-dev-dependencies.json +1 -1
- package/blueprints/addon/files/.github/workflows/ci.yml +0 -1
- package/blueprints/addon/files/.travis.yml +0 -1
- package/blueprints/addon/files/addon-config/ember-try.js +0 -13
- package/blueprints/app/files/config/environment.js +1 -1
- package/blueprints/app/files/package.json +6 -6
- package/docs/build/data.json +3 -3
- package/lib/models/host-info-cache.js +3 -5
- package/lib/models/per-bundle-addon-cache/index.js +2 -3
- package/lib/tasks/npm-task.js +1 -1
- package/lib/utilities/get-lang-arg.js +45 -45
- package/package.json +25 -25
- package/tests/helpers/mock-project.js +1 -1
- package/.github/ISSUE_TEMPLATE.md +0 -12
- package/.github/dependabot.yml +0 -15
- package/.github/workflows/coverage.yml +0 -31
- package/docs/analytics.md +0 -44
- package/docs/architecture.md +0 -316
- package/docs/assets/architecture/Ember-CLI architecture.png +0 -0
- package/docs/assets/architecture/Ember-CLI architecture.xml +0 -1
- package/docs/assets/architecture/README.md +0 -5
- package/docs/brocfile-transition.md +0 -46
- package/docs/build/api.js +0 -44
- package/docs/build/assets/css/external-small.png +0 -0
- package/docs/build/assets/css/logo.png +0 -0
- package/docs/build/assets/css/main.css +0 -555
- package/docs/build/assets/favicon.ico +0 -0
- package/docs/build/assets/img/spinner.gif +0 -0
- package/docs/build/assets/index.html +0 -10
- package/docs/build/assets/js/api-filter.js +0 -56
- package/docs/build/assets/js/api-list.js +0 -255
- package/docs/build/assets/js/api-search.js +0 -98
- package/docs/build/assets/js/apidocs.js +0 -376
- package/docs/build/assets/js/yui-prettify.js +0 -17
- package/docs/build/assets/vendor/prettify/CHANGES.html +0 -130
- package/docs/build/assets/vendor/prettify/COPYING +0 -202
- package/docs/build/assets/vendor/prettify/README.html +0 -203
- package/docs/build/assets/vendor/prettify/prettify-min.css +0 -1
- package/docs/build/assets/vendor/prettify/prettify-min.js +0 -1
- package/docs/build/classes/Addon.html +0 -4318
- package/docs/build/classes/AmdTransformAddon.html +0 -202
- package/docs/build/classes/Blueprint.html +0 -4796
- package/docs/build/classes/Builder.html +0 -611
- package/docs/build/classes/CLI.html +0 -810
- package/docs/build/classes/Command.html +0 -1655
- package/docs/build/classes/DefaultPackager.html +0 -202
- package/docs/build/classes/EmberAddon.html +0 -2207
- package/docs/build/classes/EmberApp.html +0 -2225
- package/docs/build/classes/HardwareInfo.html +0 -620
- package/docs/build/classes/HistorySupportAddon.html +0 -203
- package/docs/build/classes/Instrumentation.html +0 -695
- package/docs/build/classes/NodeModulesList.html +0 -460
- package/docs/build/classes/NpmTask.html +0 -333
- package/docs/build/classes/PackageInfo.html +0 -1390
- package/docs/build/classes/PackageInfoCache.html +0 -963
- package/docs/build/classes/PerBundleAddonCache {.html +0 -1010
- package/docs/build/classes/Project.html +0 -2083
- package/docs/build/classes/ServeFilesAddon.html +0 -260
- package/docs/build/classes/TestsServerAddon.html +0 -203
- package/docs/build/classes/WatcherAddon.html +0 -204
- package/docs/build/classes/WindowsSymlinkChecker.html +0 -1505
- package/docs/build/files/lib_broccoli_default-packager.js.html +0 -1426
- package/docs/build/files/lib_broccoli_ember-addon.js.html +0 -159
- package/docs/build/files/lib_broccoli_ember-app.js.html +0 -1913
- package/docs/build/files/lib_cli_cli.js.html +0 -417
- package/docs/build/files/lib_models_addon-info.js.html +0 -112
- package/docs/build/files/lib_models_addon.js.html +0 -1866
- package/docs/build/files/lib_models_blueprint.js.html +0 -1678
- package/docs/build/files/lib_models_builder.js.html +0 -417
- package/docs/build/files/lib_models_command.js.html +0 -804
- package/docs/build/files/lib_models_hardware-info.js.html +0 -479
- package/docs/build/files/lib_models_host-info-cache.js.html +0 -428
- package/docs/build/files/lib_models_installation-checker.js.html +0 -181
- package/docs/build/files/lib_models_instantiate-addons.js.html +0 -191
- package/docs/build/files/lib_models_instrumentation.js.html +0 -433
- package/docs/build/files/lib_models_package-info-cache_index.js.html +0 -793
- package/docs/build/files/lib_models_package-info-cache_node-modules-list.js.html +0 -208
- package/docs/build/files/lib_models_package-info-cache_package-info.js.html +0 -661
- package/docs/build/files/lib_models_per-bundle-addon-cache_addon-proxy.js.html +0 -252
- package/docs/build/files/lib_models_per-bundle-addon-cache_index.js.html +0 -485
- package/docs/build/files/lib_models_per-bundle-addon-cache_target-instance.js.html +0 -108
- package/docs/build/files/lib_models_project.js.html +0 -913
- package/docs/build/files/lib_models_task.js.html +0 -117
- package/docs/build/files/lib_tasks_build-watch.js.html +0 -157
- package/docs/build/files/lib_tasks_npm-task.js.html +0 -463
- package/docs/build/files/lib_tasks_serve.js.html +0 -207
- package/docs/build/files/lib_tasks_server_middleware_broccoli-serve-files_index.js.html +0 -127
- package/docs/build/files/lib_tasks_server_middleware_broccoli-watcher_index.js.html +0 -158
- package/docs/build/files/lib_tasks_server_middleware_history-support_index.js.html +0 -181
- package/docs/build/files/lib_tasks_server_middleware_tests-server_index.js.html +0 -171
- package/docs/build/files/lib_tasks_test-server.js.html +0 -167
- package/docs/build/files/lib_tasks_transforms_amd_index.js.html +0 -143
- package/docs/build/files/lib_utilities_ember-app-utils.js.html +0 -292
- package/docs/build/files/lib_utilities_insert-into-file.js.html +0 -219
- package/docs/build/files/lib_utilities_is-lazy-engine.js.html +0 -125
- package/docs/build/files/lib_utilities_is-yarn-project.js.html +0 -120
- package/docs/build/files/lib_utilities_valid-project-name.js.html +0 -142
- package/docs/build/files/lib_utilities_will-interrupt-process.js.html +0 -290
- package/docs/build/files/lib_utilities_windows-admin.js.html +0 -230
- package/docs/build/index.html +0 -125
- package/docs/build/modules/ember-cli.html +0 -152
- package/docs/build/modules/is-lazy-engine.html +0 -106
- package/docs/build-concurrency.md +0 -15
- package/docs/build-pipeline-debugging.md +0 -33
- package/docs/code-coverage.md +0 -14
- package/docs/error-propagation.md +0 -136
- package/docs/experiments.md +0 -53
- package/docs/node-support.md +0 -43
- package/docs/perf-guide.md +0 -250
- package/docs/project_version_preprocessor.js +0 -8
- package/docs/sourcemaps.md +0 -60
- package/docs/yuidoc.json +0 -13
|
@@ -1,485 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="utf-8">
|
|
5
|
-
<title>lib/models/per-bundle-addon-cache/index.js - ember-cli</title>
|
|
6
|
-
<link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
|
|
7
|
-
<link rel="stylesheet" href="../assets/css/main.css" id="site_styles">
|
|
8
|
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/yui/3.18.0/yui/yui-min.js"></script>
|
|
9
|
-
</head>
|
|
10
|
-
<body class="yui3-skin-sam">
|
|
11
|
-
|
|
12
|
-
<div id="doc">
|
|
13
|
-
<div class="yui3-g">
|
|
14
|
-
<div id="sidebar" class="yui3-u">
|
|
15
|
-
<div class="logo">
|
|
16
|
-
<a href="../index.html">
|
|
17
|
-
<img src="https://ember-cli.com/assets/images/ember-cli-logo-small-dark.png">
|
|
18
|
-
</a>
|
|
19
|
-
</div>
|
|
20
|
-
|
|
21
|
-
<div id="modules" class="sidebox">
|
|
22
|
-
<div class="hd">
|
|
23
|
-
<h2 class="no-toc">Modules</h2>
|
|
24
|
-
</div>
|
|
25
|
-
<div class="bd">
|
|
26
|
-
<ul>
|
|
27
|
-
<li><a href="../modules/ember-cli.html">ember-cli</a>
|
|
28
|
-
</li>
|
|
29
|
-
<li><a href="../modules/is-lazy-engine.html">is-lazy-engine</a>
|
|
30
|
-
</li>
|
|
31
|
-
</ul>
|
|
32
|
-
</div>
|
|
33
|
-
</div>
|
|
34
|
-
|
|
35
|
-
<div id="classes" class="sidebox">
|
|
36
|
-
<div class="hd">
|
|
37
|
-
<h2 class="no-toc">Classes</h2>
|
|
38
|
-
</div>
|
|
39
|
-
<div class="bd">
|
|
40
|
-
<ul>
|
|
41
|
-
<li><a href="../classes/Addon.html">Addon</a></li>
|
|
42
|
-
<li><a href="../classes/AmdTransformAddon.html">AmdTransformAddon</a></li>
|
|
43
|
-
<li><a href="../classes/Blueprint.html">Blueprint</a></li>
|
|
44
|
-
<li><a href="../classes/Builder.html">Builder</a></li>
|
|
45
|
-
<li><a href="../classes/CLI.html">CLI</a></li>
|
|
46
|
-
<li><a href="../classes/Command.html">Command</a></li>
|
|
47
|
-
<li><a href="../classes/DefaultPackager.html">DefaultPackager</a></li>
|
|
48
|
-
<li><a href="../classes/EmberAddon.html">EmberAddon</a></li>
|
|
49
|
-
<li><a href="../classes/EmberApp.html">EmberApp</a></li>
|
|
50
|
-
<li><a href="../classes/HardwareInfo.html">HardwareInfo</a></li>
|
|
51
|
-
<li><a href="../classes/HistorySupportAddon.html">HistorySupportAddon</a></li>
|
|
52
|
-
<li><a href="../classes/Instrumentation.html">Instrumentation</a></li>
|
|
53
|
-
<li><a href="../classes/NodeModulesList.html">NodeModulesList</a></li>
|
|
54
|
-
<li><a href="../classes/NpmTask.html">NpmTask</a></li>
|
|
55
|
-
<li><a href="../classes/PackageInfo.html">PackageInfo</a></li>
|
|
56
|
-
<li><a href="../classes/PackageInfoCache.html">PackageInfoCache</a></li>
|
|
57
|
-
<li><a href="../classes/PerBundleAddonCache {.html">PerBundleAddonCache {</a></li>
|
|
58
|
-
<li><a href="../classes/Project.html">Project</a></li>
|
|
59
|
-
<li><a href="../classes/ServeFilesAddon.html">ServeFilesAddon</a></li>
|
|
60
|
-
<li><a href="../classes/TestsServerAddon.html">TestsServerAddon</a></li>
|
|
61
|
-
<li><a href="../classes/WatcherAddon.html">WatcherAddon</a></li>
|
|
62
|
-
<li><a href="../classes/WindowsSymlinkChecker.html">WindowsSymlinkChecker</a></li>
|
|
63
|
-
</ul>
|
|
64
|
-
</div>
|
|
65
|
-
</div>
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
<div class="version-info">
|
|
72
|
-
Version: 4.0.0-release-b4cbb1029f
|
|
73
|
-
</div>
|
|
74
|
-
|
|
75
|
-
</div>
|
|
76
|
-
|
|
77
|
-
<div id="main" class="yui3-u">
|
|
78
|
-
<div class="content"><div class="title">
|
|
79
|
-
<h1 class="file-name">lib/models/per-bundle-addon-cache/index.js</h1>
|
|
80
|
-
</div>
|
|
81
|
-
|
|
82
|
-
<pre class="code prettyprint linenums">
|
|
83
|
-
'use strict';
|
|
84
|
-
|
|
85
|
-
const fs = require('fs');
|
|
86
|
-
const path = require('path');
|
|
87
|
-
const isLazyEngine = require('../../utilities/is-lazy-engine');
|
|
88
|
-
const { getAddonProxy } = require('./addon-proxy');
|
|
89
|
-
const logger = require('heimdalljs-logger')('ember-cli:per-bundle-addon-cache');
|
|
90
|
-
const { TARGET_INSTANCE } = require('./target-instance');
|
|
91
|
-
|
|
92
|
-
function defaultAllowCachingPerBundle({ addonEntryPointModule }) {
|
|
93
|
-
return (
|
|
94
|
-
addonEntryPointModule.allowCachingPerBundle ||
|
|
95
|
-
(addonEntryPointModule.prototype && addonEntryPointModule.prototype.allowCachingPerBundle)
|
|
96
|
-
);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Resolves the perBundleAddonCacheUtil; this prefers the custom provided version by
|
|
101
|
-
* the consuming application, and defaults to an internal implementation here.
|
|
102
|
-
*
|
|
103
|
-
* @method resolvePerBundleAddonCacheUtil
|
|
104
|
-
* @param {Project} project
|
|
105
|
-
* @return {{allowCachingPerBundle: Function}}
|
|
106
|
-
*/
|
|
107
|
-
function resolvePerBundleAddonCacheUtil(project) {
|
|
108
|
-
const relativePathToUtil =
|
|
109
|
-
project.pkg && project.pkg['ember-addon'] && project.pkg['ember-addon'].perBundleAddonCacheUtil;
|
|
110
|
-
|
|
111
|
-
if (typeof relativePathToUtil === 'string') {
|
|
112
|
-
const absolutePathToUtil = path.resolve(project.root, relativePathToUtil);
|
|
113
|
-
|
|
114
|
-
if (!fs.existsSync(absolutePathToUtil)) {
|
|
115
|
-
throw new Error(
|
|
116
|
-
`[ember-cli] the provided \`${relativePathToUtil}\` for \`ember-addon.perBundleAddonCacheUtil\` does not exist`
|
|
117
|
-
);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
return require(absolutePathToUtil);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
return {
|
|
124
|
-
allowCachingPerBundle: defaultAllowCachingPerBundle,
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* For large applications with many addons (and many instances of each, resulting in
|
|
130
|
-
* potentially many millions of addon instances during a build), the build can become
|
|
131
|
-
* very, very slow (tens of minutes) partially due to the sheer number of addon instances.
|
|
132
|
-
* The PerBundleAddonCache deals with this slowness by doing 3 things:
|
|
133
|
-
*
|
|
134
|
-
* (1) Making only a single copy of each of certain addons and their dependent addons
|
|
135
|
-
* (2) Replacing any other instances of those addons with Proxy copies to the single instance
|
|
136
|
-
* (3) Having the Proxies return an empty array for their dependent addons, rather
|
|
137
|
-
* than proxying to the contents of the single addon instance. This gives up the
|
|
138
|
-
* ability of the Proxies to traverse downward into their child addons,
|
|
139
|
-
* something that many addons do not do anyway, for the huge reduction in duplications
|
|
140
|
-
* of those child addons. For applications that enable `ember-engines` dedupe logic,
|
|
141
|
-
* that logic is stateful, and having the Proxies allow access to the child addons array
|
|
142
|
-
* just breaks everything, because that logic will try multiple times to remove items
|
|
143
|
-
* it thinks are duplicated, messing up the single copy of the child addon array.
|
|
144
|
-
* See the explanation of the dedupe logic in
|
|
145
|
-
* {@link https://github.com/ember-engines/ember-engines/blob/master/packages/ember-engines/lib/utils/deeply-non-duplicated-addon.js}
|
|
146
|
-
*
|
|
147
|
-
* What follows are the more technical details of how the PerBundleAddonCache implements
|
|
148
|
-
* the above 3 behaviors.
|
|
149
|
-
*
|
|
150
|
-
* This class supports per-bundle-host (bundle host = project or lazy engine)
|
|
151
|
-
* caching of addon instances. During addon initialization we cannot add a
|
|
152
|
-
* cache to each bundle host object AFTER it is instantiated because running the
|
|
153
|
-
* addon constructor ultimately causes Addon class `setupRegistry` code to
|
|
154
|
-
* run which instantiates child addons, which need the cache to already be
|
|
155
|
-
* in place for the parent bundle host.
|
|
156
|
-
* We handle this by providing a global cache that exists independent of the
|
|
157
|
-
* bundle host objects. That is this object.
|
|
158
|
-
*
|
|
159
|
-
* There are a number of "behaviors" being implemented by this object and
|
|
160
|
-
* its contents. They are:
|
|
161
|
-
* (1) Any addon that is a lazy engine has only a single real instance per
|
|
162
|
-
* project - all other references to the lazy engine are to be proxies. These
|
|
163
|
-
* lazy engines are compared by name, not by packageInfo.realPath.
|
|
164
|
-
* (2) Any addon that is not a lazy engine, there is only a single real instance
|
|
165
|
-
* of the addon per "bundle host" (i.e. lazy engine or project).
|
|
166
|
-
* (3) An optimization - any addon that is in a lazy engine but that is also
|
|
167
|
-
* in bundled by its LCA host - the single instance is the one bundled by this
|
|
168
|
-
* host. All other instances (in any lazy engine) are proxies.
|
|
169
|
-
*
|
|
170
|
-
* NOTE: the optimization is only enabled if the environment variable that controls
|
|
171
|
-
* `ember-engines` transitive deduplication (process.env.EMBER_ENGINES_ADDON_DEDUPE)
|
|
172
|
-
* is set to a truthy value. For more info, see:
|
|
173
|
-
* https://github.com/ember-engines/ember-engines/blob/master/packages/ember-engines/lib/engine-addon.js#L396
|
|
174
|
-
*
|
|
175
|
-
* @public
|
|
176
|
-
* @class PerBundleAddonCache {
|
|
177
|
-
*/
|
|
178
|
-
class PerBundleAddonCache {
|
|
179
|
-
constructor(project) {
|
|
180
|
-
this.project = project;
|
|
181
|
-
|
|
182
|
-
// The cache of bundle-host package infos and their individual addon caches.
|
|
183
|
-
// The cache is keyed by package info (representing a bundle host (project or
|
|
184
|
-
// lazy engine)) and an addon instance cache to bundle with that bundle host.
|
|
185
|
-
this.bundleHostCache = new Map();
|
|
186
|
-
|
|
187
|
-
// Indicate if ember-engines transitive dedupe is enabled.
|
|
188
|
-
this.engineAddonTransitiveDedupeEnabled = !!process.env.EMBER_ENGINES_ADDON_DEDUPE;
|
|
189
|
-
this._perBundleAddonCacheUtil = resolvePerBundleAddonCacheUtil(this.project);
|
|
190
|
-
|
|
191
|
-
// For stats purposes, counts on the # addons and proxies created. Addons we
|
|
192
|
-
// can compare against the bundleHostCache addon caches. Proxies, not so much,
|
|
193
|
-
// but we'll count them here.
|
|
194
|
-
this.numAddonInstances = 0;
|
|
195
|
-
this.numProxies = 0;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
/**
|
|
199
|
-
* The default implementation here is to indicate if the original addon entry point has
|
|
200
|
-
* the `allowCachingPerBundle` flag set either on itself or on its prototype.
|
|
201
|
-
*
|
|
202
|
-
* If a consuming application specifies a relative path to a custom utility via the
|
|
203
|
-
* `ember-addon.perBundleAddonCacheUtil` configuration, we prefer the custom implementation
|
|
204
|
-
* provided by the consumer.
|
|
205
|
-
*
|
|
206
|
-
* @method allowCachingPerBundle
|
|
207
|
-
* @param {Object|Function} addonEntryPointModule
|
|
208
|
-
* @return {Boolean} true if the given constructor function or class supports caching per bundle, false otherwise
|
|
209
|
-
*/
|
|
210
|
-
allowCachingPerBundle(addonEntryPointModule) {
|
|
211
|
-
return this._perBundleAddonCacheUtil.allowCachingPerBundle({ addonEntryPointModule });
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
/**
|
|
215
|
-
* Creates a cache entry for the bundleHostCache. Because we want to use the same sort of proxy
|
|
216
|
-
* for both bundle hosts and for 'regular' addon instances (though their cache entries have
|
|
217
|
-
* slightly different structures) we'll use the Symbol from getAddonProxy.
|
|
218
|
-
*
|
|
219
|
-
* @method createBundleHostCacheEntry
|
|
220
|
-
* @param {PackageInfo} bundleHostPkgInfo bundle host's pkgInfo.realPath
|
|
221
|
-
* @return {Object} an object in the form of a bundle-host cache entry
|
|
222
|
-
*/
|
|
223
|
-
createBundleHostCacheEntry(bundleHostPkgInfo) {
|
|
224
|
-
return { [TARGET_INSTANCE]: null, realPath: bundleHostPkgInfo.realPath, addonInstanceCache: new Map() };
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
/**
|
|
228
|
-
* Create a cache entry object for a given (non-bundle-host) addon to put into
|
|
229
|
-
* an addon cache.
|
|
230
|
-
*
|
|
231
|
-
* @method createAddonCacheEntry
|
|
232
|
-
* @param {Addon} addonInstance the addon instance to cache
|
|
233
|
-
* @param {String} addonRealPath the addon's pkgInfo.realPath
|
|
234
|
-
* @return {Object} an object in the form of an addon-cache entry
|
|
235
|
-
*/
|
|
236
|
-
createAddonCacheEntry(addonInstance, addonRealPath) {
|
|
237
|
-
return { [TARGET_INSTANCE]: addonInstance, realPath: addonRealPath };
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
/**
|
|
241
|
-
* Given a parent object of a potential addon (another addon or the project),
|
|
242
|
-
* go up the 'parent' chain to find the potential addon's bundle host object
|
|
243
|
-
* (i.e. lazy engine or project.) Because Projects are always bundle hosts,
|
|
244
|
-
* this should always pass, but we'll throw if somehow it doesn't work.
|
|
245
|
-
*
|
|
246
|
-
* @method findBundleHost
|
|
247
|
-
* @param {Project|Addon} addonParent the direct parent object of a (potential or real) addon.
|
|
248
|
-
* @param {PackageInfo} addonPkgInfo the PackageInfo for an addon being instantiated. This is only
|
|
249
|
-
* used for information if an error is going to be thrown.
|
|
250
|
-
* @return {Object} the object in the 'parent' chain that is a bundle host.
|
|
251
|
-
* @throws {Error} if there is not bundle host
|
|
252
|
-
*/
|
|
253
|
-
findBundleHost(addonParent, addonPkgInfo) {
|
|
254
|
-
let curr = addonParent;
|
|
255
|
-
|
|
256
|
-
while (curr) {
|
|
257
|
-
if (curr === this.project) {
|
|
258
|
-
return curr;
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
if (isLazyEngine(curr)) {
|
|
262
|
-
// if we're building a lazy engine in isolation, prefer that the bundle host is
|
|
263
|
-
// the project, not the lazy engine addon instance
|
|
264
|
-
if (curr.parent === this.project && curr._packageInfo === this.project._packageInfo) {
|
|
265
|
-
return this.project;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
return curr;
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
curr = curr.parent;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
// the following should not be able to happen given that Projects are always
|
|
275
|
-
// bundle hosts, but just in case, throw an error if we didn't find one.
|
|
276
|
-
throw new Error(`Addon at path\n ${addonPkgInfo.realPath}\n has 'allowCachingPerBundle' but has no bundleHost`);
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
/**
|
|
280
|
-
* An optimization we support from lazy engines is the following:
|
|
281
|
-
*
|
|
282
|
-
* If an addon instance is supposed to be bundled with a particular lazy engine, and
|
|
283
|
-
* same addon is also to be bundled by a common LCA host, prefer the one bundled by the
|
|
284
|
-
* host (since it's ultimately going to be deduped later by `ember-engines`).
|
|
285
|
-
*
|
|
286
|
-
* NOTE: this only applies if this.engineAddonTransitiveDedupeEnabled is truthy. If it is not,
|
|
287
|
-
* the bundle host always "owns" the addon instance.
|
|
288
|
-
*
|
|
289
|
-
* If deduping is enabled and the LCA host also depends on the same addon,
|
|
290
|
-
* the lazy-engine instances of the addon will all be proxies to the one in
|
|
291
|
-
* the LCA host. This function indicates whether the bundle host passed in
|
|
292
|
-
* (either the project or a lazy engine) is really the bundle host to "own" the
|
|
293
|
-
* new addon.
|
|
294
|
-
*
|
|
295
|
-
* @method bundleHostOwnsInstance
|
|
296
|
-
* @param (Object} bundleHost the project or lazy engine that is trying to "own"
|
|
297
|
-
* the new addon instance specified by addonPkgInfo
|
|
298
|
-
* @param {PackageInfo} addonPkgInfo the PackageInfo of the potential new addon instance
|
|
299
|
-
* @return {Boolean} true if the bundle host is to "own" the instance, false otherwise.
|
|
300
|
-
*/
|
|
301
|
-
bundleHostOwnsInstance(bundleHost, addonPkgInfo) {
|
|
302
|
-
if (isLazyEngine(bundleHost)) {
|
|
303
|
-
return (
|
|
304
|
-
!this.engineAddonTransitiveDedupeEnabled ||
|
|
305
|
-
!this.project.hostInfoCache
|
|
306
|
-
.getHostAddonInfo(bundleHost._packageInfo)
|
|
307
|
-
.hostAndAncestorBundledPackageInfos.has(addonPkgInfo)
|
|
308
|
-
);
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
return true;
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
findBundleOwner(bundleHost, addonPkgInfo) {
|
|
315
|
-
if (bundleHost === this.project._packageInfo) {
|
|
316
|
-
return bundleHost;
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
let { hostPackageInfo, hostAndAncestorBundledPackageInfos } = this.project.hostInfoCache.getHostAddonInfo(
|
|
320
|
-
bundleHost
|
|
321
|
-
);
|
|
322
|
-
|
|
323
|
-
if (!hostAndAncestorBundledPackageInfos.has(addonPkgInfo)) {
|
|
324
|
-
return bundleHost;
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
return this.findBundleOwner(hostPackageInfo, addonPkgInfo);
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
/**
|
|
331
|
-
* Called from PackageInfo.getAddonInstance(), return an instance of the requested
|
|
332
|
-
* addon or a Proxy, based on the type of addon and its bundle host.
|
|
333
|
-
*
|
|
334
|
-
* @method getAddonInstance
|
|
335
|
-
* @param {Addon|Project} parent the parent Addon or Project this addon instance is
|
|
336
|
-
* a child of.
|
|
337
|
-
* @param {*} addonPkgInfo the PackageInfo for the addon being created.
|
|
338
|
-
* @return {Addon|Proxy} An addon instance (for the first copy of the addon) or a Proxy.
|
|
339
|
-
* An addon that is a lazy engine will only ever have a single copy in the cache.
|
|
340
|
-
* An addon that is not will have 1 copy per bundle host (Project or lazy engine),
|
|
341
|
-
* except if it is an addon that's also owned by a given LCA host and transitive
|
|
342
|
-
* dedupe is enabled (`engineAddonTransitiveDedupeEnabled`), in which case it will
|
|
343
|
-
* only have a single copy in the project's addon cache.
|
|
344
|
-
*/
|
|
345
|
-
getAddonInstance(parent, addonPkgInfo) {
|
|
346
|
-
// If the new addon is itself a bundle host (i.e. lazy engine), there is only one
|
|
347
|
-
// instance of the bundle host, and it's in the entries of the bundleHostCache, outside
|
|
348
|
-
// of the 'regular' addon caches. Because 'setupBundleHostCache' ran during construction,
|
|
349
|
-
// we know that an entry is in the cache with this engine name.
|
|
350
|
-
if (addonPkgInfo.isForBundleHost()) {
|
|
351
|
-
let cacheEntry = this._getBundleHostCacheEntry(addonPkgInfo);
|
|
352
|
-
|
|
353
|
-
if (cacheEntry[TARGET_INSTANCE]) {
|
|
354
|
-
logger.debug(`About to construct BR PROXY to cache entry for addon at: ${addonPkgInfo.realPath}`);
|
|
355
|
-
this.numProxies++;
|
|
356
|
-
return getAddonProxy(cacheEntry, parent);
|
|
357
|
-
} else {
|
|
358
|
-
// create an instance, put it in the pre-existing cache entry, then
|
|
359
|
-
// return it (as the first instance of the lazy engine.)
|
|
360
|
-
logger.debug(`About to fill in BR EXISTING cache entry for addon at: ${addonPkgInfo.realPath}`);
|
|
361
|
-
this.numAddonInstances++;
|
|
362
|
-
let addon = addonPkgInfo.constructAddonInstance(parent, this.project);
|
|
363
|
-
cacheEntry[TARGET_INSTANCE] = addon; // cache BEFORE initializing child addons
|
|
364
|
-
addonPkgInfo.initChildAddons(addon);
|
|
365
|
-
return addon;
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
// We know now we're asking for a 'regular' (non-bundle-host) addon instance.
|
|
370
|
-
|
|
371
|
-
let bundleHost = this.findBundleHost(parent, addonPkgInfo);
|
|
372
|
-
|
|
373
|
-
// if the bundle host "owns" the new addon instance
|
|
374
|
-
// * Do we already have an instance of the addon cached?
|
|
375
|
-
// * If so, make a proxy for it.
|
|
376
|
-
// * If not, make a new instance of the addon and cache it in the
|
|
377
|
-
// bundle host's addon cache.
|
|
378
|
-
// If not, it means the bundle host is a lazy engine but the LCA host also uses
|
|
379
|
-
// the addon and deduping is enabled
|
|
380
|
-
// * If the LCA host already has a cached entry, return a proxy to that
|
|
381
|
-
// * If it does not, create a 'blank' cache entry and return a proxy to that.
|
|
382
|
-
// When the addon is encountered later when processing the LCA host's addons,
|
|
383
|
-
// fill in the instance.
|
|
384
|
-
if (this.bundleHostOwnsInstance(bundleHost, addonPkgInfo)) {
|
|
385
|
-
let bundleHostCacheEntry = this._getBundleHostCacheEntry(bundleHost._packageInfo);
|
|
386
|
-
let addonInstanceCache = bundleHostCacheEntry.addonInstanceCache;
|
|
387
|
-
let addonCacheEntry = addonInstanceCache.get(addonPkgInfo.realPath);
|
|
388
|
-
let addonInstance;
|
|
389
|
-
|
|
390
|
-
if (addonCacheEntry) {
|
|
391
|
-
if (addonCacheEntry[TARGET_INSTANCE]) {
|
|
392
|
-
logger.debug(`About to construct REGULAR ADDON PROXY for addon at: ${addonPkgInfo.realPath}`);
|
|
393
|
-
this.numProxies++;
|
|
394
|
-
return getAddonProxy(addonCacheEntry, parent);
|
|
395
|
-
} else {
|
|
396
|
-
// the cache entry was created 'empty' by an earlier call, indicating
|
|
397
|
-
// an addon that is used in a lazy engine but also used by its LCA host,
|
|
398
|
-
// and we're now creating the instance for the LCA host.
|
|
399
|
-
// Fill in the entry and return the new instance.
|
|
400
|
-
logger.debug(`About to fill in REGULAR ADDON EXISTING cache entry for addon at: ${addonPkgInfo.realPath}`);
|
|
401
|
-
this.numAddonInstances++;
|
|
402
|
-
addonInstance = addonPkgInfo.constructAddonInstance(parent, this.project);
|
|
403
|
-
addonCacheEntry[TARGET_INSTANCE] = addonInstance; // cache BEFORE initializing child addons
|
|
404
|
-
addonPkgInfo.initChildAddons(addonInstance);
|
|
405
|
-
return addonInstance;
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
// There is no entry for this addon in the bundleHost's addon cache. Create a new
|
|
410
|
-
// instance, cache it in the addon cache, and return it.
|
|
411
|
-
logger.debug(`About to construct REGULAR ADDON NEW cache entry for addon at: ${addonPkgInfo.realPath}`);
|
|
412
|
-
this.numAddonInstances++;
|
|
413
|
-
addonInstance = addonPkgInfo.constructAddonInstance(parent, this.project);
|
|
414
|
-
addonCacheEntry = this.createAddonCacheEntry(addonInstance, addonPkgInfo.realPath);
|
|
415
|
-
addonInstanceCache.set(addonPkgInfo.realPath, addonCacheEntry); // cache BEFORE initializing child addons
|
|
416
|
-
addonPkgInfo.initChildAddons(addonInstance);
|
|
417
|
-
return addonInstance;
|
|
418
|
-
} else {
|
|
419
|
-
// The bundleHost is not the project but the some ancestor bundles the addon and
|
|
420
|
-
// deduping is enabled, so the cache entry needs to go in the bundle owner's cache.
|
|
421
|
-
// Get/create an empty cache entry and return a proxy to it. The bundle owner will
|
|
422
|
-
// set the instance later (see above).
|
|
423
|
-
let bundleHostCacheEntry = this._getBundleHostCacheEntry(
|
|
424
|
-
this.findBundleOwner(bundleHost._packageInfo, addonPkgInfo)
|
|
425
|
-
);
|
|
426
|
-
let addonCacheEntry = bundleHostCacheEntry.addonInstanceCache.get(addonPkgInfo.realPath);
|
|
427
|
-
|
|
428
|
-
if (!addonCacheEntry) {
|
|
429
|
-
logger.debug(`About to construct REGULAR ADDON EMPTY cache entry for addon at: ${addonPkgInfo.realPath}`);
|
|
430
|
-
addonCacheEntry = this.createAddonCacheEntry(null, addonPkgInfo.realPath);
|
|
431
|
-
bundleHostCacheEntry.addonInstanceCache.set(addonPkgInfo.realPath, addonCacheEntry);
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
logger.debug(`About to construct REGULAR ADDON PROXY for EMPTY addon at: ${addonPkgInfo.realPath}`);
|
|
435
|
-
this.numProxies++;
|
|
436
|
-
return getAddonProxy(addonCacheEntry, parent);
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
getPathsToAddonsOptedIn() {
|
|
441
|
-
const addonSet = new Set();
|
|
442
|
-
|
|
443
|
-
for (const [, { addonInstanceCache }] of this.bundleHostCache) {
|
|
444
|
-
Array.from(addonInstanceCache.keys()).forEach((realPath) => {
|
|
445
|
-
addonSet.add(realPath);
|
|
446
|
-
});
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
return Array.from(addonSet);
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
_getBundleHostCacheEntry(pkgInfo) {
|
|
453
|
-
let cacheEntry = this.bundleHostCache.get(pkgInfo);
|
|
454
|
-
|
|
455
|
-
if (!cacheEntry) {
|
|
456
|
-
cacheEntry = this.createBundleHostCacheEntry(pkgInfo);
|
|
457
|
-
this.bundleHostCache.set(pkgInfo, cacheEntry);
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
return cacheEntry;
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
// Support for per-bundle addon caching is GLOBAL opt OUT (unless you explicitly set
|
|
464
|
-
// EMBER_CLI_ADDON_INSTANCE_CACHING to false, it will be enabled.) If you opt out, that
|
|
465
|
-
// overrides setting `allowCachingPerBundle` for any particular addon type to true.
|
|
466
|
-
// To help make testing easier, we'll expose the setting as a function so it can be
|
|
467
|
-
// called multiple times and evaluate each time.
|
|
468
|
-
static isEnabled() {
|
|
469
|
-
return process.env.EMBER_CLI_ADDON_INSTANCE_CACHING !== 'false';
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
module.exports = PerBundleAddonCache;
|
|
474
|
-
|
|
475
|
-
</pre>
|
|
476
|
-
|
|
477
|
-
</div>
|
|
478
|
-
</div>
|
|
479
|
-
</div>
|
|
480
|
-
</div>
|
|
481
|
-
<script src="../assets/vendor/prettify/prettify-min.js"></script>
|
|
482
|
-
<script>prettyPrint();</script>
|
|
483
|
-
<script src="../assets/js/yui-prettify.js"></script>
|
|
484
|
-
</body>
|
|
485
|
-
</html>
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="utf-8">
|
|
5
|
-
<title>lib/models/per-bundle-addon-cache/target-instance.js - ember-cli</title>
|
|
6
|
-
<link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
|
|
7
|
-
<link rel="stylesheet" href="../assets/css/main.css" id="site_styles">
|
|
8
|
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/yui/3.18.0/yui/yui-min.js"></script>
|
|
9
|
-
</head>
|
|
10
|
-
<body class="yui3-skin-sam">
|
|
11
|
-
|
|
12
|
-
<div id="doc">
|
|
13
|
-
<div class="yui3-g">
|
|
14
|
-
<div id="sidebar" class="yui3-u">
|
|
15
|
-
<div class="logo">
|
|
16
|
-
<a href="../index.html">
|
|
17
|
-
<img src="https://ember-cli.com/assets/images/ember-cli-logo-small-dark.png">
|
|
18
|
-
</a>
|
|
19
|
-
</div>
|
|
20
|
-
|
|
21
|
-
<div id="modules" class="sidebox">
|
|
22
|
-
<div class="hd">
|
|
23
|
-
<h2 class="no-toc">Modules</h2>
|
|
24
|
-
</div>
|
|
25
|
-
<div class="bd">
|
|
26
|
-
<ul>
|
|
27
|
-
<li><a href="../modules/ember-cli.html">ember-cli</a>
|
|
28
|
-
</li>
|
|
29
|
-
<li><a href="../modules/is-lazy-engine.html">is-lazy-engine</a>
|
|
30
|
-
</li>
|
|
31
|
-
</ul>
|
|
32
|
-
</div>
|
|
33
|
-
</div>
|
|
34
|
-
|
|
35
|
-
<div id="classes" class="sidebox">
|
|
36
|
-
<div class="hd">
|
|
37
|
-
<h2 class="no-toc">Classes</h2>
|
|
38
|
-
</div>
|
|
39
|
-
<div class="bd">
|
|
40
|
-
<ul>
|
|
41
|
-
<li><a href="../classes/Addon.html">Addon</a></li>
|
|
42
|
-
<li><a href="../classes/AmdTransformAddon.html">AmdTransformAddon</a></li>
|
|
43
|
-
<li><a href="../classes/Blueprint.html">Blueprint</a></li>
|
|
44
|
-
<li><a href="../classes/Builder.html">Builder</a></li>
|
|
45
|
-
<li><a href="../classes/CLI.html">CLI</a></li>
|
|
46
|
-
<li><a href="../classes/Command.html">Command</a></li>
|
|
47
|
-
<li><a href="../classes/DefaultPackager.html">DefaultPackager</a></li>
|
|
48
|
-
<li><a href="../classes/EmberAddon.html">EmberAddon</a></li>
|
|
49
|
-
<li><a href="../classes/EmberApp.html">EmberApp</a></li>
|
|
50
|
-
<li><a href="../classes/HardwareInfo.html">HardwareInfo</a></li>
|
|
51
|
-
<li><a href="../classes/HistorySupportAddon.html">HistorySupportAddon</a></li>
|
|
52
|
-
<li><a href="../classes/Instrumentation.html">Instrumentation</a></li>
|
|
53
|
-
<li><a href="../classes/NodeModulesList.html">NodeModulesList</a></li>
|
|
54
|
-
<li><a href="../classes/NpmTask.html">NpmTask</a></li>
|
|
55
|
-
<li><a href="../classes/PackageInfo.html">PackageInfo</a></li>
|
|
56
|
-
<li><a href="../classes/PackageInfoCache.html">PackageInfoCache</a></li>
|
|
57
|
-
<li><a href="../classes/PerBundleAddonCache {.html">PerBundleAddonCache {</a></li>
|
|
58
|
-
<li><a href="../classes/Project.html">Project</a></li>
|
|
59
|
-
<li><a href="../classes/ServeFilesAddon.html">ServeFilesAddon</a></li>
|
|
60
|
-
<li><a href="../classes/TestsServerAddon.html">TestsServerAddon</a></li>
|
|
61
|
-
<li><a href="../classes/WatcherAddon.html">WatcherAddon</a></li>
|
|
62
|
-
<li><a href="../classes/WindowsSymlinkChecker.html">WindowsSymlinkChecker</a></li>
|
|
63
|
-
</ul>
|
|
64
|
-
</div>
|
|
65
|
-
</div>
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
<div class="version-info">
|
|
72
|
-
Version: 4.0.0-release-b4cbb1029f
|
|
73
|
-
</div>
|
|
74
|
-
|
|
75
|
-
</div>
|
|
76
|
-
|
|
77
|
-
<div id="main" class="yui3-u">
|
|
78
|
-
<div class="content"><div class="title">
|
|
79
|
-
<h1 class="file-name">lib/models/per-bundle-addon-cache/target-instance.js</h1>
|
|
80
|
-
</div>
|
|
81
|
-
|
|
82
|
-
<pre class="code prettyprint linenums">
|
|
83
|
-
'use strict';
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* A Symbol constant for sharing between index.js and addon-proxy.js rather than
|
|
87
|
-
* putting the symbol into the Symbol global cache. The symbol is used in per-bundle
|
|
88
|
-
* cache entries to refer to the field that points at the real instance that a Proxy
|
|
89
|
-
* refers to.
|
|
90
|
-
* @property
|
|
91
|
-
* @type Symbol
|
|
92
|
-
* @final
|
|
93
|
-
*/
|
|
94
|
-
const TARGET_INSTANCE = Symbol('_targetInstance_');
|
|
95
|
-
|
|
96
|
-
module.exports.TARGET_INSTANCE = TARGET_INSTANCE;
|
|
97
|
-
|
|
98
|
-
</pre>
|
|
99
|
-
|
|
100
|
-
</div>
|
|
101
|
-
</div>
|
|
102
|
-
</div>
|
|
103
|
-
</div>
|
|
104
|
-
<script src="../assets/vendor/prettify/prettify-min.js"></script>
|
|
105
|
-
<script>prettyPrint();</script>
|
|
106
|
-
<script src="../assets/js/yui-prettify.js"></script>
|
|
107
|
-
</body>
|
|
108
|
-
</html>
|