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.

Using requires instead of imports prevents from prerendering

See original GitHub issue

It seems using require statements (e.g. const mod = require('module'); instead of imports (e.g. import mod from 'module' ) anywhere in the code prevents any prerendering from occuring.

However, the code still works properly in the browser.

I certainly need to investigate that more and will follow up with a more precise example if there is interest. Meanwhile I’m curious if any of you can confirm / explain this behaviour.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:13 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
toveruxcommented, Feb 23, 2017

I’ve also had that ReferenceError: Can't find variable: Promise error, I’ve fixed it (before seeing this issue) by adding core-js’ Promise polyfill in my app.

import 'core-js/es6/promise';

@chrisvfritz are you saying that I shouldn’t do that just to support Phantom?

1reaction
alanaasmaacommented, Jul 25, 2017

@drewlustro Manually editing this file like this has fixed the same issue for me on 3 PC’s.

https://github.com/chrisvfritz/prerender-spa-plugin/pull/54/commits/85d7d8cf722d9358c7e9b97def6b72d2e130e61c

Read more comments on GitHub >

github_iconTop Results From Across the Web

JavaScript Require vs. Import - Bits and Pieces
With modern web development, we use require or import to refer to JavaScript dependencies. And, sometimes, we use both in combination and ...
Read more >
Prerender and integrate ASP.NET Core Razor components
Use the following guidance to integrate Razor components into pages and views of an existing Razor Pages or MVC app. Add an imports...
Read more >
Detect require vs. import based on the entry point, not ... - GitHub
any instance of import during the run is now a perfectly normal "import is a reserved keyword" error. any instance of the dynamic...
Read more >
Precomposing, nesting, and pre-rendering After Effects ...
Read about precomposing layers and nesting compositions in After Effects, its uses and preferences.
Read more >
Using Node.js require vs. ES6 import/export - Stack Overflow
Your answer is totally valid, but I think we're comparing two different characteristics. All import/export is converted to require , granted. But what...
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