Skip to content

Commit

Permalink
Update JSDOM and create script to automate it
Browse files Browse the repository at this point in the history
  • Loading branch information
CompuIves committed Aug 5, 2020
1 parent 8c717ce commit b7e98af
Show file tree
Hide file tree
Showing 6 changed files with 2,021 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/app/src/sandbox/eval/tests/jest-lite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ let jsdomPromise = null;
* Load JSDOM while the sandbox loads. Before we run a test we make sure that this has been loaded.
*/
const getJSDOM = () => {
let jsdomPath = '/static/js/jsdom-4.0.0.min.js';
let jsdomPath = '/static/js/jsdom-16.3.0.min.js';
if (
navigator.userAgent.indexOf('jsdom') !== -1 &&
process.env.NODE_ENV === 'test'
) {
jsdomPath = 'file://' + path.resolve('./static/js/jsdom-4.0.0.min.js');
jsdomPath = 'file://' + path.resolve('./static/js/jsdom-16.3.0.min.js');
}

jsdomPromise = jsdomPromise || addScript(jsdomPath);
Expand Down
298 changes: 298 additions & 0 deletions packages/app/static/js/jsdom-16.3.0.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions standalone-packages/browser-jsdom/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
out
13 changes: 13 additions & 0 deletions standalone-packages/browser-jsdom/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const fs = require('fs');
const path = require('path');
const cp = require('child_process');

const jsdompkg = JSON.parse(
fs.readFileSync('./node_modules/jsdom/package.json').toString()
);
const jsdomloc = path.resolve(path.join('./node_modules/jsdom', jsdompkg.main));

const outLoc = `out/jsdom-${jsdompkg.version}.js`;
const outMinLoc = `out/jsdom-${jsdompkg.version}.min.js`;
cp.execSync(`node_modules/.bin/browserify -s JSDOM ${jsdomloc} > ${outLoc}`);
cp.execSync(`node_modules/.bin/terser ${outLoc} > ${outMinLoc}`);
18 changes: 18 additions & 0 deletions standalone-packages/browser-jsdom/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "browser-jsdom",
"version": "1.0.0",
"description": "Browserified version of JSDOM",
"main": "index.js",
"license": "MIT",
"scripts": {
"generate": "node index.js",
"move": "cp -R out/* ../../packages/app/static/js"
},
"dependencies": {
"jsdom": "^16.2.2"
},
"devDependencies": {
"browserify": "^16.5.1",
"terser": "^4.8.0"
}
}

0 comments on commit b7e98af

Please sign in to comment.