Skip to content
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

Error: Cannot assign to read only property 'exports' of object '#<Object>' #304

Open
ronnac opened this issue Sep 15, 2021 · 4 comments
Open

Comments

@ronnac
Copy link

ronnac commented Sep 15, 2021

I am following the react native instructions for Android with the web simulator using expo start --web (I can't install any other simulator on termux).
When I run clj -m figwheel.main -b android -r my browser displays an error

TypeError: Cannot assign to read only property 'exports' of object '#<Object>'

Module.<anonymous>

/data/data/com.termux/files/home/fig-app/target/public/cljs-out/android_rn/figwheel-bridge.js:165

162 | ReactNative.AppRegistry.registerComponent(options.appName, () => createBridgeComponent(options));
163 | }
164 | 
> 165 | module.exports = {
166 | shimRequire: shimRequire,
167 | start: startApp,
168 | createBridgeComponent: createBridgeComponentView compiled

Module../target/public/cljs-out/android_rn/figwheel-bridge.js

http://localhost:19006/static/js/bundle.js:60587:30

__webpack_require__

/data/data/com.termux/files/home/fig-app/webpack/bootstrap:789

786 | };
787 | 
788 | // Execute the module function
> 789 | modules[moduleId].call(module.exports, module, module.exports, hotCreateRequire(moduleId));
| ^ 790 | 
791 | // Flag the module as loaded
792 | module.l = true;View compiled

fn

/data/data/com.termux/files/home/fig-app/webpack/bootstrap:100

97 | 		);
98 | 		hotCurrentParents = [];
99 | 	}
> 100 | 	return __webpack_require__(request);
| ^ 101 | };
102 | var ObjectFactory = function ObjectFactory(name) {
103 | 	return {View compiled

Module../index.js

/data/data/com.termux/files/home/fig-app/index.js:6

3 | import {krellNpmDeps} from "./target/public/cljs-out/android/krell_npm_deps.js";
4 | var options = {optionsUrl: "http://localhost:9500/cljs-out/android/cljsc_opts.json",
5 | autoRefresh: true};
> 6 | var figBridge = require("./target/public/cljs-out/android_rn/figwheel-bridge.js");
7 | figBridge.shimRequire({...assets, ...krellNpmDeps, ...npmDeps});
8 | import { registerRootComponent } from 'expo';
9 | registerRootComponent(figBridge.createBridgeComponent(options));View compiled

__webpack_require__

/data/data/com.termux/files/home/fig-app/webpack/bootstrap:789

786 | };
787 | 
788 | // Execute the module function
> 789 | modules[moduleId].call(module.exports, module, module.exports, hotCreateRequire(moduleId));
| ^ 790 | 
791 | // Flag the module as loaded
792 | module.l = true;View compiled

fn

/data/data/com.termux/files/home/fig-app/webpack/bootstrap:100

97 | 		);
98 | 		hotCurrentParents = [];
99 | 	}
> 100 | 	return __webpack_require__(request);
| ^ 101 | };
102 | var ObjectFactory = function ObjectFactory(name) {
103 | 	return {View compiled

1

http://localhost:19006/static/js/bundle.js:60616:18

__webpack_require__

/data/data/com.termux/files/home/fig-app/webpack/bootstrap:789

786 | };
787 | 
788 | // Execute the module function
> 789 | modules[moduleId].call(module.exports, module, module.exports, hotCreateRequire(moduleId));
| ^ 790 | 
791 | // Flag the module as loaded
792 | module.l = true;View compiled

(anonymous function)

/data/data/com.termux/files/home/fig-app/webpack/bootstrap:856

853 | 
854 | 
855 | // Load entry module and return exports
> 856 | return hotCreateRequire(1)(__webpack_require__.s = 1);
| ^ 857 | View compiled

(anonymous function)

http://localhost:19006/static/js/bundle.js:860:10

On this page they say that the JS code needs to be ES instead of CommonJS. Following their hint I can get it to work when I replace the following code at the end of /data/data/com.termux/files/home/fig-app/target/public/cljs-out/android_rn/figwheel-bridge.js:165

module.exports = {
  shimRequire: shimRequire,
  start: startApp,
  createBridgeComponent: createBridgeComp
};

with

export {
          shimRequire,
  startApp as start,
  createBridgeComponent
};

However, this is file dynamically created by figwheel and overwritten everytime I restart figwheel. The code needs to be fixed upstream.

@bhauman
Copy link
Owner

bhauman commented Sep 15, 2021

Yeah this seems like a tooling evolution. I'll check it out.

Unfortunately it requires quite a bit of set up to verify this so it won't be super soon.

If you are using the latest tools feel free to submit a PR.

@ronnac
Copy link
Author

ronnac commented Sep 15, 2021 via email

@bhauman
Copy link
Owner

bhauman commented Sep 15, 2021 via email

@ronnac
Copy link
Author

ronnac commented Sep 15, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants