-
Notifications
You must be signed in to change notification settings - Fork 213
Conversation
Feel free to use https://github.com/helfi92/webextension-neutrino-test to test this preset.
For linting, should we simply create a preset for it. What about the sign command? |
To develop with this preset, you first need to |
I added react specific babel presets to support building extensions using React. Should this be included as a default? I'm not sure we should include React specifics in the preset... |
Most of this seems like a copy of the Web preset. Can we just use web and disable the pieces we don't need? |
For react, I think we probably don't need it. At least right now. |
My only concern is that adding something to the web preset in the future may break the web-extension preset. If you still feel like this shouldn't be a concern, I am okay with it.
Sure thing. Maybe we could add the react bit to the scaffolding part. |
Understood, and I'm not concerned about it. If there is something that causes breakage in another preset, we should consider that to be a breaking change anyway, and something worthy of a major version bump. We shouldn't be purposefully breaking middleware.
Yeah we can consider it. Maybe it would be cool if it could be composed like so, but that does assume ordering, which I am not the biggest fan of: module.exports = {
use: [
'@neutrinojs/web',
'@neutrinojs/webextension'
]
};
module.exports = {
use: [
'@neutrinojs/react',
'@neutrinojs/webextension'
]
}; I guess we could say something about composition, but I still haven't figured out what a nice API for this would look like: module.exports = {
use: [
['@neutrinojs/webextension', {
extends: '@neutrinojs/react'
}]
]
}; |
As an aside, I think this will be named https://developer.mozilla.org/en-US/Add-ons/WebExtensions/What_are_WebExtensions |
* Renamed the preset to webextension * Deleted unwanted configs from the web preset * Store hot-update.{js, json} files in build/hot/ * Stop using hashes because it's not useful for web extensions. Also, the main html and js files need to be referenced in manifest.json and so it becomes hard to reference them if they have hashes.
bfaa738
to
05bdce4
Compare
I updated https://github.com/helfi92/webextension-neutrino-test to help test and experiment with the preset. |
@kumar303 I am creating a preset for creating web-extensions using Neutrino. I was wondering if you could give me some feedback on the current pull-request. Thanks in advance! |
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.
Thanks for the heads up. I took a look at the code but didn't test it. I think it needs some error handling otherwise it looks good. Feel free to ping me again if you have questions.
packages/webextension/index.js
Outdated
.end() | ||
.end() | ||
.when(neutrino.options.command === 'start', () => { | ||
webExt.cmd.run({ |
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.
This returns a promise which could be rejected in some situations. I don't see .catch()
handled. At the very least it should log the error because I don't think web-ext will do that in the run()
function. You could test it by omitting sourceDir
because that should reject the promise with some kind of error.
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.
Agreed. I added a .catch()
in my last commit.
packages/webextension/index.js
Outdated
.when(neutrino.options.command === 'start', () => { | ||
webExt.cmd.run({ | ||
noInput: true, | ||
sourceDir: neutrino.options.output |
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.
If this directory contains any unimportant build artifacts then you should consider passing an ignoreFiles
array to run()
.
run()
will start a file watcher within sourceDir
. When a file gets touched, it will reload the extension unless the file matches any pattern in ignoreFiles
.
It's important that the web-ext
file watcher does not look for changes in the actual source files. It should only look for changes in the final executable files that are built from the source (I think that's how you have it configured). This is because if web-ext
starts to reload the extension when a source file changes, it might reload too soon, before the final files are built by babel/webpack/whatever.
packages/webextension/index.js
Outdated
.end() | ||
.end() | ||
.when(neutrino.options.command === 'start', () => { | ||
webExt.cmd.run({ |
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.
I don't know much about neutrino but is there a way to make some run()
parameters configurable by the user? I can see a couple parameters here that the user may want to configure such as firefox
(path to executable), firefoxProfile
, browserConsole
, pref
...
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.
Yep. I made all the options configurable in my latest commit. That was a good point!
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.
So far so good.
Do you think we should perform some extra magic by reading and doing some things if a user provides a manifest.json?
Also, we will need documentation around this, and how it works with the manifest.json.
"repository": "https://github.com/mozilla-neutrino/neutrino-dev/tree/master/packages/webextension", | ||
"homepage": "https://neutrino.js.org", | ||
"bugs": "https://github.com/mozilla-neutrino/neutrino-dev/issues", | ||
"dependencies": { |
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.
We will need the publishConfig
and engines
copied here.
.end() | ||
.end() | ||
.when(neutrino.options.command === 'start', () => { | ||
webExt.cmd |
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.
I see where we are going with this, but exiting the process from here is going to skip all the error handling we have in the API.
What if we took this part out of this conditional and use an event?
neutrino.on('start', () => webExt.cmd.run(options.webExtRun, { shouldExitProgram: false }));
This way would mean we could skip handling the promise altogether and let the API handle it. Give it a shot and let me know if that works.
I just checked, it looks promising. However a few questions:
What do you mean ? Also allowing web-ext to read a config.js file would be nice to let the user choose the profile, firefox executable and so on. Finally, a command like |
My preference would be for the
For example, if the user sets the popup file in the manifest.json, should we automatically add it to Neutrino's mains?
Yes, that's the gist of it. :)
We would like this to be driven by settings in
Could this happen in the |
Aside from hooking into the standard ways of configuring neutrino presets, I should mention that web-ext now supports standalone config files. The config feature was added after this PR began. A |
Make sense, it respects the standard behavior.
@kumar303 said what I was thinking for. Everything is already provided by web-ext and would avoid to bind too much
Yes, it would avoid new commands. @helfi92 do you have some plan to go ahead ? @kumar303 What about chome/chromium support ? |
There is a reason for this. By managing this in
@helfi92 will be out for the next week or so, so if you want to take this PR over the finish line with the suggestions, we would be happy to have your contribution! |
This feature is being tracked in mozilla/web-ext#809 and we may have someone to work on it soon but no concrete plans. |
@eliperelman One question about the PR workflow. So, after my commits will be added on top of helfi92's ones in this PR. |
I would recommend rebasing against master. If you need a guide of how to do a rebase, I would recommend giving this a read: http://blessing.io/git/git-rebase/open-source/2015/08/23/git-rebasing-to-resolve-conflicts.html |
In neutrino by adding an entry in mains, can you compile only a JS without an HTML ? |
@Morikko I don't understand the question, could you rephrase? |
UPDATE:
|
I have commited new things but it is visible only on my local repository. In brief:
Also I am using this extension to test it. |
@eliperelman Do neutrino has an event for when a command ends ? Like
|
Few updates:
@eliperelman On Note: JavaScript files are background and content scripts. |
Yes, there is |
See #831 for next steps here, or if you think we should just close this at the moment. |
Closing this in favour of #831. |
No description provided.