-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Packages: Move data module to the package maintained by Lerna #6828
Conversation
For me it's fine. I think it's not even used by default unless you explicitly import the persisting helper. |
Since this is the first packages that users So what I propose is to do something similar to React:
|
packages/data/README.md
Outdated
@@ -1,9 +1,17 @@ | |||
# Data | |||
# @wordpress/date |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be @wordpress/data
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copy pasta 😃
0f721cd
to
04e52b0
Compare
True, however, I added a way to override the default persistence storage with 04e52b0 :) |
Sounds like a good idea. With the small exception, we should limit Eslint check to |
04e52b0
to
d458cb9
Compare
Done with 6c26c4b. There is one more thing which popped up after rebase. We need to move |
075da81
to
d1f6717
Compare
Introduced also |
@gziolo Do you think it's possible to extract the devtools package to its own PR, I feel it could make it way quicker than the data one? |
Sure thing - it is in its own commit - doing it now. |
@youknowriad - I opened #6914 with |
d1f6717
to
169ae93
Compare
|
}, | ||
}, | ||
}, | ||
], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe we still need a similar config for babel to generate the Right JS (instead of using the global)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confirmed, I will look into it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be fixed with f7afc46.
169ae93
to
f7afc46
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with explicit createElement
pragma. Would hope we'd apply it consistently eventually.
bin/packages/build.js
Outdated
@@ -36,6 +36,8 @@ const DONE = chalk.reset.inverse.bold.green( ' DONE ' ); | |||
*/ | |||
const babelDefaultConfig = require( '@wordpress/babel-preset-default' ); | |||
babelDefaultConfig.babelrc = false; | |||
// TODO: It should become the default value when all modules are moved to packages. | |||
babelDefaultConfig.plugins[ 1 ][ 1 ].pragma = 'createElement'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Must we mutate? Can we assign into a new object? Not sure what would break, but certainly seems prone to cause breakage as implemented.
- Similarly, the
[ 1 ][ 1 ]
assumes a very specific order which, while we maintain and is unlikely to change anytime soon, is certainly incredibly fragile.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I opted for a quick fix with the hope that it won't last for long. I guess it is going to be around for a couple of weeks at least so I'm happy to provide more solid processing of default Babel config.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fdb107e - done
packages/data/README.md
Outdated
Install the module | ||
|
||
```bash | ||
npm install @wordpress/data@next --save |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we @next
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, we can publish alpha without using dev :)
"url": "https://github.com/WordPress/gutenberg/issues" | ||
}, | ||
"main": "src/index.js", | ||
"dependencies": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests use deep-freeze
and enzyme
. Do we need to reflect that anywhere in this file as a dependency?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that we are going to move those packages elsewhere one day, let's keep all dependencies listed. I will add them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I forgot that enzyme
is already included in @wordpress/scripts
by design.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should be explicit :) If we use enzyme
directly here in our tests, it should be a direct dependency
packages/data/package.json
Outdated
{ | ||
"name": "@wordpress/data", | ||
"version": "0.0.1", | ||
"description": "Data Redux module for WordPress", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation clearly states:
The data module is built upon and shares many of the same core principles of Redux, but shouldn't be mistaken as merely Redux for WordPress
Is this not in contradiction?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is, I will update.
@@ -8,6 +8,18 @@ import deprecated from '@wordpress/deprecated'; | |||
*/ | |||
import { get } from 'lodash'; | |||
|
|||
// Defaults to the local storage. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So we default to a broken (error-throwing) state for Node environments where this package is used?
It's probably a larger dependency than we'd want, but something like Store.js is a good abstraction for this sort of thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really, you can make it work by using setter method introduced in this PR:
import store from 'store';
setPersistenceStorage( store );
It isn't ideal, needs to be documented but should allow us to move forward. I will add the following example in the README file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's tackle it seperately as we don't have any docs for loadAndPersist
anyways.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opened #7015 to solve it.
Let's get it in and see how it goes 🎉 |
Description
Related issues: #3955, #6594.
Similar: #6658, #6756, #6758.
After moving
date
andelement
, this PR movesdata
module topackages
folder maintained byLerna
.This is the first time where a package depends on another Gutenberg package (
element
).Open question
data
module useswindow.localStorage
which won't work in non-browser environments. Are we fine with having it included in the initial release? Should we add guard which disable persistence when local storage is not provided?How has this been tested?
Manually:
node_modules
folder.npm install
npm test
npm run dev
npm run build
npm run package-plugin
Types of changes
Refactoring.
Checklist: