The team is now working on the WordPress Interactivity API. This unblocks the same UX Frontity framework enabled but directly in WordPress Core, fully compatible with the new Site Editor.
So our starting bundle will weight only a third than the previous version
I hope Lighthouse likes it more this time
luisherranz2
I have been thinking if we should interface some of those packages.
For example, use frontity/dynamic to interface loadable-components. That means users would do
import dynamic from 'frontity/dynamic'
const OtherComponent = dynamic(() => import('./OtherComponent'))
instead of
import loadable from '@loadable/component'
const OtherComponent = loadable(() => import('./OtherComponent'))
Same for the other packages:
import useStores from 'frontity/stores'
// instead of
import { useOvermind } from 'overmind-react'
import Head from 'frontity/head'
// instead of
import { Helmet } from 'react-helmet'
import { Slot, Fill } from 'frontity/slot-and-fill'
// instead of
import { Slot, Fill } from 'react-slot-fill'
import { css, styled } from 'frontity/styles'
// instead of
import { css } from '@emotion/core'
import { styled } from '@emotion/styled'
It’s not to obscure that those packages are coming from their original packages but to help in package migrations. For example, in the future, we may move react-helmet to another, much smaller or much more performant package. This way the update won’t be major as long as the basic API remains the same and users won’t have to refactor their themes/extensions.
import Head from 'next/head'
function IndexPage() {
return (
<div>
<Head>
<title>My page title</title>
<meta name="viewport" content="initial-scale=1.0, width=device-width" />
</Head>
<p>Hello world!</p>
</div>
)
}
export default IndexPage
So there are examples of both. I think our case is more similar to Next because users can’t decide what library to use.
luisherranz5
Following the conversation here.
If we are going to use things like @frontity/types/packages or @frontity/api/analytics I think we can use @frontity for everything. For example:
// instead of
import { Helmet } from 'react-helmet'
// or
import Head from 'frontity/head'
// use
import Head from '@frontity/head'
and so on
// instead of
import { css } from '@emotion/core'
import { styled } from '@emotion/styled'
// use
import { css, styled } from '@frontity/css'
// instead of
import { Slot, Fill } from 'react-slot-fill'
// use
import { Slot, Fill } from '@frontity/slot-fill'
We keep the frontity package for the CLI only.
luisherranz6
We need to decide this.
My last proposal is: use frontity for everything!
Why? Because it’s easier to remember. Two ways:
Direct imports:
import Head from 'frontity/head'
import css from 'frontity/css'
import styled from 'frontity/styled'
import dynamic from 'frontity/dynamic'
import connect from 'frontity/connect'
import Slot from 'frontity/slot'
import Fill from 'frontity/fill'
Named imports from the root:
import { Head, css, styled, dynamic... } from 'frontity'
That’s it.
2 Likes
luisherranz7
I’m tempted to do it for types as well:
import Package from 'frontity/types/package'
import Settings from 'frontity/types/settings'
import Action from 'frontity/types/action'
import Derived from 'frontity/types/derived'
and
import { Package, Settings, Action... } from 'frontity/types'
and
import Source from 'frontity/types/source'
import Router from 'frontity/types/router'
import Comments from 'frontity/types/comments'
And leave @frontity/... only for official themes and extensions.
2 Likes
orballo8
I think it’s a good idea.
David9
Indeed.
luisherranz10
We need to maintain @frontity/types to avoid a circular dependency between frontity and @frontity/core.
But I will use frontity/types to export stuff from @frontity/types anyway.
I have to say, the packages we need are rather small (react-helmet, @frontity/connect, @emotion/core…). I think npx frontity would still be fast.
orballo12
I don’t understand what you mean when you say we need to install @frontity/connect in frontity. Why? I mean, you’ll use npx frontity mostly with the create command and I don’t see where we need @frontity/connect.
If you were to run frontity dev or any of its sibling commands, you would already need to have installed @frontity/core and its dependencies.
luisherranz13
It is related to the idea of using imports from frontity/... like this:
import Head from 'frontity/head'
import css from 'frontity/css'
import styled from 'frontity/styled'
import dynamic from 'frontity/dynamic'
import connect from 'frontity/connect'
import Slot from 'frontity/slot'
import Fill from 'frontity/fill'
If we want to do this, the packages needs to be installed in frontity because Webpack needs static imports.
import Head from 'frontity/head'
import css from 'frontity/css'
import styled from 'frontity/styled'
import dynamic from 'frontity/dynamic'
import connect from 'frontity/connect'
import Slot from 'frontity/slot'
import Fill from 'frontity/fill'
import Package from 'frontity/types/package'
import Action from 'frontity/types/action'
// Packages
dependencies: {
"frontity": "^1.0.0"
}
import Head from '@frontity/head'
import css from '@frontity/css'
import styled from '@frontity/styled'
import dynamic from '@frontity/dynamic'
import connect from '@frontity/connect'
import Slot from '@frontity/slot'
import Fill from '@frontity/fill'
import Package from '@frontity/types/package'
import Action from '@frontity/types/action'
// Packages
dependencies: {
"@frontity/types": "^1.0.0",
"@frontity/css": "^1.0.0",
"@frontity/styled": "^1.0.0"
...
}