diff --git a/lib/accessibility.js b/lib/accessibility.js index 5f73ac2..59a9947 100644 --- a/lib/accessibility.js +++ b/lib/accessibility.js @@ -2,7 +2,7 @@ const Eval = require('./eval') exports.audit = () => { return Eval.execute(function () { - const {axs} = window + const {axs} = window.__devtron // defined in browserGlobals.js const config = new axs.AuditConfiguration({showUnsupportedRulesWarning: false}) const results = axs.Audit.run(config) diff --git a/lib/browserGlobals.js b/lib/browserGlobals.js new file mode 100644 index 0000000..b56f52e --- /dev/null +++ b/lib/browserGlobals.js @@ -0,0 +1,8 @@ +// This defines globals that will be used in the browser context +// (via the content_scripts definition in manifest.json) +// +// It is generated via `npm run-script prepublish` +const axs = require('accessibility-developer-tools') + +window.__devtron = window.__devtron || {} +window.__devtron.axs = axs diff --git a/manifest.json b/manifest.json index b7ebd0d..8fc7d95 100644 --- a/manifest.json +++ b/manifest.json @@ -5,7 +5,7 @@ "content_scripts": [ { "matches": ["*"], - "js": ["node_modules/accessibility-developer-tools/dist/js/axs_testing.js"] + "js": ["out/browserGlobals.js"] } ] } diff --git a/package.json b/package.json index 8da4890..5409467 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "Electron DevTools Extension", "main": "./api.js", "scripts": { - "prepublish": "browserify lib/*.js -o out/index.js --ignore-missing --entry lib/index.js", + "prepublish": "browserify lib/*.js -o out/index.js --ignore-missing --entry lib/index.js && browserify lib/browserGlobals.js -o out/browserGlobals.js", "start": "watchify lib/*.js -o out/index.js --ignore-missing --entry lib/index.js --verbose", "test": "mocha test/unit/*-test.js test/integration/*-test.js && standard" },