Skip to content
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

Revert "fix: use lerna to share code instead of copying resources (#214) #216

Merged
merged 1 commit into from
Feb 27, 2019

Conversation

jenniferarnesen
Copy link
Collaborator

@jenniferarnesen jenniferarnesen commented Feb 20, 2019

This reverts commit eecfea0.

The code-sharing solution does not work when the plugin is pulled in as a dependency in other apps (e.g., dashboards), since imports like:

import { apiFetchVisualization } from 'data-visualizer-app/src/api/visualization';

don't exist in dashboards. This code will have to remain duplicated until we are ready with a published, shared library.

@varl
Copy link
Contributor

varl commented Feb 20, 2019

How are you pulling in the plugin in dashboards?

You will need to create a plugin bundle file which contains all of the dependencies in the bundle. This requires building the plugin with e.g. Webpack.

@varl
Copy link
Contributor

varl commented Feb 20, 2019

Currently the plugin build is just a transpiled build: https://github.com/d2-ci/data-visualizer-plugin

@amcgee
Copy link
Member

amcgee commented Feb 20, 2019

I've been trying to work with the existing app/plugin split in DV and I don't find it usable. I really don't think they should exist as separate packages, they should just be separate entrypoints to the same package (i.e. webpack bundles as @varl mentioned). This isn't natively supported by CRA, but it could be layered on top of CRA. It will also be built into the next-gen app build infrastructure.

@jenniferarnesen
Copy link
Collaborator Author

jenniferarnesen commented Feb 20, 2019

You will need to create a plugin bundle file which contains all of the dependencies in the bundle. This requires building the plugin with e.g. Webpack.

I thought in general we did not want to create bundles, so that we can do treeshaking? If I do this, then I add more customization to the webpack file, which is what we want to move away from.

@amcgee
Copy link
Member

amcgee commented Feb 20, 2019

I thought in general we did not want to create bundles, so that we can do treeshaking?

I think that's a good goal eventually, but I don't think it's the right optimization here for two reasons:

  1. If any dependency in the tree isn't published on NPM, it can't be accessed by the consumer. So if Dashboards App is the consumer which does the bundling and tree shaking, then both plugin and app need to be published to npm (or they need to live together and have separate entrypoints, whether that's pre-bundled or not)
  2. Importantly, we're already duplicating all of the shared code between the plugin and the app, so tree shaking between i.e. DV and Dashboards doesn't make a whole ton of sense to me. The solution I'm working towards is using SplitChunksPlugin to pull out the common deps from plugin and app into a separate, cacheable chunk which can be referenced from both plugin and app bundles. That is open to duplication between a host app and a plugin, but it makes plugin for any given app self-contained and doesn't require all app plugins to be known and host-app compile time.

@jenniferarnesen
Copy link
Collaborator Author

I've been trying to work with the existing app/plugin split in DV and I don't find it usable.

Can you be more specific about what you dont find "usable"? Yes, I know it should be tagged so the apps can be assured to get the desired functionality. What else?

I really don't think they should exist as separate packages, they should just be separate entrypoints to the same package (i.e. webpack bundles as @varl mentioned). This isn't natively supported by CRA, but it could be layered on top of CRA. It will also be built into the next-gen app build infrastructure.

This requires more discussion, and doesn't really help me out right now. The issue I'm trying to fix right now is for the dashboard to build with a tagged version of the plugin so we get rid of the plugin issues that people are experiencing.

So yes, this is obviously a short term solution.

@amcgee
Copy link
Member

amcgee commented Feb 20, 2019

Can you be more specific about what you dont find "usable"? Yes, I know it should be tagged so the apps can be assured to get the desired functionality. What else?

It doesn't link into dashboards because the app code isn't transpiled. Bundling the plugin with webpack would solve this, so that it pulls in the dependent code from the app when it's built. I can take a stab at fixing that if you'd like.

I believe that's an alternative solution to backing out the switch to lerna and going back to using github for dependency resolution.

@jenniferarnesen
Copy link
Collaborator Author

Can you be more specific about what you dont find "usable"? Yes, I know it should be tagged so the apps can be assured to get the desired functionality. What else?

It doesn't link into dashboards because the app code isn't transpiled. Bundling the plugin with webpack would solve this, so that it pulls in the dependent code from the app when it's built. I can take a stab at fixing that if you'd like.

Go ahead :)

@varl
Copy link
Contributor

varl commented Feb 20, 2019

I really don't think they should exist as separate packages, they should just be separate entrypoints to the same package (i.e. webpack bundles as @varl mentioned).

App to app dependencies is a messy system architecture, and I do not think it's a good idea when considering the larger picture of our ecosystem. App to app dependencies is one point I am unwilling to budge on until we have exhausted all other options.

Having them in separate packages allows us to be explicit about which app has a plugin and which does not, and other apps can depend on the plugin. It's not a perfect solution but I vastly prefer it over app to app dependencies.

I thought in general we did not want to create bundles, so that we can do treeshaking?

When creating the plugin.bundle.js Webpack will tree-shake what it can from that bundle.

IIRC that plugin exposes a single component which presumably uses everything left in the bundle, so there shouldn't be anything left to shake out?

@varl
Copy link
Contributor

varl commented Feb 20, 2019

I believe that's an alternative solution to backing out the switch to lerna and going back to using github for dependency resolution.

Can we try the bundle route first?

@jenniferarnesen
Copy link
Collaborator Author

jenniferarnesen commented Feb 20, 2019

App to app dependencies is a messy system architecture, and I do not think it's a good idea when considering the larger picture of our ecosystem. App to app dependencies is one point I am unwilling to budge on until we have exhausted all other options.

Having them in separate packages allows us to be explicit about which app has a plugin and which does not, and other apps can depend on the plugin. It's not a perfect solution but I vastly prefer it over app to app dependencies.

I have another PR that I'm awaiting feedback on, where I am trying to figure out how to share other code. I agree that the "app" should not contain the shared code. #206

When creating the plugin.bundle.js Webpack will tree-shake what it can from that bundle.

IIRC that plugin exposes a single component which presumably uses everything left in the bundle, so there shouldn't be anything left to shake out?

It was more about what the dashboard ends up bundling. In the case of this plugin, there probably isn't much common code between dashboard and what the plugin uses, it was more of a principle thing.

@amcgee
Copy link
Member

amcgee commented Feb 20, 2019

IIRC that plugin exposes a single component which presumably uses everything left in the bundle, so there shouldn't be anything left to shake out?

Things like Mui aren't de-duplicated when bundled at the plugin level instead of at the host app (Dashboards) level (Dependencies could theoretically exist in the host app and also every plugin). So yeah, we're good for tree-shaking but not for de-duplication.

App to app dependencies is a messy system architecture, and I do not think it's a good idea when considering the larger picture of our ecosystem. App to app dependencies is one point I am unwilling to budge on until we have exhausted all other options.

Having them in separate packages allows us to be explicit about which app has a plugin and which does not, and other apps can depend on the plugin. It's not a perfect solution but I vastly prefer it over app to app dependencies.

I agree we should avoid arbitrary app-to-app dependencies (which is exactly what we have here, just with a "plugin" shim between the two apps). However, having two different "artifacts" of an app build (one app, one plugin) seems quite a bit safer.

@amcgee
Copy link
Member

amcgee commented Feb 20, 2019

Can we try the bundle route first?

Yes, let's.

@varl
Copy link
Contributor

varl commented Feb 20, 2019

It was more about what the dashboard ends up bundling. In the case of this plugin, there probably isn't much common code between dashboard and what the plugin uses, it was more of a principle thing.

Ah, as a principle, yes. Bundling here is to strike a pragmatic balance.

So yeah, we're good for tree-shaking but not for de-duplication.

You're right, that's an important distinction.

@varl
Copy link
Contributor

varl commented Feb 20, 2019

I agree we should avoid arbitrary app-to-app dependencies (which is exactly what we have here, just with a "plugin" shim between the two apps).

Agreed, though that "shim" layer at least keeps the system level architecture some-what sane and I can maintain a graph of how the apps interact. If we start to introduce inter-app dependencies before we've even gotten rid of the single one we have (core-resource-app) my brain is going to melt.

However, having two different "artifacts" of an app build (one app, one plugin) seems quite a bit safer.

Essentially that is what was the plan with using Lerna for these app+plugin packages. Each build would produce two artifacts: one app artifact and one plugin artifact.

The app would be used for DHIS2 and the plugin would be published to NPM so other apps can use it. There are different technical was to go about this, and there are some drawbacks to each, but the principle of creating two artifacts from the same source is the same.

@jenniferarnesen jenniferarnesen merged commit de00b4f into master Feb 27, 2019
@jenniferarnesen jenniferarnesen deleted the chore/revert-lerna-package-link branch February 27, 2019 08:45
@jenniferarnesen
Copy link
Collaborator Author

I've merged this. Here is the commit message:

Revert "fix: use lerna to share code instead of copying resources (#214)" (#216)

This reverts commit eecfea0dd13e7620e0dd5c1f104e8aba0a3b5505.

This reintroduces code duplication that had been removed. The implementation causes the plugin to break in dashboards app. Reverting this now and will re-introduce a better solution with webpack bundling soon.

The reason this is being rushed in now is because we are migrating the data-visualizer-app to a mono-repo.

dhis2-bot added a commit that referenced this pull request Feb 12, 2020
# [33.0.0](v32.0.3...v33.0.0) (2020-02-12)

### Bug Fixes

* @dhis2/analytics 2.6.11 ([#448](#448)) ([231bcd8](231bcd8))
* added icons to tooltip for warning and locked ([#447](#447)) ([26a95e8](26a95e8))
* added lint, commit message and test commit/push hooks ([#526](#526)) ([0292a63](0292a63))
* adjust options dialog for easier scanning ([#580](#580)) ([b0393ff](b0393ff))
* assigned categories and new dimension types ([#576](#576)) ([2faae50](2faae50))
* avoid infinite loading and make chart plugin use hooks (DHIS2-8290) ([#653](#653)) ([9de60dd](9de60dd))
* avoid React warning about required proptype ([#311](#311)) ([5dda862](5dda862))
* changed height to min-height for the axes area ([#361](#361)) ([8c0ed13](8c0ed13))
* changed incorrect prop types and tests ([#372](#372)) ([c96ac09](c96ac09))
* chip cursor ([#566](#566)) ([8701256](8701256))
* convert numeric options to strings to silence ui-core warnings ([#617](#617)) ([c3fe18d](c3fe18d))
* correctly set showDimensionLabels option ([#621](#621)) ([01427ac](01427ac))
* d2-ui-analytics 1.0.2 ([#277](#277)) ([62241f8](62241f8))
* dashboard items resize should trigger chart reload ([#282](#282)) ([86070ae](86070ae))
* dimension dialog update validation ([#486](#486)) ([429c51e](429c51e))
* dimensions panel divided in to sections ([#581](#581)) ([3a9627a](3a9627a))
* do not run default adapter for pivot tables ([#616](#616)) ([27d8ab7](27d8ab7))
* don't render pivot table before data has loaded ([#635](#635)) ([844d989](844d989))
* download menu options for PT ([#624](#624)) ([c131970](c131970))
* dynamic axis names based on vis type ([#623](#623)) ([24510e0](24510e0))
* equal padding for the AO title bar ([#567](#567)) ([17238ed](17238ed))
* Fetching analytics for analytical object with undefined aggregationType in plugin ([#232](#232)) ([bfe41b4](bfe41b4))
* Fetching analytics for year over year charts in plugin ([#231](#231)) ([16853ef](16853ef))
* fix prop type for value in SortOrder option component ([#568](#568)) ([8379621](8379621))
* fix styling issues in options ([#585](#585)) ([d4c5bc6](d4c5bc6))
* fix values for topLimit option ([#579](#579)) ([3d249a6](3d249a6))
* fixes for DND between axes ([#554](#554)) ([886de23](886de23))
* fixes for options with numeric values and toggleable Select ([#583](#583)) ([8a40296](8a40296))
* gauge now follows the behaviour of single value instead of pie ([#489](#489)) ([9969e61](9969e61))
* gauge plot lines and range values in options ([#654](#654)) ([7736b29](7736b29))
* i18n merge conflict ([ac8c383](ac8c383))
* impl max dims rule ([#517](#517)) ([241de69](241de69))
* implemented the error code for assigned categories ([#557](#557)) ([7b9f52b](7b9f52b))
* layout for pivot tables ([#577](#577)) ([033be21](033be21))
* loading spinner for plugins (DHIS2-8117) ([#587](#587)) ([f8be30b](f8be30b))
* locked dims not array ([#491](#491)) ([15ae8a8](15ae8a8))
* long names for dimensions, chip and tooltip (DHIS2-7932) ([#556](#556)) ([2212398](2212398))
* manifest credentials bug in chrome ([#233](#233)) ([a0032e0](a0032e0))
* map is not vis type ([#371](#371)) ([22c36e2](22c36e2))
* merge conflicts ([3eb1c77](3eb1c77))
* only point series to axes for certain types ([#264](#264)) ([24b6ac0](24b6ac0))
* only run empty check after all values have been added ([#627](#627)) ([75b6ae4](75b6ae4))
* open modal for empty dims ([#625](#625)) ([e07d786](e07d786))
* options with numeric values (sortOrder) ([#564](#564)) ([94ad11d](94ad11d))
* org unit selector - only act on path if it exists ([#276](#276)) ([9299038](9299038))
* pie tooltip DHIS2-7532 ([#330](#330)) ([72eb5db](72eb5db))
* pin to analytics@2.6.11 ([#495](#495)) ([5f21406](5f21406))
* pin to analytics@2.6.11 ([#495](#495)) ([25b4545](25b4545))
* properly set layout on vis type change for all vis types ([#586](#586)) ([489fbf9](489fbf9))
* provide useful error messages (DHIS2-5029) ([#552](#552)) ([ef16c68](ef16c68))
* remove api.baseUrl duplicate ([#573](#573)) ([ac05af6](ac05af6))
* remove code climate config for now ([80c891a](80c891a))
* remove colon from chip if no selection ([#312](#312)) ([e667134](e667134))
* remove custom title when Auto is selected (DHIS2-8252) ([#636](#636)) ([44ed1a5](44ed1a5))
* remove ripple effect in dimension list when drag starts/ends ([#584](#584)) ([c91ed3b](c91ed3b))
* rename axis name constants ([#445](#445)) ([b75967a](b75967a))
* rules dim handling ([#446](#446)) ([445f1d8](445f1d8))
* single value without dx items ([#313](#313)) ([f1fbe22](f1fbe22))
* start screen icons ([#558](#558)) ([841c9c7](841c9c7))
* swap full axis dims to filter ([#518](#518)) ([a79e329](a79e329))
* tooltip message ([#449](#449)) ([ca55b7e](ca55b7e))
* turn class vars into functions ([#569](#569)) ([236885b](236885b))
* ui glitches ([#618](#618)) ([2788daf](2788daf))
* ui updates to the start screen ([#548](#548)) ([20dd6ca](20dd6ca))
* ui updates to the start screen ([#548](#548)) ([fee2153](fee2153))
* update @dhis2/analytics dependency ([#319](#319)) ([5752bea](5752bea))
* update analytics and plugin dep ([#324](#324)) ([8bb0202](8bb0202))
* update charts api dep ([#297](#297)) ([ab13e1c](ab13e1c))
* update gradient colors check ([#261](#261)) ([b39cec2](b39cec2))
* update plugin dependency ([#318](#318)) ([452a287](452a287))
* update plugin version ([#320](#320)) ([3921334](3921334))
* update recuder to handle empty axes ([#630](#630)) ([077dd68](077dd68))
* updated proptype for error ([#553](#553)) ([21a9b4a](21a9b4a))
* upgrade @dhis2/analytics to fix dimension dialog styling ([#551](#551)) ([c90f2b8](c90f2b8))
* upgrade @dhis2/cli-app-scripts and use platform-provided height ([#550](#550)) ([b6ffdfb](b6ffdfb))
* upgrade cli-app-scripts to fix package resolution ([#540](#540)) ([a52f7f3](a52f7f3))
* use a doc-like icon for PT downloads ([#626](#626)) ([a407372](a407372))
* use axisName instead of axisKey ([204fe7a](204fe7a))
* use layout type to get the right layout comp ([#563](#563)) ([17c26ba](17c26ba))
* use locked dimensions rule from analytics ([#444](#444)) ([883304f](883304f))
* use max items rule ([#373](#373)) ([ded0ee9](ded0ee9))
* use shared vis types ([#368](#368)) ([26d12c6](26d12c6))
* viewport layout with visible interpretations panel ([#323](#323)) ([2e2803b](2e2803b))
* vis type imports ([#496](#496)) ([2a1daaf](2a1daaf))

### chore

* **github-actions:** add workflows for lint and publish ([#638](#638)) ([739bb13](739bb13))

### Features

* add dnd from dimensions to specific position in layout axis ([#575](#575)) ([7c573b7](7c573b7))
* assigned categories DHIS2-7701 ([#539](#539)) ([636b365](636b365))
* drag 'n drop for reordering dimension items in layout ([#519](#519)) ([efd4acb](efd4acb))
* dual axis support ([#239](#239)) ([a50075c](a50075c))
* multiple orgunit roots support ([#328](#328)) ([e85668f](e85668f))
* show most viewed saved AO (DHIS2-7835) ([#547](#547)) ([97b0622](97b0622))
* summarize chart filters that have orgunit levels and/or groups ([#298](#298)) ([e5e0a7b](e5e0a7b))
* use layout rules for add-to-layout ui ([#362](#362)) ([a3dbb9f](a3dbb9f))
* use new pivot engine ([#574](#574)) ([f4ccef1](f4ccef1))
* WIP pivot table type ([#335](#335)) ([626f447](626f447))

### Reverts

* Revert "fix: use lerna to share code instead of copying resources (#214)" (#216) ([de00b4f](de00b4f)), closes [#214](#214) [#216](#216)

### BREAKING CHANGES

* **github-actions:** Ensure that the plugin and app versions are locked to each other.
@dhis2-bot
Copy link
Contributor

🎉 This PR is included in version 33.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

dhis2-bot added a commit that referenced this pull request Jun 8, 2020
# [32.1.0](v32.0.3...v32.1.0) (2020-06-08)

### Bug Fixes

* upgrade d2-ui dependencies for latest translations [v32] [DHIS2-8892] ([#1061](#1061)) ([6bc2f8c](6bc2f8c))
* **translations:** sync translations from transifex (v32) ([ff4839e](ff4839e))
* **translations:** sync translations from transifex (v32) ([bb026d0](bb026d0))
* **translations:** sync translations from transifex (v32) ([c15e3b6](c15e3b6))
* **translations:** sync translations from transifex (v32) ([0620c69](0620c69))
* @dhis2/analytics@2.4.9 ([4ed10df](4ed10df))
* allow : after bold and italic ([#314](#314)) ([59aed20](59aed20))
* changed height to min-height for the axes area ([#361](#361)) ([#366](#366)) ([5848460](5848460))
* d2-charts-api@32.0.9 ([27eff19](27eff19))
* deep check styles for changes ([#283](#283)) ([e76555c](e76555c))
* display 'and x others...' on tooltip (DHIS2-8753) v32 backport ([#945](#945)) ([0590fdf](0590fdf)), closes [#927](#927) [#925](#925)
* epi curve bug (v32) ([#529](#529)) ([2908206](2908206))
* epi curve bug v32 (v2) ([#530](#530)) ([de40d3d](de40d3d))
* Fetching analytics for analytical object with undefined aggregationType in plugin ([#232](#232)) ([bfe41b4](bfe41b4))
* Fetching analytics for year over year charts in plugin ([#231](#231)) ([16853ef](16853ef))
* manifest credentials bug in chrome ([#233](#233)) ([a0032e0](a0032e0))
* merge conflict ([#545](#545)) ([8e5f7aa](8e5f7aa))
* pie tooltip v32 ([#332](#332)) ([77b2628](77b2628))
* plugin - add deep checks to determine whether to redraw chart  ([#284](#284)) ([4b8837e](4b8837e))
* remove api.baseUrl duplicate ([#571](#571)) ([fafd58e](fafd58e))
* v32 backport, upgraded to Analytics v2.4.7 to support long dimension names (DHIS2-7932) ([#622](#622)) ([2cd524a](2cd524a))
* working translations [v32] ([#1001](#1001)) ([c32c623](c32c623))

### Features

* dual axis support ([#239](#239)) ([a50075c](a50075c))
* multiple org units support ([#333](#333)) ([6392efa](6392efa))

### Reverts

* Revert "fix: use lerna to share code instead of copying resources (#214)" (#216) ([de00b4f](de00b4f)), closes [#214](#214) [#216](#216)
@dhis2-bot
Copy link
Contributor

🎉 This PR is included in version 32.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@dhis2-bot
Copy link
Contributor

🎉 This PR is included in version 33.1.13 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants