Skip to content

Commit 470dddb

Browse files
authored
Merge pull request #16548 from rwjblue/move-ember-debug
Migrate ember-debug to @ember/debug and @ember/canary-features.
2 parents 857a1c8 + d44b56c commit 470dddb

File tree

158 files changed

+343
-481
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

158 files changed

+343
-481
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ publish_to_bower/
4040
bower_components/
4141
npm-debug.log
4242
.ember-cli
43-
DEBUG/
43+
/DEBUG/
4444
*.tgz
4545
*.tar.gz
4646
*.log

RELEASE.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,11 @@ end
128128
1. Branch locally to `beta`
129129
1. `git checkout -b beta`
130130
1. Manually disable features
131-
1. Change everything in `features.json` from `null` to `false` to ensure they are stripped
131+
1. Change everything in `packages/@ember/canary-features.ts`'s `DEFAULT_FEATURES` export from `null` to `false` to ensure they are stripped
132132
1. Any feature that has been GOed gets changed to true
133133
1. Run `ember s -prod`
134134
1. Run tests at `http://localhost:4200/tests/index.html`
135-
1. Run production tests `http://localhost:4200/tests/index.htmlskipPackage=container,ember-testing,ember-debug&dist=prod&prod=true`
135+
1. Run production tests `http://localhost:4200/tests/index.htmlskipPackage=container,ember-testing,@ember/debug&dist=prod&prod=true`
136136
1. In `.travis.yml`, remove `branches:` section e.g. [this commit](https://github.com/emberjs/ember.js/commit/e38ec5d910721a9e02a819b4105a4875723f4b1b).
137137
1. Now we have to look at the commit just prior to branching 2.4.0.beta-1. Then find the commit after that to start the new branch at.
138138

bin/feature-flag-yuidoc-filter.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
var fs = require('fs');
1+
var FEATURES = require('../broccoli/features');
22

33
function isClassToBeIncluded(item, featuresToFilter) {
44
if (item.category) {
@@ -14,8 +14,7 @@ function isClassToBeIncluded(item, featuresToFilter) {
1414
}
1515

1616
function gatherFeatures() {
17-
var featuresJson = JSON.parse(fs.readFileSync('features.json'));
18-
var featuresObj = featuresJson.features;
17+
var featuresObj = Object.assign({}, FEATURES);
1918
var featuresToFilter = [];
2019
for (var feature in featuresObj) {
2120
if (featuresObj[feature] === null || featuresObj[feature] === false) {

bin/run-tests.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,8 @@ function generateEachPackageTests() {
233233

234234
function generateBuiltTests() {
235235
// Container isn't publicly available.
236-
// ember-testing/ember-debug are stripped from prod/min.
237-
var common = 'skipPackage=container,ember-testing,ember-debug';
236+
// ember-testing and @ember/debug are stripped from prod/min.
237+
var common = 'skipPackage=container,ember-testing,@ember/debug';
238238
testFunctions.push(function() {
239239
return run(common + '&nolint=true');
240240
});

broccoli/features.js

+42-16
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,46 @@
11
'use strict';
22

3-
function getFeatures(isDebug) {
4-
let features = Object.assign({}, require('../features').features);
3+
const resolve = require('resolve');
4+
const fs = require('fs');
5+
const path = require('path');
6+
7+
function getFeatures() {
8+
let fileName = 'packages/@ember/canary-features/index.ts';
9+
let fileContents = fs.readFileSync(fileName).toString();
10+
11+
// our typescript version comes from a dependency in
12+
// broccoli-typescript-compiler, so we look typescript up
13+
// from there...
14+
let broccoliTypescriptCompilerRoot = path.dirname(
15+
resolve.sync('broccoli-typescript-compiler/package.json'),
16+
{ basedir: __dirname }
17+
);
18+
let typescriptEntryPoint = resolve.sync('typescript', {
19+
basedir: broccoliTypescriptCompilerRoot,
20+
});
21+
22+
let ts = require(typescriptEntryPoint);
23+
let sourceFile = ts.createSourceFile(
24+
fileName,
25+
fileContents,
26+
ts.ScriptTarget.ES2017,
27+
/*setParentNodes */ true
28+
);
29+
30+
let features;
31+
32+
ts.forEachChild(sourceFile, processVariableDeclarations);
33+
34+
function processVariableDeclarations(node) {
35+
if (node.kind === ts.SyntaxKind.VariableDeclaration && node.name.text === 'DEFAULT_FEATURES') {
36+
let featuresText = node.initializer.getFullText();
37+
features = new Function(`return ${featuresText}`)();
38+
return;
39+
}
40+
41+
ts.forEachChild(node, processVariableDeclarations);
42+
}
43+
544
let featureName;
645

746
if (process.env.BUILD_TYPE === 'alpha') {
@@ -21,20 +60,7 @@ function getFeatures(isDebug) {
2160
}
2261
}
2362

24-
features['ember-glimmer-detect-backtracking-rerender'] = isDebug;
25-
2663
return features;
2764
}
2865

29-
function toConst(features) {
30-
let consted = {};
31-
Object.keys(features).forEach(feature => {
32-
consted[feature.toUpperCase().replace(/-/g, '_')] = features[feature];
33-
});
34-
35-
return consted;
36-
}
37-
38-
module.exports.toConst = toConst;
39-
module.exports.RELEASE = getFeatures(false);
40-
module.exports.DEBUG = getFeatures(true);
66+
module.exports = getFeatures();

broccoli/packages.js

-23
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,8 @@ const funnelLib = require('./funnel-lib');
1313
const { VERSION } = require('./version');
1414
const WriteFile = require('broccoli-file-creator');
1515
const StringReplace = require('broccoli-string-replace');
16-
const { RELEASE, DEBUG, toConst } = require('./features');
1716
const GlimmerTemplatePrecompiler = require('./glimmer-template-compiler');
1817
const VERSION_PLACEHOLDER = /VERSION_STRING_PLACEHOLDER/g;
19-
const { stripIndent } = require('common-tags');
2018

2119
const debugTree = BroccoliDebug.buildDebugCallback('ember-source');
2220

@@ -296,27 +294,6 @@ module.exports.emberLicense = function _emberLicense() {
296294
});
297295
};
298296

299-
module.exports.emberFeaturesES = function _emberFeaturesES(production = false) {
300-
let FEATURES = production ? RELEASE : DEBUG;
301-
let content = stripIndent`
302-
import { ENV } from 'ember-environment';
303-
import { assign } from '@ember/polyfills';
304-
export const DEFAULT_FEATURES = ${JSON.stringify(FEATURES)};
305-
export const FEATURES = assign(DEFAULT_FEATURES, ENV.FEATURES);
306-
307-
308-
${Object.keys(toConst(FEATURES))
309-
.map(FEATURE => {
310-
return `export const ${FEATURE} = FEATURES["${FEATURE.replace(/_/g, '-').toLowerCase()}"];`;
311-
})
312-
.join('\n')}
313-
`;
314-
315-
return new WriteFile('ember/features.js', content, {
316-
annotation: `ember/features ${production ? 'production' : 'debug'}`,
317-
});
318-
};
319-
320297
module.exports.nodeTests = function _nodeTests() {
321298
return new Funnel('tests', {
322299
include: ['**/*/*.js'],

broccoli/to-es5.js

+14-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const Babel = require('broccoli-babel-transpiler');
44
const injectBabelHelpers = require('./transforms/inject-babel-helpers');
55
const injectNodeGlobals = require('./transforms/inject-node-globals');
66
const enifed = require('./transforms/transform-define');
7-
const { RELEASE, DEBUG, toConst } = require('./features');
7+
const FEATURES = require('./features');
88
const stripClassCallCheck = require('./transforms/strip-class-call-check');
99
const resolveModuleSource = require('amd-name-resolver').moduleResolve;
1010

@@ -24,7 +24,7 @@ module.exports = function toES5(tree, _options) {
2424
'debug-macros',
2525
{
2626
debugTools: {
27-
source: 'ember-debug',
27+
source: '@ember/debug',
2828
assertPredicateIndex: 1,
2929
},
3030
envFlags: {
@@ -33,8 +33,18 @@ module.exports = function toES5(tree, _options) {
3333
},
3434
features: {
3535
name: 'ember',
36-
source: 'ember/features',
37-
flags: options.environment === 'production' ? toConst(RELEASE) : toConst(DEBUG),
36+
source: '@ember/canary-features',
37+
flags: Object.assign(
38+
// explicit list of additional exports within @ember/canary-features
39+
// without adding this (with a null value) an error is thrown during
40+
// the feature replacement process (e.g. XYZ is not a supported flag)
41+
{
42+
FEATURES: null,
43+
DEFAULT_FEATURES: null,
44+
isEnabled: null,
45+
},
46+
FEATURES
47+
),
3848
},
3949
externalizeHelpers: {
4050
module: true,

ember-cli-build.js

+13-18
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ const {
2929
nodeModuleUtils,
3030
emberVersionES,
3131
emberLicense,
32-
emberFeaturesES,
3332
nodeTests,
3433
buildEmberEnvFlagsES,
3534
getPackagesES,
@@ -66,12 +65,9 @@ module.exports = function() {
6665
getPackagesES(),
6766
]);
6867

69-
let es = new MergeTrees(
70-
[packagesES, emberFeaturesES(), dependenciesES, templateCompilerDependenciesES],
71-
{
72-
overwrite: true,
73-
}
74-
);
68+
let es = new MergeTrees([packagesES, dependenciesES, templateCompilerDependenciesES], {
69+
overwrite: true,
70+
});
7571
let pkgAndTestESInAMD = toNamedAMD(es);
7672
let emberEnvFlagsDebug = toNamedAMD(buildEmberEnvFlagsES({ DEBUG: true }));
7773

@@ -118,7 +114,6 @@ module.exports = function() {
118114
let packagesES5 = toES5(packagesESRollup);
119115
let dependenciesES5 = toES5(dependenciesES);
120116
let templateCompilerDependenciesES5 = toES5(templateCompilerDependenciesES);
121-
let emberDebugFeaturesES5 = toES5(emberFeaturesES());
122117

123118
// Bundling
124119
let emberTestsBundle = new MergeTrees([
@@ -141,7 +136,6 @@ module.exports = function() {
141136
exclude: ['*/tests/**', 'ember-template-compiler/**', 'internal-test-helpers/**'],
142137
}),
143138
dependenciesES5,
144-
emberDebugFeaturesES5,
145139
loader,
146140
license,
147141
nodeModule,
@@ -155,7 +149,13 @@ module.exports = function() {
155149

156150
let emberTestingBundle = new MergeTrees([
157151
new Funnel(packagesES5, {
158-
include: ['ember-debug/**', 'ember-testing/**', 'license.js'],
152+
include: [
153+
'@ember/debug/lib/**',
154+
'@ember/debug/index.js',
155+
'ember-testing/index.js',
156+
'ember-testing/lib/**',
157+
'license.js',
158+
],
159159
}),
160160
loader,
161161
license,
@@ -179,12 +179,13 @@ module.exports = function() {
179179
return new MergeTrees([
180180
new Funnel(packagesES5, {
181181
include: [
182-
'@ember/error/index.js',
182+
'@ember/canary-features/**',
183183
'@ember/debug/index.js',
184+
'@ember/debug/lib/**',
185+
'@ember/error/index.js',
184186
'@ember/polyfills/index.js',
185187
'@ember/polyfills/lib/**',
186188
'ember/version.js',
187-
'ember-debug/**',
188189
'ember-environment.js',
189190
'ember-browser-environment.js',
190191
'ember-template-compiler/**',
@@ -202,9 +203,6 @@ module.exports = function() {
202203
let babelProdHelpersES5 = toES5(babelHelpers('prod'), {
203204
environment: 'production',
204205
});
205-
let productionFeatures = toES5(emberFeaturesES(true), {
206-
environment: 'production',
207-
});
208206

209207
let emberProdBundle = new MergeTrees([
210208
new Funnel(prodPackagesES5, {
@@ -221,7 +219,6 @@ module.exports = function() {
221219
nodeModule,
222220
bootstrapModule('ember'),
223221
babelProdHelpersES5,
224-
productionFeatures,
225222
]);
226223

227224
emberProdBundle = concatBundle(emberProdBundle, {
@@ -261,7 +258,6 @@ module.exports = function() {
261258
license,
262259
babelProdHelpersES5,
263260
nodeModule,
264-
productionFeatures,
265261
]);
266262

267263
emberTemplateCompilerBundle = concatBundle(emberTemplateCompilerBundle, {
@@ -276,7 +272,6 @@ module.exports = function() {
276272
license,
277273
babelDebugHelpersES5,
278274
nodeModule,
279-
emberDebugFeaturesES5,
280275
]);
281276

282277
emberTemplateCompilerBundle = concatBundle(emberTemplateCompilerBundle, {

features.json

-12
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,4 @@
11
{
2-
"features": {
3-
"features-stripped-test": null,
4-
"ember-libraries-isregistered": null,
5-
"ember-improved-instrumentation": null,
6-
"ember-glimmer-named-arguments": true,
7-
"ember-routing-router-service": true,
8-
"ember-engines-mount-params": true,
9-
"ember-module-unification": null,
10-
"glimmer-custom-component-manager": null,
11-
"ember-template-block-let-helper": true,
12-
"ember-metal-tracked-properties": null
13-
},
142
"deprecations": {
153
"container-lookupFactory": "2.12.0",
164
"ember-application.injected-container": "2.3.0",

packages/@ember/application/globals-resolver.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import { dictionary } from 'ember-utils';
66
import { get, findNamespace } from 'ember-metal';
7-
import { assert, info } from 'ember-debug';
7+
import { assert, info } from '@ember/debug';
88
import { capitalize, classify, dasherize, decamelize } from '@ember/string';
99
import { Object as EmberObject } from 'ember-runtime';
1010
import validateType from './lib/validate-type';

packages/@ember/application/lib/application.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import { dictionary } from 'ember-utils';
66
import { ENV } from 'ember-environment';
77
import { hasDOM } from 'ember-browser-environment';
8-
import { assert, isTesting } from 'ember-debug';
8+
import { assert, isTesting } from '@ember/debug';
99
import { DEBUG } from '@glimmer/env';
1010
import { bind, join, once, run, schedule } from '@ember/runloop';
1111
import { libraries, processAllNamespaces, setNamespaceSearchDisabled } from 'ember-metal';
@@ -26,7 +26,7 @@ import Engine from '@ember/engine';
2626
import { privatize as P } from 'container';
2727
import { setupApplicationRegistry } from 'ember-glimmer';
2828
import { RouterService } from 'ember-routing';
29-
import { EMBER_ROUTING_ROUTER_SERVICE } from 'ember/features';
29+
import { EMBER_ROUTING_ROUTER_SERVICE } from '@ember/canary-features';
3030

3131
let librariesRegistered = false;
3232

packages/@ember/application/lib/validate-type.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { assert } from 'ember-debug';
1+
import { assert } from '@ember/debug';
22

33
const VALIDATED_TYPES = {
44
route: ['assert', 'isRouteFactory', 'Ember.Route'],

packages/@ember/application/tests/application_instance_test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { privatize as P } from 'container';
66
import { factory } from 'internal-test-helpers';
77
import { Object as EmberObject } from 'ember-runtime';
88
import { moduleFor, AbstractTestCase as TestCase } from 'internal-test-helpers';
9-
import { getDebugFunction, setDebugFunction } from 'ember-debug';
9+
import { getDebugFunction, setDebugFunction } from '@ember/debug';
1010

1111
const originalDebug = getDebugFunction('debug');
1212
const noop = function() {};

packages/@ember/application/tests/application_test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import VERSION from 'ember/version';
33
import { ENV, context } from 'ember-environment';
44
import { libraries, setNamespaceSearchDisabled } from 'ember-metal';
5-
import { getDebugFunction, setDebugFunction } from 'ember-debug';
5+
import { getDebugFunction, setDebugFunction } from '@ember/debug';
66
import Application from '..';
77
import { Router, NoneLocation, Route as EmberRoute } from 'ember-routing';
88
import { jQuery } from 'ember-views';

packages/@ember/application/tests/dependency_injection/default_resolver_test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import Service from '@ember/service';
77
import { Object as EmberObject, Namespace } from 'ember-runtime';
88
import { Route } from 'ember-routing';
99
import { Component, Helper, helper as makeHelper } from 'ember-glimmer';
10-
import { getDebugFunction, setDebugFunction } from 'ember-debug';
10+
import { getDebugFunction, setDebugFunction } from '@ember/debug';
1111

1212
moduleFor(
1313
'Application Dependency Injection - Integration - default resolver',

0 commit comments

Comments
 (0)