Skip to content

Add feature flags for Phase 2#13324

Merged
gziolo merged 22 commits intomasterfrom
try/feature-flags
Feb 15, 2019
Merged

Add feature flags for Phase 2#13324
gziolo merged 22 commits intomasterfrom
try/feature-flags

Conversation

@talldan
Copy link
Copy Markdown
Contributor

@talldan talldan commented Jan 15, 2019

Description

An attempt at introducing feature flags for phase 2 (see #11016).

The proposal is to use webpack's define plugin (https://webpack.js.org/plugins/define-plugin/) to replace instances of process.env.GUTENBERG_PHASE with an integer denoting the phase (1 or 2) during the build.

Within the codebase, the GUTENBERG_PHASE variable would be used to conditionally avoid executing code:

// file A
function futurePhaseTwoFeature() {
  // implementation
}

export const phaseTwoFeature = process.env.GUTENBERG_PHASE === 2 ? futurePhaseTwoFeature : undefined;

// file B
import { phaseTwoFeature } from 'file-a';

// ...
if ( process.env.GUTENBERG_PHASE === 2 ) {
  phaseTwoFeature();
}

When building for core, the majority code would be stripped out by webpack's minfication/dead code elimination process.

This PR also introduces docs and linting rules to ensure that process.env.GUTENBERG_PHASE is used in the correct way.

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Framework Issues related to broader framework topics, especially as it relates to javascript [Type] Build Tooling Issues or PRs related to build tooling [Type] Task Issues or PRs that have been broken down into an individual action to take

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants