Skip to content

Commit

Permalink
Add memory leak test-suite
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasnordquist committed Apr 25, 2019
1 parent 8cd11cd commit af2ff01
Show file tree
Hide file tree
Showing 13 changed files with 700 additions and 36 deletions.
7 changes: 5 additions & 2 deletions app/package.json
Expand Up @@ -4,8 +4,9 @@
"description": "",
"main": "index.js",
"scripts": {
"build": "webpack --mode production",
"dev": "node_modules/.bin/webpack-dev-server --mode development --progress"
"build": "yarn rebuild && webpack --mode production",
"dev": "node_modules/.bin/webpack-dev-server --mode development --progress",
"rebuild": "cd node_modules/heapdump && node-gyp rebuild --target=4.1.4 --arch=x64 --dist-url=https://atom.io/download/electron; cd -"
},
"author": "",
"license": "ISC",
Expand Down Expand Up @@ -60,7 +61,9 @@
"awesome-typescript-loader": "^5.2.1",
"css-loader": "^2.1.0",
"hard-source-webpack-plugin": "^0.13.1",
"heapdump": "^0.3.12",
"html-webpack-plugin": "^4.0.0-beta.5",
"node-loader": "^0.6.0",
"source-map-loader": "^0.2.4",
"style-loader": "^0.23.1",
"typescript": "^3.2.2",
Expand Down
14 changes: 13 additions & 1 deletion app/src/components/Demo/index.tsx
@@ -1,8 +1,20 @@
import * as React from 'react'
import ShowText from './ShowText'
import Mouse from './Mouse'
let heapdump: any

(window as any).demo = {}
function writeHeapdump(path?: string) {
if (!heapdump) {
heapdump = require('heapdump')
}

heapdump.writeSnapshot(path || `${Date.now()}.heapsnapshot`)
return path
}

(window as any).demo = {
writeHeapdump,
}

export default function render(props: any) {
return (
Expand Down
18 changes: 16 additions & 2 deletions app/webpack.config.js
Expand Up @@ -14,6 +14,7 @@ module.exports = {
path: `${__dirname}/build`,
},
optimization: {
minimize: false,
splitChunks: {
chunks: 'all',
minSize: 30000,
Expand Down Expand Up @@ -47,7 +48,7 @@ module.exports = {
devtool: 'source-map',
resolve: {
// Add '.ts' and '.tsx' as resolvable extensions.
extensions: ['.ts', '.tsx', '.js', '.json'],
extensions: ['.ts', '.tsx', '.js', '.json', '.node'],
},
module: {
rules: [
Expand Down Expand Up @@ -77,14 +78,27 @@ module.exports = {
},
],
},
{
test: /\.node$/,
use: {
loader: 'node-loader',
options: {
modules: true,
}
}
},
],
},

plugins: [
new HtmlWebpackPlugin({ template: './index.html', file: './build/index.html', inject: false }),
// new BundleAnalyzerPlugin(),
new HardSourceWebpackPlugin(),
new webpack.HotModuleReplacementPlugin()
new webpack.HotModuleReplacementPlugin(),
new webpack.IgnorePlugin({
resourceRegExp: /\.\/build\/Debug\/addon/,
contextRegExp: /heapdump$/
}),
],

// When importing a module whose path matches one of the following, just
Expand Down

0 comments on commit af2ff01

Please sign in to comment.