ES6 Module Consumption
See original GitHub issueWhen attempting you use a modern bundler (in my case its Rollup http://rollupjs.org/). I cannot import individual modules that I need because they aren’t exported correctly.
Module MY_PROJECT/node_modules/web3-provider-engine/subproviders/rpc.js does not export default (imported by MY_PROJECT/lib/index.js)
Error: Module MY_PROJECT/node_modules/web3-provider-engine/subproviders/rpc.js does not export default (imported by MY_PROJECT/lib/index.js)
at Module.trace (MY_PROJECT/node_modules/rollup/src/Module.js:683:30)
at MY_PROJECT/node_modules/rollup/src/Module.js:265:30
at Array.forEach (native)
at MY_PROJECT/node_modules/rollup/src/Module.js:263:25
at Array.forEach (native)
at Module.bindReferences (MY_PROJECT/node_modules/rollup/src/Module.js:256:19)
at MY_PROJECT/node_modules/rollup/src/Bundle.js:104:44
at Array.forEach (native)
at MY_PROJECT/node_modules/rollup/src/Bundle.js:104:18
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
JavaScript modules - MDN Web Docs
Use of native JavaScript modules is dependent on the import and export statements; these are supported in browsers as shown in the compatibility ......
Read more >A Practical guide to ES6 modules - freeCodeCamp
In short, we need ES6 modules in order to effectively reuse, maintain, separate and encapsulate internal behaviour from external behaviour. It's ...
Read more >JavaScript modules via script tag | Can I use... Support tables ...
Loading JavaScript module scripts (aka ES6 modules) using <script type="module"> Includes support for the nomodule attribute. Usage % of.
Read more >ES6 Modules and How to Use Import and Export in JavaScript
The ES2015 (ES6) edition of the JavaScript standard gives us native support for modules with the import and export syntax.
Read more >ES6 module usage - CodeSandbox
ES6 module usage. 0. Embed Fork Create Sandbox Sign in. Sandbox Info. ES6 module usage. 0. 2.0k. 230. eugenechen0514eugenechen0514. Environmentcreate-react- ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Ok got it to work using the following syntax in my code:
I’m using Webpack instead of rollup and am also experiencing difficulties. After importing
import { Web3ProviderEngine } from 'web3-provider-engine';and creating an object
var engine = new Web3ProviderEngine();I get the error: Web3ProviderEngine is not a constructor function.
The generated javascript looks like this:
var engine = new web3_provider_engine_1.Web3ProviderEngine();While poking around in the browser I can find the function at the prefix.
Not sure if this is a webpack issue or the way the library is structured. I don’t experience this issue with for instance web3 or eth-lightwallet.