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 assert and debug code from production builds of app.js #3200

Closed
sivakumar-kailasam opened this Issue Feb 4, 2015 · 14 comments

Comments

Projects
None yet
7 participants
@sivakumar-kailasam
Member

sivakumar-kailasam commented Feb 4, 2015

Since Ember assert and debug modules are replaced with noop function in production builds, does it make sense to strip away assert and debug code from app.js? Would definitely lead to a smaller footprint in the minified file. This would definitely motivate everyone to write more assert and debug messages.

@sivakumar-kailasam sivakumar-kailasam changed the title from Remove assert and debug code to Remove assert and debug code from production builds of app.js Feb 4, 2015

@rwjblue

This comment has been minimized.

Show comment
Hide comment
@rwjblue

rwjblue Feb 4, 2015

Contributor

Yes, this should (very recently) be possible with ember-cli-defeatureify. I believe it may need a little more work to be compatible with CSP, but generally it looks really good.

Contributor

rwjblue commented Feb 4, 2015

Yes, this should (very recently) be possible with ember-cli-defeatureify. I believe it may need a little more work to be compatible with CSP, but generally it looks really good.

@rwjblue

This comment has been minimized.

Show comment
Hide comment
@rwjblue

rwjblue Feb 4, 2015

Contributor

/cc @jkarsrud

Contributor

rwjblue commented Feb 4, 2015

/cc @jkarsrud

@sivakumar-kailasam

This comment has been minimized.

Show comment
Hide comment
@sivakumar-kailasam

sivakumar-kailasam Feb 5, 2015

Member

awesome, anything I can do to help out?

Member

sivakumar-kailasam commented Feb 5, 2015

awesome, anything I can do to help out?

@jkarsrud

This comment has been minimized.

Show comment
Hide comment
@jkarsrud

jkarsrud Feb 7, 2015

Contributor

@sivakumar-kailasam I've pushed some docs and updated the code in ember-cli-defeatureify to be CSP compatible after #3218. It works if you run off master now, but also when 0.1.13 ships.

Contributor

jkarsrud commented Feb 7, 2015

@sivakumar-kailasam I've pushed some docs and updated the code in ember-cli-defeatureify to be CSP compatible after #3218. It works if you run off master now, but also when 0.1.13 ships.

@sivakumar-kailasam

This comment has been minimized.

Show comment
Hide comment
@sivakumar-kailasam

sivakumar-kailasam Feb 7, 2015

Member

Awesome 👍 just tried it on my app. From the ember source code this looks particularly useful to strip away code based on canary/any specific features during build. But in apps like mine where we just want to strip away debug and assert messages now we have to add an extra if wrapper around it to achieve that. This is a big step over what we have today but I'm wondering if there could be a simpler way to achieve this by just dropping an addon without changes to existing code.

Member

sivakumar-kailasam commented Feb 7, 2015

Awesome 👍 just tried it on my app. From the ember source code this looks particularly useful to strip away code based on canary/any specific features during build. But in apps like mine where we just want to strip away debug and assert messages now we have to add an extra if wrapper around it to achieve that. This is a big step over what we have today but I'm wondering if there could be a simpler way to achieve this by just dropping an addon without changes to existing code.

@jkarsrud

This comment has been minimized.

Show comment
Hide comment
@jkarsrud

jkarsrud Feb 7, 2015

Contributor

It should strip out debug and assert messages if you pass them in to debugStatements array along with enableStripDebug under the defeatureify object in your config.

Contributor

jkarsrud commented Feb 7, 2015

It should strip out debug and assert messages if you pass them in to debugStatements array along with enableStripDebug under the defeatureify object in your config.

@rwjblue

This comment has been minimized.

Show comment
Hide comment
@rwjblue

rwjblue Feb 7, 2015

Contributor

I've been chatting with @mmun and I think we can also make a way to do the same kind of stripping for templates (by walking the AST on precompile), ember-cli-defeatureify seems like a great place for this...

Contributor

rwjblue commented Feb 7, 2015

I've been chatting with @mmun and I think we can also make a way to do the same kind of stripping for templates (by walking the AST on precompile), ember-cli-defeatureify seems like a great place for this...

@sivakumar-kailasam

This comment has been minimized.

Show comment
Hide comment
@sivakumar-kailasam

sivakumar-kailasam Feb 7, 2015

Member

I tried two different configs from what I could figure from the docs and both don't seem to work.

defeatureify: {
        'strip_debug': {
            options: {
                'enableStripDebug': true,
                'debugStatements': [
                    'Ember.warn',
                    'Ember.assert',
                    'Ember.deprecate',
                    'Ember.debug',
                    'Ember.Logger.info'
                ]
            }
        },
        'features': {

        }
    }

and

defeatureify: {
         'enableStripDebug': true,
         'debugStatements': [
            'Ember.warn',
            'Ember.assert',
            'Ember.deprecate',
            'Ember.debug',
            'Ember.Logger.info'             
        ],
    'features': {

        }
}
Member

sivakumar-kailasam commented Feb 7, 2015

I tried two different configs from what I could figure from the docs and both don't seem to work.

defeatureify: {
        'strip_debug': {
            options: {
                'enableStripDebug': true,
                'debugStatements': [
                    'Ember.warn',
                    'Ember.assert',
                    'Ember.deprecate',
                    'Ember.debug',
                    'Ember.Logger.info'
                ]
            }
        },
        'features': {

        }
    }

and

defeatureify: {
         'enableStripDebug': true,
         'debugStatements': [
            'Ember.warn',
            'Ember.assert',
            'Ember.deprecate',
            'Ember.debug',
            'Ember.Logger.info'             
        ],
    'features': {

        }
}
@mmun

This comment has been minimized.

Show comment
Hide comment
@mmun
Member

mmun commented Feb 7, 2015

@sivakumar-kailasam

This comment has been minimized.

Show comment
Hide comment
@sivakumar-kailasam

sivakumar-kailasam Feb 8, 2015

Member

After adding the Ember.default.* versions of debug and assert in my config the messages were stripped out. Thanks @jkarsrud 💯

Member

sivakumar-kailasam commented Feb 8, 2015

After adding the Ember.default.* versions of debug and assert in my config the messages were stripped out. Thanks @jkarsrud 💯

@jkarsrud

This comment has been minimized.

Show comment
Hide comment
@jkarsrud

jkarsrud Feb 8, 2015

Contributor

@sivakumar-kailasam That makes sense, as this addon runs after the module transpilation step. Glad you figured it out! 😃

@rwjblue Are you thinking of stripping the templates based on feature flags? If so, that would be a really useful feature, and one that could definitely be built into ember-cli-defeatureify at some point!

Contributor

jkarsrud commented Feb 8, 2015

@sivakumar-kailasam That makes sense, as this addon runs after the module transpilation step. Glad you figured it out! 😃

@rwjblue Are you thinking of stripping the templates based on feature flags? If so, that would be a really useful feature, and one that could definitely be built into ember-cli-defeatureify at some point!

@alexBaizeau

This comment has been minimized.

Show comment
Hide comment
@alexBaizeau

alexBaizeau Feb 8, 2015

👍 for "defeaturifying" templates.

My use case would be able to ship features both in JS and templates to our staging environment but strip them out of our production code.

The main reason is that I'd like to be be able to QA and demo some half finish features but hide them from my users. A beneficial side effect would be to be able to be stealthy about our roadmap as inspecting the code/templates would not reveal what's still in progress.

alexBaizeau commented Feb 8, 2015

👍 for "defeaturifying" templates.

My use case would be able to ship features both in JS and templates to our staging environment but strip them out of our production code.

The main reason is that I'd like to be be able to QA and demo some half finish features but hide them from my users. A beneficial side effect would be to be able to be stealthy about our roadmap as inspecting the code/templates would not reveal what's still in progress.

@stefanpenner

This comment has been minimized.

Show comment
Hide comment
@stefanpenner

stefanpenner Feb 24, 2015

Contributor

This seems to be handled by the ember-cli-defeaturify addon, any further issues or requests should be targeted there. If issues with ember-cli exist that prevent that addon from doing what it should, we can gladly open a new issue.

Contributor

stefanpenner commented Feb 24, 2015

This seems to be handled by the ember-cli-defeaturify addon, any further issues or requests should be targeted there. If issues with ember-cli exist that prevent that addon from doing what it should, we can gladly open a new issue.

@kimroen kimroen referenced this issue Feb 24, 2015

Open

Defeatureify templates #12

0 of 2 tasks complete
@notmessenger

This comment has been minimized.

Show comment
Hide comment
@notmessenger

notmessenger Mar 11, 2015

To save anyone typing later, this is the configuration I am using to strip all debug statements:

        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': {}
        }

notmessenger commented Mar 11, 2015

To save anyone typing later, this is the configuration I am using to strip all debug statements:

        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': {}
        }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment