webhintio / hint

💡 A hinting engine for the web
https://webhint.io/
Apache License 2.0
3.63k stars 678 forks source link

[Feature] Electron support for browser extension #3059

Open Kilian opened 5 years ago

Kilian commented 5 years ago

🚀 Feature request

Description

Electron support for the browser extension.

When running the Chrome browser extension in Electron, which supports devtools extensions, the scan times out. I don't get any specific error message, also not when inspecting the devtools with a remote session, so I don't know why.

One hint (sorry) is that in the bug report the "url for which webhint failed" seems to be empty, so maybe it's not resolving the right URL. I tested this both with devtools on an Electron window directly (where the url would resolve to a file) and on a webview, whose url would resolve to a proper https url, and neither bug report includes the url.

What scenarios will this solve?

Running in Electron lets people run webhint on their application code, and would let me run it inside the browser I'm developing, Polypane. If pointed in the right direction, I'd be willing to dig deeper into where the timeout occurs and see if I can fix it.

The below is the generated bug report when using the extension in Electron


🐛 Bug report

Description

Environment

webhint configuration

webhint’s configuration Categories: * [ ] Accessibility * [ ] Compatibility * [x] Performance * [ ] Pitfalls * [ ] PWA * [ ] Security Your target browsers: * [x] Recommended settings * [ ] Custom: Ignored resources: * * [x] None * * [ ] Different origin * * [ ] Custom:

Debug output

Please include the content of the Error details section if an error message was displayed.

webhint’s Error details ```text Scan timed out. ```
molant commented 5 years ago

My first thought is that it's something related to local resource. IIRC we are filtering out resources that do not start with http(s).

@antross what do you think?

antross commented 5 years ago

@Kilian Thanks for the suggestion! This seems like a great scenario for us to support.

If you want to dig deeper you can create your own custom build of the extension by following the steps at the top of the CONTRIBUTING file for the browser extension. The initial build of the repo takes some time (10-20min), but after that you can rebuild directly from the packages/extension-browser folder by running yarn build (which should take less than a minute).

You'll probably want to start by looking at the expected call to _onComplete and work your way back to figure out why it's not getting called.

My first thought is that it's something related to local resource. IIRC we are filtering out resources that do not start with http(s).

@molant That could cause us to omit some data, but the scan should still complete shortly after the onLoad event fires for the document. I checked the code and we should finish even if we never got the raw source for the top-level document.

Kilian commented 5 years ago

My first thought is that it's something related to local resource. IIRC we are filtering out resources that do not start with http(s).

@molant That's why I also tested with the <webview>, which has a regular url as origin.

@antross I'll see what I can do there, thanks!

Kilian commented 5 years ago

I've been trying to get this to run (on Ubuntu 18.04) folloing the contributing guidelines but I'm running into issues.

My initial yarn build is really fast:

build all packages
Verifying if repo does not have any changes
Downloading revision "cdaa672fb1ad081ee224aa339d2a48d468259061"
Unzipping
Deleting cdaa672fb1ad081ee224aa339d2a48d468259061.zip
Done!
build time: 0m:2s
Done in 13.14s.

but a yarn build in the extension-browser folder spits out this:

webhint’s yarn build error output ```sh ➜ extension-browser git:(master) yarn build yarn run v1.19.1 $ npm-run-all build:* && webpack $ cpx "./src/**/*.{html,json,png}" dist/bundle && cpx "./src/*.svg" dist/bundle && cpx "./src/browser-action/*.svg" dist/bundle/browser-action $ cpx "./{src,tests}/**/{!(*.ts),.!(ts),!(*.tsx),.!(tsx)}" dist && npm-run-all prebuild:* $ cpx "./src/**/*.{html,json,png}" dist/bundle && cpx "./src/*.svg" dist/bundle && cpx "./src/browser-action/*.svg" dist/bundle/browser-action $ tcm src Wrote /home/kilian/Workspace/OS/hint/packages/extension-browser/src/devtools/views/app.fluent.css.d.ts Wrote /home/kilian/Workspace/OS/hint/packages/extension-browser/src/devtools/views/app.base.css.d.ts Wrote /home/kilian/Workspace/OS/hint/packages/extension-browser/src/devtools/views/controls/button.css.d.ts Wrote /home/kilian/Workspace/OS/hint/packages/extension-browser/src/devtools/views/app.photon.css.d.ts Wrote /home/kilian/Workspace/OS/hint/packages/extension-browser/src/devtools/views/controls/checkbox.base.css.d.ts Wrote /home/kilian/Workspace/OS/hint/packages/extension-browser/src/devtools/views/controls/external-link.css.d.ts Wrote /home/kilian/Workspace/OS/hint/packages/extension-browser/src/devtools/views/controls/inspect-button.css.d.ts Wrote /home/kilian/Workspace/OS/hint/packages/extension-browser/src/devtools/views/controls/checkbox.fluent.css.d.ts Wrote /home/kilian/Workspace/OS/hint/packages/extension-browser/src/devtools/views/controls/checkbox.photon.css.d.ts Wrote /home/kilian/Workspace/OS/hint/packages/extension-browser/src/devtools/views/controls/label-text.css.d.ts Wrote /home/kilian/Workspace/OS/hint/packages/extension-browser/src/devtools/views/controls/notification.css.d.ts Wrote /home/kilian/Workspace/OS/hint/packages/extension-browser/src/devtools/views/controls/label.css.d.ts Wrote /home/kilian/Workspace/OS/hint/packages/extension-browser/src/devtools/views/controls/progress-bar.css.d.ts Wrote /home/kilian/Workspace/OS/hint/packages/extension-browser/src/devtools/views/controls/radio.fluent.css.d.ts Wrote /home/kilian/Workspace/OS/hint/packages/extension-browser/src/devtools/views/controls/radio.base.css.d.ts Wrote /home/kilian/Workspace/OS/hint/packages/extension-browser/src/devtools/views/controls/radio.photon.css.d.ts Wrote /home/kilian/Workspace/OS/hint/packages/extension-browser/src/devtools/views/controls/source-code.css.d.ts Wrote /home/kilian/Workspace/OS/hint/packages/extension-browser/src/devtools/views/controls/summary.css.d.ts Wrote /home/kilian/Workspace/OS/hint/packages/extension-browser/src/devtools/views/controls/telemetry-notification.css.d.ts Wrote /home/kilian/Workspace/OS/hint/packages/extension-browser/src/devtools/views/controls/toggle.css.d.ts Wrote /home/kilian/Workspace/OS/hint/packages/extension-browser/src/devtools/views/controls/valid-input.css.d.ts Wrote /home/kilian/Workspace/OS/hint/packages/extension-browser/src/devtools/views/page.css.d.ts Wrote /home/kilian/Workspace/OS/hint/packages/extension-browser/src/devtools/views/pages/analyze.css.d.ts Wrote /home/kilian/Workspace/OS/hint/packages/extension-browser/src/devtools/views/pages/config.css.d.ts Wrote /home/kilian/Workspace/OS/hint/packages/extension-browser/src/devtools/views/pages/config/example.css.d.ts Wrote /home/kilian/Workspace/OS/hint/packages/extension-browser/src/devtools/views/pages/config/header.css.d.ts Wrote /home/kilian/Workspace/OS/hint/packages/extension-browser/src/devtools/views/pages/config/section.css.d.ts Wrote /home/kilian/Workspace/OS/hint/packages/extension-browser/src/devtools/views/pages/config/label.css.d.ts Wrote /home/kilian/Workspace/OS/hint/packages/extension-browser/src/devtools/views/pages/config/sections/categories.css.d.ts Wrote /home/kilian/Workspace/OS/hint/packages/extension-browser/src/devtools/views/pages/error.css.d.ts Wrote /home/kilian/Workspace/OS/hint/packages/extension-browser/src/devtools/views/pages/results/category-summary.css.d.ts Wrote /home/kilian/Workspace/OS/hint/packages/extension-browser/src/devtools/views/pages/results/header.css.d.ts Wrote /home/kilian/Workspace/OS/hint/packages/extension-browser/src/devtools/views/pages/results.css.d.ts Wrote /home/kilian/Workspace/OS/hint/packages/extension-browser/src/devtools/views/pages/results/category.css.d.ts Wrote /home/kilian/Workspace/OS/hint/packages/extension-browser/src/devtools/views/pages/results/hint.css.d.ts Wrote /home/kilian/Workspace/OS/hint/packages/extension-browser/src/devtools/views/pages/results/problem.css.d.ts Wrote /home/kilian/Workspace/OS/hint/packages/extension-browser/src/devtools/views/pages/results/message-group.css.d.ts $ node ./scripts/import-hints.js Created: /home/kilian/Workspace/OS/hint/packages/extension-browser/src/shared/hints.import.ts Created: /home/kilian/Workspace/OS/hint/packages/extension-browser/src/shared/metas.import.ts $ node ./scripts/create-i18n.js && node ./scripts/merge-i18n.js Created: /home/kilian/Workspace/OS/hint/packages/extension-browser/src/shared/i18n.import.ts Created: /home/kilian/Workspace/OS/hint/packages/extension-browser/dist/bundle/_locales/en/messages.json $ node ./scripts/copy-version.js Set version to 1.0.3 in /home/kilian/Workspace/OS/hint/packages/extension-browser/dist/bundle/manifest.json Set version to 1.0.3 in /home/kilian/Workspace/OS/hint/packages/extension-browser/dist/src/manifest.json $ tsc -b ../utils/dist/src/content-type.d.ts:2:29 - error TS2307: Cannot find module './dom'. 2 import { HTMLElement } from './dom'; ~~~~~~~ ../utils/dist/src/content-type.d.ts:3:29 - error TS2307: Cannot find module './types/http-header'. 3 import { HttpHeaders } from './types/http-header'; ~~~~~~~~~~~~~~~~~~~~~ ../utils/dist/src/content-type.d.ts:4:51 - error TS2307: Cannot find module './fs'. 4 import { fileExtension as getFileExtension } from './fs'; ~~~~~~ ../utils/dist/src/npm.d.ts:1:28 - error TS2307: Cannot find module './types/npm'. 1 import { NpmPackage } from './types/npm'; ~~~~~~~~~~~~~ ../utils/dist/src/index.d.ts:6:26 - error TS2307: Cannot find module './fs'. 6 import * as fsUtils from './fs'; ~~~~~~ ../utils/dist/src/index.d.ts:8:28 - error TS2307: Cannot find module './misc'. 8 import * as miscUtils from './misc'; ~~~~~~~~ ../utils/dist/src/index.d.ts:9:31 - error TS2307: Cannot find module './network'. 9 import * as networkUtils from './network'; ~~~~~~~~~~~ ../utils/dist/src/index.d.ts:11:23 - error TS2307: Cannot find module './packages'. 11 import * as pkgs from './packages'; ~~~~~~~~~~~~ ../utils/dist/src/index.d.ts:12:28 - error TS2307: Cannot find module './test'. 12 import * as testUtils from './test'; ~~~~~~~~ ../utils/dist/src/index.d.ts:13:27 - error TS2307: Cannot find module './dom'. 13 import * as domUtils from './dom'; ~~~~~~~ ../utils/dist/src/index.d.ts:14:30 - error TS2307: Cannot find module './report'. 14 import * as reportUtils from './report'; ~~~~~~~~~~ ../utils/dist/src/index.d.ts:16:28 - error TS2307: Cannot find module './i18n'. 16 import * as i18nUtils from './i18n'; ~~~~~~~~ ../utils/dist/src/index.d.ts:17:15 - error TS2307: Cannot find module './types/config'. 17 export * from './types/config'; ~~~~~~~~~~~~~~~~ ../utils/dist/src/index.d.ts:18:15 - error TS2307: Cannot find module './types/http-header'. 18 export * from './types/http-header'; ~~~~~~~~~~~~~~~~~~~~~ ../utils/dist/src/index.d.ts:19:15 - error TS2307: Cannot find module './types/npm'. 19 export * from './types/npm'; ~~~~~~~~~~~~~ ../utils/dist/src/index.d.ts:20:15 - error TS2307: Cannot find module './types/html'. 20 export * from './types/html'; ~~~~~~~~~~~~~~ ../utils/dist/src/index.d.ts:21:15 - error TS2307: Cannot find module './types/problem-location'. 21 export * from './types/problem-location'; ~~~~~~~~~~~~~~~~~~~~~~~~~~ ../utils/dist/src/index.d.ts:22:15 - error TS2307: Cannot find module './types/category'. 22 export * from './types/category'; ~~~~~~~~~~~~~~~~~~ ../utils/dist/src/index.d.ts:23:15 - error TS2307: Cannot find module './compat'. 23 export * from './compat'; ~~~~~~~~~~ ../utils/dist/src/index.d.ts:24:15 - error TS2307: Cannot find module './config'. 24 export * from './config'; ~~~~~~~~~~ ../utils/dist/src/index.d.ts:25:15 - error TS2307: Cannot find module './dom/html'. 25 export * from './dom/html'; ~~~~~~~~~~~~ ../hint/src/lib/utils/packages/load-hint-package.ts:1:15 - error TS2307: Cannot find module '@hint/utils/dist/src/packages/load-hint-package'. 1 export * from '@hint/utils/dist/src/packages/load-hint-package'; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../hint/src/lib/types/formatters.ts:1:25 - error TS2307: Cannot find module '@hint/utils/dist/src/types/problems'. 1 import { Problem } from '@hint/utils/dist/src/types/problems'; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../hint/src/lib/types/formatters.ts:2:10 - error TS2305: Module '"../types"' has no exported member 'UserConfig'. 2 import { UserConfig, HintResources } from '../types'; ~~~~~~~~~~ ../hint/src/lib/types/network.ts:1:29 - error TS2307: Cannot find module '@hint/utils/dist/src/types/http-header'. 1 import { HttpHeaders } from '@hint/utils/dist/src/types/http-header'; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../hint/src/lib/config/config-hints.ts:13:45 - error TS2307: Cannot find module '@hint/utils/dist/src/schema-validation/schema-validator'. 13 import { validate as schemaValidator } from '@hint/utils/dist/src/schema-validation/schema-validator'; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../hint/src/lib/config/config-hints.ts:14:24 - error TS2305: Module '"../types"' has no exported member 'HintConfig'. 14 import { HintMetadata, HintConfig } from '../types'; ~~~~~~~~~~ ../hint/src/lib/config/config-hints.ts:15:26 - error TS2307: Cannot find module '@hint/utils/dist/src/types/problems'. 15 import { Severity } from '@hint/utils/dist/src/types/problems'; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../hint/src/lib/hint-context.ts:9:29 - error TS2307: Cannot find module '@hint/utils/dist/src/dom/html'. 9 import { HTMLElement } from '@hint/utils/dist/src/dom/html'; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../hint/src/lib/hint-context.ts:18:43 - error TS2307: Cannot find module '@hint/utils/dist/src/types/problems'. 18 import { ProblemLocation, Severity } from '@hint/utils/dist/src/types/problems'; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../hint/src/lib/hint-context.ts:19:26 - error TS2307: Cannot find module '@hint/utils/dist/src/types/category'. 19 import { Category } from '@hint/utils/dist/src/types/category'; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../hint/src/lib/hint-context.ts:20:36 - error TS2307: Cannot find module '@hint/utils/dist/src/report/get-html-code-snippet'. 20 import { getHTMLCodeSnippet } from '@hint/utils/dist/src/report/get-html-code-snippet'; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../hint/src/lib/config/config-validator.ts:14:26 - error TS2307: Cannot find module '@hint/utils/dist/src/schema-validation/schema-validator'. 14 import { validate } from '@hint/utils/dist/src/schema-validation/schema-validator'; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../hint/src/lib/config/config-validator.ts:15:10 - error TS2305: Module '"../types"' has no exported member 'UserConfig'. 15 import { UserConfig } from '../types'; ~~~~~~~~~~ ../hint/src/lib/config/config-validator.ts:16:54 - error TS2307: Cannot find module '@hint/utils/dist/src/schema-validation/schema-validation-result'. 16 import { SchemaValidationResult, GroupedError } from '@hint/utils/dist/src/schema-validation/schema-validation-result'; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../hint/src/lib/config/normalize-hints.ts:1:25 - error TS2307: Cannot find module '@hint/utils/dist/src/config/normalize-hints'. 1 export { default } from '@hint/utils/dist/src/config/normalize-hints'; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../hint/src/lib/enums/resource-type.ts:1:15 - error TS2307: Cannot find module '@hint/utils/dist/src/types/resource-type'. 1 export * from '@hint/utils/dist/src/types/resource-type'; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../hint/src/lib/enums/error-status.ts:1:15 - error TS2307: Cannot find module '@hint/utils/dist/src/types/resource-error-status'. 1 export * from '@hint/utils/dist/src/types/resource-error-status'; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../hint/src/lib/utils/resource-loader.ts:22:10 - error TS2305: Module '"../enums/resource-type"' has no exported member 'ResourceType'. 22 import { ResourceType } from '../enums/resource-type'; ~~~~~~~~~~~~ ../hint/src/lib/utils/resource-loader.ts:23:10 - error TS2305: Module '"../enums/error-status"' has no exported member 'ResourceErrorStatus'. 23 import { ResourceErrorStatus } from '../enums/error-status'; ~~~~~~~~~~~~~~~~~~~ ../hint/src/lib/utils/resource-loader.ts:26:15 - error TS2307: Cannot find module '@hint/utils/dist/src/packages/load-resource'. 26 export * from '@hint/utils/dist/src/packages/load-resource'; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../hint/src/lib/enums/index.ts:1:15 - error TS2307: Cannot find module '@hint/utils/dist/src/types/category'. 1 export * from '@hint/utils/dist/src/types/category'; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../hint/src/lib/config.ts:22:37 - error TS2305: Module '"../../../../node_modules/@hint/utils/dist/src"' has no exported member 'toAbsolutePaths'. 22 import { debug as d, fs as fsUtils, toAbsolutePaths } from '@hint/utils'; ~~~~~~~~~~~~~~~ ../hint/src/lib/config.ts:23:45 - error TS2307: Cannot find module '@hint/utils/dist/src/schema-validation/schema-validator'. 23 import { validate as schemaValidator } from '@hint/utils/dist/src/schema-validation/schema-validator'; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../hint/src/lib/config.ts:25:10 - error TS2305: Module '"./types"' has no exported member 'UserConfig'. 25 import { UserConfig, IgnoredUrl, ConnectorConfig, HintsConfigObject, HintSeverity, CreateAnalyzerOptions } from './types'; ~~~~~~~~~~ ../hint/src/lib/config.ts:25:22 - error TS2305: Module '"./types"' has no exported member 'IgnoredUrl'. 25 import { UserConfig, IgnoredUrl, ConnectorConfig, HintsConfigObject, HintSeverity, CreateAnalyzerOptions } from './types'; ~~~~~~~~~~ ../hint/src/lib/config.ts:25:34 - error TS2305: Module '"./types"' has no exported member 'ConnectorConfig'. 25 import { UserConfig, IgnoredUrl, ConnectorConfig, HintsConfigObject, HintSeverity, CreateAnalyzerOptions } from './types'; ~~~~~~~~~~~~~~~ ../hint/src/lib/config.ts:25:51 - error TS2305: Module '"./types"' has no exported member 'HintsConfigObject'. 25 import { UserConfig, IgnoredUrl, ConnectorConfig, HintsConfigObject, HintSeverity, CreateAnalyzerOptions } from './types'; ~~~~~~~~~~~~~~~~~ ../hint/src/lib/config.ts:25:70 - error TS2305: Module '"./types"' has no exported member 'HintSeverity'. 25 import { UserConfig, IgnoredUrl, ConnectorConfig, HintsConfigObject, HintSeverity, CreateAnalyzerOptions } from './types'; ~~~~~~~~~~~~ ../hint/src/lib/config.ts:30:10 - error TS2305: Module '"./enums"' has no exported member 'ResourceType'. 30 import { ResourceType } from './enums'; ~~~~~~~~~~~~ ../hint/src/lib/config.ts:83:52 - error TS7006: Parameter 'config' implicitly has an 'any' type. 83 const configurations = userConfig.extends.map((config) => { ~~~~~~ ../hint/src/lib/config.ts:306:42 - error TS2551: Property 'loadResource' does not exist on type 'typeof import("/home/kilian/Workspace/OS/hint/packages/hint/src/lib/utils/resource-loader")'. Did you mean 'loadResources'? 306 const Connector = resourceLoader.loadResource(connectorId, ResourceType.connector) as IConnectorConstructor; ~~~~~~~~~~~~ ../hint/src/lib/utils/resource-loader.ts:160:14 160 export const loadResources = (config: Configuration): HintResources => { ~~~~~~~~~~~~~ 'loadResources' is declared here. ../hint/src/lib/engine.ts:19:29 - error TS2307: Cannot find module '@hint/utils/dist/src/types/http-header'. 19 import { HttpHeaders } from '@hint/utils/dist/src/types/http-header'; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../hint/src/lib/engine.ts:21:43 - error TS2307: Cannot find module '@hint/utils/dist/src/dom/html'. 21 import { HTMLElement, HTMLDocument } from '@hint/utils/dist/src/dom/html'; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../hint/src/lib/engine.ts:26:5 - error TS2305: Module '"./types"' has no exported member 'HintConfig'. 26 HintConfig, ~~~~~~~~~~ ../hint/src/lib/engine.ts:44:8 - error TS2307: Cannot find module '@hint/utils/dist/src/types/problems'. 44 } from '@hint/utils/dist/src/types/problems'; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../hint/src/lib/types/connector.ts:3:29 - error TS2307: Cannot find module '@hint/utils/dist/src/types/http-header'. 3 import { HttpHeaders } from '@hint/utils/dist/src/types/http-header'; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../hint/src/lib/types/connector.ts:4:43 - error TS2307: Cannot find module '@hint/utils/dist/src/dom/html'. 4 import { HTMLElement, HTMLDocument } from '@hint/utils/dist/src/dom/html'; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../hint/src/lib/types/events.ts:1:29 - error TS2307: Cannot find module '@hint/utils/dist/src/dom/html'. 1 import { HTMLElement } from '@hint/utils/dist/src/dom/html'; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../hint/src/lib/types/events.ts:4:25 - error TS2307: Cannot find module '@hint/utils/dist/src/types/problems'. 4 import { Problem } from '@hint/utils/dist/src/types/problems'; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../hint/src/lib/types/parser.ts:5:30 - error TS2307: Cannot find module '@hint/utils/dist/src/fs/load-json-file'. 5 import { loadJSONFile } from '@hint/utils/dist/src/fs/load-json-file'; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../hint/src/lib/types/parser.ts:6:30 - error TS2307: Cannot find module '@hint/utils/dist/src/network/as-path-string'. 6 import { asPathString } from '@hint/utils/dist/src/network/as-path-string'; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../hint/src/lib/types/parser.ts:7:26 - error TS2307: Cannot find module '@hint/utils/dist/src/network/as-uri'. 7 import { getAsUri } from '@hint/utils/dist/src/network/as-uri'; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../hint/src/lib/types/hint-meta.ts:1:26 - error TS2307: Cannot find module '@hint/utils/dist/src/types/category'. 1 import { Category } from '@hint/utils/dist/src/types/category'; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../hint/src/lib/types/analyzer.ts:1:25 - error TS2307: Cannot find module '@hint/utils/dist/src/types/problems'. 1 import { Problem } from '@hint/utils/dist/src/types/problems'; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../hint/src/lib/types.ts:6:15 - error TS2307: Cannot find module '@hint/utils/dist/src/types/config'. 6 export * from '@hint/utils/dist/src/types/config'; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../hint/src/lib/types.ts:10:15 - error TS2307: Cannot find module '@hint/utils/dist/src/types/json-parser'. 10 export * from '@hint/utils/dist/src/types/json-parser'; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../hint/src/lib/types.ts:12:15 - error TS2307: Cannot find module '@hint/utils/dist/src/types/problems'. 12 export * from '@hint/utils/dist/src/types/problems'; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../hint/src/lib/types.ts:15:15 - error TS2307: Cannot find module '@hint/utils/dist/src/schema-validation/schema-validation-result'. 15 export * from '@hint/utils/dist/src/schema-validation/schema-validation-result'; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../hint/src/lib/cli.ts:22:10 - error TS2305: Module '"./utils/packages"' has no exported member 'loadHintPackage'. 22 import { loadHintPackage } from './utils/packages'; ~~~~~~~~~~~~~~~ ../hint/src/lib/analyzer.ts:13:5 - error TS2305: Module '"./types"' has no exported member 'UserConfig'. 13 UserConfig, ~~~~~~~~~~ ../hint/src/lib/analyzer.ts:23:25 - error TS2307: Cannot find module '@hint/utils/dist/src/types/problems'. 23 import { Problem } from '@hint/utils/dist/src/types/problems'; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../utils/dist/src/json-parser.d.ts:1:29 - error TS2307: Cannot find module './types/json-parser'. 1 import { IJSONResult } from './types/json-parser'; ~~~~~~~~~~~~~~~~~~~~~ ../hint/src/lib/utils/index.ts:3:39 - error TS2307: Cannot find module '@hint/utils/dist/src/schema-validation/schema-validator'. 3 import * as schemaValidatorUtils from '@hint/utils/dist/src/schema-validation/schema-validator'; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../hint/src/lib/cli/analyze.ts:9:52 - error TS2305: Module '"../../../../../node_modules/@hint/utils/dist/src"' has no exported member 'getHintsFromConfiguration'. 9 import { appInsights, configStore, debug as d, fs, getHintsFromConfiguration, logger, misc, network, npm, ConnectorConfig, normalizeHints, HintsConfigObject, HintSeverity } from '@hint/utils'; ~~~~~~~~~~~~~~~~~~~~~~~~~ ../hint/src/lib/cli/analyze.ts:9:107 - error TS2305: Module '"../../../../../node_modules/@hint/utils/dist/src"' has no exported member 'ConnectorConfig'. 9 import { appInsights, configStore, debug as d, fs, getHintsFromConfiguration, logger, misc, network, npm, ConnectorConfig, normalizeHints, HintsConfigObject, HintSeverity } from '@hint/utils'; ~~~~~~~~~~~~~~~ ../hint/src/lib/cli/analyze.ts:9:124 - error TS2305: Module '"../../../../../node_modules/@hint/utils/dist/src"' has no exported member 'normalizeHints'. 9 import { appInsights, configStore, debug as d, fs, getHintsFromConfiguration, logger, misc, network, npm, ConnectorConfig, normalizeHints, HintsConfigObject, HintSeverity } from '@hint/utils'; ~~~~~~~~~~~~~~ ../hint/src/lib/cli/analyze.ts:9:140 - error TS2305: Module '"../../../../../node_modules/@hint/utils/dist/src"' has no exported member 'HintsConfigObject'. 9 import { appInsights, configStore, debug as d, fs, getHintsFromConfiguration, logger, misc, network, npm, ConnectorConfig, normalizeHints, HintsConfigObject, HintSeverity } from '@hint/utils'; ~~~~~~~~~~~~~~~~~ ../hint/src/lib/cli/analyze.ts:9:159 - error TS2305: Module '"../../../../../node_modules/@hint/utils/dist/src"' has no exported member 'HintSeverity'. 9 import { appInsights, configStore, debug as d, fs, getHintsFromConfiguration, logger, misc, network, npm, ConnectorConfig, normalizeHints, HintsConfigObject, HintSeverity } from '@hint/utils'; ~~~~~~~~~~~~ ../hint/src/lib/cli/analyze.ts:10:35 - error TS2307: Cannot find module '@hint/utils/dist/src/types/problems'. 10 import { Problem, Severity } from '@hint/utils/dist/src/types/problems'; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../hint/src/lib/cli/analyze.ts:18:5 - error TS2305: Module '"../types"' has no exported member 'UserConfig'. 18 UserConfig ~~~~~~~~~~ ../hint/src/lib/cli/analyze.ts:20:10 - error TS2305: Module '"../utils/packages/load-hint-package"' has no exported member 'loadHintPackage'. 20 import { loadHintPackage } from '../utils/packages/load-hint-package'; ~~~~~~~~~~~~~~~ ../hint/src/lib/enums/category.ts:1:15 - error TS2307: Cannot find module '@hint/utils/dist/src/types/category'. 1 export * from '@hint/utils/dist/src/types/category'; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../hint/tests/lib/analyzer.ts:9:5 - error TS2305: Module '"../../src/lib/types"' has no exported member 'ConnectorConfig'. 9 ConnectorConfig, ~~~~~~~~~~~~~~~ ../hint/tests/lib/analyzer.ts:13:5 - error TS2305: Module '"../../src/lib/types"' has no exported member 'UserConfig'. 13 UserConfig ~~~~~~~~~~ ../hint/tests/lib/analyzer.ts:16:25 - error TS2307: Cannot find module '@hint/utils/dist/src/types/problems'. 16 import { Problem } from '@hint/utils/dist/src/types/problems'; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../hint/tests/lib/engine.ts:13:25 - error TS2307: Cannot find module '@hint/utils/dist/src/types/problems'. 13 import { Problem } from '@hint/utils/dist/src/types/problems'; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../hint/tests/lib/engine.ts:14:26 - error TS2307: Cannot find module '@hint/utils/dist/src/types/category'. 14 import { Category } from '@hint/utils/dist/src/types/category'; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../hint/tests/lib/hint-context.ts:4:26 - error TS2307: Cannot find module '@hint/utils/dist/src/types/problems'. 4 import { Severity } from '@hint/utils/dist/src/types/problems'; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../hint/tests/lib/cli/analyze.ts:6:35 - error TS2307: Cannot find module '@hint/utils/dist/src/types/problems'. 6 import { Problem, Severity } from '@hint/utils/dist/src/types/problems'; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../hint/tests/lib/cli/analyze.ts:15:5 - error TS2305: Module '"../../../src/lib/types"' has no exported member 'UserConfig'. 15 UserConfig, ~~~~~~~~~~ ../hint/tests/lib/cli/analyze.ts:16:5 - error TS2305: Module '"../../../src/lib/types"' has no exported member 'HintsConfigObject'. 16 HintsConfigObject ~~~~~~~~~~~~~~~~~ ../hint/tests/lib/config/config-hints.ts:4:10 - error TS2305: Module '"../../../src/lib/types"' has no exported member 'HintConfig'. 4 import { HintConfig, IHint, HintMetadata } from '../../../src/lib/types'; ~~~~~~~~~~ ../hint/tests/lib/utils/resource-loader.ts:13:31 - error TS2307: Cannot find module '@hint/utils/dist/src/types/resource-error'. 13 import { ResourceError } from '@hint/utils/dist/src/types/resource-error'; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../hint/tests/lib/utils/resource-loader.ts:16:10 - error TS2305: Module '"../../../src/lib/enums/resource-type"' has no exported member 'ResourceType'. 16 import { ResourceType } from '../../../src/lib/enums/resource-type'; ~~~~~~~~~~~~ ../hint/tests/lib/utils/resource-loader.ts:17:10 - error TS2305: Module '"../../../src/lib/enums/error-status"' has no exported member 'ResourceErrorStatus'. 17 import { ResourceErrorStatus } from '../../../src/lib/enums/error-status'; ~~~~~~~~~~~~~~~~~~~ ../utils/dist/src/content-type.d.ts:2:29 - error TS2307: Cannot find module './dom'. 2 import { HTMLElement } from './dom'; ~~~~~~~ ../utils/dist/src/content-type.d.ts:3:29 - error TS2307: Cannot find module './types/http-header'. 3 import { HttpHeaders } from './types/http-header'; ~~~~~~~~~~~~~~~~~~~~~ ../utils/dist/src/content-type.d.ts:4:51 - error TS2307: Cannot find module './fs'. 4 import { fileExtension as getFileExtension } from './fs'; ~~~~~~ ../utils/dist/src/npm.d.ts:1:28 - error TS2307: Cannot find module './types/npm'. 1 import { NpmPackage } from './types/npm'; ~~~~~~~~~~~~~ ../utils/dist/src/index.d.ts:6:26 - error TS2307: Cannot find module './fs'. 6 import * as fsUtils from './fs'; ~~~~~~ ../utils/dist/src/index.d.ts:8:28 - error TS2307: Cannot find module './misc'. 8 import * as miscUtils from './misc'; ~~~~~~~~ ../utils/dist/src/index.d.ts:9:31 - error TS2307: Cannot find module './network'. 9 import * as networkUtils from './network'; ~~~~~~~~~~~ ../utils/dist/src/index.d.ts:11:23 - error TS2307: Cannot find module './packages'. 11 import * as pkgs from './packages'; ~~~~~~~~~~~~ ../utils/dist/src/index.d.ts:12:28 - error TS2307: Cannot find module './test'. 12 import * as testUtils from './test'; ~~~~~~~~ ../utils/dist/src/index.d.ts:13:27 - error TS2307: Cannot find module './dom'. 13 import * as domUtils from './dom'; ~~~~~~~ ../utils/dist/src/index.d.ts:14:30 - error TS2307: Cannot find module './report'. 14 import * as reportUtils from './report'; ~~~~~~~~~~ ../utils/dist/src/index.d.ts:16:28 - error TS2307: Cannot find module './i18n'. 16 import * as i18nUtils from './i18n'; ~~~~~~~~ ../utils/dist/src/index.d.ts:17:15 - error TS2307: Cannot find module './types/config'. 17 export * from './types/config'; ~~~~~~~~~~~~~~~~ ../utils/dist/src/index.d.ts:18:15 - error TS2307: Cannot find module './types/http-header'. 18 export * from './types/http-header'; ~~~~~~~~~~~~~~~~~~~~~ ../utils/dist/src/index.d.ts:19:15 - error TS2307: Cannot find module './types/npm'. 19 export * from './types/npm'; ~~~~~~~~~~~~~ ../utils/dist/src/index.d.ts:20:15 - error TS2307: Cannot find module './types/html'. 20 export * from './types/html'; ~~~~~~~~~~~~~~ ../utils/dist/src/index.d.ts:21:15 - error TS2307: Cannot find module './types/problem-location'. 21 export * from './types/problem-location'; ~~~~~~~~~~~~~~~~~~~~~~~~~~ ../utils/dist/src/index.d.ts:22:15 - error TS2307: Cannot find module './types/category'. 22 export * from './types/category'; ~~~~~~~~~~~~~~~~~~ ../utils/dist/src/index.d.ts:23:15 - error TS2307: Cannot find module './compat'. 23 export * from './compat'; ~~~~~~~~~~ ../utils/dist/src/index.d.ts:24:15 - error TS2307: Cannot find module './config'. 24 export * from './config'; ~~~~~~~~~~ ../utils/dist/src/index.d.ts:25:15 - error TS2307: Cannot find module './dom/html'. 25 export * from './dom/html'; ~~~~~~~~~~~~ ../connector-puppeteer/dist/src/connector.d.ts:4:19 - error TS2305: Module '"../../../../node_modules/@hint/utils/dist/src"' has no exported member 'HTMLElement'. 4 import { Browser, HTMLElement, HTMLDocument, HttpHeaders } from '@hint/utils'; ~~~~~~~~~~~ ../connector-puppeteer/dist/src/connector.d.ts:4:32 - error TS2305: Module '"../../../../node_modules/@hint/utils/dist/src"' has no exported member 'HTMLDocument'. 4 import { Browser, HTMLElement, HTMLDocument, HttpHeaders } from '@hint/utils'; ~~~~~~~~~~~~ ../connector-puppeteer/dist/src/connector.d.ts:4:46 - error TS2305: Module '"../../../../node_modules/@hint/utils/dist/src"' has no exported member 'HttpHeaders'. 4 import { Browser, HTMLElement, HTMLDocument, HttpHeaders } from '@hint/utils'; ~~~~~~~~~~~ ../connector-puppeteer/dist/src/connector.d.ts:5:49 - error TS2307: Cannot find module 'hint'. 5 import { IConnector, Engine, NetworkData } from 'hint'; ~~~~~~ ../connector-puppeteer/dist/src/connector.d.ts:6:30 - error TS2307: Cannot find module './lib/actions'. 6 import { ActionConfig } from './lib/actions'; ~~~~~~~~~~~~~~~ ../connector-puppeteer/dist/src/connector.d.ts:7:44 - error TS2307: Cannot find module './lib/authenticators'. 7 import { AuthConfig, HTTPAuthConfig } from './lib/authenticators'; ~~~~~~~~~~~~~~~~~~~~~~ ../utils-connector-tools/dist/src/requester.d.ts:10:29 - error TS2307: Cannot find module 'hint'. 10 import { NetworkData } from 'hint'; ~~~~~~ ../connector-jsdom/dist/src/connector.d.ts:23:10 - error TS2305: Module '"../../../../node_modules/@hint/utils/dist/src"' has no exported member 'HTMLElement'. 23 import { HTMLElement, HTMLDocument, HttpHeaders } from '@hint/utils'; ~~~~~~~~~~~ ../connector-jsdom/dist/src/connector.d.ts:23:23 - error TS2305: Module '"../../../../node_modules/@hint/utils/dist/src"' has no exported member 'HTMLDocument'. 23 import { HTMLElement, HTMLDocument, HttpHeaders } from '@hint/utils'; ~~~~~~~~~~~~ ../connector-jsdom/dist/src/connector.d.ts:23:37 - error TS2305: Module '"../../../../node_modules/@hint/utils/dist/src"' has no exported member 'HttpHeaders'. 23 import { HTMLElement, HTMLDocument, HttpHeaders } from '@hint/utils'; ~~~~~~~~~~~ ../connector-jsdom/dist/src/connector.d.ts:24:49 - error TS2307: Cannot find module 'hint'. 24 import { Engine, IConnector, NetworkData } from 'hint'; ~~~~~~ ../utils-tests-helpers/src/connectors.ts:5:39 - error TS2307: Cannot find module 'hint'. 5 import { IConnectorConstructor } from 'hint'; ~~~~~~ ../utils-tests-helpers/src/hint-test-type.ts:3:33 - error TS2307: Cannot find module 'hint'. 3 import { ProblemLocation } from 'hint'; ~~~~~~ ../utils-tests-helpers/src/hint-runner.ts:12:109 - error TS2307: Cannot find module 'hint'. 12 import { Configuration, Engine, HintsConfigObject, IHintConstructor, Problem, ProblemLocation, utils } from 'hint'; ~~~~~~ Found 131 errors. error Command failed with exit code 2. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. ERROR: "build:ts" exited with 2. error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. ```

An additional yarn in that directory will say everything is ok though:

➜  extension-browser git:(master) yarn
yarn install v1.19.1
[1/5] Validating package.json...
[2/5] Resolving packages...
success Already up-to-date.
Done in 1.11s.

So I think i'm missing a step here. I'm using master. Any suggestions?

molant commented 5 years ago

I'm looking into this now see if I can repro.

In the meantime, the order of commands is:

  1. yarn --> This should download all packages and create any necessary symbolic links.
  2. yarn build --> Will download the artifacts if already available or otherwise fallback to build, so it can be really fast (otherwise it can be 10+ minutes).
molant commented 5 years ago

I can repro this locally. Looks like some dist folders don't get zipped.

molant commented 5 years ago

@Kilian working on a solution. CI is currently running to validate the changes and I hope to merge the change within the next couple hours 🤞

molant commented 5 years ago

https://github.com/webhintio/hint/pull/3119 is on the pipeline now and should fix this issue.

molant commented 5 years ago

Commit just got merged. You can run the command now (it will default to build everything from source as CI hasn't finished yet) or wait a bit until it's done.

Kilian commented 5 years ago

It runs now, but it does end with this warning:

WARNING in ../parser-html/dist/src/parser.js
Module not found: Error: Can't resolve 'module' in '/home/kilian/Workspace/OS/hint/packages/parser-html/dist/src'
 @ ../parser-html/dist/src/parser.js
 @ ./dist/src/content-script/webhint.js
Done in 21.63s.

Is that expected?

antross commented 5 years ago

@Kilian Yes, that warning is currently expected when we bundle parser-html using webpack as part of the extension-browser build.

Kilian commented 5 years ago

Electron currently doesn't support two of the Chrome extension API's that Webhint uses in the background script: webNavigation.onCommitted and browser.tabs.reload. Electron is currently moving to a new implementation of the Chrome extension API, so I'm checking if it makes sense to add support for these specific calls to the current implementation.

molant commented 5 years ago

FYI we want to add an option to scan a site without reloading. For this scenario reload and onComitted shouldn't be used so in theory things should then work in electron.

Is that something you'd be interested in looking into?


From: Kilian Valkhof notifications@github.com Sent: Monday, October 21, 2019 03:10 To: webhintio/hint Cc: Antón Molleda; Mention Subject: Re: [webhintio/hint] [Feature] Electron support for browser extension (#3059)

Electron currently doesn't support two of the Chrome extension API's that Webhint uses in the background script: webNavigation.onCommitted and browser.tabs.reload. Electron is currently moving to a new implementation of the Chrome extension API, so I'm checking if it makes sense to add support for these specific calls to the current implementation.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/webhintio/hint/issues/3059?email_source=notifications&email_token=AAEUDAR5CWV33T6OBOAOCLDQPV5ZLA5CNFSM4I4WLPTKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEBZZSPI#issuecomment-544446781, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAEUDAVJ3B7BEK6ZCQYZ2GDQPV5ZLANCNFSM4I4WLPTA.

Kilian commented 5 years ago

@molant that would mean neither call is required so that should work. It took me a very long time to track this down though, so I'd be up for it if someone could pair with me to talk me through where to make the changes for that.

antross commented 5 years ago

@Kilian I'd be willing to help here.

I'm wondering if it might first be worth making a modified build that just calls injectContentScript(tabId) directly in the enable helper of the background script to see if that's the last missing piece.

If so and we can detect that either onCommited or browser.tabs.reload is not available (or detect that we're running in Electron) we could do this automatically. I suspect we may need also to remember that we've already injected the content-script in this case to avoid having multiple listeners on subsequent runs, probably by having the content script itself set some global flag on setup and exit early if it's already set.

And once those two pieces are working we can look into extending the direct call to injectContentScript be triggered via the UI to support scans without reloading generally.

How does that sound?

Kilian commented 4 years ago

Sorry for the late reply. This isn't off my radar. Electron has been working on a new chrome extensions api that changes the way this integration would work, but currently has a fair amount of bugs so I'm waiting for that to stabilize.