All Projects → ember-cli → Babel Plugin Debug Macros

ember-cli / Babel Plugin Debug Macros

Programming Languages

javascript
184084 projects - #8 most used programming language
macros
77 projects

Projects that are alternatives of or similar to Babel Plugin Debug Macros

Braid Design System
Themeable design system for the SEEK Group
Stars: ✭ 888 (+6242.86%)
Mutual labels:  babel
Video Containers Debugging Tools
A set of command lines to debug video streaming files like mp4 (MPEG-4 Part 14), ts (MPEG-2 Part 1), fmp4 in Dash, HLS, or MSS, with or without DRM.
Stars: ✭ 27 (+92.86%)
Mutual labels:  debugging
Dbgbench.github.io
DBGBench Website:
Stars: ✭ 11 (-21.43%)
Mutual labels:  debugging
Pegviz
PEG trace visualizer
Stars: ✭ 18 (+28.57%)
Mutual labels:  debugging
Wordpress Starter
📦 A starter template for WordPress websites
Stars: ✭ 26 (+85.71%)
Mutual labels:  babel
Flask Bones
An example of a large scale Flask application using blueprints and extensions.
Stars: ✭ 849 (+5964.29%)
Mutual labels:  babel
Generator Node Module
A Yeoman module to author Node libraries with Prettier, Jest, Flow and Babel.
Stars: ✭ 16 (+14.29%)
Mutual labels:  babel
Babel Plugin Danger Remove Unused Import
babel-plugin-danger-remove-unused-import
Stars: ✭ 12 (-14.29%)
Mutual labels:  babel
Dpcwait
Driver demonstrating how to register a DPC to asynchronously wait on an object
Stars: ✭ 27 (+92.86%)
Mutual labels:  debugging
Debug kit
Debug Toolbar for CakePHP applications.
Stars: ✭ 858 (+6028.57%)
Mutual labels:  debugging
Unitydbgdraw
DbgDraw is an API that provides the ability to render various 2D and 3D shapes for visual debugging purposes.
Stars: ✭ 20 (+42.86%)
Mutual labels:  debugging
Epsagon Go
Automated tracing library for Go 1.x ⚡️
Stars: ✭ 24 (+71.43%)
Mutual labels:  debugging
Online Bling
Stars: ✭ 9 (-35.71%)
Mutual labels:  babel
React Native Dotenv
A Babel preset let you import application configs from .env file (zero runtime dependency)
Stars: ✭ 895 (+6292.86%)
Mutual labels:  babel
Electron Webpack Boilerplate
use webpack2 to bundle react app in electron
Stars: ✭ 11 (-21.43%)
Mutual labels:  babel
Eylogviewer
A simple viewer to see your app's logs on your iDevice in realtime.
Stars: ✭ 16 (+14.29%)
Mutual labels:  debugging
Next Boilerplate
A well-structured production ready Next.js boilerplate with Typescript, Redux, Jest, Enzyme, Express.js, Sass, Css, EnvConfig, Fetch, Reverse Proxy, Bundle Analyzer and Built-in Project CLI. https://pankod.github.io/next-boilerplate/
Stars: ✭ 936 (+6585.71%)
Mutual labels:  babel
Babel Plugin Styled Components
Improve the debugging experience and add server-side rendering support to styled-components
Stars: ✭ 878 (+6171.43%)
Mutual labels:  babel
Ember Api Feature Flags
API based, read-only feature flags for Ember
Stars: ✭ 11 (-21.43%)
Mutual labels:  feature-flags
Yarn Package Boilerplate
An Yarn package with babel, jest, flow, prettier and more
Stars: ✭ 10 (-28.57%)
Mutual labels:  babel

Babel Debug Macros And Feature Flags

This provides debug macros and feature flagging.

Setup

The plugin takes 4 types options: flags, svelte, debugTools, and externalizeHelpers. The importSpecifier is used as a hint to this plugin as to where macros are being imported and completely configurable by the host.

Like Babel you can supply your own helpers using the externalizeHelpers options.

{
  plugins: [
    ['babel-debug-macros', {
      // @optional
      debugTools: {
        isDebug: true,
        source: 'debug-tools',
        // @optional
        assertPredicateIndex: 0
      },

      flags: [
        { source: '@ember/env-flags', flags: { DEBUG: true } },
        {
          name: 'ember-source',
          source: '@ember/features',
          flags: {
            FEATURE_A: false,
            FEATURE_B: true,
            DEPRECATED_CONTROLLERS: "2.12.0"
          }
        }
      ],

      // @optional
      svelte: {
        'ember-source': "2.15.0"
      },

      // @optional
      externalizeHelpers: {
        module: true,
        // global: '__my_global_ns__'
      }
    }]
  ]
}

Flags and features are inlined into the consuming module so that something like UglifyJS will DCE them when they are unreachable.

Simple environment and feature flags

import { DEBUG } from '@ember/env-flags';
import { FEATURE_A, FEATURE_B } from '@ember/features';

if (DEBUG) {
  console.log('Hello from debug');
}

let woot;
if (FEATURE_A) {
  woot = () => 'woot';
} else if (FEATURE_B) {
  woot = () => 'toow';
}

woot();

Transforms to:

if (true /* DEBUG */) {
  console.log('Hello from debug');
}

let woot;
if (false /* FEATURE_A */) {
  woot = () => 'woot';
} else if (true) {
  woot = () => 'toow';
}

woot();

warn macro expansion

import { warn } from 'debug-tools';

warn('this is a warning');

Expands into:

(true && console.warn('this is a warning'));

assert macro expansion

The assert macro can expand in a more intelligent way with the correct configuration. When babel-plugin-debug-macros is provided with the assertPredicateIndex the predicate is injected in front of the assertion in order to avoid costly assertion message generation when not needed.

import { assert } from 'debug-tools';

assert((() => {
  return 1 === 1;
})(), 'You bad!');

With the debugTools: { assertPredicateIndex: 0 } configuration the following expansion is done:

(true && !((() => { return 1 === 1;})()) && console.assert(false, 'this is a warning'));

When assertPredicateIndex is not specified, the following expansion is done:

(true && console.assert((() => { return 1 === 1;})(), 'this is a warning'));

deprecate macro expansion

import { deprecate } from 'debug-tools';

let foo = 2;

deprecate('This is deprecated.', foo % 2);

Expands into:

let foo = 2;

(true && !(foo % 2) && console.warn('This is deprecated.'));

Externalized Helpers

When you externalize helpers you must provide runtime implementations for the above macros. An expansion will still occur, however we will emit references to those runtime helpers.

A global expansion looks like the following:

import { warn } from 'debug-tools';

warn('this is a warning');

Expands into:

(true && Ember.warn('this is a warning'));

While externalizing the helpers to a module looks like the following:

import { warn } from 'debug-tools';

warn('this is a warning');

Expands into:

(true && warn('this is a warning'));

Svelte

Svelte allows for consumers to opt into stripping deprecated code from your dependecies. By adding a package name and minimum version that contains no deprecations, that code will be compiled away.

For example, consider you are on [email protected] and you have no deprecations. All deprecated code in ember-source that is <=2.10.0 will be removed.


svelte: {
  "ember-source": "2.10.0"
}

Now if you bump to [email protected] you may encounter new deprecations. The workflow would then be to clear out all deprecations and then bump the version in the svelte options.

svelte: {
  "ember-source": "2.11.0"
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].