faceyspacey / faceyspacey/babel-plugin-universal-import
Massive performance improvement by using sync requires in NodeJS
- Dominant language
- JavaScript
- Stars
- 114
- Forks
- 38
- PR merge metrics
- No merged PRs in 30d
Description
Hi everyone,
I've seen a pretty big performance improvement by using sync requires in NodeJS. I just tweaked the `loadOption` function:
```js
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?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.