gorhom / react-native-bottom-sheet

A performant interactive bottom sheet with fully configurable options 🚀
https://gorhom.dev/react-native-bottom-sheet/
MIT License
6.8k stars 745 forks source link

[v4] | [v2] 'import' and 'export' may appear only with 'sourceType: module' (14:0) #1502

Closed jeff1evesque closed 1 year ago

jeff1evesque commented 1 year ago

Bug

When I try to build my react script using the following command:

browserify -t [ babelify --presets [ @babel/preset-env @babel/preset-react ] ] moomoo.jsx > moomoo.js

I get the following error:

(stargate) monkeypoo@TubeToob crap-code % ./deploy --js                                          
Now using node v14.21.2 (npm v6.14.17)
Notice: compiling javascript

> reactjs@1.0.0 build:browserify /Users/monkeypoo/doghouse/crap-code/jsx
> browserify -t [ babelify --presets [ @babel/preset-env @babel/preset-react ] ] moomoo.jsx > moomoo.js

Error: Parsing file /Users/monkeypoo/doghouse/crap-code/jsx/node_modules/react-native/index.js: 'import' and 'export' may appear only with 'sourceType: module' (14:0)
    at Deps.parseDeps (/Users/monkeypoo/doghouse/crap-code/jsx/node_modules/module-deps/index.js:519:15)
    at getDeps (/Users/monkeypoo/doghouse/crap-code/jsx/node_modules/module-deps/index.js:447:44)
    at /Users/monkeypoo/doghouse/crap-code/jsx/node_modules/module-deps/index.js:430:38
    at ConcatStream.<anonymous> (/Users/monkeypoo/doghouse/crap-code/jsx/node_modules/concat-stream/index.js:37:43)
    at ConcatStream.emit (events.js:412:35)
    at finishMaybe (/Users/monkeypoo/doghouse/crap-code/jsx/node_modules/readable-stream/lib/_stream_writable.js:630:14)
    at endWritable (/Users/monkeypoo/doghouse/crap-code/jsx/node_modules/readable-stream/lib/_stream_writable.js:638:3)
    at ConcatStream.Writable.end (/Users/monkeypoo/doghouse/crap-code/jsx/node_modules/readable-stream/lib/_stream_writable.js:594:41)
    at DuplexWrapper.onend (/Users/monkeypoo/doghouse/crap-code/jsx/node_modules/readable-stream/lib/_stream_readable.js:577:10)
    at Object.onceWrapper (events.js:519:28)
    at DuplexWrapper.emit (events.js:412:35)
    at endReadableNT (/Users/monkeypoo/doghouse/crap-code/jsx/node_modules/readable-stream/lib/_stream_readable.js:1010:12)
    at processTicksAndRejections (internal/process/task_queues.js:82:21)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! reactjs@1.0.0 build:browserify: `browserify -t [ babelify --presets [ @babel/preset-env @babel/preset-react ] ] moomoo.jsx > moomoo.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the reactjs@1.0.0 build:browserify script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/monkeypoo/.npm/_logs/2023-08-29T22_50_26_611Z-debug.log
(stargate) monkeypoo@TubeToob crap-code %

If I remove the import { BottomSheet } from '@gorhom/bottom-sheet'; from the below provided react script in "Reproducible sample code", the above/earlier browserify command succeeds, and I have a desired javascript moomoo.js file.

Environment info

  "dependencies": {
    "@aws-amplify/analytics": "^4.0.11",
    "@aws-amplify/auth": "^3.4.22",
    "@aws-amplify/core": "^3.8.14",
    "@babel/core": "^7.22.11",
    "@babel/plugin-proposal-class-properties": "^7.18.6",
    "@babel/plugin-transform-runtime": "^7.22.10",
    "@babel/preset-env": "^7.22.10",
    "@babel/preset-react": "^7.22.5",
    "@gorhom/bottom-sheet": "^4.4.7",
    "esmify": "^2.1.1",
    "@popperjs/core": "^2.8.1",
    "@wojtekmaj/enzyme-adapter-react-17": "^0.4.1",
    "aws-amplify": "^5.2.5",
    "aws-amplify-react": "^5.1.43",
    "babel-jest": "^26.6.3",
    "babelify": "^10.0.0",
    "browserify": "^17.0.0",
    "core-js": "^2.6.5",
    "coveralls": "^3.1.0",
    "d3": "^6.5.0",
    "dos2unix-cli": "^1.0.1",
    "enzyme": "^3.11.0",
    "global": "^4.4.0",
    "history": "^5.0.0",
    "jest-cli": "^26.6.3",
    "recharts": "^2.6.2",
    "onchange": "^7.1.0",
    "promise-polyfill": "^8.2.0",
    "prop-types": "15.7.2",
    "query-string": "^6.14.0",
    "react": "^17.0.1",
    "react-bootstrap": "^2.7.2",
    "react-csv-to-table": "^0.0.4",
    "react-datepicker": "^4.8.0",
    "react-dom": "^17.0.1",
    "react-error-boundary": "^3.1.0",
    "react-gauge-chart": "^0.3.0",
    "react-json-view": "1.21.1",
    "react-papaparse": "^4.1.0",
    "react-native": "^0.72.4",
    "react-native-reanimated": "^3.4.2",
    "react-phone-input-2": "^2.13.9",
    "react-redux": "^7.2.2",
    "react-router-dom": "^6.8.0",
    "react-tabs": "^4.2.1",
    "rearm": "^0.13.1",
    "redux": "^4.0.5",
    "whatwg-fetch": "^3.4.1",
    "react-device-detect": "^2.2.3"
  }

Steps To Reproduce

Using the below provided "Reproducible sample code", if I try to build:

browserify -t [ babelify --presets [ @babel/preset-env @babel/preset-react ] ] moomoo.jsx > moomoo.js

I get the error specified in the above "Bug" section. However, if I remove the import { BottomSheet } from '@gorhom/bottom-sheet'; statement from my below provided moomoo.jsx, then the browserify command succeeds completely with no error.

Reproducible sample code

I have import { BottomSheet } from '@gorhom/bottom-sheet'; declared at top of my react moomoo.jsx script:

import React from 'react';
import ReactDOM from 'react-dom';
import { BottomSheet } from '@gorhom/bottom-sheet';

ReactDOM.render(
    <div>Hello Moo Moo</div>,
    document.querySelector('.react-container')
);

As well as a trivial index.html which dynamically builds off the react-container CSS class:

<!DOCTYPE html>
<html>
  <head>
    <meta charset='utf-8'>
    <meta http-equiv='X-UA-Compatible' content='IE=edge' />
    <meta name='viewport' content='width=device-width, initial-scale=1.0'>
    <link rel='shortcut icon' href='#'>
  </head>
  <body>
    <div class='react-container' id='bootstrap-override'></div>
    <script src='moomoo.js'></script>
  </body>
</html>
github-actions[bot] commented 1 year ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] commented 1 year ago

This issue was closed because it has been stalled for 5 days with no activity.