jkarsrud / ember-cli-defeatureify Goto Github PK
View Code? Open in Web Editor NEWEmber-CLI addon to defeatureify your apps
License: MIT License
Ember-CLI addon to defeatureify your apps
License: MIT License
Look at the way it's done in emberjs-build by looking at the implementations done in emberjs/emberjs-build#49 and emberjs/ember.js#10221.
Doing this will enable users to use feature flags without running through defeatureify for debug/development builds, and only trigger defeatureify on production builds.
I'd like to move away from inserting feature state as a global inside of app-prefix
to make it easier to move to a modules-only world. See: ember-cli/ember-cli#5240
As a result I would want to modify ember-cli-defeatureify to generate a module which could be included into any ember app's module that needs defeatureifying:
import myNamespace from 'ember-cli-defeatureify/config';
The change for any existing users of this addon would be the above mechanical change. Would you accept a PR for this functionality?
Believe #15 may resolve this though
Its great that you have tests, you should enable Travis and add a badge to your README to flaunt it!
As of now, Esprima doesn't support ES6 good enough to work directly on the app tree. This makes ember build
fail with an "Unexpected reserved word"-error, and thus doesn't really defeature your code.
Related issues:
Added in ember-cli/ember-cli#3218, and should be available in [email protected].
This will ensure that in development the features are injected into my-app.js
before the app code (which should fix the current issue).
Here's a thing that would be great to get working: Stripping out parts of templates based on features being enabled or disabled. This originated as a discussion in this issue: ember-cli/ember-cli#3200
Things to figure out:
There were some interest in solving this by @rwjblue, @mmun and @alexBaizeau
Hi,
The ember-cli-babel compress the file if file size is larger than 100kb.
Then, it seems that defeatureify also remove first character in next statement.
And error occur when do uglify. Could anyone help me?
babel-output_path-jVys26A1.tmp
Ember.debug('test');if(!this.flag){this.hoge = false;}
defeatureify_filter-tmp_dest_dir-H1J41JaT.tmp
:f(!this.flag){this.hoge = false;}
my environment is following:
ember: 1.12.0
ember-cli: 0.2.7
ember-cli-babel: 5.1.5
ember-cli-defeatureify: 1.1.1
my defeatureify option is following:
defeatureify: {
'enableStripDebug': true,
'debugStatements': [
'Ember.default.debug',
'Ember.default.runInDebug'
],
'features': {}
}
Thanks
defeatureify: {
'enableStripDebug': true,
'debugStatements': [
'Ember.default.warn',
'Ember.default.assert',
'Ember.default.deprecate',
'Ember.default.debug',
'Ember.default.Logger.assert',
'Ember.default.Logger.debug',
'Ember.default.Logger.error',
'Ember.default.Logger.info',
'Ember.default.Logger.log',
'Ember.default.Logger.warn',
'console.assert',
'console.clear',
'console.count',
'console.debug',
'console.dir',
'console.dirxml',
'console.error',
'console.group',
'console.groupCollapsed',
'console.groupEnd',
'console.info',
// 'console.log',
'console.profile',
'console.profileEnd',
'console.select',
'console.table',
'console.time',
'console.timeEnd',
'console.trace',
'console.warn'
],
'features': {}
}
If uncomment the console.log
entry in the above configuration the error below is thrown. Have not had this issue when using a different version of Ember and this addon, but while using Ember 2.1.0 and version 1.1.1 of this addon it occurs:
Build failed.
File: assets/vendor.js (88398:229)
Unexpected token: punc ())
Error
at new JS_Parse_Error (eval at <anonymous> (/Users/me/projects/myApp/node_modules/ember-cli-uglify/node_modules/broccoli-uglify-sourcemap/node_modules/uglify-js/tools/node.js:1:0), <anonymous>:1508:18)
at js_error (eval at <anonymous> (/Users/me/projects/myApp/node_modules/ember-cli-uglify/node_modules/broccoli-uglify-sourcemap/node_modules/uglify-js/tools/node.js:1:0), <anonymous>:1516:11)
at croak (eval at <anonymous> (/Users/me/projects/myApp/node_modules/ember-cli-uglify/node_modules/broccoli-uglify-sourcemap/node_modules/uglify-js/tools/node.js:1:0), <anonymous>:2008:9)
at token_error (eval at <anonymous> (/Users/me/projects/myApp/node_modules/ember-cli-uglify/node_modules/broccoli-uglify-sourcemap/node_modules/uglify-js/tools/node.js:1:0), <anonymous>:2016:9)
at unexpected (eval at <anonymous> (/Users/me/projects/myApp/node_modules/ember-cli-uglify/node_modules/broccoli-uglify-sourcemap/node_modules/uglify-js/tools/node.js:1:0), <anonymous>:2022:9)
at eval (eval at <anonymous> (/Users/me/projects/myApp/node_modules/ember-cli-uglify/node_modules/broccoli-uglify-sourcemap/node_modules/uglify-js/tools/node.js:1:0), <anonymous>:2112:17)
at eval (eval at <anonymous> (/Users/me/projects/myApp/node_modules/ember-cli-uglify/node_modules/broccoli-uglify-sourcemap/node_modules/uglify-js/tools/node.js:1:0), <anonymous>:2055:24)
at block_ (eval at <anonymous> (/Users/me/projects/myApp/node_modules/ember-cli-uglify/node_modules/broccoli-uglify-sourcemap/node_modules/uglify-js/tools/node.js:1:0), <anonymous>:2335:20)
at eval (eval at <anonymous> (/Users/me/projects/myApp/node_modules/ember-cli-uglify/node_modules/broccoli-uglify-sourcemap/node_modules/uglify-js/tools/node.js:1:0), <anonymous>:2308:25)
at function_ (eval at <anonymous> (/Users/me/projects/myApp/node_modules/ember-cli-uglify/node_modules/broccoli-uglify-sourcemap/node_modules/uglify-js/tools/node.js:1:0), <anonymous>:2313:15)
DEPRECATION: Overriding init without calling this._super is deprecated.
Please call `this._super.init && this._super.init.apply(this, arguments);` addon: `ember-cli-defeatureify`
Version 1.1.1 and ember-cli
version 2.6.2.
Some users might want to use this package just to strip away debug and assert messages and instead of providing the config shown below, would it make sense to have a boolean option like stripDebugAndAsserts which can set these options internally?
defeatureify: {
'features': {},
'enableStripDebug': true,
'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'
]
}
If you find this useful I can make the change and send a PR
The way defeatureify works, is that it parses the code for a given namespace regardless of whether the namespace is defined or not. This means that if you have a namespace that contains dashes (that #7 included), using window['special-namespace'].FEATURES.isEnabled('a-feature')
won't actually remove the feature from the code (since defeaureify only looks for the namespace). When building in production, this will most likely result in an error, since window['special-namespace']
is undefined.
A fix for this might be to camelize the namespace using something like Ember's String.prototype.camelize
, making a namespace like special-namespace
become specialNamespace
. This will need to be noted in the readme.
Its common now to have destructured code like,
let {
assert,
debug
} = Ember;
and use those functions, defeatureify doesn't seem to remove those statements.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.