GithubHelp home page GithubHelp logo

ember-cli-defeatureify's People

Contributors

dwickern avatar ember-tomster avatar jkarsrud avatar nathanhammond avatar rwjblue avatar sivakumar-kailasam avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ember-cli-defeatureify's Issues

Generate a module instead of using globals.

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?

Enable Travis CI?

Its great that you have tests, you should enable Travis and add a badge to your README to flaunt it!

Defeatureify templates

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:

  • Do we have the tools in ember-cli to do this? If not, what is needed should be identified and then issues created there to get it working.
  • Syntax. It doesn't really matter as it will be stripped, but maybe it should look like handlebars for syntax highlighting's sake? Or maybe it shouldn't, so it's clear it's not a part of the template?

There were some interest in solving this by @rwjblue, @mmun and @alexBaizeau

The first character in next statement is removed when I write multiple statements on a single line.

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?

  • in babel-output_path-jVys26A1.tmp
    Ember.debug('test');if(!this.flag){this.hoge = false;}
  • in 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

Populating "debugStatements" with "console.log" entry causes error

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)

Simplify the option to remove debug and assert messages in production builds

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

Camelize namespace if it contains dashes

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.

/cc @sivakumar-kailasam

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.