Skip to content

Conversation

BosEriko
Copy link
Contributor

@BosEriko BosEriko commented Jul 24, 2020

📦 Published PR as canary version: 3.1.3-canary.15.931587d.0

✨ Test out this PR locally via:

npm install [email protected]
# or 
yarn add [email protected]

Copy link
Contributor

@ericclemmons ericclemmons left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How did a dedicated Editmode.native.jsx go?

@BosEriko BosEriko requested a review from ericclemmons July 26, 2020 00:34
@BosEriko BosEriko self-assigned this Jul 26, 2020
@BosEriko BosEriko added bug Something isn't working enhancement New feature or request labels Jul 26, 2020
@BosEriko BosEriko marked this pull request as ready for review July 26, 2020 00:34
@BosEriko
Copy link
Contributor Author

How did a dedicated Editmode.native.jsx go?
@ericclemmons

I didn't go with it because I thought it might be too overkill? And also confusing in the long run. I just think the current approach will make more sense if someone is not using React Native. At least that's how I see it.

What do you think?

@ericclemmons
Copy link
Contributor

The .native extensions is basically a way of opting into RN support without breaking non-RN projects.

From the looks of this PR, RN is now a required dependency for consumers, which would be a breaking change.

Am I reading that correctly?

Another way libraries support both web and RN is having a separate entry point: editmode-react/native.

Anyway, there are a variety of methods, but the primary goal is that non-RN projections won't have RN as a dependency directly or indirectly (from this lib).

@BosEriko
Copy link
Contributor Author

BosEriko commented Jul 27, 2020

Googled a few stackoverflow answers.

https://stackoverflow.com/questions/46455202/react-native-project-do-not-have-index-ios-js-or-index-android-js

Says there that separate entry routes do not work anymore after 0.49.3. They also said to use { Platform } instead. Which is what we have right now.

From the looks of this PR, RN is now a required dependency for consumers, which would be a breaking change.

I'm not sure how an import can be a breaking change? It will probably be an extra kb, though.

@ericclemmons
Copy link
Contributor

ericclemmons commented Jul 28, 2020 via email

@BosEriko
Copy link
Contributor Author

@ericclemmons that is so weird. The docs say 0.63 so it should probably work, right? I couldn't make it work and when I searched for it they were saying that it shouldn't work anymore.

Is this by any chance a mistake in the docs? Or am I just doing something wrong?

Copy link
Contributor

@ericclemmons ericclemmons left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BosEriko We can revisit this, but if things are working in your testing, let's ship 👍

Track bundle-sizes here post-release:

https://bundlephobia.com/result?p=editmode-react

@ericclemmons ericclemmons removed the bug Something isn't working label Aug 1, 2020
@ericclemmons ericclemmons changed the title Feature: React Native Adjustment Feature: React Native Support Aug 1, 2020
@ericclemmons ericclemmons changed the title Feature: React Native Support React Native Support Aug 1, 2020
@BosEriko BosEriko merged commit f53fcc5 into master Aug 3, 2020
@github-actions
Copy link

github-actions bot commented Aug 3, 2020

🚀 PR was released in v3.1.3 🚀

@github-actions github-actions bot added the released This issue/pull request has been released. label Aug 3, 2020
"axios": "^0.19.2",
"dompurify": "^2.0.11",
"lodash-es": "^4.17.15",
"react": "^16.13.1",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • react should be both in devDependencies and peerDepenencies because we depend on it for local development directly (e.g. import React from "react") and consumers should have it in their project.
  • react-dom should be a peerDependencies because consumers should have it in their project.
  • react-native can be a devDependencies if we're using it for tests or in a local project, but likely won't need it listed anywhere at all.

// @ts-check
import React, { useEffect } from "react";
import { EditmodeContext } from "./EditmodeContext";
import { Platform } from 'react-native';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't safely depend on react-native within a web environment because of how react-native publishes to NPM (under the expectation that it's bundled via expo or metro bundler)

@@ -1,23 +1,28 @@
// @ts-check
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to re-investigate splitting Editmode.jsx into 2 files:

  • Editmode.jsx for web
  • Editmode.native.jsx for react-native

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request released This issue/pull request has been released.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants