Change import behavior to distinguish internal, WordPress, and external dependencies #716
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.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
andBlockSwitcher
), moved to the top of their directory structure (blocks/editable
andeditor/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
).components
top-level directory, moving shared components (Button
,Dashicon
,IconButton
) Add root components directory #736blocks
andeditor
directory, movingcomponents
of 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';