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 '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'
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.
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.
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"
...
}