Unverified Commit b72e00eb authored by Robert Knight's avatar Robert Knight Committed by GitHub

Merge pull request #1681 from hypothesis/convert-boot-to-es-modules

Convert src/boot to ES modules
parents c3a1170d c0070e6b
const { requiredPolyfillSets } = require('../shared/polyfills'); import { requiredPolyfillSets } from '../shared/polyfills';
function injectStylesheet(doc, href) { function injectStylesheet(doc, href) {
const link = doc.createElement('link'); const link = doc.createElement('link');
...@@ -126,12 +126,10 @@ function bootSidebarApp(doc, config) { ...@@ -126,12 +126,10 @@ function bootSidebarApp(doc, config) {
]); ]);
} }
function boot(document_, config) { export default function boot(document_, config) {
if (document_.querySelector('hypothesis-app')) { if (document_.querySelector('hypothesis-app')) {
bootSidebarApp(document_, config); bootSidebarApp(document_, config);
} else { } else {
bootHypothesisClient(document_, config); bootHypothesisClient(document_, config);
} }
} }
module.exports = boot;
...@@ -9,9 +9,10 @@ ...@@ -9,9 +9,10 @@
/* global __MANIFEST__ */ /* global __MANIFEST__ */
const boot = require('./boot'); import { jsonConfigsFrom } from '../shared/settings';
const { jsonConfigsFrom } = require('../shared/settings');
const processUrlTemplate = require('./url-template'); import boot from './boot';
import processUrlTemplate from './url-template';
const settings = jsonConfigsFrom(document); const settings = jsonConfigsFrom(document);
......
const boot = require('../boot'); import boot from '../boot';
const { $imports } = require('../boot'); import { $imports } from '../boot';
function assetUrl(url) { function assetUrl(url) {
return `https://marginal.ly/client/build/${url}`; return `https://marginal.ly/client/build/${url}`;
......
const processUrlTemplate = require('../url-template'); import processUrlTemplate from '../url-template';
describe('processUrlTemplate', () => { describe('processUrlTemplate', () => {
let fakeDocument; let fakeDocument;
......
...@@ -38,7 +38,7 @@ function currentScriptOrigin(document_ = document) { ...@@ -38,7 +38,7 @@ function currentScriptOrigin(document_ = document) {
* running. In that case, all references to `localhost` need to be replaced * running. In that case, all references to `localhost` need to be replaced
* with the IP/hostname of the dev server. * with the IP/hostname of the dev server.
*/ */
function processUrlTemplate(url, document_ = document) { export default function processUrlTemplate(url, document_ = document) {
if (url.indexOf('{') === -1) { if (url.indexOf('{') === -1) {
// Not a template. This should always be the case in production. // Not a template. This should always be the case in production.
return url; return url;
...@@ -53,5 +53,3 @@ function processUrlTemplate(url, document_ = document) { ...@@ -53,5 +53,3 @@ function processUrlTemplate(url, document_ = document) {
return url; return url;
} }
module.exports = processUrlTemplate;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment