Skip to content

Commit

Permalink
fix webpack build!
Browse files Browse the repository at this point in the history
  • Loading branch information
emma-sg committed Jan 12, 2024
1 parent 675ac7c commit c0c8f49
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 22 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"svg-inline-loader": "^0.8.2",
"terser-webpack-plugin": "^5.2.4",
"to-string-loader": "^1.1.6",
"ts-loader": "^9.5.1",
"ts-migrate": "^0.1.35",
"typescript": "^5.3.3",
"webpack": "^5.74.0",
Expand Down
2 changes: 1 addition & 1 deletion src/electron/electron-rec-preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import { ensureDefaultColl } from "../utils";

import { loader, getDB } from "replaywebpage/dist/electron-preload";
import { loader, getDB } from "replaywebpage/src/electron-preload";

// eslint-disable-next-line @typescript-eslint/no-var-requires
const { ipcRenderer, contextBridge } = require("electron");
Expand Down
2 changes: 1 addition & 1 deletion src/electron/electron-recorder-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { ElectronRecorder } from "./electron-recorder";
import {
ElectronReplayApp,
STATIC_PREFIX,
} from "replaywebpage/dist/electron-replay-app";
} from "replaywebpage/src/electron-replay-app";

import path from "path";

Expand Down
2 changes: 1 addition & 1 deletion src/recorder.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { RequestResponseInfo } from "./requestresponseinfo.js";
import { RequestResponseInfo } from "./requestresponseinfo";

import { baseRules as baseDSRules } from "@webrecorder/wabac/src/rewrite";
import {
Expand Down
2 changes: 1 addition & 1 deletion src/ui/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class ArchiveWebApp extends ReplayWebApp {
// ignore empty
}

this.ipfsOpts = this.ipfsOpts || {
this.ipfsOpts ||= {
daemonUrl: "",
message: "",
useCustom: false,
Expand Down
33 changes: 25 additions & 8 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ const DIST_EMBED = path.join(__dirname, "dist", "embed");
/** @type {import('webpack').Configuration['module']} */
const moduleSettings = {
rules: [
{
test: /\.tsx?$/,
loader: "ts-loader",
options: {
onlyCompileBundledFiles: true,
},
},
{
test: /\.svg$/,
use: "svg-inline-loader",
Expand Down Expand Up @@ -70,7 +77,7 @@ const electronMainConfig = (/*env, argv*/) => {
target: "electron-main",
mode: "production",
entry: {
electron: "./src/electron/electron-rec-main.js",
electron: "./src/electron/electron-rec-main.ts",
},
optimization,
output: {
Expand Down Expand Up @@ -108,12 +115,22 @@ const electronPreloadConfig = (/*env, argv*/) => {
filename: "[name].js",
},
plugins: [new webpack.DefinePlugin(defaultDefines)],
module: moduleSettings,
resolve,
};
};

// ===========================================================================
/** @returns {import('webpack').Configuration} */
/**
* @param {string} outputPath
* @param {Object} [param1={}]
* @param {import('webpack').Configuration['plugins']} [param1.plugins=[]]
* @param {import('copy-webpack-plugin').CopyPlugin['Configuration']['patterns']} [param1.copy=[]]
* @param {import('webpack').Configuration['entry']} [param1.entry={}]
* @param {Partial<import('webpack').Configuration>} [param1.extra={}]
* @param {boolean} [param1.flat=false]
* @returns {import('webpack').Configuration}
*/
function sharedBuild(
outputPath,
{ plugins = [], copy = [], entry = {}, extra = {}, flat = false } = {}
Expand All @@ -126,8 +143,8 @@ function sharedBuild(
mode: "production",
target: "web",
entry: {
ui: "./src/ui/app.js",
sw: "./src/sw/main.js",
ui: "./src/ui/app.ts",
sw: "./src/sw/main.ts",
...entry,
},
optimization,
Expand Down Expand Up @@ -199,8 +216,8 @@ const extensionWebConfig = (env, argv) => {
const copy = [{ from: "static/", to: "./" }];

const entry = {
bg: "./src/ext/bg.js",
popup: "./src/popup.js",
bg: "./src/ext/bg.ts",
popup: "./src/popup.ts",
};

return sharedBuild(DIST_EXT, { plugins, copy, entry });
Expand All @@ -209,12 +226,12 @@ const extensionWebConfig = (env, argv) => {
// ===========================================================================
const electronWebConfig = (/*env, argv*/) => {
const entry = {
"rec-window": "./src/electron/rec-window.js",
"rec-window": "./src/electron/rec-window.ts",
};

const copy = [
{ from: "static/", to: "./" },
{ from: "src/electron/rec-preload.js", to: "" },
{ from: "src/electron/rec-preload.ts", to: "" },
{ from: "src/electron/rec-window.html", to: "" },
];

Expand Down
36 changes: 26 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4052,18 +4052,18 @@ end-of-stream@^1.1.0:
dependencies:
once "^1.4.0"

enhanced-resolve@^5.10.0:
version "5.10.0"
resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.10.0.tgz#0dc579c3bb2a1032e357ac45b8f3a6f3ad4fb1e6"
integrity sha512-T0yTFjdpldGY8PmuXXR0PyQ1ufZpEGiHVrp7zHKB7jdR4qlmZHhONVM5AQOAWXuF/w3dnHbEQVrNptJgt7F+cQ==
enhanced-resolve@^5.0.0, enhanced-resolve@^5.7.0:
version "5.15.0"
resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.15.0.tgz#1af946c7d93603eb88e9896cee4904dc012e9c35"
integrity sha512-LXYT42KJ7lpIKECr2mAXIaMldcNCh/7E0KBKOu4KSfkHmP+mZmSs+8V5gBAqisWBy0OO4W5Oyys0GO1Y8KtdKg==
dependencies:
graceful-fs "^4.2.4"
tapable "^2.2.0"

enhanced-resolve@^5.7.0:
version "5.15.0"
resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.15.0.tgz#1af946c7d93603eb88e9896cee4904dc012e9c35"
integrity sha512-LXYT42KJ7lpIKECr2mAXIaMldcNCh/7E0KBKOu4KSfkHmP+mZmSs+8V5gBAqisWBy0OO4W5Oyys0GO1Y8KtdKg==
enhanced-resolve@^5.10.0:
version "5.10.0"
resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.10.0.tgz#0dc579c3bb2a1032e357ac45b8f3a6f3ad4fb1e6"
integrity sha512-T0yTFjdpldGY8PmuXXR0PyQ1ufZpEGiHVrp7zHKB7jdR4qlmZHhONVM5AQOAWXuF/w3dnHbEQVrNptJgt7F+cQ==
dependencies:
graceful-fs "^4.2.4"
tapable "^2.2.0"
Expand Down Expand Up @@ -6317,7 +6317,7 @@ micromatch@^3.1.10:
snapdragon "^0.8.1"
to-regex "^3.0.2"

micromatch@^4.0.2:
micromatch@^4.0.0, micromatch@^4.0.2:
version "4.0.5"
resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.5.tgz#bc8999a7cbbf77cdc89f132f6e467051b49090c6"
integrity sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==
Expand Down Expand Up @@ -7642,7 +7642,7 @@ repeat-string@^1.6.1:

"replaywebpage@git+https://github.com/webrecorder/replayweb.page.git#emma/publish-generated-types":
version "2.0.0-beta"
resolved "git+https://github.com/webrecorder/replayweb.page.git#6fa436b0051df5489e875ce37cb2174f0953464a"
resolved "git+https://github.com/webrecorder/replayweb.page.git#7a7232896e98c6f7a6c98ce85b76f1667cc527bd"
dependencies:
"@fortawesome/fontawesome-free" "^5.15.4"
"@shoelace-style/shoelace" "^2.8.0"
Expand Down Expand Up @@ -8370,6 +8370,11 @@ source-map@^0.7.3:
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.7.3.tgz#5302f8169031735226544092e64981f751750383"
integrity sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==

source-map@^0.7.4:
version "0.7.4"
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.7.4.tgz#a9bbe705c9d8846f4e08ff6765acf0f1b0898656"
integrity sha512-l3BikUxvPOcn5E74dZiq5BGsTb5yEwhaTSzccU6t4sDOH8NWJCstKO5QT2CvtFoK6F0saL7p9xHAqHOlCPJygA==

spdx-correct@^3.0.0:
version "3.1.1"
resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-3.1.1.tgz#dece81ac9c1e6713e5f7d1b6f17d468fa53d89a9"
Expand Down Expand Up @@ -8850,6 +8855,17 @@ ts-api-utils@^1.0.1:
resolved "https://registry.yarnpkg.com/ts-api-utils/-/ts-api-utils-1.0.3.tgz#f12c1c781d04427313dbac808f453f050e54a331"
integrity sha512-wNMeqtMz5NtwpT/UZGY5alT+VoKdSsOOP/kqHFcUW1P/VRhH2wJ48+DN2WwUliNbQ976ETwDL0Ifd2VVvgonvg==

ts-loader@^9.5.1:
version "9.5.1"
resolved "https://registry.yarnpkg.com/ts-loader/-/ts-loader-9.5.1.tgz#63d5912a86312f1fbe32cef0859fb8b2193d9b89"
integrity sha512-rNH3sK9kGZcH9dYzC7CewQm4NtxJTjSEVRJ2DyBZR7f8/wcta+iV44UPCXc5+nzDzivKtlzV6c9P4e+oFhDLYg==
dependencies:
chalk "^4.1.0"
enhanced-resolve "^5.0.0"
micromatch "^4.0.0"
semver "^7.3.4"
source-map "^0.7.4"

ts-migrate-plugins@^0.1.35:
version "0.1.35"
resolved "https://registry.yarnpkg.com/ts-migrate-plugins/-/ts-migrate-plugins-0.1.35.tgz#96579e07ba8ffa31ff85dfbdd0220482e641f654"
Expand Down

0 comments on commit c0c8f49

Please sign in to comment.