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.

Massive performance improvement by using sync requires in NodeJS

See original GitHub issue

Hi everyone,

I’ve seen a pretty big performance improvement by using sync requires in NodeJS. I just tweaked the loadOption function:

if (opts.isNode) {
  // import('aaa') => require('aaa')
  argPath.parent.callee.type = 'Identifier'
  argPath.parent.callee.name = 'require'
}
else {
  // import('aaa') => import(/* webpackChunkName: 'aaa-123' */ 'aaa')
  argPath.addComment('leading', ` webpackChunkName: '${chunkName}' `)
  otherValidMagicComments.forEach(validLeadingComment =>
    argPath.addComment('leading', validLeadingComment.value)
  )
}

It seems like generating multiple chunks, and then using LimitChunksWebpackPlugin to merge them all together for SSR is slow. Does my change make sense? Could it break stuff?

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
ScriptedAlchemycommented, Nov 9, 2018

what you can do, is just disable ssr builds in development. What I’ve been doing do one build and turn off HMR on the server

0reactions
cdoublevcommented, Aug 27, 2020

I believe that the suggested change will break chunk names flushing, and that adding an example in the README isn’t a good idea since it’s the RUC responsibility to provide it and having multiple examples in different repositories will make it hard to maintain. Or maybe add a link to Universal Demo.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Performance Optimization tips for Node.js Applications
This article covers performance optimization techniques, tools, and tips to make high-performing Node.js apps.
Read more >
6 Tips and Techniques to Speed Up and Improve Your Node ...
6 Tips and Techniques to Speed Up and Improve Your Node.js Performance · 1. Caching Your App with Redis · 2. Make sure...
Read more >
How to Optimize Your Node.js API - freeCodeCamp
In this article, I will walk you through some of the best methods to optimize APIs written in Node.js. Prerequisites.
Read more >
This is why your Node.js application is slow
The simple problem with it is that it is capable of slowing down your application greatly when not correctly used. Whenever a promise...
Read more >
Moving 100.000+ files in Node.js sync / async performance ...
The test cases showed, that synchronous renameSync() is slower at 20% then asynchronous rename() . In the same time asynchronous rename() using ......
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