Change import behavior to distinguish internal, WordPress, and external dependencies#716
Merged
Change import behavior to distinguish internal, WordPress, and external dependencies#716
Conversation
youknowriad
reviewed
May 9, 2017
Contributor
There was a problem hiding this comment.
Should we change these to import { Component } from 'element';?
Member
Author
There was a problem hiding this comment.
Should we change these to
import { Component } from 'element';?
Yep, I'll cover this in this next step: "Replace wp. global references with respective "WordPress dependency" equivalent"
mtias
approved these changes
May 9, 2017
youknowriad
approved these changes
May 9, 2017
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request is a first step in a series of pull requests aimed at providing a better structure for sharing code within top-level directories and across top-level directories, with side objectives of flattening directories and creating clearer distinctions of what a module is expected to export. See "Next steps" for more context on what's left to be done.
To inform and justify these changes, the
docs/coding-guidelines.mddocument has been updated with these changes describing the role each dependency serves:https://github.com/WordPress/gutenberg/blob/71dab6f/docs/coding-guidelines.md#javascript
Effectively this modifies module resolution to the root project directory, encourages relative path imports within a subfolder, and imports across subfolders prefixed by directory name.
Testing instructions:
Ensure the build completes, tests pass, and editor initializes without regressions.
Next steps:
This is a first step in creating a new components directory which will serve as a resource for general-purpose components. We will default to creating components in respective features (like
EditableandBlockSwitcher), moved to the top of their directory structure (blocks/editableandeditor/block-switcher), and allow them to be extracted or abstracted into general purpose components only when they've proven to serve purpose across multiple features (likecomponents/dashicon).componentstop-level directory, moving shared components (Button,Dashicon,IconButton) Add root components directory #736blocksandeditordirectory, movingcomponentsof each up one level Flatten blocks directory #737, Flatten editor directory #739wp.global references with respective "WordPress dependency" equivalent Replace wp globals with module equivalents #742wp.i18n.__toimport { __ } from 'i18n';