Skip to content
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

Change import behavior to distinguish internal, WordPress, and external dependencies #716

Merged
merged 2 commits into from
May 9, 2017

Conversation

aduth
Copy link
Member

@aduth aduth commented May 8, 2017

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.md document 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 Editable and BlockSwitcher), moved to the top of their directory structure (blocks/editable and editor/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 (like components/dashicon).

@aduth aduth added the Framework Issues related to broader framework topics, especially as it relates to javascript label May 8, 2017
@aduth aduth requested a review from mtias May 8, 2017 21:52
@@ -9,7 +9,7 @@ import clickOutside from 'react-click-outside';
* Internal dependencies
*/
import './style.scss';
import IconButton from 'components/icon-button';
import IconButton from '../icon-button';

class BlockSwitcher extends wp.element.Component {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we change these to import { Component } from 'element';?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"

@aduth aduth force-pushed the update/import-roots branch from e5aed3e to 73f1398 Compare May 9, 2017 16:14
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants