Search code examples
aliasparceljs

Using alias in ParcelJS


I'm trying to alias 'react-native' to 'react-native-web' using ParcelJs as the bundler.

In package.json the alias is defined as:

"alias": { "react-native": "react-native-web" }

On running the project, the following error is produced.

    $ parcel src/Index.html --open
Server running at http://localhost:1234
🚨  /Users/prisc_000/Downloads/parcel-bundler-reason-react-native-web/node_modules/bs-react-native/src/components/view.js:5:26: Cannot resolve dependency 'react-native'
  3 |
  4 | var ReasonReact = require("reason-react/src/ReasonReact.js");
> 5 | var ReactNative = require("react-native");
    |                          ^
  6 | var Props$BsReactNative = require("../private/props.js");
  7 |
  8 | function CreateComponent(Impl) {
^C

How do I set up aliasing correctly? Thanks.

sample repo: https://github.com/idkjs/parcel-bundler-reason-react-native-web/tree/react-native-web


Solution

  • So I got this to work by deleting the .cache and lib directories and running parcel src/index.html --open script again. Hope this helps someone.