question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Import Not Working From Remote Require

See original GitHub issue

I have a fairly large electron app I’m working on and things have generally been going ok. I want to be able to build my app in production mode so that I can start showing it around but I have been hitting snag after snag getting the build process to produce a working production Electron build.

The latest issue I’m seeing is that using import from a requireed module is failing in production builds:

(function (exports, require, module, __filename, __dirname, process, global, Buffer) { return function (exports, require, module, __filename, __dirname) { import Promise from 'bluebird';

In dev mode, everything works swimmingly. I have created a very simple app that reproduces the issue here:

https://github.com/staufman/electron-boilerplate-import-fail.git

My guess is that I have some basic misunderstanding with how require works from the renderer thread but given that everything works fine in dev but not in production, this is a bit of a head scratcher.

Note that this code is a fresh clone from the current electron-react-boilerplate but with a few small code modifications to demonstrate the issue.

Any help would be much appreciated. Thanks!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
amilajackcommented, Jun 21, 2018

You’re right. Ideally no one would have to worry about these kinds of things. I’ll investigate further to see if i can provide a solution for this

2reactions
amilajackcommented, Jun 21, 2018
Read more comments on GitHub >

github_iconTop Results From Across the Web

Why my code work with require but don't work with import ...
Import and require are not the same. This link is informative. The difference between "require(x)" and "import x".
Read more >
JavaScript require vs import - Flexiple
One of the major differences between require() and import() is that require() can be called from anywhere inside the program whereas import() ...
Read more >
remote-import - npm
They won't work if there're remote imports within the imported module. This library solved this issue by customizing Node module loader logic.
Read more >
Modules, introduction - The Modern JavaScript Tutorial
The browser automatically fetches and evaluates the imported module (and its imports if needed), and then runs the script. Modules work only via ......
Read more >
How to Import Resources into a Remote State Managed by ...
It is important to note that not all resources can be imported. ... Try running "terraform plan" to see any changes that are...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found