Skip to content

Commit

Permalink
🔀 Merge pull request #578 from FrostCo/switch_to_module
Browse files Browse the repository at this point in the history
Switch project type to module
  • Loading branch information
richardfrost authored Oct 6, 2024
2 parents c32224f + 1cfa49d commit 66a41ef
Show file tree
Hide file tree
Showing 22 changed files with 78 additions and 73 deletions.
2 changes: 1 addition & 1 deletion bin/clean.mjs → bin/clean.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Clean from './cleanClass.mjs';
import Clean from './cleanClass.js';

const clean = new Clean(process.argv);
clean.run();
2 changes: 1 addition & 1 deletion bin/cleanClass.mjs → bin/cleanClass.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable no-console */
import path from 'path';
import Common from './common.mjs';
import Common from './common.js';

export default class Clean {
//#region Class reference helpers
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion bin/copyStatic.mjs → bin/copyStatic.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import CopyStatic from './copyStaticClass.mjs';
import CopyStatic from './copyStaticClass.js';

const copyStatic = new CopyStatic();
copyStatic.run();
File renamed without changes.
2 changes: 1 addition & 1 deletion bin/packageExtension.mjs → bin/packageExtension.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import PackageExtension from './packageExtensionClass.mjs';
import PackageExtension from './packageExtensionClass.js';

const packageExtension = new PackageExtension();
packageExtension.run();
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable no-console */
import AdmZip from 'adm-zip';
import { globbySync } from 'globby';
import Common from './common.mjs';
import Common from './common.js';
import fse from 'fs-extra';

export default class PackageExtension {
Expand Down
2 changes: 1 addition & 1 deletion bin/packageSource.mjs → bin/packageSource.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import PackageSource from './packageSourceClass.mjs';
import PackageSource from './packageSourceClass.js';

const packageSource = new PackageSource();
packageSource.run();
28 changes: 14 additions & 14 deletions bin/packageSourceClass.mjs → bin/packageSourceClass.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable no-console */
import AdmZip from 'adm-zip';
import Common from './common.mjs';
import Common from './common.js';

// Required for Firefox due to bundled code
export default class PackageSource {
Expand Down Expand Up @@ -33,19 +33,19 @@ export default class PackageSource {

get binFiles() {
return [
'bin/clean.mjs',
'bin/cleanClass.mjs',
'bin/common.mjs',
'bin/copyStatic.mjs',
'bin/copyStaticClass.mjs',
'bin/packageExtension.mjs',
'bin/packageExtensionClass.mjs',
'bin/packageSource.mjs',
'bin/packageSourceClass.mjs',
'bin/postbuild.mjs',
'bin/postbuildClass.mjs',
'bin/prebuild.mjs',
'bin/prebuildClass.mjs',
'bin/clean.js',
'bin/cleanClass.js',
'bin/common.js',
'bin/copyStatic.js',
'bin/copyStaticClass.js',
'bin/packageExtension.js',
'bin/packageExtensionClass.js',
'bin/packageSource.js',
'bin/packageSourceClass.js',
'bin/postbuild.js',
'bin/postbuildClass.js',
'bin/prebuild.js',
'bin/prebuildClass.js',
'bin/webpack.bookmarklet.js',
'bin/webpack.common.js',
'bin/webpack.dev.js',
Expand Down
2 changes: 1 addition & 1 deletion bin/postbuild.mjs → bin/postbuild.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Postbuild from './postbuildClass.mjs';
import Postbuild from './postbuildClass.js';

const postbuild = new Postbuild();
postbuild.run();
2 changes: 1 addition & 1 deletion bin/postbuildClass.mjs → bin/postbuildClass.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import fse from 'fs-extra';
import Common from './common.mjs';
import Common from './common.js';

export default class Postbuild {
//#region Class reference helpers
Expand Down
2 changes: 1 addition & 1 deletion bin/prebuild.mjs → bin/prebuild.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Prebuild from './prebuildClass.mjs';
import Prebuild from './prebuildClass.js';

const prebuild = new Prebuild(process.argv);
prebuild.run();
2 changes: 1 addition & 1 deletion bin/prebuildClass.mjs → bin/prebuildClass.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable no-console */
import fse from 'fs-extra';
// import Constants from '../src/script/lib/constants'; // Temp?
import Common from './common.mjs';
import Common from './common.js';

export default class Prebuild {
//#region Class reference helpers
Expand Down
File renamed without changes.
File renamed without changes.
12 changes: 7 additions & 5 deletions bin/webpack.bookmarklet.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
const BUILD = require('../.build.json');
const TerserPlugin = require('terser-webpack-plugin');
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
const webpack = require('webpack');
import fs from 'fs-extra';
import TerserPlugin from 'terser-webpack-plugin';
import TsconfigPathsPlugin from 'tsconfig-paths-webpack-plugin';
import webpack from 'webpack';

module.exports = {
const BUILD = fs.readJsonSync('.build.json');

export default {
entry: {
bookmarkletFilter: './src/script/mainBookmarklet.ts',
},
Expand Down
10 changes: 6 additions & 4 deletions bin/webpack.common.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
const BUILD = require('../.build.json');
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
const webpack = require('webpack');
import fs from 'fs-extra';
import TsconfigPathsPlugin from 'tsconfig-paths-webpack-plugin';
import webpack from 'webpack';

module.exports = {
const BUILD = fs.readJsonSync('.build.json');

export default {
entry: {
background: './src/script/mainBackground.ts',
optionPage: './src/script/mainOptionPage.ts',
Expand Down
6 changes: 3 additions & 3 deletions bin/webpack.dev.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');
import { merge } from 'webpack-merge';
import common from './webpack.common.js';

module.exports = merge(common, {
export default merge(common, {
devtool: 'inline-source-map',
});
6 changes: 3 additions & 3 deletions bin/webpack.prod.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');
import { merge } from 'webpack-merge';
import common from './webpack.common.js';

module.exports = merge(common, {
export default merge(common, {
output: {
clean: false,
},
Expand Down
40 changes: 20 additions & 20 deletions development.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@ Once the extension has been built, you can load the unpacked extension (found in

## State Files

The state files hold the details about the current build. These files are managed by `bin/prebuild.mjs`.
The state files hold the details about the current build. These files are managed by `bin/prebuild.js`.

- `.build.json`
- Active build state file that is referenced when building/packaging/releasing
- Gets replaced by the dev or release build files outlined below
- `.build.dev.json`
- Holds the development build details and allows the developer to omit the target from commands such as `npm run build` to rebuild the project for the target specified in the file
- Overwrites `.build.json` when `--release` is **not** passed to `bin/prebuild.mjs`
- Overwrites `.build.json` when `--release` is **not** passed to `bin/prebuild.js`
- `.build.release.json`
- Holds the release build details
- Overwrites `.build.json` when `--release` **is** passed to `bin/prebuild.mjs`
- Overwrites `.build.json` when `--release` **is** passed to `bin/prebuild.js`

### Details Contained In State Files

Expand All @@ -73,58 +73,58 @@ For all scripts, please see `package.json`.
- `npm run build`
- npm run prebuild
- npm run clean:build
- node bin/clean.mjs --build
- node bin/prebuild.mjs --$npm_config_target
- node bin/clean.js --build
- node bin/prebuild.js --$npm_config_target
- NOTE: $npm_config_target will be blank (`--`)
- webpack --config bin/webpack.dev.js
- npm run build:static
- node bin/copyStatic.mjs
- node bin/copyStatic.js
- npm run postbuild
- node bin/postbuild.mjs
- node bin/postbuild.js

### Build Chrome Manifest V2

- `npm run build:chrome:mv2`
- npm run build --target=chrome-mv2
- npm run prebuild
- npm run clean:build
- node bin/clean.mjs --build
- node bin/prebuild.mjs --$npm_config_target
- node bin/clean.js --build
- node bin/prebuild.js --$npm_config_target
- npm run build
- webpack --config bin/webpack.dev.js
- npm run build:static
- node bin/copyStatic.mjs
- node bin/copyStatic.js
- npm run postbuild
- node bin/postbuild.mjs
- node bin/postbuild.js

### Release Chrome Manifest V3

- `npm run release:chrome:mv3`
- npm run release:build --target=chrome-mv3
- npm run prerelease:build
- npm run clean:build
- node bin/clean.mjs --build
- node bin/prebuild.mjs --release --$npm_config_target
- node bin/clean.js --build
- node bin/prebuild.js --release --$npm_config_target
- webpack --config bin/webpack.prod.js
- npm run build:static
- node bin/copyStatic.mjs
- node bin/copyStatic.js
- postrelease:build
- node bin/postbuild.mjs
- node bin/postbuild.js
- npm run package
- node bin/packageExtension.mjs
- node bin/packageExtension.js

### Test Addon (Firefox Manifest V2)

- `npm run test:addon`
- npm run release:build --target=firefox-mv2
- npm run prerelease:build
- npm run clean:build
- node bin/clean.mjs --build
- node bin/prebuild.mjs --release --$npm_config_target
- node bin/clean.js --build
- node bin/prebuild.js --release --$npm_config_target
- webpack --config bin/webpack.prod.js
- npm run build:static
- node bin/copyStatic.mjs
- node bin/copyStatic.js
- postrelease:build
- node bin/postbuild.mjs
- node bin/postbuild.js
- npm run package
- npx addons-linter ./dist
2 changes: 1 addition & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import tseslint from 'typescript-eslint';
export default [
{
// JavaScript files
files: ['**/*.js', '**/*.mjs'],
files: ['**/*.js'],
ignores: ['node_modules/**'],
languageOptions: {
globals: {
Expand Down
27 changes: 14 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"type": "git",
"url": "git+https://github.com/FrostCo/AdvancedProfanityFilter.git"
},
"type": "module",
"keywords": [
"Profanity",
"Filter"
Expand All @@ -26,22 +27,22 @@
"build:firefox:mv2": "npm run build --target=firefox-mv2",
"build:firefox:mv3": "npm run build --target=firefox-mv3",
"build:libs": "tsc -p ./src/script/lib/tsconfig.json",
"build:static": "node bin/copyStatic.mjs",
"build:static": "node bin/copyStatic.js",
"build": "webpack --config bin/webpack.dev.js && npm run build:static",
"clean:all": "node bin/clean.mjs --all",
"clean:build": "node bin/clean.mjs --build",
"clean:dist": "node bin/clean.mjs --dist",
"clean": "node bin/clean.mjs",
"package": "node bin/packageExtension.mjs",
"postbuild": "node bin/postbuild.mjs",
"clean:all": "node bin/clean.js --all",
"clean:build": "node bin/clean.js --build",
"clean:dist": "node bin/clean.js --dist",
"clean": "node bin/clean.js",
"package": "node bin/packageExtension.js",
"postbuild": "node bin/postbuild.js",
"postrelease:all": "npm run build",
"postrelease:build": "node bin/postbuild.mjs && npm run package",
"postrelease:firefox:mv2": "node bin/packageSource.mjs",
"prebuild": "npm run clean:build && node bin/prebuild.mjs --$npm_config_environment --$npm_config_target",
"postrelease:build": "node bin/postbuild.js && npm run package",
"postrelease:firefox:mv2": "node bin/packageSource.js",
"prebuild": "npm run clean:build && node bin/prebuild.js --$npm_config_environment --$npm_config_target",
"prerelease:all": "npm run clean && npm run release:bookmarklet",
"prerelease:build": "npm run clean:build && node bin/prebuild.mjs --release --$npm_config_target",
"prerelease:build": "npm run clean:build && node bin/prebuild.js --release --$npm_config_target",
"release:all": "npm run release:chrome:mv2 && npm run release:chrome:mv3 && npm run release:edgeLegacy && npm run release:firefox:mv2 && npm run release:firefox:mv3",
"release:bookmarklet": "node bin/prebuild.mjs --release --bookmarklet && webpack --config bin/webpack.bookmarklet.js",
"release:bookmarklet": "node bin/prebuild.js --release --bookmarklet && webpack --config bin/webpack.bookmarklet.js",
"release:build": "webpack --config bin/webpack.prod.js && npm run build:static",
"release:chrome:mv2": "npm run release:build --target=chrome-mv2",
"release:chrome:mv3": "npm run release:build --target=chrome-mv3",
Expand All @@ -66,7 +67,7 @@
"test": "npm run test:lint && npm run test:types && npm run test:addon && npm run test:cov",
"type-check:watch": "npm run type-check -- --watch",
"update:deps": "npx npm-check-updates --concurrency 10 --timeout 600000 --upgrade",
"update:help": "node bin/updateHelp.mjs",
"update:help": "node bin/updateHelp.js",
"watch": "node bin/watch.js"
},
"devDependencies": {
Expand Down

0 comments on commit 66a41ef

Please sign in to comment.