wxt 0.15.1 → 0.15.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-T57ALCJ4.js → chunk-6OOILYIE.js} +69 -29
- package/dist/cli.js +144 -67
- package/dist/index.cjs +91 -51
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/testing.cjs +50 -17
- package/dist/testing.js +1 -1
- package/package.json +3 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// package.json
|
|
2
|
-
var version = "0.15.
|
|
2
|
+
var version = "0.15.3";
|
|
3
3
|
|
|
4
4
|
// src/core/utils/arrays.ts
|
|
5
5
|
function every(array, predicate) {
|
|
@@ -102,10 +102,10 @@ function findEffectedSteps(changedFile, currentOutput) {
|
|
|
102
102
|
const changes = [];
|
|
103
103
|
const changedPath = normalizePath(changedFile);
|
|
104
104
|
const isChunkEffected = (chunk) => (
|
|
105
|
-
// If it's an HTML file with the same path, is is effected because HTML files need to be
|
|
106
|
-
// fileName is normalized, relative bundle path
|
|
107
|
-
chunk.type === "asset" && changedPath.endsWith(chunk.fileName) || // If it's a chunk that depends on the changed file, it is effected
|
|
108
|
-
// moduleIds are absolute, normalized paths
|
|
105
|
+
// If it's an HTML file with the same path, is is effected because HTML files need to be re-rendered
|
|
106
|
+
// - fileName is normalized, relative bundle path, "<entrypoint-name>.html"
|
|
107
|
+
chunk.type === "asset" && changedPath.replace("/index.html", ".html").endsWith(chunk.fileName) || // If it's a chunk that depends on the changed file, it is effected
|
|
108
|
+
// - moduleIds are absolute, normalized paths
|
|
109
109
|
chunk.type === "chunk" && chunk.moduleIds.includes(changedPath)
|
|
110
110
|
);
|
|
111
111
|
for (const step of currentOutput.steps) {
|
|
@@ -533,7 +533,7 @@ import consola, { LogLevels } from "consola";
|
|
|
533
533
|
|
|
534
534
|
// src/core/builders/vite/plugins/devHtmlPrerender.ts
|
|
535
535
|
import { parseHTML } from "linkedom";
|
|
536
|
-
import { dirname as dirname3,
|
|
536
|
+
import { dirname as dirname3, relative as relative3, resolve as resolve5 } from "node:path";
|
|
537
537
|
var reactRefreshPreamble = "";
|
|
538
538
|
function devHtmlPrerender(config) {
|
|
539
539
|
const htmlReloadId = "@wxt/reload-html";
|
|
@@ -563,22 +563,9 @@ function devHtmlPrerender(config) {
|
|
|
563
563
|
if (config.command !== "serve" || server == null || !id.endsWith(".html"))
|
|
564
564
|
return;
|
|
565
565
|
const { document } = parseHTML(code);
|
|
566
|
-
const
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
if (!src)
|
|
570
|
-
return;
|
|
571
|
-
if (isAbsolute(src)) {
|
|
572
|
-
element.setAttribute(attr, server.origin + src);
|
|
573
|
-
} else if (src.startsWith(".")) {
|
|
574
|
-
const abs = resolve5(dirname3(id), src);
|
|
575
|
-
const pathname = relative3(config.root, abs);
|
|
576
|
-
element.setAttribute(attr, `${server.origin}/${pathname}`);
|
|
577
|
-
}
|
|
578
|
-
});
|
|
579
|
-
};
|
|
580
|
-
pointToDevServer("script[type=module]", "src");
|
|
581
|
-
pointToDevServer("link[rel=stylesheet]", "href");
|
|
566
|
+
const _pointToDevServer = (querySelector, attr) => pointToDevServer(config, server, id, document, querySelector, attr);
|
|
567
|
+
_pointToDevServer("script[type=module]", "src");
|
|
568
|
+
_pointToDevServer("link[rel=stylesheet]", "href");
|
|
582
569
|
const reloader = document.createElement("script");
|
|
583
570
|
reloader.src = htmlReloadId;
|
|
584
571
|
reloader.type = "module";
|
|
@@ -644,6 +631,48 @@ function devHtmlPrerender(config) {
|
|
|
644
631
|
}
|
|
645
632
|
];
|
|
646
633
|
}
|
|
634
|
+
function pointToDevServer(config, server, id, document, querySelector, attr) {
|
|
635
|
+
document.querySelectorAll(querySelector).forEach((element) => {
|
|
636
|
+
const src = element.getAttribute(attr);
|
|
637
|
+
if (!src || isUrl(src))
|
|
638
|
+
return;
|
|
639
|
+
let resolvedAbsolutePath;
|
|
640
|
+
const matchingAlias = Object.entries(config.alias).find(
|
|
641
|
+
([key]) => src.startsWith(key)
|
|
642
|
+
);
|
|
643
|
+
if (matchingAlias) {
|
|
644
|
+
const [alias, replacement] = matchingAlias;
|
|
645
|
+
resolvedAbsolutePath = resolve5(
|
|
646
|
+
config.root,
|
|
647
|
+
src.replace(alias, replacement)
|
|
648
|
+
);
|
|
649
|
+
} else {
|
|
650
|
+
resolvedAbsolutePath = resolve5(dirname3(id), src);
|
|
651
|
+
}
|
|
652
|
+
if (resolvedAbsolutePath) {
|
|
653
|
+
const relativePath = normalizePath(
|
|
654
|
+
relative3(config.root, resolvedAbsolutePath)
|
|
655
|
+
);
|
|
656
|
+
if (relativePath.startsWith(".")) {
|
|
657
|
+
let path6 = normalizePath(resolvedAbsolutePath);
|
|
658
|
+
if (!path6.startsWith("/"))
|
|
659
|
+
path6 = "/" + path6;
|
|
660
|
+
element.setAttribute(attr, `${server.origin}/@fs${path6}`);
|
|
661
|
+
} else {
|
|
662
|
+
const url = new URL(relativePath, server.origin);
|
|
663
|
+
element.setAttribute(attr, url.href);
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
});
|
|
667
|
+
}
|
|
668
|
+
function isUrl(str) {
|
|
669
|
+
try {
|
|
670
|
+
new URL(str);
|
|
671
|
+
return true;
|
|
672
|
+
} catch {
|
|
673
|
+
return false;
|
|
674
|
+
}
|
|
675
|
+
}
|
|
647
676
|
|
|
648
677
|
// src/core/builders/vite/plugins/devServerGlobals.ts
|
|
649
678
|
function devServerGlobals(config) {
|
|
@@ -2251,8 +2280,7 @@ async function rebuild(config, allEntrypoints, entrypointGroups, existingOutput
|
|
|
2251
2280
|
}
|
|
2252
2281
|
|
|
2253
2282
|
// src/core/utils/building/internal-build.ts
|
|
2254
|
-
import
|
|
2255
|
-
import { resolve as resolve12, relative as relative5 } from "node:path";
|
|
2283
|
+
import { relative as relative5 } from "node:path";
|
|
2256
2284
|
|
|
2257
2285
|
// src/core/utils/validation.ts
|
|
2258
2286
|
function validateEntrypoints(entrypoints) {
|
|
@@ -2315,6 +2343,19 @@ var ValidationError = class extends Error {
|
|
|
2315
2343
|
|
|
2316
2344
|
// src/core/utils/building/internal-build.ts
|
|
2317
2345
|
import consola3 from "consola";
|
|
2346
|
+
|
|
2347
|
+
// src/core/utils/exec.ts
|
|
2348
|
+
import managePath from "manage-path";
|
|
2349
|
+
import { resolve as resolve12 } from "node:path";
|
|
2350
|
+
var managedPath = managePath(process.env);
|
|
2351
|
+
var exec = async (config, file, args, options) => {
|
|
2352
|
+
managedPath.restore();
|
|
2353
|
+
managedPath.push(resolve12(config.root, "node_modules/wxt/node_modules/.bin"));
|
|
2354
|
+
const { execa } = await import("./execa-4F7CCWCA.js");
|
|
2355
|
+
return await execa(file, args, options);
|
|
2356
|
+
};
|
|
2357
|
+
|
|
2358
|
+
// src/core/utils/building/internal-build.ts
|
|
2318
2359
|
async function internalBuild(config) {
|
|
2319
2360
|
const verb = config.command === "serve" ? "Pre-rendering" : "Building";
|
|
2320
2361
|
const target = `${config.browser}-mv${config.manifestVersion}`;
|
|
@@ -2363,16 +2404,15 @@ async function internalBuild(config) {
|
|
|
2363
2404
|
return output;
|
|
2364
2405
|
}
|
|
2365
2406
|
async function combineAnalysisStats(config) {
|
|
2366
|
-
const { execaCommand } = await import("./execa-4F7CCWCA.js");
|
|
2367
2407
|
const unixFiles = await glob2(`stats-*.json`, {
|
|
2368
2408
|
cwd: config.outDir,
|
|
2369
2409
|
absolute: true
|
|
2370
2410
|
});
|
|
2371
2411
|
const absolutePaths = unixFiles.map(unnormalizePath);
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2412
|
+
await exec(
|
|
2413
|
+
config,
|
|
2414
|
+
"rollup-plugin-visualizer",
|
|
2415
|
+
[...absolutePaths, "--template", config.analysis.template],
|
|
2376
2416
|
{ cwd: config.root, stdio: "inherit" }
|
|
2377
2417
|
);
|
|
2378
2418
|
}
|
package/dist/cli.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import { createRequire } from 'module';const require = createRequire(import.meta.url);
|
|
2
2
|
import "./chunk-73I7FAJU.js";
|
|
3
3
|
|
|
4
|
-
// src/cli.ts
|
|
4
|
+
// src/cli/commands.ts
|
|
5
5
|
import cac from "cac";
|
|
6
6
|
|
|
7
|
-
// package.json
|
|
8
|
-
var version = "0.15.1";
|
|
9
|
-
|
|
10
7
|
// src/core/utils/fs.ts
|
|
11
8
|
import fs from "fs-extra";
|
|
12
9
|
import glob from "fast-glob";
|
|
@@ -164,10 +161,10 @@ function findEffectedSteps(changedFile, currentOutput) {
|
|
|
164
161
|
const changes = [];
|
|
165
162
|
const changedPath = normalizePath(changedFile);
|
|
166
163
|
const isChunkEffected = (chunk) => (
|
|
167
|
-
// If it's an HTML file with the same path, is is effected because HTML files need to be
|
|
168
|
-
// fileName is normalized, relative bundle path
|
|
169
|
-
chunk.type === "asset" && changedPath.endsWith(chunk.fileName) || // If it's a chunk that depends on the changed file, it is effected
|
|
170
|
-
// moduleIds are absolute, normalized paths
|
|
164
|
+
// If it's an HTML file with the same path, is is effected because HTML files need to be re-rendered
|
|
165
|
+
// - fileName is normalized, relative bundle path, "<entrypoint-name>.html"
|
|
166
|
+
chunk.type === "asset" && changedPath.replace("/index.html", ".html").endsWith(chunk.fileName) || // If it's a chunk that depends on the changed file, it is effected
|
|
167
|
+
// - moduleIds are absolute, normalized paths
|
|
171
168
|
chunk.type === "chunk" && chunk.moduleIds.includes(changedPath)
|
|
172
169
|
);
|
|
173
170
|
for (const step of currentOutput.steps) {
|
|
@@ -878,7 +875,7 @@ import consola, { LogLevels } from "consola";
|
|
|
878
875
|
|
|
879
876
|
// src/core/builders/vite/plugins/devHtmlPrerender.ts
|
|
880
877
|
import { parseHTML as parseHTML2 } from "linkedom";
|
|
881
|
-
import { dirname as dirname3,
|
|
878
|
+
import { dirname as dirname3, relative as relative4, resolve as resolve6 } from "node:path";
|
|
882
879
|
var reactRefreshPreamble = "";
|
|
883
880
|
function devHtmlPrerender(config) {
|
|
884
881
|
const htmlReloadId = "@wxt/reload-html";
|
|
@@ -908,22 +905,9 @@ function devHtmlPrerender(config) {
|
|
|
908
905
|
if (config.command !== "serve" || server == null || !id.endsWith(".html"))
|
|
909
906
|
return;
|
|
910
907
|
const { document } = parseHTML2(code);
|
|
911
|
-
const
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
if (!src)
|
|
915
|
-
return;
|
|
916
|
-
if (isAbsolute(src)) {
|
|
917
|
-
element.setAttribute(attr, server.origin + src);
|
|
918
|
-
} else if (src.startsWith(".")) {
|
|
919
|
-
const abs = resolve6(dirname3(id), src);
|
|
920
|
-
const pathname = relative4(config.root, abs);
|
|
921
|
-
element.setAttribute(attr, `${server.origin}/${pathname}`);
|
|
922
|
-
}
|
|
923
|
-
});
|
|
924
|
-
};
|
|
925
|
-
pointToDevServer("script[type=module]", "src");
|
|
926
|
-
pointToDevServer("link[rel=stylesheet]", "href");
|
|
908
|
+
const _pointToDevServer = (querySelector, attr) => pointToDevServer(config, server, id, document, querySelector, attr);
|
|
909
|
+
_pointToDevServer("script[type=module]", "src");
|
|
910
|
+
_pointToDevServer("link[rel=stylesheet]", "href");
|
|
927
911
|
const reloader = document.createElement("script");
|
|
928
912
|
reloader.src = htmlReloadId;
|
|
929
913
|
reloader.type = "module";
|
|
@@ -989,6 +973,48 @@ function devHtmlPrerender(config) {
|
|
|
989
973
|
}
|
|
990
974
|
];
|
|
991
975
|
}
|
|
976
|
+
function pointToDevServer(config, server, id, document, querySelector, attr) {
|
|
977
|
+
document.querySelectorAll(querySelector).forEach((element) => {
|
|
978
|
+
const src = element.getAttribute(attr);
|
|
979
|
+
if (!src || isUrl(src))
|
|
980
|
+
return;
|
|
981
|
+
let resolvedAbsolutePath;
|
|
982
|
+
const matchingAlias = Object.entries(config.alias).find(
|
|
983
|
+
([key]) => src.startsWith(key)
|
|
984
|
+
);
|
|
985
|
+
if (matchingAlias) {
|
|
986
|
+
const [alias, replacement] = matchingAlias;
|
|
987
|
+
resolvedAbsolutePath = resolve6(
|
|
988
|
+
config.root,
|
|
989
|
+
src.replace(alias, replacement)
|
|
990
|
+
);
|
|
991
|
+
} else {
|
|
992
|
+
resolvedAbsolutePath = resolve6(dirname3(id), src);
|
|
993
|
+
}
|
|
994
|
+
if (resolvedAbsolutePath) {
|
|
995
|
+
const relativePath = normalizePath(
|
|
996
|
+
relative4(config.root, resolvedAbsolutePath)
|
|
997
|
+
);
|
|
998
|
+
if (relativePath.startsWith(".")) {
|
|
999
|
+
let path7 = normalizePath(resolvedAbsolutePath);
|
|
1000
|
+
if (!path7.startsWith("/"))
|
|
1001
|
+
path7 = "/" + path7;
|
|
1002
|
+
element.setAttribute(attr, `${server.origin}/@fs${path7}`);
|
|
1003
|
+
} else {
|
|
1004
|
+
const url = new URL(relativePath, server.origin);
|
|
1005
|
+
element.setAttribute(attr, url.href);
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
});
|
|
1009
|
+
}
|
|
1010
|
+
function isUrl(str) {
|
|
1011
|
+
try {
|
|
1012
|
+
new URL(str);
|
|
1013
|
+
return true;
|
|
1014
|
+
} catch {
|
|
1015
|
+
return false;
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
992
1018
|
|
|
993
1019
|
// src/core/builders/vite/plugins/devServerGlobals.ts
|
|
994
1020
|
function devServerGlobals(config) {
|
|
@@ -1988,6 +2014,11 @@ function getChunkSortWeight(filename) {
|
|
|
1988
2014
|
|
|
1989
2015
|
// src/core/utils/log/printHeader.ts
|
|
1990
2016
|
import pc4 from "picocolors";
|
|
2017
|
+
|
|
2018
|
+
// package.json
|
|
2019
|
+
var version = "0.15.3";
|
|
2020
|
+
|
|
2021
|
+
// src/core/utils/log/printHeader.ts
|
|
1991
2022
|
import { consola as consola2 } from "consola";
|
|
1992
2023
|
function printHeader() {
|
|
1993
2024
|
console.log();
|
|
@@ -2572,8 +2603,7 @@ async function rebuild(config, allEntrypoints, entrypointGroups, existingOutput
|
|
|
2572
2603
|
}
|
|
2573
2604
|
|
|
2574
2605
|
// src/core/utils/building/internal-build.ts
|
|
2575
|
-
import
|
|
2576
|
-
import { resolve as resolve13, relative as relative6 } from "node:path";
|
|
2606
|
+
import { relative as relative6 } from "node:path";
|
|
2577
2607
|
|
|
2578
2608
|
// src/core/utils/validation.ts
|
|
2579
2609
|
function validateEntrypoints(entrypoints) {
|
|
@@ -2636,6 +2666,19 @@ var ValidationError = class extends Error {
|
|
|
2636
2666
|
|
|
2637
2667
|
// src/core/utils/building/internal-build.ts
|
|
2638
2668
|
import consola3 from "consola";
|
|
2669
|
+
|
|
2670
|
+
// src/core/utils/exec.ts
|
|
2671
|
+
import managePath from "manage-path";
|
|
2672
|
+
import { resolve as resolve13 } from "node:path";
|
|
2673
|
+
var managedPath = managePath(process.env);
|
|
2674
|
+
var exec = async (config, file, args, options) => {
|
|
2675
|
+
managedPath.restore();
|
|
2676
|
+
managedPath.push(resolve13(config.root, "node_modules/wxt/node_modules/.bin"));
|
|
2677
|
+
const { execa } = await import("./execa-Y2EWTC4S.js");
|
|
2678
|
+
return await execa(file, args, options);
|
|
2679
|
+
};
|
|
2680
|
+
|
|
2681
|
+
// src/core/utils/building/internal-build.ts
|
|
2639
2682
|
async function internalBuild(config) {
|
|
2640
2683
|
const verb = config.command === "serve" ? "Pre-rendering" : "Building";
|
|
2641
2684
|
const target = `${config.browser}-mv${config.manifestVersion}`;
|
|
@@ -2684,16 +2727,15 @@ async function internalBuild(config) {
|
|
|
2684
2727
|
return output;
|
|
2685
2728
|
}
|
|
2686
2729
|
async function combineAnalysisStats(config) {
|
|
2687
|
-
const { execaCommand } = await import("./execa-Y2EWTC4S.js");
|
|
2688
2730
|
const unixFiles = await glob3(`stats-*.json`, {
|
|
2689
2731
|
cwd: config.outDir,
|
|
2690
2732
|
absolute: true
|
|
2691
2733
|
});
|
|
2692
2734
|
const absolutePaths = unixFiles.map(unnormalizePath);
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2735
|
+
await exec(
|
|
2736
|
+
config,
|
|
2737
|
+
"rollup-plugin-visualizer",
|
|
2738
|
+
[...absolutePaths, "--template", config.analysis.template],
|
|
2697
2739
|
{ cwd: config.root, stdio: "inherit" }
|
|
2698
2740
|
);
|
|
2699
2741
|
}
|
|
@@ -3288,12 +3330,62 @@ async function zip(config) {
|
|
|
3288
3330
|
return zipFiles;
|
|
3289
3331
|
}
|
|
3290
3332
|
|
|
3291
|
-
// src/cli.ts
|
|
3333
|
+
// src/cli/cli-utils.ts
|
|
3292
3334
|
import consola7, { LogLevels as LogLevels2 } from "consola";
|
|
3293
|
-
|
|
3335
|
+
function wrapAction(cb, options) {
|
|
3336
|
+
return async (...args) => {
|
|
3337
|
+
const isDebug = !!args.find((arg) => arg?.debug);
|
|
3338
|
+
if (isDebug) {
|
|
3339
|
+
consola7.level = LogLevels2.debug;
|
|
3340
|
+
}
|
|
3341
|
+
const startTime = Date.now();
|
|
3342
|
+
try {
|
|
3343
|
+
printHeader();
|
|
3344
|
+
const status = await cb(...args);
|
|
3345
|
+
if (!status?.isOngoing && !options?.disableFinishedLog)
|
|
3346
|
+
consola7.success(
|
|
3347
|
+
`Finished in ${formatDuration(Date.now() - startTime)}`
|
|
3348
|
+
);
|
|
3349
|
+
} catch (err) {
|
|
3350
|
+
consola7.fail(
|
|
3351
|
+
`Command failed after ${formatDuration(Date.now() - startTime)}`
|
|
3352
|
+
);
|
|
3353
|
+
if (err instanceof ValidationError) {
|
|
3354
|
+
} else {
|
|
3355
|
+
consola7.error(err);
|
|
3356
|
+
}
|
|
3357
|
+
process.exit(1);
|
|
3358
|
+
}
|
|
3359
|
+
};
|
|
3360
|
+
}
|
|
3361
|
+
function getArrayFromFlags(flags, name) {
|
|
3362
|
+
const array = [flags[name]].flat();
|
|
3363
|
+
const result = array.filter((item) => item != null);
|
|
3364
|
+
return result.length ? result : void 0;
|
|
3365
|
+
}
|
|
3366
|
+
var aliasCommandNames = /* @__PURE__ */ new Set();
|
|
3367
|
+
function createAliasedCommand(base, name, alias, docsUrl) {
|
|
3368
|
+
const aliasedCommand = base.command(name, `Alias for ${alias} (${docsUrl})`).allowUnknownOptions().action(async () => {
|
|
3369
|
+
try {
|
|
3370
|
+
const config = await getInternalConfig({}, "build");
|
|
3371
|
+
const args = process.argv.slice(
|
|
3372
|
+
process.argv.indexOf(aliasedCommand.name) + 1
|
|
3373
|
+
);
|
|
3374
|
+
await exec(config, alias, args, {
|
|
3375
|
+
stdio: "inherit"
|
|
3376
|
+
});
|
|
3377
|
+
} catch {
|
|
3378
|
+
process.exit(1);
|
|
3379
|
+
}
|
|
3380
|
+
});
|
|
3381
|
+
aliasCommandNames.add(aliasedCommand.name);
|
|
3382
|
+
}
|
|
3383
|
+
function isAliasedCommand(command) {
|
|
3384
|
+
return !!command && aliasCommandNames.has(command.name);
|
|
3385
|
+
}
|
|
3386
|
+
|
|
3387
|
+
// src/cli/commands.ts
|
|
3294
3388
|
var cli = cac("wxt");
|
|
3295
|
-
cli.help();
|
|
3296
|
-
cli.version(version);
|
|
3297
3389
|
cli.option("--debug", "enable debug mode");
|
|
3298
3390
|
cli.command("[root]", "start dev server").option("-c, --config <file>", "use specified config file").option("-m, --mode <mode>", "set env mode").option("-b, --browser <browser>", "specify a browser").option(
|
|
3299
3391
|
"-e, --filter-entrypoint <entrypoint>",
|
|
@@ -3374,35 +3466,20 @@ cli.command("init [directory]", "initialize a new project").option("-t, --templa
|
|
|
3374
3466
|
{ disableFinishedLog: true }
|
|
3375
3467
|
)
|
|
3376
3468
|
);
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
} catch (err) {
|
|
3393
|
-
consola7.fail(
|
|
3394
|
-
`Command failed after ${formatDuration(Date.now() - startTime)}`
|
|
3395
|
-
);
|
|
3396
|
-
if (err instanceof ValidationError) {
|
|
3397
|
-
} else {
|
|
3398
|
-
consola7.error(err);
|
|
3399
|
-
}
|
|
3400
|
-
process.exit(1);
|
|
3401
|
-
}
|
|
3402
|
-
};
|
|
3403
|
-
}
|
|
3404
|
-
function getArrayFromFlags(flags, name) {
|
|
3405
|
-
const array = [flags[name]].flat();
|
|
3406
|
-
const result = array.filter((item) => item != null);
|
|
3407
|
-
return result.length ? result : void 0;
|
|
3469
|
+
createAliasedCommand(
|
|
3470
|
+
cli,
|
|
3471
|
+
"submit",
|
|
3472
|
+
"publish-extension",
|
|
3473
|
+
"https://www.npmjs.com/publish-browser-extension"
|
|
3474
|
+
);
|
|
3475
|
+
var commands_default = cli;
|
|
3476
|
+
|
|
3477
|
+
// src/cli/index.ts
|
|
3478
|
+
process.env.VITE_CJS_IGNORE_WARNING = "true";
|
|
3479
|
+
commands_default.parse(process.argv, { run: false });
|
|
3480
|
+
if (!isAliasedCommand(commands_default.matchedCommand)) {
|
|
3481
|
+
commands_default.help();
|
|
3482
|
+
commands_default.version(version);
|
|
3483
|
+
commands_default.parse(process.argv, { run: false });
|
|
3408
3484
|
}
|
|
3485
|
+
await commands_default.runMatchedCommand();
|
package/dist/index.cjs
CHANGED
|
@@ -2584,10 +2584,10 @@ function findEffectedSteps(changedFile, currentOutput) {
|
|
|
2584
2584
|
const changes = [];
|
|
2585
2585
|
const changedPath = normalizePath(changedFile);
|
|
2586
2586
|
const isChunkEffected = (chunk) => (
|
|
2587
|
-
// If it's an HTML file with the same path, is is effected because HTML files need to be
|
|
2588
|
-
// fileName is normalized, relative bundle path
|
|
2589
|
-
chunk.type === "asset" && changedPath.endsWith(chunk.fileName) || // If it's a chunk that depends on the changed file, it is effected
|
|
2590
|
-
// moduleIds are absolute, normalized paths
|
|
2587
|
+
// If it's an HTML file with the same path, is is effected because HTML files need to be re-rendered
|
|
2588
|
+
// - fileName is normalized, relative bundle path, "<entrypoint-name>.html"
|
|
2589
|
+
chunk.type === "asset" && changedPath.replace("/index.html", ".html").endsWith(chunk.fileName) || // If it's a chunk that depends on the changed file, it is effected
|
|
2590
|
+
// - moduleIds are absolute, normalized paths
|
|
2591
2591
|
chunk.type === "chunk" && chunk.moduleIds.includes(changedPath)
|
|
2592
2592
|
);
|
|
2593
2593
|
for (const step of currentOutput.steps) {
|
|
@@ -3328,22 +3328,9 @@ function devHtmlPrerender(config) {
|
|
|
3328
3328
|
if (config.command !== "serve" || server == null || !id.endsWith(".html"))
|
|
3329
3329
|
return;
|
|
3330
3330
|
const { document } = (0, import_linkedom2.parseHTML)(code);
|
|
3331
|
-
const
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
if (!src)
|
|
3335
|
-
return;
|
|
3336
|
-
if ((0, import_node_path4.isAbsolute)(src)) {
|
|
3337
|
-
element.setAttribute(attr, server.origin + src);
|
|
3338
|
-
} else if (src.startsWith(".")) {
|
|
3339
|
-
const abs = (0, import_node_path4.resolve)((0, import_node_path4.dirname)(id), src);
|
|
3340
|
-
const pathname = (0, import_node_path4.relative)(config.root, abs);
|
|
3341
|
-
element.setAttribute(attr, `${server.origin}/${pathname}`);
|
|
3342
|
-
}
|
|
3343
|
-
});
|
|
3344
|
-
};
|
|
3345
|
-
pointToDevServer("script[type=module]", "src");
|
|
3346
|
-
pointToDevServer("link[rel=stylesheet]", "href");
|
|
3331
|
+
const _pointToDevServer = (querySelector, attr) => pointToDevServer(config, server, id, document, querySelector, attr);
|
|
3332
|
+
_pointToDevServer("script[type=module]", "src");
|
|
3333
|
+
_pointToDevServer("link[rel=stylesheet]", "href");
|
|
3347
3334
|
const reloader = document.createElement("script");
|
|
3348
3335
|
reloader.src = htmlReloadId;
|
|
3349
3336
|
reloader.type = "module";
|
|
@@ -3409,6 +3396,48 @@ function devHtmlPrerender(config) {
|
|
|
3409
3396
|
}
|
|
3410
3397
|
];
|
|
3411
3398
|
}
|
|
3399
|
+
function pointToDevServer(config, server, id, document, querySelector, attr) {
|
|
3400
|
+
document.querySelectorAll(querySelector).forEach((element) => {
|
|
3401
|
+
const src = element.getAttribute(attr);
|
|
3402
|
+
if (!src || isUrl(src))
|
|
3403
|
+
return;
|
|
3404
|
+
let resolvedAbsolutePath;
|
|
3405
|
+
const matchingAlias = Object.entries(config.alias).find(
|
|
3406
|
+
([key]) => src.startsWith(key)
|
|
3407
|
+
);
|
|
3408
|
+
if (matchingAlias) {
|
|
3409
|
+
const [alias, replacement] = matchingAlias;
|
|
3410
|
+
resolvedAbsolutePath = (0, import_node_path4.resolve)(
|
|
3411
|
+
config.root,
|
|
3412
|
+
src.replace(alias, replacement)
|
|
3413
|
+
);
|
|
3414
|
+
} else {
|
|
3415
|
+
resolvedAbsolutePath = (0, import_node_path4.resolve)((0, import_node_path4.dirname)(id), src);
|
|
3416
|
+
}
|
|
3417
|
+
if (resolvedAbsolutePath) {
|
|
3418
|
+
const relativePath = normalizePath(
|
|
3419
|
+
(0, import_node_path4.relative)(config.root, resolvedAbsolutePath)
|
|
3420
|
+
);
|
|
3421
|
+
if (relativePath.startsWith(".")) {
|
|
3422
|
+
let path10 = normalizePath(resolvedAbsolutePath);
|
|
3423
|
+
if (!path10.startsWith("/"))
|
|
3424
|
+
path10 = "/" + path10;
|
|
3425
|
+
element.setAttribute(attr, `${server.origin}/@fs${path10}`);
|
|
3426
|
+
} else {
|
|
3427
|
+
const url2 = new URL(relativePath, server.origin);
|
|
3428
|
+
element.setAttribute(attr, url2.href);
|
|
3429
|
+
}
|
|
3430
|
+
}
|
|
3431
|
+
});
|
|
3432
|
+
}
|
|
3433
|
+
function isUrl(str) {
|
|
3434
|
+
try {
|
|
3435
|
+
new URL(str);
|
|
3436
|
+
return true;
|
|
3437
|
+
} catch {
|
|
3438
|
+
return false;
|
|
3439
|
+
}
|
|
3440
|
+
}
|
|
3412
3441
|
|
|
3413
3442
|
// src/core/builders/vite/plugins/devServerGlobals.ts
|
|
3414
3443
|
function devServerGlobals(config) {
|
|
@@ -4414,7 +4443,7 @@ function getChunkSortWeight(filename) {
|
|
|
4414
4443
|
var import_picocolors4 = __toESM(require("picocolors"), 1);
|
|
4415
4444
|
|
|
4416
4445
|
// package.json
|
|
4417
|
-
var version = "0.15.
|
|
4446
|
+
var version = "0.15.3";
|
|
4418
4447
|
|
|
4419
4448
|
// src/core/utils/log/printHeader.ts
|
|
4420
4449
|
var import_consola2 = require("consola");
|
|
@@ -4997,8 +5026,7 @@ async function rebuild(config, allEntrypoints, entrypointGroups, existingOutput
|
|
|
4997
5026
|
}
|
|
4998
5027
|
|
|
4999
5028
|
// src/core/utils/building/internal-build.ts
|
|
5000
|
-
var
|
|
5001
|
-
var import_node_path13 = require("path");
|
|
5029
|
+
var import_node_path14 = require("path");
|
|
5002
5030
|
|
|
5003
5031
|
// src/core/utils/validation.ts
|
|
5004
5032
|
function validateEntrypoints(entrypoints) {
|
|
@@ -5061,6 +5089,19 @@ var ValidationError = class extends Error {
|
|
|
5061
5089
|
|
|
5062
5090
|
// src/core/utils/building/internal-build.ts
|
|
5063
5091
|
var import_consola3 = __toESM(require("consola"), 1);
|
|
5092
|
+
|
|
5093
|
+
// src/core/utils/exec.ts
|
|
5094
|
+
var import_manage_path = __toESM(require("manage-path"), 1);
|
|
5095
|
+
var import_node_path13 = require("path");
|
|
5096
|
+
var managedPath = (0, import_manage_path.default)(process.env);
|
|
5097
|
+
var exec = async (config, file, args, options) => {
|
|
5098
|
+
managedPath.restore();
|
|
5099
|
+
managedPath.push((0, import_node_path13.resolve)(config.root, "node_modules/wxt/node_modules/.bin"));
|
|
5100
|
+
const { execa: execa2 } = await Promise.resolve().then(() => (init_execa(), execa_exports));
|
|
5101
|
+
return await execa2(file, args, options);
|
|
5102
|
+
};
|
|
5103
|
+
|
|
5104
|
+
// src/core/utils/building/internal-build.ts
|
|
5064
5105
|
async function internalBuild(config) {
|
|
5065
5106
|
const verb = config.command === "serve" ? "Pre-rendering" : "Building";
|
|
5066
5107
|
const target = `${config.browser}-mv${config.manifestVersion}`;
|
|
@@ -5109,16 +5150,15 @@ async function internalBuild(config) {
|
|
|
5109
5150
|
return output;
|
|
5110
5151
|
}
|
|
5111
5152
|
async function combineAnalysisStats(config) {
|
|
5112
|
-
const { execaCommand: execaCommand2 } = await Promise.resolve().then(() => (init_execa(), execa_exports));
|
|
5113
5153
|
const unixFiles = await (0, import_fast_glob3.default)(`stats-*.json`, {
|
|
5114
5154
|
cwd: config.outDir,
|
|
5115
5155
|
absolute: true
|
|
5116
5156
|
});
|
|
5117
5157
|
const absolutePaths = unixFiles.map(unnormalizePath);
|
|
5118
|
-
|
|
5119
|
-
|
|
5120
|
-
|
|
5121
|
-
|
|
5158
|
+
await exec(
|
|
5159
|
+
config,
|
|
5160
|
+
"rollup-plugin-visualizer",
|
|
5161
|
+
[...absolutePaths, "--template", config.analysis.template],
|
|
5122
5162
|
{ cwd: config.root, stdio: "inherit" }
|
|
5123
5163
|
);
|
|
5124
5164
|
}
|
|
@@ -5134,7 +5174,7 @@ function printValidationResults(config, { errorCount, errors, warningCount }) {
|
|
|
5134
5174
|
return map;
|
|
5135
5175
|
}, /* @__PURE__ */ new Map());
|
|
5136
5176
|
Array.from(entrypointErrors.entries()).forEach(([entrypoint, errors2]) => {
|
|
5137
|
-
import_consola3.default.log((0,
|
|
5177
|
+
import_consola3.default.log((0, import_node_path14.relative)(cwd, entrypoint.inputPath));
|
|
5138
5178
|
console.log();
|
|
5139
5179
|
errors2.forEach((err) => {
|
|
5140
5180
|
const type = err.type === "error" ? import_picocolors5.default.red("ERROR") : import_picocolors5.default.yellow("WARN");
|
|
@@ -5152,7 +5192,7 @@ async function build(config) {
|
|
|
5152
5192
|
}
|
|
5153
5193
|
|
|
5154
5194
|
// src/core/clean.ts
|
|
5155
|
-
var
|
|
5195
|
+
var import_node_path15 = __toESM(require("path"), 1);
|
|
5156
5196
|
var import_fast_glob4 = __toESM(require("fast-glob"), 1);
|
|
5157
5197
|
var import_fs_extra13 = __toESM(require("fs-extra"), 1);
|
|
5158
5198
|
var import_consola4 = require("consola");
|
|
@@ -5167,7 +5207,7 @@ async function clean(root = process.cwd()) {
|
|
|
5167
5207
|
];
|
|
5168
5208
|
import_consola4.consola.debug("Looking for:", tempDirs.map(import_picocolors6.default.cyan).join(", "));
|
|
5169
5209
|
const directories = await (0, import_fast_glob4.default)(tempDirs, {
|
|
5170
|
-
cwd:
|
|
5210
|
+
cwd: import_node_path15.default.resolve(root),
|
|
5171
5211
|
absolute: true,
|
|
5172
5212
|
onlyDirectories: true,
|
|
5173
5213
|
deep: 2
|
|
@@ -5178,11 +5218,11 @@ async function clean(root = process.cwd()) {
|
|
|
5178
5218
|
}
|
|
5179
5219
|
import_consola4.consola.debug(
|
|
5180
5220
|
"Found:",
|
|
5181
|
-
directories.map((dir) => import_picocolors6.default.cyan(
|
|
5221
|
+
directories.map((dir) => import_picocolors6.default.cyan(import_node_path15.default.relative(root, dir))).join(", ")
|
|
5182
5222
|
);
|
|
5183
5223
|
for (const directory of directories) {
|
|
5184
5224
|
await import_fs_extra13.default.rm(directory, { force: true, recursive: true });
|
|
5185
|
-
import_consola4.consola.debug("Deleted " + import_picocolors6.default.cyan(
|
|
5225
|
+
import_consola4.consola.debug("Deleted " + import_picocolors6.default.cyan(import_node_path15.default.relative(root, directory)));
|
|
5186
5226
|
}
|
|
5187
5227
|
}
|
|
5188
5228
|
|
|
@@ -5197,12 +5237,12 @@ function defineRunnerConfig(config) {
|
|
|
5197
5237
|
}
|
|
5198
5238
|
|
|
5199
5239
|
// src/core/runners/wsl.ts
|
|
5200
|
-
var
|
|
5240
|
+
var import_node_path16 = require("path");
|
|
5201
5241
|
function createWslRunner() {
|
|
5202
5242
|
return {
|
|
5203
5243
|
async openBrowser(config) {
|
|
5204
5244
|
config.logger.warn(
|
|
5205
|
-
`Cannot open browser when using WSL. Load "${(0,
|
|
5245
|
+
`Cannot open browser when using WSL. Load "${(0, import_node_path16.relative)(
|
|
5206
5246
|
process.cwd(),
|
|
5207
5247
|
config.outDir
|
|
5208
5248
|
)}" as an unpacked extension manually`
|
|
@@ -5290,12 +5330,12 @@ var DEFAULT_CHROMIUM_PREFS = {
|
|
|
5290
5330
|
};
|
|
5291
5331
|
|
|
5292
5332
|
// src/core/runners/safari.ts
|
|
5293
|
-
var
|
|
5333
|
+
var import_node_path17 = require("path");
|
|
5294
5334
|
function createSafariRunner() {
|
|
5295
5335
|
return {
|
|
5296
5336
|
async openBrowser(config) {
|
|
5297
5337
|
config.logger.warn(
|
|
5298
|
-
`Cannot Safari using web-ext. Load "${(0,
|
|
5338
|
+
`Cannot Safari using web-ext. Load "${(0, import_node_path17.relative)(
|
|
5299
5339
|
process.cwd(),
|
|
5300
5340
|
config.outDir
|
|
5301
5341
|
)}" as an unpacked extension manually`
|
|
@@ -5307,12 +5347,12 @@ function createSafariRunner() {
|
|
|
5307
5347
|
}
|
|
5308
5348
|
|
|
5309
5349
|
// src/core/runners/manual.ts
|
|
5310
|
-
var
|
|
5350
|
+
var import_node_path18 = require("path");
|
|
5311
5351
|
function createManualRunner() {
|
|
5312
5352
|
return {
|
|
5313
5353
|
async openBrowser(config) {
|
|
5314
5354
|
config.logger.info(
|
|
5315
|
-
`Load "${(0,
|
|
5355
|
+
`Load "${(0, import_node_path18.relative)(
|
|
5316
5356
|
process.cwd(),
|
|
5317
5357
|
config.outDir
|
|
5318
5358
|
)}" as an unpacked extension manually`
|
|
@@ -5344,7 +5384,7 @@ async function createExtensionRunner(config) {
|
|
|
5344
5384
|
var import_consola5 = require("consola");
|
|
5345
5385
|
var import_async_mutex = require("async-mutex");
|
|
5346
5386
|
var import_picocolors7 = __toESM(require("picocolors"), 1);
|
|
5347
|
-
var
|
|
5387
|
+
var import_node_path19 = require("path");
|
|
5348
5388
|
async function createServer(inlineConfig) {
|
|
5349
5389
|
const port = await getPort();
|
|
5350
5390
|
const hostname = "localhost";
|
|
@@ -5461,11 +5501,11 @@ function createFileReloader(options) {
|
|
|
5461
5501
|
return;
|
|
5462
5502
|
}
|
|
5463
5503
|
config.logger.info(
|
|
5464
|
-
`Changed: ${Array.from(new Set(fileChanges)).map((file) => import_picocolors7.default.dim((0,
|
|
5504
|
+
`Changed: ${Array.from(new Set(fileChanges)).map((file) => import_picocolors7.default.dim((0, import_node_path19.relative)(config.root, file))).join(", ")}`
|
|
5465
5505
|
);
|
|
5466
5506
|
const rebuiltNames = changes.rebuildGroups.flat().map((entry) => {
|
|
5467
5507
|
return import_picocolors7.default.cyan(
|
|
5468
|
-
(0,
|
|
5508
|
+
(0, import_node_path19.relative)(config.outDir, getEntrypointOutputFile(entry, ""))
|
|
5469
5509
|
);
|
|
5470
5510
|
}).join(import_picocolors7.default.dim(", "));
|
|
5471
5511
|
const allEntrypoints = await findEntrypoints(config);
|
|
@@ -5536,7 +5576,7 @@ var import_prompts = __toESM(require("prompts"), 1);
|
|
|
5536
5576
|
var import_consola6 = require("consola");
|
|
5537
5577
|
var import_giget = require("giget");
|
|
5538
5578
|
var import_fs_extra14 = __toESM(require("fs-extra"), 1);
|
|
5539
|
-
var
|
|
5579
|
+
var import_node_path20 = __toESM(require("path"), 1);
|
|
5540
5580
|
var import_picocolors8 = __toESM(require("picocolors"), 1);
|
|
5541
5581
|
async function initialize(options) {
|
|
5542
5582
|
import_consola6.consola.info("Initalizing new project");
|
|
@@ -5584,7 +5624,7 @@ async function initialize(options) {
|
|
|
5584
5624
|
input.template ??= defaultTemplate;
|
|
5585
5625
|
input.packageManager ??= options.packageManager;
|
|
5586
5626
|
await cloneProject(input);
|
|
5587
|
-
const cdPath =
|
|
5627
|
+
const cdPath = import_node_path20.default.relative(process.cwd(), import_node_path20.default.resolve(input.directory));
|
|
5588
5628
|
console.log();
|
|
5589
5629
|
import_consola6.consola.log(
|
|
5590
5630
|
`\u2728 WXT project created with the ${TEMPLATE_COLORS[input.template.name]?.(input.template.name) ?? input.template.name} template.`
|
|
@@ -5636,8 +5676,8 @@ async function cloneProject({
|
|
|
5636
5676
|
force: true
|
|
5637
5677
|
});
|
|
5638
5678
|
await import_fs_extra14.default.move(
|
|
5639
|
-
|
|
5640
|
-
|
|
5679
|
+
import_node_path20.default.join(directory, "_gitignore"),
|
|
5680
|
+
import_node_path20.default.join(directory, ".gitignore")
|
|
5641
5681
|
).catch(
|
|
5642
5682
|
(err) => import_consola6.consola.warn("Failed to move _gitignore to .gitignore:", err)
|
|
5643
5683
|
);
|
|
@@ -5670,7 +5710,7 @@ async function prepare(config) {
|
|
|
5670
5710
|
|
|
5671
5711
|
// src/core/zip.ts
|
|
5672
5712
|
var import_zip_dir = __toESM(require("zip-dir"), 1);
|
|
5673
|
-
var
|
|
5713
|
+
var import_node_path21 = require("path");
|
|
5674
5714
|
var import_fs_extra15 = __toESM(require("fs-extra"), 1);
|
|
5675
5715
|
var import_minimatch2 = require("minimatch");
|
|
5676
5716
|
async function zip(config) {
|
|
@@ -5680,7 +5720,7 @@ async function zip(config) {
|
|
|
5680
5720
|
internalConfig.logger.info("Zipping extension...");
|
|
5681
5721
|
const zipFiles = [];
|
|
5682
5722
|
const projectName = internalConfig.zip.name ?? kebabCaseAlphanumeric(
|
|
5683
|
-
(await getPackageJson(internalConfig))?.name || (0,
|
|
5723
|
+
(await getPackageJson(internalConfig))?.name || (0, import_node_path21.dirname)(process.cwd())
|
|
5684
5724
|
);
|
|
5685
5725
|
const applyTemplate = (template) => template.replaceAll("{{name}}", projectName).replaceAll("{{browser}}", internalConfig.browser).replaceAll(
|
|
5686
5726
|
"{{version}}",
|
|
@@ -5688,7 +5728,7 @@ async function zip(config) {
|
|
|
5688
5728
|
).replaceAll("{{manifestVersion}}", `mv${internalConfig.manifestVersion}`);
|
|
5689
5729
|
await import_fs_extra15.default.ensureDir(internalConfig.outBaseDir);
|
|
5690
5730
|
const outZipFilename = applyTemplate(internalConfig.zip.artifactTemplate);
|
|
5691
|
-
const outZipPath = (0,
|
|
5731
|
+
const outZipPath = (0, import_node_path21.resolve)(internalConfig.outBaseDir, outZipFilename);
|
|
5692
5732
|
await (0, import_zip_dir.default)(internalConfig.outDir, {
|
|
5693
5733
|
saveTo: outZipPath
|
|
5694
5734
|
});
|
|
@@ -5697,14 +5737,14 @@ async function zip(config) {
|
|
|
5697
5737
|
const sourcesZipFilename = applyTemplate(
|
|
5698
5738
|
internalConfig.zip.sourcesTemplate
|
|
5699
5739
|
);
|
|
5700
|
-
const sourcesZipPath = (0,
|
|
5740
|
+
const sourcesZipPath = (0, import_node_path21.resolve)(
|
|
5701
5741
|
internalConfig.outBaseDir,
|
|
5702
5742
|
sourcesZipFilename
|
|
5703
5743
|
);
|
|
5704
5744
|
await (0, import_zip_dir.default)(internalConfig.zip.sourcesRoot, {
|
|
5705
5745
|
saveTo: sourcesZipPath,
|
|
5706
5746
|
filter(path10) {
|
|
5707
|
-
const relativePath = (0,
|
|
5747
|
+
const relativePath = (0, import_node_path21.relative)(internalConfig.zip.sourcesRoot, path10);
|
|
5708
5748
|
return internalConfig.zip.includeSources.some(
|
|
5709
5749
|
(pattern) => (0, import_minimatch2.minimatch)(relativePath, pattern)
|
|
5710
5750
|
) || !internalConfig.zip.excludeSources.some(
|
package/dist/index.d.cts
CHANGED
|
@@ -62,6 +62,6 @@ declare function prepare(config: InlineConfig): Promise<void>;
|
|
|
62
62
|
*/
|
|
63
63
|
declare function zip(config?: InlineConfig): Promise<string[]>;
|
|
64
64
|
|
|
65
|
-
var version = "0.15.
|
|
65
|
+
var version = "0.15.3";
|
|
66
66
|
|
|
67
67
|
export { BuildOutput, ExtensionRunnerConfig, InlineConfig, UserConfig, WxtDevServer, build, clean, createServer, defineConfig, defineRunnerConfig, initialize, prepare, version, zip };
|
package/dist/index.d.ts
CHANGED
|
@@ -62,6 +62,6 @@ declare function prepare(config: InlineConfig): Promise<void>;
|
|
|
62
62
|
*/
|
|
63
63
|
declare function zip(config?: InlineConfig): Promise<string[]>;
|
|
64
64
|
|
|
65
|
-
var version = "0.15.
|
|
65
|
+
var version = "0.15.3";
|
|
66
66
|
|
|
67
67
|
export { BuildOutput, ExtensionRunnerConfig, InlineConfig, UserConfig, WxtDevServer, build, clean, createServer, defineConfig, defineRunnerConfig, initialize, prepare, version, zip };
|
package/dist/index.js
CHANGED
package/dist/testing.cjs
CHANGED
|
@@ -97,22 +97,9 @@ function devHtmlPrerender(config) {
|
|
|
97
97
|
if (config.command !== "serve" || server == null || !id.endsWith(".html"))
|
|
98
98
|
return;
|
|
99
99
|
const { document } = (0, import_linkedom.parseHTML)(code);
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
if (!src)
|
|
104
|
-
return;
|
|
105
|
-
if ((0, import_node_path3.isAbsolute)(src)) {
|
|
106
|
-
element.setAttribute(attr, server.origin + src);
|
|
107
|
-
} else if (src.startsWith(".")) {
|
|
108
|
-
const abs = (0, import_node_path3.resolve)((0, import_node_path3.dirname)(id), src);
|
|
109
|
-
const pathname = (0, import_node_path3.relative)(config.root, abs);
|
|
110
|
-
element.setAttribute(attr, `${server.origin}/${pathname}`);
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
};
|
|
114
|
-
pointToDevServer("script[type=module]", "src");
|
|
115
|
-
pointToDevServer("link[rel=stylesheet]", "href");
|
|
100
|
+
const _pointToDevServer = (querySelector, attr) => pointToDevServer(config, server, id, document, querySelector, attr);
|
|
101
|
+
_pointToDevServer("script[type=module]", "src");
|
|
102
|
+
_pointToDevServer("link[rel=stylesheet]", "href");
|
|
116
103
|
const reloader = document.createElement("script");
|
|
117
104
|
reloader.src = htmlReloadId;
|
|
118
105
|
reloader.type = "module";
|
|
@@ -178,6 +165,48 @@ function devHtmlPrerender(config) {
|
|
|
178
165
|
}
|
|
179
166
|
];
|
|
180
167
|
}
|
|
168
|
+
function pointToDevServer(config, server, id, document, querySelector, attr) {
|
|
169
|
+
document.querySelectorAll(querySelector).forEach((element) => {
|
|
170
|
+
const src = element.getAttribute(attr);
|
|
171
|
+
if (!src || isUrl(src))
|
|
172
|
+
return;
|
|
173
|
+
let resolvedAbsolutePath;
|
|
174
|
+
const matchingAlias = Object.entries(config.alias).find(
|
|
175
|
+
([key]) => src.startsWith(key)
|
|
176
|
+
);
|
|
177
|
+
if (matchingAlias) {
|
|
178
|
+
const [alias, replacement] = matchingAlias;
|
|
179
|
+
resolvedAbsolutePath = (0, import_node_path3.resolve)(
|
|
180
|
+
config.root,
|
|
181
|
+
src.replace(alias, replacement)
|
|
182
|
+
);
|
|
183
|
+
} else {
|
|
184
|
+
resolvedAbsolutePath = (0, import_node_path3.resolve)((0, import_node_path3.dirname)(id), src);
|
|
185
|
+
}
|
|
186
|
+
if (resolvedAbsolutePath) {
|
|
187
|
+
const relativePath = normalizePath(
|
|
188
|
+
(0, import_node_path3.relative)(config.root, resolvedAbsolutePath)
|
|
189
|
+
);
|
|
190
|
+
if (relativePath.startsWith(".")) {
|
|
191
|
+
let path6 = normalizePath(resolvedAbsolutePath);
|
|
192
|
+
if (!path6.startsWith("/"))
|
|
193
|
+
path6 = "/" + path6;
|
|
194
|
+
element.setAttribute(attr, `${server.origin}/@fs${path6}`);
|
|
195
|
+
} else {
|
|
196
|
+
const url = new URL(relativePath, server.origin);
|
|
197
|
+
element.setAttribute(attr, url.href);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
function isUrl(str) {
|
|
203
|
+
try {
|
|
204
|
+
new URL(str);
|
|
205
|
+
return true;
|
|
206
|
+
} catch {
|
|
207
|
+
return false;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
181
210
|
|
|
182
211
|
// src/core/builders/vite/plugins/devServerGlobals.ts
|
|
183
212
|
function devServerGlobals(config) {
|
|
@@ -1170,9 +1199,13 @@ var import_immer = require("immer");
|
|
|
1170
1199
|
var import_defu3 = __toESM(require("defu"), 1);
|
|
1171
1200
|
|
|
1172
1201
|
// src/core/utils/building/internal-build.ts
|
|
1202
|
+
var import_node_path12 = require("path");
|
|
1203
|
+
var import_consola3 = __toESM(require("consola"), 1);
|
|
1204
|
+
|
|
1205
|
+
// src/core/utils/exec.ts
|
|
1173
1206
|
var import_manage_path = __toESM(require("manage-path"), 1);
|
|
1174
1207
|
var import_node_path11 = require("path");
|
|
1175
|
-
var
|
|
1208
|
+
var managedPath = (0, import_manage_path.default)(process.env);
|
|
1176
1209
|
|
|
1177
1210
|
// src/testing/wxt-vitest-plugin.ts
|
|
1178
1211
|
function WxtVitest(inlineConfig) {
|
package/dist/testing.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wxt",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.15.
|
|
4
|
+
"version": "0.15.3",
|
|
5
5
|
"description": "Next gen framework for developing web extensions",
|
|
6
6
|
"engines": {
|
|
7
7
|
"node": ">=18",
|
|
@@ -111,6 +111,7 @@
|
|
|
111
111
|
"ora": "^7.0.1",
|
|
112
112
|
"picocolors": "^1.0.0",
|
|
113
113
|
"prompts": "^2.4.2",
|
|
114
|
+
"publish-browser-extension": "^2.0.0",
|
|
114
115
|
"rollup-plugin-visualizer": "^5.9.2",
|
|
115
116
|
"unimport": "^3.4.0",
|
|
116
117
|
"vite": "^5.0.12",
|
|
@@ -160,7 +161,7 @@
|
|
|
160
161
|
]
|
|
161
162
|
},
|
|
162
163
|
"scripts": {
|
|
163
|
-
"wxt": "tsx src/cli.ts",
|
|
164
|
+
"wxt": "tsx src/cli/index.ts",
|
|
164
165
|
"build": "tsx scripts/build.ts",
|
|
165
166
|
"format": "prettier --write .",
|
|
166
167
|
"format:check": "prettier --check .",
|