10000 How do I bundle different modules for different platforms · Issue #576 · facebook/metro · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
How do I bundle different modules for different platforms #576
Open
@earonesty

Description

@earonesty

I have a library that requires:

  • rnkata.js when running in react native
  • webkata.js when running in a browser
  • nodekata.js when running in node

This hack works OK as long as I'm only targeting node/web:

if (getEnv() == "node") {
  eval('require')('nodekata')
} else {
  require('webkata')
}

But once I started targeting mobile, metro bundler would complain "webkata not available":

if (getEnv() == "node") {
  eval('require')('nodekata')
} else if (getEnv() == "mobile") {
  require('rnkata')
} else {
  require('webkata')
}

Is there some documentation on how to manage this situation? IE: how can i suppress bundling or interpreting of a 'require' call by platform. Is there a "suppress by module" feature?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0