Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
@loadable/webpack-plugin
Advanced tools
@loadable/webpack-plugin is a plugin for Webpack that works in conjunction with @loadable/component to enable code-splitting and dynamic imports in React applications. It helps in generating a stats file that is used to load only the necessary chunks for a given page, improving the performance and load times of web applications.
Code Splitting
This feature allows you to split your code into smaller chunks that can be loaded on demand. The LoadablePlugin generates a stats file that helps in loading only the necessary chunks for a given page.
const LoadablePlugin = require('@loadable/webpack-plugin');
module.exports = {
plugins: [
new LoadablePlugin()
]
};
Dynamic Imports
This feature allows you to dynamically import components in your React application. The @loadable/component library works with @loadable/webpack-plugin to ensure that only the necessary chunks are loaded.
import loadable from '@loadable/component';
const MyComponent = loadable(() => import('./MyComponent'));
function App() {
return (
<div>
<MyComponent />
</div>
);
}
Server-Side Rendering (SSR) Support
This feature provides support for server-side rendering by using the ChunkExtractor to collect and render the necessary chunks on the server.
import { ChunkExtractor } from '@loadable/server';
import stats from './dist/loadable-stats.json';
const extractor = new ChunkExtractor({ statsFile: stats });
const jsx = extractor.collectChunks(<App />);
const html = renderToString(jsx);
react-loadable is a higher-order component for loading components with dynamic imports. It provides similar functionality to @loadable/component but does not have built-in support for Webpack plugins like @loadable/webpack-plugin.
webpack-bundle-analyzer is a plugin and CLI utility that represents bundle content as a convenient interactive zoomable treemap. While it does not provide code-splitting or dynamic import functionalities, it helps in analyzing the size and composition of Webpack bundles.
react-async-component is another library for code-splitting and loading React components asynchronously. It provides similar functionality to @loadable/component but does not have the same level of integration with Webpack.
This plugin is required only if you use Server Side Rendering in your application. See @loadable/server
for more information.
npm install --save-dev @loadable/webpack-plugin
webpack.config.js
const LoadablePlugin = require('@loadable/webpack-plugin')
module.exports = {
plugins: [new LoadablePlugin()],
}
Create a webpack loadable plugin.
Arguments | Description |
---|---|
options | Optional options |
options.filename | Stats filename (default to loadable-stats.json ) |
options.writeToDisk | Accepts boolean or object . Always write stats file to disk. Default to false . |
options.writeToDisk.filename | Write assets to disk at given filename location |
new LoadablePlugin({ filename: 'stats.json', writeToDisk: true })
Writing file to disk can be useful if you are using
razzle
orwebpack-dev-server
.
MIT
FAQs
Webpack plugin for loadable (required for SSR).
The npm package @loadable/webpack-plugin receives a total of 99,595 weekly downloads. As such, @loadable/webpack-plugin popularity was classified as popular.
We found that @loadable/webpack-plugin demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.