Skip to content
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

Added Manifest V3 compatibility for Firefox #197

Merged
merged 3 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
#1.3.66
- Added Firefox build script for Manifest V3 compatibility

#1.3.65
- Changed manifest.json to comply with Manifest V3

#1.3.64
- Fix the sidebar not redrawing when looking at GH issues

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Sometimes it is necessary to install and enable the public version of the extens

# Creating your PR
Be sure to do the following before pushing up your branch:
1. Bump the version number in `assets/manifest.json` (use major.minor.patch version scheme)
1. Bump the version number in `assets/manifest.json` and `assets/manifest-firefox.json` (use major.minor.patch version scheme)
1. Bump the version number in `package.json` and `package-lock.json` to match
1. Add a new change log entry in `CHANGELOG.md`

Expand Down
39 changes: 39 additions & 0 deletions assets/manifest-firefox.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"manifest_version": 3,

"name": "K2 for GitHub",
"version": "1.3.66",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe there are instructions in the README to update this version for every PR. Can you please update the instructions to include this manifest file too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

"description": "Manage your Kernel Scheduling from directly inside GitHub",

"browser_specific_settings": {
"gecko": {
"id": "[email protected]",
"strict_min_version": "42.0"
}
},

"icons": {
"16": "icon16.png",
"48": "icon48.png",
"128": "icon128.png"
},

"permissions": [
"webNavigation"
],

"host_permissions": [
"*://api.github.com/*"
],

"content_scripts": [{
"matches": ["*://*.github.com/*"],
"css": ["content.css"],
"js": ["content.js"]
}],

"background": {
"persistent": "false",
"scripts": ["events.js"]
}
}
2 changes: 1 addition & 1 deletion assets/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 3,

"name": "K2 for GitHub",
"version": "1.3.65",
"version": "1.3.66",
"description": "Manage your Kernel Scheduling from directly inside GitHub",

"browser_specific_settings": {
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
{
"name": "k2-extension",
"version": "1.3.65",
"version": "1.3.66",
"description": "A Chrome Extension for Kernel Schedule",
"private": true,
"scripts": {
"preinstall": "./tools/checkRuntimeVersions.sh",
"build": "webpack --progress --config webpack.prod.js",
"build": "npm run build:chrome",
"build:chrome": "webpack --progress --config webpack.prod.js --env platform=chrome",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the chrome build necessary? If so, let's be sure to update the README instructions for that too (and maybe remove the build command completely).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's not necessary, but my intention was to leave the default build command as it was, maintaining Chrome compatibility, add a new one for Firefox, and have build:chrome as an alias for build just for clarity

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made a change to make it clearer that build is just an alias for build:chrome

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, OK. I like the alias change. Thanks!

"build:firefox": "webpack --progress --config webpack.prod.js --env platform=firefox",
"package": "cd dist && zip -r -X ../dist.zip *",
"lint": "eslint . --max-warnings=0",
"lintfix": "eslint . --fix",
Expand Down
161 changes: 88 additions & 73 deletions webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,87 +5,102 @@ const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const {IgnorePlugin} = require('webpack');
const ESLintPlugin = require('eslint-webpack-plugin');

module.exports = {
context: path.resolve(__dirname, '.'),
entry: {
content: './src/js/content.js',
events: './src/js/events.js',
},
output: {
filename: '[name].js',
path: path.resolve(__dirname, 'dist'),
},
resolve: {
extensions: ['.jsx', '.js'],
},
module.exports = (env) => {
const isFirefox = env && env.platform === 'firefox';

plugins: [
new CleanWebpackPlugin(),
new MiniCssExtractPlugin(),
return {
context: path.resolve(__dirname, '.'),
entry: {
content: './src/js/content.js',
events: './src/js/events.js',
},
output: {
filename: '[name].js',
path: path.resolve(__dirname, 'dist'),
},
resolve: {
extensions: ['.jsx', '.js'],
},

// This is necessary because when moment.js is imported, it require()s some locale files which aren't needed and this results
// in console errors. By ignoring those imports, it allows everything to work without errors. More can be read about this here:
// https://webpack.js.org/plugins/ignore-plugin/#example-of-ignoring-moment-locales
new IgnorePlugin({
resourceRegExp: /^\.\/locale$/,
}),
plugins: [
new CleanWebpackPlugin(),
new MiniCssExtractPlugin(),

new ESLintPlugin({
cache: false,
emitWarning: true,
overrideConfigFile: path.resolve(__dirname, '.eslintrc.js'),
}),
// This is necessary because when moment.js is imported, it require()s some locale files which aren't needed and this results
// in console errors. By ignoring those imports, it allows everything to work without errors. More can be read about this here:
// https://webpack.js.org/plugins/ignore-plugin/#example-of-ignoring-moment-locales
new IgnorePlugin({
resourceRegExp: /^\.\/locale$/,
}),

// Copies icons and manifest file into our dist folder
new CopyPlugin({
patterns: [
{from: './assets/', to: path.resolve(__dirname, 'dist')}
]
}),
],
new ESLintPlugin({
cache: false,
emitWarning: true,
overrideConfigFile: path.resolve(__dirname, '.eslintrc.js'),
}),

module: {
rules: [
// Load .html files as strings, used for underscore templates
{
test: /\.html$/i,
use: 'underscore-template-loader'
},
// Conditional copy of manifest files and other assets
new CopyPlugin({
patterns: [
{
from: './assets/',
to: path.resolve(__dirname, 'dist'),
globOptions: {
ignore: ['**/manifest*.json'], // Ignore all manifest*.json files
},
},
{
// Conditionally copy the manifest based on platform
from: isFirefox ? './assets/manifest-firefox.json' : './assets/manifest.json',
to: path.resolve(__dirname, 'dist/manifest.json'),
},
],
}),
],

// Transpiles ES6 and JSX
{
test: /\.js$/,
use: {
loader: 'babel-loader',
module: {
rules: [
// Load .html files as strings, used for underscore templates
{
test: /\.html$/i,
use: 'underscore-template-loader'
},

/**
* Exclude node_modules except two packages we need to convert for rendering HTML because they import
* "react-native" internally and use JSX which we need to convert to JS for the browser.
*
* You can remove something from this list if it doesn't use JSX/JS that needs to be transformed by babel.
*/
include: [
path.resolve(__dirname, 'src'),
path.resolve(__dirname, 'node_modules/react-native-onyx'),
],
exclude: [
path.resolve(__dirname, 'node_modules/react-native-onyx/node_modules'),
],
},
{
test: /\.s[ac]ss$/i,
use: [
// Outputs the generated CSS to the dist folder
MiniCssExtractPlugin.loader,
// Transpiles ES6 and JSX
{
test: /\.js$/,
use: {
loader: 'babel-loader',
},

// Translates CSS into CommonJS
'css-loader',
/**
* Exclude node_modules except two packages we need to convert for rendering HTML because they import
* "react-native" internally and use JSX which we need to convert to JS for the browser.
*
* You can remove something from this list if it doesn't use JSX/JS that needs to be transformed by babel.
*/
include: [
path.resolve(__dirname, 'src'),
path.resolve(__dirname, 'node_modules/react-native-onyx'),
],
exclude: [
path.resolve(__dirname, 'node_modules/react-native-onyx/node_modules'),
],
},
{
test: /\.s[ac]ss$/i,
use: [
// Outputs the generated CSS to the dist folder
MiniCssExtractPlugin.loader,

// Compiles Sass to CSS
'sass-loader',
],
},
]
},
// Translates CSS into CommonJS
'css-loader',

// Compiles Sass to CSS
'sass-loader',
],
},
]
},
};
};
2 changes: 1 addition & 1 deletion webpack.dev.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const {merge} = require('webpack-merge');
const common = require('./webpack.common.js');

module.exports = merge(common, {
module.exports = (env) => merge(common(env), {
mode: 'development',
devtool: 'inline-source-map',
watch: true,
Expand Down
4 changes: 2 additions & 2 deletions webpack.prod.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const {merge} = require('webpack-merge');
const common = require('./webpack.common.js');

module.exports = merge(common, {
mode: 'production',
module.exports = (env) => merge(common(env), {
mode: 'production',
});
Loading