-
-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ext] Allow the extension to connect to dev-env #1868
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks very good to me 👌 it was very easy to use my local environment.
Regarding the remaining hardcoded links in the options, as you suggested we can dynamically write them with JavaScript. There is already a script options.js
responsible of configuring the behaviour of the page options.html
.
And also fix the missing `?` in `learnMore.href`.
And use distinct .eslintrc.json for the scripts and for the extension code, to support top level await and remove the eslint-env comments in the scripts. The new src/.eslintrc.json is not added to the extension package because root hidden files are not added by build.sh.
I did that in 21414ca. As discussed elsewhere I also: |
Thank you. @amatissart do you also want to have a look before merging? I read the documentation about .eslintrc file cascading, and if I understood correctly it could be a good idea to define the key
https://eslint.org/docs/latest/use/configure/configuration-files#cascading-and-hierarchy |
It's indeed good to not merge the files, but as I understand it, to do that the |
I discovered that the |
The `prepare` script is run automatically by `yarn install`, so it may unexpectedly change the configuration.
related issues #1850
Description
These changes add a new script
prepareExtension.js
that generates themanifest.json
and a newconfig.js
. This allows us to generate an extension that connects to the dev-env (and other environments can be added).I ended up making a script instead of using a vite plugin because the plugins actually implied some unnecessary changes to the extension code, we don't need all the features the plugin provides, and I didn't feel comfortable adding so many new dependencies. The only dependency added here is node. But if we ever want to use TypeScript or React in the extension I think the best solution is to use the rollup version of this plugin: it's quite minimal and is very similar to what I did in the script.
To get all the content scripts to connect to the right servers, we need to import the config. Since content scripts can't use static imports, this would require wrapping all of them inside an anonymous async function to use the dynamic import. To avoid this, and to make development easier by enabling static imports in content scripts I copied the above plugin's method of replacing the content scripts in the manifest with small import wrappers that only import the actual content script.
The only references to the Tournesol production servers that I didn't change are inside HTML files:
These references are not very important to change when we are working on the extension, but it may be confusing to have links to the production servers when we are setting up the environment to not use production. I'm not sure what the best way is to change them. The easiest and safest way is probably to write these references in javascript at runtime.
Checklist