Last active
February 19, 2018 22:45
-
-
Save arjunguha/c8c565405cda9233690ab1216db2a894 to your computer and use it in GitHub Desktop.
Stopify as a webpack plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<body> | |
<div id="output"></div> | |
<script src="node_modules/stopify/dist/stopify.bundle.js"></script> | |
<script src="driver.js"> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var out = document.getElementById('output'); | |
var i = 0; | |
function infloop() { | |
while(true) { | |
i++; | |
out.innerText = 'Running ' + i; | |
} | |
} | |
infloop(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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