Skip to content

Commit fbf280c

Browse files
committed
fix: build error
1 parent 5e686ec commit fbf280c

3 files changed

Lines changed: 28 additions & 4 deletions

File tree

extension/content/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(async function bootstrap() {
22
try {
3-
const { init } = await import(chrome.runtime.getURL('content/app.js'));
3+
const { init } = await import(/* webpackIgnore: true */ chrome.runtime.getURL('content/app.js'));
44
init();
55
} catch (error) {
66
console.error('[SpeedMaster] Failed to initialize:', error);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "speedmaster-extension",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"private": true,
55
"type": "module",
66
"scripts": {

webpack.config.js

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1+
import fs from 'fs';
12
import path from 'path';
23
import { fileURLToPath } from 'url';
34
import CopyWebpackPlugin from 'copy-webpack-plugin';
45

56
const __filename = fileURLToPath(import.meta.url);
67
const __dirname = path.dirname(__filename);
8+
const pkg = JSON.parse(fs.readFileSync(new URL('./package.json', import.meta.url), 'utf-8'));
9+
const PACKAGE_VERSION = process.env.npm_package_version || pkg.version;
710

8-
const entries = {
11+
const rawEntries = {
912
background: './extension/background.js',
1013
'content/app': './extension/content/app.js',
1114
'content/main': './extension/content/main.js',
@@ -16,6 +19,16 @@ const entries = {
1619
'options/options': './extension/options/options.js'
1720
};
1821

22+
const moduleEntries = new Set(['content/app']);
23+
const entries = Object.fromEntries(
24+
Object.entries(rawEntries).map(([name, entryPath]) => {
25+
if (moduleEntries.has(name)) {
26+
return [name, { import: entryPath, library: { type: 'module' } }];
27+
}
28+
return [name, entryPath];
29+
})
30+
);
31+
1932
export default (env, argv) => {
2033
const mode = argv.mode || 'production';
2134
return {
@@ -46,7 +59,15 @@ export default (env, argv) => {
4659
plugins: [
4760
new CopyWebpackPlugin({
4861
patterns: [
49-
{ from: 'extension/manifest.json', to: '.' },
62+
{
63+
from: 'extension/manifest.json',
64+
to: '.',
65+
transform(content) {
66+
const manifest = JSON.parse(content.toString('utf-8'));
67+
manifest.version = PACKAGE_VERSION;
68+
return JSON.stringify(manifest, null, 2).concat('\n');
69+
}
70+
},
5071
{ from: 'extension/assets', to: 'assets' },
5172
{ from: 'extension/content/controller.css', to: 'content/controller.css' },
5273
{ from: 'extension/popup/index.html', to: 'popup/index.html' },
@@ -59,6 +80,9 @@ export default (env, argv) => {
5980
resolve: {
6081
extensions: ['.js']
6182
},
83+
experiments: {
84+
outputModule: true
85+
},
6286
devtool: mode === 'production' ? false : 'source-map',
6387
watch: Boolean(argv.watch)
6488
};

0 commit comments

Comments
 (0)