Commit 50831d53 authored by Alejandro Celaya's avatar Alejandro Celaya Committed by Alejandro Celaya

Add support for TS in boot script

parent 26a12c9f
......@@ -109,7 +109,7 @@ gulp.task('watch-boot-script', () => {
//
// We could alternatively use `watchJS` to rebuild the bundle, but we'd
// need to make its logging less noisy first.
'src/boot/**/*.js',
'src/boot/**/*.{js,ts,tsx}',
],
{ delay: 500 },
gulp.task('build-boot-script')
......
......@@ -64,11 +64,11 @@ export default {
// Rollup docs recommend against "inline", but for this tiny bundle it
// produces a prod bundle of the same size and dev bundle that has less cruft in it.
babelHelpers: 'inline',
exclude: 'node_modules/**',
extensions: ['.js', '.ts', '.tsx']
}),
json(),
nodeResolve(),
nodeResolve({ extensions: ['.js', '.ts', '.tsx'] }),
...prodPlugins,
],
};
{
"presets": [
"@babel/preset-typescript",
["@babel/preset-env", {
"targets": {
"chrome": "40",
......
/**
* Returns the extension ID which is running this script, or undefined if this
* script is not being run by the browser extension.
*
* @param {Window} window_
* @return {string | undefined}
*/
export function getExtensionId(window_ = window) {
return /** @type {any} */ (window_).chrome?.runtime?.id;
export function getExtensionId(window_: Window = window): string | undefined {
return (window_ as any).chrome?.runtime?.id;
}
/**
* Verifies if there's a config script in the document that was generated by a
* specific browser extension.
*
* @param {string} extensionId
* @param {Document} document_
* @return {boolean}
*/
export function hasExtensionConfig(extensionId, document_ = document) {
export function hasExtensionConfig(
extensionId: string,
document_: Document = document
): boolean {
return !!document_.querySelector(
`script.js-hypothesis-config[data-extension-id=${extensionId}]`
);
......
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