Skip to content

Node module includes .babelrc which causes Metro bundler errors #6

@byCedric

Description

@byCedric

A couple of weeks ago I found your package, and I must say I'm impressed. I had a sort of similar idea, so I was happy it was already out there! I've been playing a bit with your library and tried using it with React Native (Expo). Works like a charm!

I also put this example and your library out in the Expo's Slack, your library definitely deserves some attention there too! One of the users, ChronSyn (ScottP), noticed some unexpected behavior in combination with Metro bundler. When including it in such a project it errors with Babel preset "env" not found.

[22:09:45] /Users/cedric/Desktop/test/barcode-scanner/node_modules/react-async/lib/index.js: Couldn't find preset "env" relative to directory "/Users/cedric/Desktop/test/barcode-scanner/node_modules/react-async"
[22:09:45] Failed building JavaScript bundle.

I noticed that in the node_modules/react-async there was a .babelrc, and I think this is the cause of the issue. Basically, the Metro bundler found a babel configuration and tries to resolve it. But since we don't have that preset, it errors out. When I delete this file manually and restart everything, it works just fine.

I would recommend adding a files entry in your package json to whitelist all files you want to include in the npm package. This should prevent .babelrc and .travis.yml being packaged too. You can either use this or an .npmignore, but someone wrote a good article about why not to use the ignore file.

I'll create a PR now, I think only the transpiled code should be packaged right? (lib folder). The read me, license and other standard files are included by default.

PS. Have you heard about github templates? I would definitely recommend it! It makes bug reports easier and helps others to include all required information 😄

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions