tshaddix / webext-redux

A set of utilities for building Redux applications in Web Extensions.
MIT License
1.22k stars 180 forks source link

error when creating store #240

Closed lippyDesign closed 4 years ago

lippyDesign commented 4 years ago

In the following code I am getting an error when doing const store = new Store();

The error says:

Uncaught ReferenceError: browser is not defined at getBrowserAPI (util.js:19) at new Store (Store.js:83) at eval (popup.js:14) at Module../src/scripts/popup.js (popup.js:790) at __webpack_require__ (popup.js:20) at popup.js:84 at popup.js:87

`import React from 'react'; import {render} from 'react-dom'; import {Provider} from 'react-redux'; import {Store} from 'webext-redux';

const App = () =>

APP

const store = new Store();

// wait for the store to connect to the background page store.ready().then(() => { // The store implements the same interface as Redux's store // so you can use tools like react-redux no problem! render(

, document.getElementById('app'));

}); `

lippyDesign commented 4 years ago

Figured it out, in case if someone runs into this. It started working after I removed the node flag from webpack.js

tshaddix commented 4 years ago

@lippyDesign Glad you figured this out!

anotherstarburst commented 4 years ago

@lippyDesign curious to know which flag you removed from (what I gather was) your webpack config file? I'm encountering the same error with a content script which injects an iframe (where the iframe accesses the store).

Strangely this only affects Firefox - everything works swimmingly in chrome.

lippyDesign commented 4 years ago

i believe it was a node version flag or something that had to do with node js

anotherstarburst commented 4 years ago

i believe it was a node version flag or something that had to do with node js

Thanks @lippyDesign . I don't have any node specifc config that I can see ... I'lll need to keep digging.