Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
webpack-isomorphic-compiler
Advanced tools
A compiler that makes your life easier if you are building isomorphic webpack powered apps, that is, single page applications with server-side rendering
A compiler that makes your life easier if you are building isomorphic webpack powered apps, that is, single page applications with server-side rendering.
$ npm install webpack-isomorphic-compiler --save-dev
The current version only works with webpack v2.x.x.
With webpack, client-side applications with server-side rendering means compiling both the client and the server.
To make it right, the client and server compilers must be in sync and live in perfect harmony.
Webpack offers a multi-compiler that makes this easier, but unfortunately it doesn't have all the plugin handlers that a single compiler does. This makes it difficult to know what's happening under the hood.
This module packs an aggregated compiler which syncs up the client & server compilation and:
webpackIsomorphicCompiler(clientCompiler, serverCompiler)
Creates an aggregated compiler that wraps both client and server webpack compilers.
const webpack = require('webpack');
const webpackIsomorphicCompiler = require('webpack-isomorphic-compiler');
const clientCompiler = webpack(/* client config */);
const serverCompiler = webpack(/* server config */);
const compiler = webpackIsomorphicCompiler(clientCompiler, serverCompiler);
Alternatively, you may pass a config directly instead of a webpack compiler:
const webpack = require('webpack');
const compiler = webpackIsomorphicCompiler(/* client config */, /* server config */);
The compiler inherits from EventEmitter and emits the following events:
Name | Description | Argument |
---|---|---|
begin | Emitted when a compilation starts | |
error | Emitted when the compilation fails | err |
end | Emitted when the compilation completes successfully | stats |
compiler
.on('begin', () => console.log('Compilation started'))
.on('end', (stats) => {
console.log('Compilation finished successfully');
console.log('Client stats', stats.client);
console.log('Server stats', stats.server);
})
.on('error', (err) => {
console.log('Compilation failed')
console.log(err.message);
console.log(err.stats.toString());
})
Compiles both the client & server.
Returns a promise that fulfills with a stats
object or is rejected with an error.
This is similar to webpack's run() method, except that it returns a promise which gets rejected if stats contains errors.
compiler.run()
.then((stats) => {
// stats = {
// client,
// server,
// }
})
.catch((err) => {
// err = {
// message: 'Error message',
// [stats]: <webpack-stats>
// }
});
Available options:
Name | Description | Type | Default |
---|---|---|---|
report | Enable reporting | boolean/object | false |
Starts watching for changes and compiles on-the-fly.
Returns itself to allow chaining.
Calls handler
everytime the compilation fails or succeeds.
This is similar to webpack's watch() method, except that handler
gets called with an error if stats contains errors.
Available options:
Name | Description | Type | Default |
---|---|---|---|
poll | Use polling instead of native watchers | boolean | false |
aggregateTimeout | Wait so long for more changes (ms) | err | 200 |
report | Enable reporting | boolean/object | false |
compiler.watch((err, stats) => {
// err = {
// message: 'Error message',
// [stats]: <webpack-stats>
// }
// stats = {
// client,
// server,
// }
});
Stops watching for changes.
Returns a promise that fulfills when done.
Resolves the compiler result.
The promise gets immediately resolved if the compiler has finished or failed.
Otherwise waits for a compilation to be done before resolving the promise.
compiler.resolve()
.then((stats) => {
// stats = {
// client,
// server,
// }
})
.catch((err) => {
// err = {
// message: 'Error message',
// [stats]: <webpack-stats>
// }
});
Returns a boolean indicating if the code is being compiled.
Returns the compilation error or null if none.
Returns the compilation stats object ({ client, server }
) or null if it failed or not yet available.
Both client
and server
properties contain their webpack configs & compilers.
Name | Description | Type |
---|---|---|
webpackCompiler | The client's webpack compiler | Compiler |
webpackConfig | The client's webpack config | object |
Accessing webpack compiler public methods is NOT allowed and will throw an error.
Both run()
and watch()
accepts a report
option that, when enabled, prints information related to the compilation process.
The option can be a boolean or an object that maps to the following options:
Name | Description | Type | Default |
---|---|---|---|
humanErrors | Detects human errors related to webpack configuration mistakes | boolean | true |
stats | Display webpack stats after each successful compilation | boolean/string (true, false or once ) | true |
statsOptions | Which stats to display, see stats.toString() | sane default |
Additionally, you may use the reporter manually through the exported reporter
function on the webpack-isomorphic-compiler
module.
$ npm test
$ npm test:watch
during development
FAQs
A compiler that makes your life easier if you are building isomorphic webpack powered apps, that is, single page applications with server-side rendering
The npm package webpack-isomorphic-compiler receives a total of 150 weekly downloads. As such, webpack-isomorphic-compiler popularity was classified as not popular.
We found that webpack-isomorphic-compiler demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 18 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.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.