Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove most of defeaturEify in favor of babel-plugin-filter-imports #12214

Merged
merged 1 commit into from
Aug 26, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions Brocfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ var EmberBuild = require('emberjs-build');
var packages = require('./lib/packages');

var applyFeatureFlags = require('babel-plugin-feature-flags');
var filterImports = require('babel-plugin-filter-imports');

var vendoredPackage = require('emberjs-build/lib/vendored-package');
var htmlbarsPackage = require('emberjs-build/lib/htmlbars-package');
Expand All @@ -20,18 +21,25 @@ var featuresJson = fs.readFileSync('./features.json', { encoding: 'utf8' });

function babelConfigFor(environment) {
var isDevelopment = (environment === 'development');
var isProduction = (environment === 'production');

var features = JSON.parse(featuresJson).features;
features["mandatory-setter"] = isDevelopment;

return {
plugins: [
applyFeatureFlags({
import: { module: 'ember-metal/features' },
features: features
})
]
};
var plugins = [];

plugins.push(applyFeatureFlags({
import: { module: 'ember-metal/features' },
features: features
}));

if (isProduction) {
plugins.push(filterImports({
'ember-metal/debug': ['assert','debug','deprecate','runInDebug','warn']
}));
}

return { plugins: plugins };
}

var emberBuild = new EmberBuild({
Expand Down
27 changes: 1 addition & 26 deletions features.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,7 @@
"ember-routing-routable-components": null
},
"debugStatements": [
"Ember.warn",
"Ember.default.warn",
"Ember.assert",
"Ember.default.assert",
"Ember.deprecate",
"Ember.default.deprecate",
"Ember.debug",
"Ember.default.debug",
"Ember.Logger.info",
"Ember.default.Logger.info",
"Ember.runInDebug",
"Ember.default.runInDebug",
"_emberMetalCore.default.deprecate",
"_emberMetalCore.default.warn",
"_emberMetalCore.default.assert",
"_emberMetalCore.default.debug",
"_emberMetalCore.default.runInDebug",
"_emberMetal.default.deprecate",
"_emberMetal.default.warn",
"_emberMetal.default.assert",
"_emberMetal.default.debug",
"_emberMetal.default.runInDebug",
"_emberMetalDebug.deprecate",
"_emberMetalDebug.warn",
"_emberMetalDebug.assert",
"_emberMetalDebug.debug",
"_emberMetalDebug.runInDebug"
"Ember.default.Logger.info"
]
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"devDependencies": {
"aws-sdk": "~2.1.5",
"babel-plugin-feature-flags": "~0.2.0",
"babel-plugin-filter-imports": "~0.2.0",
"bower": "~1.3.2",
"chalk": "^0.5.1",
"ember-cli": "^0.2.7",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,11 @@ ComponentNodeManager.create = function(renderNode, env, options) {
// now that we have the component instance.
layout = get(component, 'layout') || layout;

// TODO: Remove this hack when defeatureify is removed.
let _assert = assert;

runInDebug(() => {
if (isAngleBracket) {
_assert(`You cannot invoke the '${tagName}' component with angle brackets, because it's a subclass of Component. Please upgrade to GlimmerComponent. Alternatively, you can invoke as '{{${tagName}}}'.`, component.isGlimmerComponent);
assert(`You cannot invoke the '${tagName}' component with angle brackets, because it's a subclass of Component. Please upgrade to GlimmerComponent. Alternatively, you can invoke as '{{${tagName}}}'.`, component.isGlimmerComponent);
} else {
_assert(`You cannot invoke the '${tagName}' component with curly braces, because it's a subclass of GlimmerComponent. Please invoke it as '<${tagName}>' instead.`, !component.isGlimmerComponent);
assert(`You cannot invoke the '${tagName}' component with curly braces, because it's a subclass of GlimmerComponent. Please invoke it as '<${tagName}>' instead.`, !component.isGlimmerComponent);
}

if (!layout) { return; }
Expand All @@ -92,14 +89,14 @@ ComponentNodeManager.create = function(renderNode, env, options) {
if (isAngleBracket && fragmentReason) {
switch (fragmentReason.name) {
case 'missing-wrapper':
_assert(`The <${tagName}> template must have a single top-level element because it is a GlimmerComponent.`);
assert(`The <${tagName}> template must have a single top-level element because it is a GlimmerComponent.`);
break;
case 'modifiers':
let modifiers = fragmentReason.modifiers.map(m => `{{${m} ...}}`);
_assert(`You cannot use ${ modifiers.join(', ') } in the top-level element of the <${tagName}> template because it is a GlimmerComponent.`);
assert(`You cannot use ${ modifiers.join(', ') } in the top-level element of the <${tagName}> template because it is a GlimmerComponent.`);
break;
case 'triple-curlies':
_assert(`You cannot use triple curlies (e.g. style={{{ ... }}}) in the top-level element of the <${tagName}> template because it is a GlimmerComponent.`);
assert(`You cannot use triple curlies (e.g. style={{{ ... }}}) in the top-level element of the <${tagName}> template because it is a GlimmerComponent.`);
break;
}
}
Expand Down
28 changes: 10 additions & 18 deletions packages/ember-metal/lib/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ Ember.isNamespace = true;

Ember.toString = function() { return 'Ember'; };

// The debug functions are exported to globals with `require` to
// prevent babel-plugin-filter-imports from removing them.
let debugModule = Ember.__loader.require('ember-metal/debug');
Ember.assert = debugModule.assert;
Ember.warn = debugModule.warn;
Ember.debug = debugModule.debug;
Ember.deprecate = debugModule.deprecate;
Ember.deprecateFunc = debugModule.deprecateFunc;
Ember.runInDebug = debugModule.runInDebug;

/**
The semantic version.
Expand All @@ -71,7 +80,7 @@ Ember.VERSION = 'VERSION_STRING_PLACEHOLDER';

if (Ember.ENV) {
// do nothing if Ember.ENV is already setup
assert('Ember.ENV should be an object.', 'object' !== typeof Ember.ENV);
Ember.assert('Ember.ENV should be an object.', 'object' !== typeof Ember.ENV);
} else if ('undefined' !== typeof EmberENV) {
Ember.ENV = EmberENV;
} else if ('undefined' !== typeof ENV) {
Expand Down Expand Up @@ -161,21 +170,4 @@ export { K };
Ember.K = K;
//TODO: ES6 GLOBAL TODO


import {
assert,
warn,
debug,
deprecate,
deprecateFunc,
runInDebug
} from 'ember-metal/debug';

Ember.assert = assert;
Ember.warn = warn;
Ember.debug = debug;
Ember.deprecate = deprecate;
Ember.deprecateFunc = deprecateFunc;
Ember.runInDebug = runInDebug;

export default Ember;
5 changes: 1 addition & 4 deletions packages/ember-metal/lib/mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,8 @@ function applyMergedProperties(obj, key, value, values) {
var baseValue = values[key] || obj[key];

runInDebug(function() {
// TODO: Remove this hack when defeatureify is removed.
let _assert = assert;

if (Array.isArray(value)) { // use conditional to avoid stringifying every time
_assert(`You passed in \`${JSON.stringify(value)}\` as the value for \`${key}\` but \`${key}\` cannot be an Array`, false);
assert(`You passed in \`${JSON.stringify(value)}\` as the value for \`${key}\` but \`${key}\` cannot be an Array`, false);
}
});

Expand Down