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

Supporting Third-party Platforms in RNPM + Metro Bundler #21

Open
empyrical opened this Issue Aug 24, 2018 · 3 comments

Comments

Projects
None yet
2 participants
@empyrical
Member

empyrical commented Aug 24, 2018

Right now (in 0.56 and the first RC of 0.57) you need to modify jest/hasteImpl.js and local-cli/core/index.js so Metro and Haste can find your platform's JS files, as can be seen with windows (facebook/react-native@5494274) and dom (facebook/react-native#20393)

@matthargett has a pull request in the main RN repo tackling this: facebook/react-native#20662

I have not turned this commit into a PR yet, but I think that an additional "haste" key could be added under a platform's "rnpm" entry in package.json (much like how it works with jest, see here)

Example:

{
  "rnpm": {
    "haste": {
      "providesModuleNodeModules": [
        "react-native-foo"
      ],
      "platforms": [
        "foo"
      ]
    }
}

My commit: empyrical/react-native@d7a0c6b (I have opted not to make a PR until more discussion is had)

I think that also whatever way is added to support custom platform plugins makes its way in, there should be some sort of unit test added in with a dummy platform to help ensure that custom platform support is unbroken. A simple little test fixture with the bare minimum files required for a successful bundle to be built. I will probably take a stab at this too.

@kelset kelset changed the title from RFC/General Discussion: Supporting Third-party Platforms in RNPM + Metro Bundler to Supporting Third-party Platforms in RNPM + Metro Bundler Aug 24, 2018

@empyrical

This comment has been minimized.

Show comment
Hide comment
@empyrical

empyrical Aug 30, 2018

Member

My pull request implementing the idea in the OP is going to land in the RN repo.

Perhaps this issue could be used to talk about other ways in which RN could be enhanced for add-on platforms? Otherwise, I may close it.

Member

empyrical commented Aug 30, 2018

My pull request implementing the idea in the OP is going to land in the RN repo.

Perhaps this issue could be used to talk about other ways in which RN could be enhanced for add-on platforms? Otherwise, I may close it.

facebook-github-bot added a commit to facebook/react-native that referenced this issue Aug 30, 2018

Add support for out-of-tree platform plugins (#20825)
Summary:
This pull request adds the ability for a platform developer to provide a `"haste"` key under the `"rnpm"` key in their `package.json` which allows the packager to pick up that platform's javascript files. The intent is to remove the need to have custom platforms hardcoded in. This is inspired by the `"jest": { "haste": {} }` key used by jest.

For example, React Native Dom would have an entry like:

```json
{
  "rnpm": {
    "haste": {
      "providesModuleNodeModules": [
        "react-native-dom"
      ],
      "platforms": [
        "dom"
      ]
    }
  }
}
```

Support for more keys (path blacklists perhaps?) could be added in the future.

This succeeds #20662, as per a discussion I had with matthargett.

I've got an open discussion over here as well: react-native-community/discussions-and-proposals#21
Pull Request resolved: #20825

Differential Revision: D9596429

Pulled By: hramos

fbshipit-source-id: a02f0da0bea8870bdc45d55e23da8ccbc36249f2
@kelset

This comment has been minimized.

Show comment
Hide comment
@kelset

kelset Aug 31, 2018

Collaborator

Yeah it looks like it landed! 🎉

Thanks for the PR first off - second, I think it may be worth talking about your question in core

Would it be worth documenting this out-of-platform registration syntax on react-native-website?

I think it would be great, maybe it could be even worth its own page in the Guides, similar to this -> https://facebook.github.io/react-native/docs/0.56/native-modules-setup

Collaborator

kelset commented Aug 31, 2018

Yeah it looks like it landed! 🎉

Thanks for the PR first off - second, I think it may be worth talking about your question in core

Would it be worth documenting this out-of-platform registration syntax on react-native-website?

I think it would be great, maybe it could be even worth its own page in the Guides, similar to this -> https://facebook.github.io/react-native/docs/0.56/native-modules-setup

kelset added a commit to facebook/react-native that referenced this issue Aug 31, 2018

Add support for out-of-tree platform plugins (#20825)
Summary:
This pull request adds the ability for a platform developer to provide a `"haste"` key under the `"rnpm"` key in their `package.json` which allows the packager to pick up that platform's javascript files. The intent is to remove the need to have custom platforms hardcoded in. This is inspired by the `"jest": { "haste": {} }` key used by jest.

For example, React Native Dom would have an entry like:

```json
{
  "rnpm": {
    "haste": {
      "providesModuleNodeModules": [
        "react-native-dom"
      ],
      "platforms": [
        "dom"
      ]
    }
  }
}
```

Support for more keys (path blacklists perhaps?) could be added in the future.

This succeeds #20662, as per a discussion I had with matthargett.

I've got an open discussion over here as well: react-native-community/discussions-and-proposals#21
Pull Request resolved: #20825

Differential Revision: D9596429

Pulled By: hramos

fbshipit-source-id: a02f0da0bea8870bdc45d55e23da8ccbc36249f2
@empyrical

This comment has been minimized.

Show comment
Hide comment
@empyrical

empyrical Sep 1, 2018

Member

I've made a PR adding a whole new page about this. I also thought it would be worth mentioning the existing platforms that have been made for React Native in the docs as well:

facebook/react-native-website#541

Member

empyrical commented Sep 1, 2018

I've made a PR adding a whole new page about this. I also thought it would be worth mentioning the existing platforms that have been made for React Native in the docs as well:

facebook/react-native-website#541

gengjiawen added a commit to gengjiawen/react-native that referenced this issue Sep 14, 2018

Add support for out-of-tree platform plugins (facebook#20825)
Summary:
This pull request adds the ability for a platform developer to provide a `"haste"` key under the `"rnpm"` key in their `package.json` which allows the packager to pick up that platform's javascript files. The intent is to remove the need to have custom platforms hardcoded in. This is inspired by the `"jest": { "haste": {} }` key used by jest.

For example, React Native Dom would have an entry like:

```json
{
  "rnpm": {
    "haste": {
      "providesModuleNodeModules": [
        "react-native-dom"
      ],
      "platforms": [
        "dom"
      ]
    }
  }
}
```

Support for more keys (path blacklists perhaps?) could be added in the future.

This succeeds #20662, as per a discussion I had with matthargett.

I've got an open discussion over here as well: react-native-community/discussions-and-proposals#21
Pull Request resolved: facebook#20825

Differential Revision: D9596429

Pulled By: hramos

fbshipit-source-id: a02f0da0bea8870bdc45d55e23da8ccbc36249f2

aleclarson added a commit to aleclarson/react-native that referenced this issue Sep 16, 2018

Add support for out-of-tree platform plugins (facebook#20825)
Summary:
This pull request adds the ability for a platform developer to provide a `"haste"` key under the `"rnpm"` key in their `package.json` which allows the packager to pick up that platform's javascript files. The intent is to remove the need to have custom platforms hardcoded in. This is inspired by the `"jest": { "haste": {} }` key used by jest.

For example, React Native Dom would have an entry like:

```json
{
  "rnpm": {
    "haste": {
      "providesModuleNodeModules": [
        "react-native-dom"
      ],
      "platforms": [
        "dom"
      ]
    }
  }
}
```

Support for more keys (path blacklists perhaps?) could be added in the future.

This succeeds #20662, as per a discussion I had with matthargett.

I've got an open discussion over here as well: react-native-community/discussions-and-proposals#21
Pull Request resolved: facebook#20825

Differential Revision: D9596429

Pulled By: hramos

fbshipit-source-id: a02f0da0bea8870bdc45d55e23da8ccbc36249f2

grabbou pushed a commit to react-native-community/react-native-cli that referenced this issue Sep 26, 2018

Add support for out-of-tree platform plugins (#20825)
Summary:
This pull request adds the ability for a platform developer to provide a `"haste"` key under the `"rnpm"` key in their `package.json` which allows the packager to pick up that platform's javascript files. The intent is to remove the need to have custom platforms hardcoded in. This is inspired by the `"jest": { "haste": {} }` key used by jest.

For example, React Native Dom would have an entry like:

```json
{
  "rnpm": {
    "haste": {
      "providesModuleNodeModules": [
        "react-native-dom"
      ],
      "platforms": [
        "dom"
      ]
    }
  }
}
```

Support for more keys (path blacklists perhaps?) could be added in the future.

This succeeds #20662, as per a discussion I had with matthargett.

I've got an open discussion over here as well: react-native-community/discussions-and-proposals#21
Pull Request resolved: facebook/react-native#20825

Differential Revision: D9596429

Pulled By: hramos

fbshipit-source-id: a02f0da0bea8870bdc45d55e23da8ccbc36249f2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment