Skip to content

Commit

Permalink
Use data, element packages directly from GB folder
Browse files Browse the repository at this point in the history
Edit the files in the `build/` subfolders directly to have hot-reload
work. If you change the ones in `src/` then the packages need to be
rebuilt via GB (npm run build:packages).

* Metro does its magic here and finds the packages directly in the
gutenberg/packages folder automagically
* Jest needs to be configured to find them (mapping)
* Flow needs configuration too
  • Loading branch information
hypest committed Jul 6, 2018
1 parent b032829 commit aac9681
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ munge_underscores=true

module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'
module.name_mapper='@gutenberg' -> '<PROJECT_ROOT>/gutenberg'
module.name_mapper='@wordpress/data' -> '<PROJECT_ROOT>/gutenberg/packages/data'
module.name_mapper='@wordpress/element' -> '<PROJECT_ROOT>/gutenberg/packages/element'

; mock/ignore style files
module.name_mapper='.*\(.scss\)' -> 'empty/object'
Expand Down
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ module.exports = {
],
moduleNameMapper: {
'@wordpress\\/(blocks|editor)$': '<rootDir>/gutenberg/$1',
'@wordpress\\/(data|element|deprecated)$': '<rootDir>/gutenberg/packages/$1',
'@gutenberg': '<rootDir>/gutenberg',

// Mock the CSS modules. See https://facebook.github.io/jest/docs/en/webpack.html#handling-static-assets
Expand Down
4 changes: 0 additions & 4 deletions rn-cli.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/** @format */
const blacklist = require( 'metro' ).createBlacklist;

const enm = require( 'node-libs-react-native' );
enm.fs = __dirname + '/__mocks__/nodejsMock.js';
Expand All @@ -8,9 +7,6 @@ enm.canvas = __dirname + '/__mocks__/nodejsMock.js';

module.exports = {
extraNodeModules: enm,
getBlacklistRE: function() {
return blacklist( [ /gutenberg\/packages\/.*/ ] );
},
getTransformModulePath() {
return require.resolve( './sass-transformer.js' );
},
Expand Down

0 comments on commit aac9681

Please sign in to comment.