Skip to content

Instantly share code, notes, and snippets.

@arjunguha
Last active February 19, 2018 22:45
Show Gist options
  • Save arjunguha/c8c565405cda9233690ab1216db2a894 to your computer and use it in GitHub Desktop.
Save arjunguha/c8c565405cda9233690ab1216db2a894 to your computer and use it in GitHub Desktop.
Stopify as a webpack plugin
var runner = stopify.stopify('index.bundle.js', {
estimator: 'reservoir',
yieldInterval: 100,
resampleInterval: 100,
timePerElapsed: 1
});
runner.run(() => console.log('done'));
// To pause execution:
// runner.pause(() => console.log('paused'));
// To resume execution:
// runner.resume();
<html>
<body>
<div id="output"></div>
<script src="node_modules/stopify/dist/stopify.bundle.js"></script>
<script src="driver.js">
</body>
</html>
var out = document.getElementById('output');
var i = 0;
function infloop() {
while(true) {
i++;
out.innerText = 'Running ' + i;
}
}
infloop();
{
"name": "stopify-webpack-demo",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"build": "./node_modules/.bin/webpack"
},
"license": "MIT",
"dependencies": {
"babel-loader": "^7.1.2",
"stopify": "^0.0.13",
"webpack": "^3.11.0"
}
}
const stopifyPlugin = require('stopify/dist/src/stopify/stopifyCallCC').plugin;
const opts = {
getters: false,
debug: false,
captureMethod: 'lazy',
newMethod: 'direct',
es: 'sane',
hofs: 'builtin',
jsArgs: 'simple',
requireRuntime: false,
noWebpack: true
};
module.exports = {
entry: './index.js',
output: {
filename: './index.bundle.js'
},
module: {
rules: [ {
test: /\.js$/,
// Exclude dependencies from stopification here
exclude: /node_modules/,
loader: 'babel-loader',
options: {
plugins: [[stopifyPlugin, opts]],
babelrc: false,
}
} ]
},
node: {
global: false,
Buffer: false,
'fs': 'empty',
'path': 'empty',
child_process: 'empty'
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment