-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
/
Copy pathindex.js
163 lines (133 loc) · 5.08 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
'use strict';
const MergeTrees = require('broccoli-merge-trees');
const Funnel = require('broccoli-funnel');
const path = require('path');
const Overrides = require('./overrides');
const SilentError = require('silent-error');
const SupportedBrowsers = require('./browsers');
const paths = {};
const absolutePaths = {};
function add(paths, name, path) {
Object.defineProperty(paths, name, {
configurable: false,
get: function () {
return path;
},
});
}
add(paths, 'prod', 'vendor/ember/ember.js');
add(paths, 'debug', 'vendor/ember/ember.js');
add(paths, 'testing', 'vendor/ember/ember-testing.js');
add(
absolutePaths,
'templateCompiler',
path.join(__dirname, '..', 'dist', 'ember-template-compiler.js')
);
const { addonV1Shim } = require('@embroider/addon-shim');
const shim = addonV1Shim(path.join(__dirname, '..'), {
autoImportCompat: {
customizeMeta(meta) {
return { ...meta, 'renamed-modules': {} };
},
},
});
module.exports = {
...shim,
paths,
absolutePaths,
init() {
if (shim.init) {
shim.init.apply(this, arguments);
} else {
this._super.init && this._super.init.apply(this, arguments);
}
// resets `this.root` to the correct location by default ember-cli
// considers `__dirname` here to be the root, but since our main entry
// point is within a subfolder we need to correct that
this.root = path.join(__dirname, '..');
// Updates the vendor tree to point to dist, so we get the correct tree in
// treeForVendor
this.treePaths.vendor = 'dist';
},
_overrideTree: undefined,
// Expose supported list of browsers for reference by other packages
supportedBrowsers: SupportedBrowsers,
included() {
if (shim.included) {
shim.included.apply(this, arguments);
} else {
this._super.included.apply(this, arguments);
}
let overrides = Overrides.for(this.project);
if (overrides.hasOverrides) {
this._overrideTree = overrides.toTree();
}
if (overrides.hasBuildTimeWarning) {
this.ui.writeWarnLine('[DEPRECATION] ' + overrides.buildTimeWarning);
}
const { has } = require('@ember/edition-utils');
let optionalFeatures = this.project.addons.find((a) => a.name === '@ember/optional-features');
let optionalFeaturesMissing = optionalFeatures === undefined;
if (has('octane')) {
let message = [];
if (optionalFeaturesMissing) {
message.push(
`* the @ember/optional-features addon is missing, run \`ember install @ember/optional-features\` to install it`
);
}
if (message.length > 0) {
message.unshift(
`You have configured your application to indicate that it is using the 'octane' edition (via \`setEdition('octane')\`), but the appropriate Octane features were not enabled:\n`
);
throw new SilentError(message.join('\n\t'));
}
} else {
throw new SilentError(
'The Ember Classic edition has been removed. Specifying "classic" in your package.json, or not specifying a value at all, is no longer supported. You must explicitly set the "ember.edition" property to "octane". You can also run `npx @ember/octanify` to do this. \n\nFor more information, see the deprecation guide: https://deprecations.emberjs.com/v3.x/#toc_editions-classic'
);
}
if (
!optionalFeaturesMissing &&
optionalFeatures.isFeatureEnabled('jquery-integration') &&
typeof optionalFeatures.isFeatureExplicitlySet === 'function' &&
optionalFeatures.isFeatureExplicitlySet('jquery-integration')
) {
throw new SilentError(
'Setting the `jquery-integration` optional feature flag to `true` was deprecated in Ember 3.x and removed in Ember 4.0.0. You must add the `@ember/optional-features` addon and set this feature to `false`.\n\nFor more information, see the deprecation guide: https://deprecations.emberjs.com/v3.x/#toc_optional-feature-jquery-integration'
);
}
},
treeForVendor(tree) {
if (shim.treeForVendor) {
tree = shim.treeForVendor.call(this, tree);
}
const isProduction = process.env.EMBER_ENV === 'production';
let templateCompiler = new Funnel(tree, {
destDir: 'ember',
include: ['ember-template-compiler.js', 'ember-template-compiler.js.map'],
});
let which = isProduction ? 'prod' : 'debug';
let ember = new Funnel(tree, {
destDir: 'ember',
include: [
`ember.${which}.js`,
`ember.${which}.js.map`,
'ember-testing.js',
'ember-testing.js.map',
],
getDestinationPath(path) {
return path.replace(`ember.${which}.`, 'ember.');
},
});
let emberCliBabel = this.addons.find((a) => a.name === 'ember-cli-babel');
// this is primarily so we get preset-env with the app's targets. All our
// special stuff was already accounted for in the building of the bundles.
return emberCliBabel.transpileTree(new MergeTrees([ember, templateCompiler]), {
'ember-cli-babel': {
compileModules: false,
disableDebugTooling: true,
disableEmberModulesAPIPolyfill: true,
},
});
},
};