Skip to content

Commit a2edc75

Browse files
committed
back to separate lib index.js build to avoid difficulity with converting all ui.js to type="module" (for now)
1 parent 7ee28eb commit a2edc75

File tree

3 files changed

+92
-10
lines changed

3 files changed

+92
-10
lines changed

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<title>ReplayWeb.page</title>
66
<meta property="og:site_name" content="ReplayWeb.page" />
77
<meta name="viewport" content="width=device-width, initial-scale=1" />
8-
<script type="module" src="./ui.js"></script>
8+
<script src="./ui.js"></script>
99
<link rel="icon" href="/favicons/favicon.ico" sizes="32x32" />
1010
<link rel="icon" href="/favicons/favicon.svg" type="image/svg+xml" />
1111
<link rel="apple-touch-icon" href="/favicons/apple-touch-icon.png" />

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "replaywebpage",
33
"productName": "ReplayWeb.page",
4-
"version": "2.2.0-beta.4",
4+
"version": "2.2.0-beta.5",
55
"description": "Serverless Web Archive Replay",
66
"repository": "https://github.com/webrecorder/replayweb.page",
77
"homepage": "https://replayweb.page/",
@@ -10,7 +10,7 @@
1010
"exports": {
1111
".": {
1212
"types": "./dist/types/index.d.ts",
13-
"default": "./ui.js"
13+
"default": "./dist/index.js"
1414
},
1515
"./src/electron-*": "./src/electron-*.ts",
1616
"./index.html": "./index.html"

webpack.config.js

Lines changed: 89 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,94 @@ const electronPreloadConfig = (/*env, argv*/) => {
9494
return merge(tsConfig, config);
9595
};
9696

97+
const libConfig = (env, argv) => {
98+
/** @type {import('webpack').Configuration['entry']} */
99+
const entry = {
100+
index: "./src/index.ts",
101+
};
102+
103+
const extraPlugins = [];
104+
105+
const patterns = [
106+
{ from: "node_modules/@webrecorder/wabac/dist/sw.js", to: "sw.js" },
107+
];
108+
extraPlugins.push(new CopyPlugin({ patterns }));
109+
110+
/** @type {import('webpack').Configuration} */
111+
const config = {
112+
target: "web",
113+
mode: "production",
114+
cache: {
115+
type: isDevServer ? "memory" : "filesystem",
116+
},
117+
resolve: {
118+
fallback: { crypto: false },
119+
},
120+
entry,
121+
optimization,
122+
output: {
123+
path: path.join(__dirname, "dist"),
124+
filename: "[name].js",
125+
globalObject: "self",
126+
library: {
127+
type: "module",
128+
},
129+
publicPath: "/",
130+
},
131+
experiments: {
132+
outputModule: true,
133+
},
134+
135+
devtool: argv.mode === "production" ? undefined : "source-map",
136+
137+
plugins: [
138+
new webpack.NormalModuleReplacementPlugin(/^node:*/, (resource) => {
139+
switch (resource.request) {
140+
case "node:stream":
141+
resource.request = "stream-browserify";
142+
break;
143+
}
144+
}),
145+
146+
new webpack.optimize.LimitChunkCountPlugin({
147+
maxChunks: 1,
148+
}),
149+
new webpack.ProvidePlugin({
150+
process: "process/browser",
151+
}),
152+
new MiniCssExtractPlugin(),
153+
new webpack.DefinePlugin({
154+
__SW_NAME__: JSON.stringify("sw.js"),
155+
__HELPER_PROXY__: JSON.stringify(HELPER_PROXY),
156+
__GDRIVE_CLIENT_ID__: JSON.stringify(GDRIVE_CLIENT_ID),
157+
__VERSION__: JSON.stringify(package_json.version),
158+
}),
159+
new webpack.BannerPlugin(BANNER_TEXT),
160+
...extraPlugins,
161+
],
162+
163+
module: {
164+
rules: [
165+
{
166+
test: /\.svg$/,
167+
use: ["raw-loader"],
168+
},
169+
{
170+
test: /main.scss$/,
171+
use: ["css-loader", "sass-loader"],
172+
},
173+
{
174+
test: /wombat.js|wombatWorkers.js|index.html$/i,
175+
use: ["raw-loader"],
176+
},
177+
],
178+
},
179+
};
180+
return merge(tsConfig, config);
181+
};
182+
183+
184+
97185
const browserConfig = (env, argv) => {
98186
const isDevServer = process.env.WEBPACK_SERVE;
99187

@@ -125,19 +213,13 @@ const browserConfig = (env, argv) => {
125213
},
126214
entry,
127215
optimization,
128-
devtool: argv.mode === "production" ? undefined : "source-map",
129216
output: {
130217
path: path.join(__dirname),
131218
filename: "[name].js",
132-
library: {
133-
type: "module",
134-
},
219+
libraryTarget: "self",
135220
globalObject: "self",
136221
publicPath: "/",
137222
},
138-
experiments: {
139-
outputModule: true,
140-
},
141223
devServer: {
142224
compress: true,
143225
port: 9990,

0 commit comments

Comments
 (0)