neos / neos-ui

Neos CMS UI written in ReactJS with Immutable data structures.
GNU General Public License v3.0
265 stars 135 forks source link

Remove PlowJS & immutable-js #3118

Closed grebaldi closed 1 year ago

grebaldi commented 2 years ago

Motivation

Once upon a time, I've decided to create PlowJS, a library that would ease the handling of immutable state within the redux reducers of the Neos UI.

It seemed like a good idea at the time, but the JavaScript ecosystem has changed drastically since (and not exactly in favor of such a solution :sweat_smile:).

There's several reasons why PlowJS has become a liability to the Neos UI code base:

The original purpose of PlowJS was to support the development of redux reducers. We already had a discussion about this a couple of years ago and decided to replace PlowJS with immer. Many (if not most) reducers have already been refactored since.

But PlowJS is being used everywhere because of it's convenient feature to hide the API of immutable-js from us.

The goal of this issue is therefore to remove both PlowJS and immutable-js entirely from the codebase.

Acceptance Criteria

References

grebaldi commented 2 years ago

Seems like immutable js is already gone from the codebase. That'll make things easier :)

mhsdesign commented 2 years ago

plow js is often used in the hoc @neos decorators, if we get around writing stuff in hooks, then we dont need plow-js in these places anymore ;)

grebaldi commented 1 year ago

Bad News:

I've just noticed, that Plow is being leaked as API for Inspector Views. Here's an example:

https://github.com/neos/neos-ui/blob/8.3/packages/neos-ui-views/src/Data/ColumnView/index.js#L24

https://github.com/Flowpack/neos-matomo/blob/0cc2034d5b866b9860a0fad3521c4ea9299b7b9a/Configuration/NodeTypes.yaml#L90-L92

data is a dot-separated path being passed plainly to the view that will read the respective value from the result of the data source. This will stop working, once Plow JS is removed.

We will need to support this use case, but that doesn't require the entirety of Plow. It's probably best to have a utility function native to the UI code base that can replace $get for this purpose.

mhsdesign commented 1 year ago

Plugin vendors using esbuild or the alias feature directly can, if they want to bundle plow-js directly (to avoid deprecation warnings), exclude plow-js from the map:

const {"plow-js": _, ...extensibilityMap} = require("@neos-project/neos-ui-extensibility/extensibilityMap.json");

build({
   alias: extensibilityMap
})